tools/libs/light/libxl_usb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
From: Anthony PERARD <anthony.perard@vates.tech>
QEMU used to ignore JSON types and do conversion string <-> integer
automatically for the command "device_add", but that was removed in
QEMU 9.2 (428d1789df91 ("docs/about: Belatedly document tightening of
QMP device_add checking")).
Fixes: 9718ab394d5d ("libxl_usb: Make libxl__device_usbctrl_add uses ev_qmp")
Fixes: 40c7eca10a82 ("libxl_usb: Make libxl__device_usbdev_add uses ev_qmp")
Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
---
Notes:
I've check other `device_add` call site which are for PCI devices and
CPUs, and they both are already correct.
tools/libs/light/libxl_usb.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/tools/libs/light/libxl_usb.c b/tools/libs/light/libxl_usb.c
index c5ae59681c..4e7c409fe6 100644
--- a/tools/libs/light/libxl_usb.c
+++ b/tools/libs/light/libxl_usb.c
@@ -367,10 +367,10 @@ static int libxl__device_usbctrl_add_hvm(libxl__egc *egc, libxl__ev_qmp *qmp,
case 3:
libxl__qmp_param_add_string(gc, &qmp_args,
"driver", "nec-usb-xhci");
- libxl__qmp_param_add_string(gc, &qmp_args, "p2",
- GCSPRINTF("%d", usbctrl->ports));
- libxl__qmp_param_add_string(gc, &qmp_args, "p3",
- GCSPRINTF("%d", usbctrl->ports));
+ libxl__qmp_param_add_integer(gc, &qmp_args, "p2",
+ usbctrl->ports);
+ libxl__qmp_param_add_integer(gc, &qmp_args, "p3",
+ usbctrl->ports);
break;
default:
abort(); /* Should not be possible. */
@@ -411,10 +411,10 @@ static int libxl__device_usbdev_add_hvm(libxl__egc *egc, libxl__ev_qmp *qmp,
GCSPRINTF("xenusb-%d.0", usbdev->ctrl));
libxl__qmp_param_add_string(gc, &qmp_args, "port",
GCSPRINTF("%d", usbdev->port));
- libxl__qmp_param_add_string(gc, &qmp_args, "hostbus",
- GCSPRINTF("%d", usbdev->u.hostdev.hostbus));
- libxl__qmp_param_add_string(gc, &qmp_args, "hostaddr",
- GCSPRINTF("%d", usbdev->u.hostdev.hostaddr));
+ libxl__qmp_param_add_integer(gc, &qmp_args, "hostbus",
+ usbdev->u.hostdev.hostbus);
+ libxl__qmp_param_add_integer(gc, &qmp_args, "hostaddr",
+ usbdev->u.hostdev.hostaddr);
return libxl__ev_qmp_send(egc, qmp, "device_add", qmp_args);
}
--
Anthony PERARD
On 15.12.25 14:51, Anthony PERARD wrote:
> From: Anthony PERARD <anthony.perard@vates.tech>
>
> QEMU used to ignore JSON types and do conversion string <-> integer
> automatically for the command "device_add", but that was removed in
> QEMU 9.2 (428d1789df91 ("docs/about: Belatedly document tightening of
> QMP device_add checking")).
>
> Fixes: 9718ab394d5d ("libxl_usb: Make libxl__device_usbctrl_add uses ev_qmp")
> Fixes: 40c7eca10a82 ("libxl_usb: Make libxl__device_usbdev_add uses ev_qmp")
> Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
Reviewed-by: Juergen Gross <jgross@suse.com>
Juergen
On 15.12.2025 14:51, Anthony PERARD wrote:
> From: Anthony PERARD <anthony.perard@vates.tech>
>
> QEMU used to ignore JSON types and do conversion string <-> integer
> automatically for the command "device_add", but that was removed in
> QEMU 9.2 (428d1789df91 ("docs/about: Belatedly document tightening of
> QMP device_add checking")).
And older qemu accepts integers as well?
Jan
On Mon, Dec 15, 2025 at 03:11:53PM +0100, Jan Beulich wrote:
> On 15.12.2025 14:51, Anthony PERARD wrote:
> > From: Anthony PERARD <anthony.perard@vates.tech>
> >
> > QEMU used to ignore JSON types and do conversion string <-> integer
> > automatically for the command "device_add", but that was removed in
> > QEMU 9.2 (428d1789df91 ("docs/about: Belatedly document tightening of
> > QMP device_add checking")).
>
> And older qemu accepts integers as well?
As the QEMU document explains about the removed feature is that they
should. We already have two users of `device_add` which use integers for
some arguments. And just to be sure, I've just tested with QEMU 8.0, the
patch works fine.
Cheers,
--
Anthony PERARD
On Monday, 15 December 2025 14:51:24 CET Anthony PERARD wrote:
> From: Anthony PERARD <anthony.perard@vates.tech>
>
> QEMU used to ignore JSON types and do conversion string <-> integer
> automatically for the command "device_add", but that was removed in
> QEMU 9.2 (428d1789df91 ("docs/about: Belatedly document tightening of
> QMP device_add checking")).
>
> Fixes: 9718ab394d5d ("libxl_usb: Make libxl__device_usbctrl_add uses
> ev_qmp")
> Fixes: 40c7eca10a82 ("libxl_usb: Make libxl__device_usbdev_add
> uses ev_qmp")
> Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
I can confirm with this patch usb passthrough works on the debian xen 4.20
package.
Tested-by: Maximilian Engelhardt <maxi@daemonizer.de>
© 2016 - 2025 Red Hat, Inc.