Message ID | 20240801140552.1021693-1-stefanha@redhat.com |
---|---|
Headers | show |
Series | qdev-monitor: avoid QemuOpts in QMP device_add | expand |
Can we additionally cut out the QemuOpts middleman in usbback_portid_add()? qdict = qdict_new(); qdict_put_str(qdict, "driver", "usb-host"); tmp = g_strdup_printf("%s.0", usbif->xendev.qdev.id); qdict_put_str(qdict, "bus", tmp); g_free(tmp); tmp = g_strdup_printf("%s-%u", usbif->xendev.qdev.id, port); qdict_put_str(qdict, "id", tmp); g_free(tmp); qdict_put_int(qdict, "port", port); qdict_put_int(qdict, "hostbus", atoi(busid)); qdict_put_str(qdict, "hostport", portname); opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, &error_abort); usbif->ports[port - 1].dev = USB_DEVICE(qdev_device_add(opts, &local_err)); Trying this is up to you!
On Fri, Aug 02, 2024 at 10:10:43AM +0200, Markus Armbruster wrote: > Can we additionally cut out the QemuOpts middleman in > usbback_portid_add()? > > qdict = qdict_new(); > qdict_put_str(qdict, "driver", "usb-host"); > tmp = g_strdup_printf("%s.0", usbif->xendev.qdev.id); > qdict_put_str(qdict, "bus", tmp); > g_free(tmp); > tmp = g_strdup_printf("%s-%u", usbif->xendev.qdev.id, port); > qdict_put_str(qdict, "id", tmp); > g_free(tmp); > qdict_put_int(qdict, "port", port); > qdict_put_int(qdict, "hostbus", atoi(busid)); > qdict_put_str(qdict, "hostport", portname); > opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, > &error_abort); > usbif->ports[port - 1].dev = USB_DEVICE(qdev_device_add(opts, &local_err)); > > Trying this is up to you! Paul or Anthony: Do you know how to run usbback_portid_add() for testing? I would like to make sure that suggested the code change works and don't have experience running the Xen code in QEMU. Thanks, Stefan
On 12/08/2024 19:15, Stefan Hajnoczi wrote: > On Fri, Aug 02, 2024 at 10:10:43AM +0200, Markus Armbruster wrote: >> Can we additionally cut out the QemuOpts middleman in >> usbback_portid_add()? >> >> qdict = qdict_new(); >> qdict_put_str(qdict, "driver", "usb-host"); >> tmp = g_strdup_printf("%s.0", usbif->xendev.qdev.id); >> qdict_put_str(qdict, "bus", tmp); >> g_free(tmp); >> tmp = g_strdup_printf("%s-%u", usbif->xendev.qdev.id, port); >> qdict_put_str(qdict, "id", tmp); >> g_free(tmp); >> qdict_put_int(qdict, "port", port); >> qdict_put_int(qdict, "hostbus", atoi(busid)); >> qdict_put_str(qdict, "hostport", portname); >> opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, >> &error_abort); >> usbif->ports[port - 1].dev = USB_DEVICE(qdev_device_add(opts, &local_err)); >> >> Trying this is up to you! > > Paul or Anthony: Do you know how to run usbback_portid_add() for > testing? I would like to make sure that suggested the code change works > and don't have experience running the Xen code in QEMU. Sorry, PV USB is not something I'm familiar with. https://wiki.xenproject.org/wiki/Xen_USB_Passthrough suggests that `xl usbdev-attach` might be the way to test... but you'd need a system with Xen installed and suitably configured guest, so not trivial to set up.
On Tue, Aug 13, 2024 at 09:18:46AM +0100, Paul Durrant wrote: > On 12/08/2024 19:15, Stefan Hajnoczi wrote: > > On Fri, Aug 02, 2024 at 10:10:43AM +0200, Markus Armbruster wrote: > > > Can we additionally cut out the QemuOpts middleman in > > > usbback_portid_add()? > > > > > > qdict = qdict_new(); > > > qdict_put_str(qdict, "driver", "usb-host"); > > > tmp = g_strdup_printf("%s.0", usbif->xendev.qdev.id); > > > qdict_put_str(qdict, "bus", tmp); > > > g_free(tmp); > > > tmp = g_strdup_printf("%s-%u", usbif->xendev.qdev.id, port); > > > qdict_put_str(qdict, "id", tmp); > > > g_free(tmp); > > > qdict_put_int(qdict, "port", port); > > > qdict_put_int(qdict, "hostbus", atoi(busid)); > > > qdict_put_str(qdict, "hostport", portname); > > > opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, > > > &error_abort); > > > usbif->ports[port - 1].dev = USB_DEVICE(qdev_device_add(opts, &local_err)); > > > > > > Trying this is up to you! > > > > Paul or Anthony: Do you know how to run usbback_portid_add() for > > testing? I would like to make sure that suggested the code change works > > and don't have experience running the Xen code in QEMU. > > Sorry, PV USB is not something I'm familiar with. > https://wiki.xenproject.org/wiki/Xen_USB_Passthrough suggests that `xl > usbdev-attach` might be the way to test... but you'd need a system with Xen > installed and suitably configured guest, so not trivial to set up. Thanks for the pointer! I will leave the usbback_portid_add() refactoring because I don't have a setup for testing it. Stefan