]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: introduce usb disk models 'usb-storage' and 'usb-bot'
authorPeter Krempa <pkrempa@redhat.com>
Thu, 19 Jun 2025 13:46:46 +0000 (15:46 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 24 Jun 2025 14:29:12 +0000 (16:29 +0200)
Historically libvirt specified 'usb-storage' as driver for USB disks.
This though combined with '-blockdev' doesn't properly configure the
device to look like CDROM for <disk type='cdrom'>.

'usb-bot' acts like a controler and allows explicitly connecting a
-device to it.

In qemu the devices share implementation so they are effectively
identical and can be used interchangably. There is a difference in how
the storage device itself (the SCSI part) looks when configured properly
as CDROM which is unfortunately not compatible/interchangable.

As this is effectively a bugfix we'll be fixing the behaviour for the
default configuration. The possibility to explicitly set the model is
added as a possibility for working around possible problems if they'd
appear.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
docs/formatdomain.rst
src/conf/domain_conf.c
src/conf/domain_conf.h
src/conf/schemas/domaincommon.rng
src/qemu/qemu_domain_address.c

index 4c7ec17d45007f6a8b61723d14273015caa5b082..9a2f065590c822687969ff07a7aa8c3721f78ec8 100644 (file)
@@ -2862,10 +2862,25 @@ paravirtualized driver is specified via the ``disk`` element.
 
    ``model``
       Indicates the emulated device model of the disk. Typically this is
-      indicated solely by the ``bus`` property but for ``bus`` "virtio" the
-      model can be specified further with "virtio", "virtio-transitional" or
-      "virtio-non-transitional". See `virtio device models`_
-      for more details. :since:`Since 5.2.0`
+      indicated solely by the ``bus`` property.
+
+      For ``bus`` "virtio" the model can be specified further with "virtio",
+      "virtio-transitional" or "virtio-non-transitional". See `virtio device
+      models`_ for more details. :since:`Since 5.2.0`
+
+      For ``bus`` "usb" the model can be specified further with ``usb-storage``
+      or ``usb-bot``. There is no difference between the two models for
+      ``<disk type='disk'>``. However  with ``usb-bot`` a device configured as
+      ``<disk type='cdrom'>`` is properly exposed as a cdrom device inside the
+      guest OS. Unfortunately this configuration is not ABI compatible with
+      ``usb-storage`` and thus it can't be interchanged during migration.
+
+      The QEMU hypervisor driver will pick ``usb-bot`` for cold starts or
+      hotplug for cdrom devices to properly configure the devices. This is
+      not compatible for migration to older versions of libvirt and explicit
+      configuration needs to be used.
+      :since:`Since 11.5.0`; relevant only for ``QEMU`` hypervisor.
+
    ``rawio``
       Indicates whether the disk needs rawio capability. Valid settings are
       "yes" or "no" (default is "no"). If any one disk in a domain has
index 2469144a66bacf350a5253bf266ff04bdab25f69..1e24e41a48ec464ed8e76444cfb99d214f061098 100644 (file)
@@ -1400,6 +1400,8 @@ VIR_ENUM_IMPL(virDomainDiskModel,
               "virtio",
               "virtio-transitional",
               "virtio-non-transitional",
+              "usb-storage",
+              "usb-bot",
 );
 
 VIR_ENUM_IMPL(virDomainDiskMirrorState,
index 667b3ff10a5cf33d5df115b17ad1830d8076de31..6997cf7c09be51339fb8136c7862705f57cd4af8 100644 (file)
@@ -438,6 +438,8 @@ typedef enum {
     VIR_DOMAIN_DISK_MODEL_VIRTIO,
     VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL,
     VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL,
+    VIR_DOMAIN_DISK_MODEL_USB_STORAGE,
+    VIR_DOMAIN_DISK_MODEL_USB_BOT,
 
     VIR_DOMAIN_DISK_MODEL_LAST
 } virDomainDiskModel;
index 1ff441e1845c434cc84fb071cc87323e76cf5b65..183dd5db5e2a37410bfb054fa81d0d2b624c4f23 100644 (file)
             <value>virtio</value>
             <value>virtio-transitional</value>
             <value>virtio-non-transitional</value>
+            <value>usb-storage</value>
+            <value>usb-bot</value>
           </choice>
         </attribute>
       </optional>
index bf77af62d0afe36cdc67084e1703e7f3ce6bce84..96a9ca9b14fd3bb4c8673596832b05488f3189c9 100644 (file)
@@ -729,6 +729,8 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev,
             case VIR_DOMAIN_DISK_MODEL_DEFAULT:
                 return virtioFlags;
             case VIR_DOMAIN_DISK_MODEL_LAST:
+            case VIR_DOMAIN_DISK_MODEL_USB_STORAGE:
+            case VIR_DOMAIN_DISK_MODEL_USB_BOT:
                 break;
             }
             return 0;