Skip to contentSkip to conversation

libxl: Fix device_add QMP calls with QEMU 9.2 and newer

PATCH In review Anthony PERARD 5 participants 8 messages Dec 15, 2025 – Mar 9

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: Fix device_add QMP calls with QEMU 9.2 and newer

From: Anthony PERARD <[email protected]>

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")

---

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(-)
tools/libs/light/libxl_usb.c +8 -8
index c5ae59681c..4e7c409fe6 100644
@@ -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);
 }
Signature · 1 line
Anthony PERARD
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Anthony PERARD

From: Anthony PERARD <[email protected]>

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")

Juergen

#2 lore raw
In reply to Anthony PERARD
Quoted 6 lines · Anthony PERARD

From: Anthony PERARD <[email protected]>

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

#3 lore raw
Quoted 9 lines · Jan Beulich
Quoted 6 lines · Anthony PERARD

From: Anthony PERARD <[email protected]>

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,

Signature · 1 line
Anthony PERARD
#4 lore raw
Quoted 9 lines · On Monday, 15 December 2025 15:41:02 CET Anthony PERARD wrote:
Quoted 8 lines · Jan Beulich
Quoted 6 lines · Anthony PERARD

From: Anthony PERARD <[email protected]>

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")).

Quoted 8 lines
Quoted 1 line

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,

Can this patch be picked for the stable branches? I'm in particular interested in 4.20 which is in Debian stable.

Thanks,
Maxi

#5 lore raw
Quoted 17 lines · Maximilian Engelhardt
Quoted 16 lines · On Monday, 15 December 2025 15:41:02 CET Anthony PERARD wrote:
Quoted 9 lines · Jan Beulich
Quoted 6 lines · Anthony PERARD

From: Anthony PERARD <[email protected]>

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.

Quoted 4 lines
Quoted 1 line

Cheers,

Can this patch be picked for the stable branches? I'm in particular interested in 4.20 which is in Debian stable.

Done, thanks.

--
Anthony Perard | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

#6 lore raw
Quoted 1 line · On Monday, 9 March 2026 15:48:55 CET Anthony PERARD wrote:

On Thu, Feb 19, 2026 at 02:29:07PM +0100, Maximilian Engelhardt wrote:

[...]

Quoted 4 lines
Quoted 2 lines

Can this patch be picked for the stable branches? I'm in particular interested in 4.20 which is in Debian stable.

Done, thanks.

Thanks also.

We meanwhile got two reports in Debian from people running into that issue (plus me), so it's good to see it fixed.

We will pull the fix with the next xen update in Debian (but not yet the upcoming 13.4 point release), which we always base on the upstream stable branch.

Maxi

Tested-by on v1 1/1
#7 lore raw
In reply to Anthony PERARD
Quoted 7 lines · On Monday, 15 December 2025 14:51:24 CET Anthony PERARD wrote:

From: Anthony PERARD <[email protected]>

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")).

Quoted 5 lines
Fixes 9718ab394d5d ("libxl_usb: Make libxl__device_usbctrl_add uses

ev_qmp")

Fixes 40c7eca10a82 ("libxl_usb: Make libxl__device_usbdev_add

uses ev_qmp")

I can confirm with this patch usb passthrough works on the debian xen 4.20 package.