]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Check for pci-ohci availability
authorAndrea Bolognani <abologna@redhat.com>
Wed, 6 Aug 2025 14:34:58 +0000 (16:34 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 6 Oct 2025 09:15:26 +0000 (11:15 +0200)
We assign the USB controller model without first checking
whether the corresponding QEMU device is available, and that
results in a late error instead of an early one.

Be consistent with how we do things in all other cases and
check the presence of the capability before attempting to set
the model.

Signed-off-by: Andrea Bolognani <abologna@redhat.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/qemuxmlconfdata/usb-controller-automatic-unavailable-realview.aarch64-latest.err
tests/qemuxmlconfdata/usb-controller-automatic-unavailable-realview.aarch64-latest.xml
tests/qemuxmlconfdata/usb-controller-automatic-unavailable-versatilepb.armv7l-latest.err
tests/qemuxmlconfdata/usb-controller-automatic-unavailable-versatilepb.armv7l-latest.xml

index 9c2427970dd6b44b1554b9cec9a35caf6be09db2..5f59b79d56c519c29c69cd213209a43bcebbbc95 100644 (file)
@@ -1299,7 +1299,8 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver,
         if (STREQ(def->os.machine, "versatilepb") ||
             STRPREFIX(def->os.machine, "realview")) {
             addDefaultUSB = true;
-            usbModel = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
+            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI))
+                usbModel = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
         }
 
         if (qemuDomainIsARMVirt(def))
index 918b72dbe9652c28190febad66f76c3f6bb73c80..cac4e8e76010a89f1aaca81df8b7cb06feddd45d 100644 (file)
@@ -1 +1 @@
-unsupported configuration: USB controller model 'pci-ohci' not supported in this QEMU binary
+internal error: Unable to determine model for USB controller idx=0
index 372d5bda6a66ad13e50243b9b37410985bd79e1d..dfa8ef8dbeab097e882c35a429825f5318b38640 100644 (file)
@@ -15,7 +15,7 @@
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-aarch64</emulator>
-    <controller type='usb' index='0' model='pci-ohci'/>
+    <controller type='usb' index='0'/>
     <audio id='1' type='none'/>
     <memballoon model='none'/>
   </devices>
index 918b72dbe9652c28190febad66f76c3f6bb73c80..cac4e8e76010a89f1aaca81df8b7cb06feddd45d 100644 (file)
@@ -1 +1 @@
-unsupported configuration: USB controller model 'pci-ohci' not supported in this QEMU binary
+internal error: Unable to determine model for USB controller idx=0
index 482029e3b09aec8397b8ca8984208bb6aaec2375..93bf8dcd0ad7766cc19bf4884d682d35595b0b7e 100644 (file)
@@ -17,7 +17,7 @@
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-armv7l</emulator>
-    <controller type='usb' index='0' model='pci-ohci'>
+    <controller type='usb' index='0'>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
     </controller>
     <controller type='pci' index='0' model='pci-root'/>