qemuDomainDefAddDefaultDevices: Populate default USB for 'versatilepb' and 'realview' ARM machines

The machine types historically have a default USB controller populated
via '-usb' which libvirt assumed implicitly. Qemu will use 'pci-ohci'
for both if '-usb' is used.

Unfortunately an USB controller instantiated via '-usb' is unusable as
the bus name libvirt generates doesn't reflect the real name qemu uses,
and thus no libvirt-defined USB devices can be put on the controller.

This patch will populate the default USB controller into the XML and
select it's model to 'pci-ohci' unconditionally as the machine would
fail to start with '-usb' if that controller model is not available.

This patch doesn't try to make any other assumptions about
auto-populated model of USB controllers, which means that for an
explicit USB controller without model a different model will be picked.

Note that this will likely cause ABI differences and break migration for
the two machine types, in the corner case when the default USB
controller would be populated, but given that both are obsolete board
types and USB was unusable it doesn't make sense to keep supporting this
specific case when '-usb' was formatted.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Peter Krempa 2024-02-26 16:17:41 +01:00
parent d885d39f10
commit c6d71bf813
13 changed files with 28 additions and 6 deletions

View File

@ -4195,6 +4195,14 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver,
if (STREQ(def->os.machine, "versatilepb"))
addPCIRoot = true;
/* Add default USB for the two machine types which historically
* supported -usb */
if (STREQ(def->os.machine, "versatilepb") ||
STRPREFIX(def->os.machine, "realview")) {
addDefaultUSB = true;
usbModel = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
}
if (qemuDomainIsARMVirt(def))
addPCIeRoot = true;

View File

@ -25,7 +25,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-aarch64test/.config \
-rtc base=utc \
-no-shutdown \
-boot strict=on \
-usb \
-device '{"driver":"pci-ohci","id":"usb"}' \
-audiodev '{"id":"audio1","driver":"none"}' \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on

View File

@ -15,6 +15,7 @@
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-aarch64</emulator>
<controller type='usb' index='0' model='pci-ohci'/>
<audio id='1' type='none'/>
<memballoon model='none'/>
</devices>

View File

@ -25,7 +25,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-aarch64test/.config \
-rtc base=utc \
-no-shutdown \
-boot strict=on \
-usb \
-device '{"driver":"pci-ohci","id":"usb"}' \
-audiodev '{"id":"audio1","driver":"none"}' \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on

View File

@ -15,6 +15,7 @@
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-aarch64</emulator>
<controller type='usb' index='0' model='pci-ohci'/>
<audio id='1' type='none'/>
<memballoon model='none'/>
</devices>

View File

@ -26,7 +26,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-aarch64test/.config \
-rtc base=utc \
-no-shutdown \
-boot strict=on \
-usb \
-device '{"driver":"pci-ohci","id":"usb","bus":"pci","addr":"0x1"}' \
-audiodev '{"id":"audio1","driver":"none"}' \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on

View File

@ -15,6 +15,9 @@
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-aarch64</emulator>
<controller type='usb' index='0' model='pci-ohci'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<audio id='1' type='none'/>
<memballoon model='none'/>

View File

@ -26,7 +26,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-aarch64test/.config \
-rtc base=utc \
-no-shutdown \
-boot strict=on \
-usb \
-device '{"driver":"pci-ohci","id":"usb","bus":"pci","addr":"0x1"}' \
-audiodev '{"id":"audio1","driver":"none"}' \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on

View File

@ -15,6 +15,9 @@
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-aarch64</emulator>
<controller type='usb' index='0' model='pci-ohci'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<audio id='1' type='none'/>
<memballoon model='none'/>

View File

@ -26,7 +26,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-armv7ltest/.config \
-rtc base=utc \
-no-shutdown \
-boot strict=on \
-usb \
-device '{"driver":"pci-ohci","id":"usb","bus":"pci","addr":"0x1"}' \
-audiodev '{"id":"audio1","driver":"none"}' \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on

View File

@ -17,6 +17,9 @@
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-armv7l</emulator>
<controller type='usb' index='0' model='pci-ohci'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<audio id='1' type='none'/>
<memballoon model='none'/>

View File

@ -26,7 +26,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-armv7ltest/.config \
-rtc base=utc \
-no-shutdown \
-boot strict=on \
-usb \
-device '{"driver":"pci-ohci","id":"usb","bus":"pci","addr":"0x1"}' \
-audiodev '{"id":"audio1","driver":"none"}' \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on

View File

@ -17,6 +17,9 @@
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-armv7l</emulator>
<controller type='usb' index='0' model='pci-ohci'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<audio id='1' type='none'/>
<memballoon model='none'/>