]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Always default to no USB controller on s390x
authorAndrea Bolognani <abologna@redhat.com>
Mon, 12 Feb 2024 19:18:46 +0000 (20:18 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 6 Oct 2025 09:15:51 +0000 (11:15 +0200)
When support for s390x was introduced in libvirt, it naturally
followed the conventions established at the time for x86, which
were to have a USB controller added by default.

Later, in 2013, commit 3a82f628a964 made the default USB
controller model for s390x VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE,
effectively overriding the architecture-independent default.

However, an exception was carved out at the time: if the USB
controller had an address assigned to it, then it would be left
alone.

A couple of years later, commit 09ab9dcc85ec changed things
again in two ways: for starters, libvirt would no longer
automatically attempt to add a USB controller to newly-defined
s390x guests; moreover, the command line generator was changed
so that the legacy USB controller (-usb) would never be used
on s390x.

In other words, unless a model name is explicitly provided for
the USB controller, which is something that only actually works
when using a recent QEMU version (see commit f9ed4d385ab8),
s390x guests will never have USB controllers attached to them.

Remove the exception carved out a decade ago and always
reflect this fact accurately in the guest XML.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_postparse.c
tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml
tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml
tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml
tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml
tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml
tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio.xml
tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml
tests/qemuxmlconfdata/s390-usb-address.s390x-latest.xml

index cf08e6e07c2f0b8d5fe0b21d9e0bae52a50f1eaf..dd2e4cb9c73ed29f64155a37e1e8efdb20f9e589 100644 (file)
@@ -380,11 +380,9 @@ qemuDomainControllerDefPostParse(virDomainControllerDef *cont,
                 cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
 
             if (ARCH_IS_S390(def->os.arch)) {
-                if (cont->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
-                    /* set the default USB model to none for s390 unless an
-                     * address is found */
-                    cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE;
-                }
+                /* No default model on s390x, one has to be provided
+                 * explicitly by the user */
+                cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE;
             } else if (ARCH_IS_PPC64(def->os.arch)) {
                 /* To not break migration we need to set default USB controller
                  * for ppc64 to pci-ohci if we cannot change ABI of the VM.
@@ -412,6 +410,13 @@ qemuDomainControllerDefPostParse(virDomainControllerDef *cont,
                     cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
             }
         }
+
+        /* Make sure the 'none' USB controller doesn't have an address
+         * associated with it, as that would trip up later checks and
+         * it doesn't make sense anyway */
+        if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE)
+            cont->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE;
+
         /* forbid usb model 'qusb1' and 'qusb2' in this kind of hyperviosr */
         if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1 ||
             cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2) {
index 6e879ded86ca4753dfce778974f957dab947607c..300dea13823ad4316388afdf46ae516f4fd20c31 100644 (file)
       <alias name='virtio-disk4'/>
       <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
     </disk>
-    <controller type='usb' index='0'>
+    <controller type='usb' index='0' model='none'>
       <alias name='usb'/>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'>
-        <zpci uid='0x0001' fid='0x00000000'/>
-      </address>
     </controller>
     <controller type='scsi' index='0' model='virtio-scsi'>
       <alias name='scsi0'/>
index 9b16951e4652daefe0bb47b41c3f36a702182b44..882a509eeb2d79f67b7c65a31c92e82a931ba405 100644 (file)
       <alias name='virtio-disk1'/>
       <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
     </disk>
-    <controller type='usb' index='0'>
+    <controller type='usb' index='0' model='none'>
       <alias name='usb'/>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'>
-        <zpci uid='0x0001' fid='0x00000000'/>
-      </address>
     </controller>
     <controller type='scsi' index='0' model='virtio-scsi'>
       <alias name='scsi0'/>
index b5292a7ed21cd5d8770e8f138a2c1fe8bc116679..6167d54bd23ee831b7c8ec20e8c2118c0af3269b 100644 (file)
       <alias name='virtio-disk0'/>
       <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
     </disk>
-    <controller type='usb' index='0'>
+    <controller type='usb' index='0' model='none'>
       <alias name='usb'/>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'>
-        <zpci uid='0x0001' fid='0x00000000'/>
-      </address>
     </controller>
     <controller type='scsi' index='0' model='virtio-scsi'>
       <alias name='scsi0'/>
index f37868101c43d3e5b4056aed0fc507140ef29178..67a5c84a6c682b5c5476927d694d3ca69327ec83 100644 (file)
       <alias name='virtio-disk4'/>
       <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
     </disk>
-    <controller type='usb' index='0'>
+    <controller type='usb' index='0' model='none'>
       <alias name='usb'/>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'>
-        <zpci uid='0x0001' fid='0x00000000'/>
-      </address>
     </controller>
     <controller type='scsi' index='0' model='virtio-scsi'>
       <alias name='scsi0'/>
index f37868101c43d3e5b4056aed0fc507140ef29178..67a5c84a6c682b5c5476927d694d3ca69327ec83 100644 (file)
       <alias name='virtio-disk4'/>
       <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
     </disk>
-    <controller type='usb' index='0'>
+    <controller type='usb' index='0' model='none'>
       <alias name='usb'/>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'>
-        <zpci uid='0x0001' fid='0x00000000'/>
-      </address>
     </controller>
     <controller type='scsi' index='0' model='virtio-scsi'>
       <alias name='scsi0'/>
index 42f89a07a2243dc4c0622083123d9e95b2badc37..07bbfa24a2ca6be1d02207cb0990037f49d3d296 100644 (file)
       <alias name='virtio-disk4'/>
       <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
     </disk>
-    <controller type='usb' index='0'>
+    <controller type='usb' index='0' model='none'>
       <alias name='usb'/>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'>
-        <zpci uid='0x0001' fid='0x00000000'/>
-      </address>
     </controller>
     <controller type='scsi' index='0' model='virtio-scsi'>
       <alias name='scsi0'/>
index f0570b5cf411ceb95acf656eeaee823a56127107..4869103a06d2690cdbd0e90010e0d3ae61756b45 100644 (file)
   <on_crash>restart</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-s390x</emulator>
-    <controller type='usb' index='0'>
+    <controller type='usb' index='0' model='none'>
       <alias name='usb'/>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'>
-        <zpci uid='0x0001' fid='0x00000000'/>
-      </address>
     </controller>
     <controller type='scsi' index='0' model='virtio-scsi'>
       <alias name='scsi0'/>
index 595d0b1a1eea0380a04b0da90ce0419e74f6392b..e17098a3dfb686d86f6be3496bf6f73e3d342bb0 100644 (file)
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-s390x</emulator>
-    <controller type='usb' index='0'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'>
-        <zpci uid='0x0001' fid='0x00000000'/>
-      </address>
-    </controller>
+    <controller type='usb' index='0' model='none'/>
     <controller type='pci' index='0' model='pci-root'/>
     <audio id='1' type='none'/>
     <memballoon model='none'/>