mirror of https://gitee.com/openkylin/libvirt.git
qemu: auto-add a USB2 controller set for Q35 machines
Use virDomainDefAddUSBController() to add an EHCI1+UHCI1+UHCI2+UHCI3 controller set to newly defined Q35 domains that don't have any USB controllers defined.
This commit is contained in:
parent
8ebca27bb7
commit
bd04ad42e7
|
@ -1039,6 +1039,7 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
|
|||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
bool addDefaultUSB = true;
|
||||
int usbModel = -1; /* "default for machinetype" */
|
||||
bool addImplicitSATA = false;
|
||||
bool addPCIRoot = false;
|
||||
bool addPCIeRoot = false;
|
||||
|
@ -1061,8 +1062,15 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
|
|||
if (STRPREFIX(def->os.machine, "pc-q35") ||
|
||||
STREQ(def->os.machine, "q35")) {
|
||||
addPCIeRoot = true;
|
||||
addDefaultUSB = false;
|
||||
addImplicitSATA = true;
|
||||
|
||||
/* add a USB2 controller set, but only if the
|
||||
* ich9-usb-ehci1 device is supported
|
||||
*/
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_USB_EHCI1))
|
||||
usbModel = VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1;
|
||||
else
|
||||
addDefaultUSB = false;
|
||||
break;
|
||||
}
|
||||
if (!STRPREFIX(def->os.machine, "pc-0.") &&
|
||||
|
@ -1120,8 +1128,8 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
|
|||
}
|
||||
|
||||
if (addDefaultUSB &&
|
||||
virDomainDefMaybeAddController(
|
||||
def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0, -1) < 0)
|
||||
virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0) < 0 &&
|
||||
virDomainDefAddUSBController(def, 0, usbModel) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (addImplicitSATA &&
|
||||
|
|
|
@ -18,6 +18,11 @@ QEMU_AUDIO_DRV=none \
|
|||
-boot c \
|
||||
-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
|
||||
-device pci-bridge,chassis_nr=56,id=pci.2,bus=pci.1,addr=0x1 \
|
||||
-device ich9-usb-ehci1,id=usb,bus=pcie.0,addr=0x1d.0x7 \
|
||||
-device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pcie.0,multifunction=on,\
|
||||
addr=0x1d \
|
||||
-device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pcie.0,addr=0x1d.0x1 \
|
||||
-device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pcie.0,addr=0x1d.0x2 \
|
||||
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-sata0-0-0 \
|
||||
-device ide-drive,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0 \
|
||||
-vga qxl \
|
||||
|
|
|
@ -1504,6 +1504,7 @@ mymain(void)
|
|||
QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
||||
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
|
||||
QEMU_CAPS_ICH9_AHCI,
|
||||
QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
|
||||
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
|
||||
QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL);
|
||||
DO_TEST("q35-pm-disable",
|
||||
|
|
Loading…
Reference in New Issue