mirror of https://gitee.com/openkylin/libvirt.git
qemu: domain: Reflect USB controller model in guest XML
When the user doesn't specify any model for a USB controller, we use an architecture-dependent default, but we don't reflect it in the guest XML. Pick the default USB controller model when parsing the guest XML instead of when creating the QEMU command line, so that our choice is saved back to disk.
This commit is contained in:
parent
f87cc927f7
commit
f55eaccb0c
|
@ -2614,6 +2614,26 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
|||
virDomainNumaGetNodeCount(def->numa));
|
||||
goto cleanup;
|
||||
}
|
||||
} else if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
|
||||
cont->model == -1) {
|
||||
/* Pick a suitable default model for the USB controller if none
|
||||
* has been selected by the user.
|
||||
*
|
||||
* We rely on device availability instead of setting the model
|
||||
* unconditionally because, for some machine types, there's a
|
||||
* chance we will get away with using the legacy USB controller
|
||||
* when the relevant device is not available.
|
||||
*
|
||||
* See qemuBuildControllerDevCommandLine() */
|
||||
if (ARCH_IS_PPC64(def->os.arch)) {
|
||||
/* Default USB controller for ppc64 is pci-ohci */
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI))
|
||||
cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
|
||||
} else {
|
||||
/* Default USB controller for anything else is piix3-uhci */
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI))
|
||||
cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<on_crash>restart</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/libexec/qemu-system-ppc64</emulator>
|
||||
<controller type='usb' index='0'>
|
||||
<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'/>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<target chassisNr='56'/>
|
||||
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
|
||||
</controller>
|
||||
<controller type='usb' index='0'>
|
||||
<controller type='usb' index='0' model='piix3-uhci'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
|
||||
</controller>
|
||||
<controller type='sata' index='0'>
|
||||
|
|
Loading…
Reference in New Issue