]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuBuildDeviceAddresDriveProps: Prepare for 'drive' address for usb-bot disks
authorPeter Krempa <pkrempa@redhat.com>
Thu, 19 Jun 2025 07:46:38 +0000 (09:46 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 24 Jun 2025 14:29:12 +0000 (16:29 +0200)
While the 'usb-storage' based disks use the USB address directly, with
'usb-bot' the USB address is on the "controller" part of the device and
the 'scsi-hd/cd' device will use a 'drive' address from qemu's PoV.

Since we do not want to expose the 'usb-bot' as explicit controller
to preserve compatibility with existing configs we plan to upgrade
implement the formatter for 'drive' address when the "diskbus" property
is VIR_DOMAIN_DISK_BUS_USB.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_command.c

index b752a828bab070ca035001432e0149926444acfd..e60b1d10380c7122c1477a8e6852653e69d8a5bb 100644 (file)
@@ -545,8 +545,21 @@ qemuBuildDeviceAddresDriveProps(virJSONValue *props,
             return -1;
         break;
 
-    case VIR_DOMAIN_DISK_BUS_VIRTIO:
     case VIR_DOMAIN_DISK_BUS_USB:
+        /* Device info with type VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE and
+         * VIR_DOMAIN_DISK_BUS_USB diskbus is an internal representation
+         * for the device address for 'usb-bot'. */
+        bus = g_strdup_printf("%s.0", info->alias);
+
+        if (virJSONValueObjectAdd(&props,
+                                  "s:bus", bus,
+                                  "u:scsi-id", info->addr.drive.target,
+                                  "u:lun", info->addr.drive.unit,
+                                  NULL) < 0)
+            return -1;
+        break;
+
+    case VIR_DOMAIN_DISK_BUS_VIRTIO:
     case VIR_DOMAIN_DISK_BUS_XEN:
     case VIR_DOMAIN_DISK_BUS_UML:
     case VIR_DOMAIN_DISK_BUS_SD: