1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

qemu: enforce maximum ports value for nec-xhci

This controller only allows up to 15 ports.

https://bugzilla.redhat.com/show_bug.cgi?id=1375417
This commit is contained in:
Ján Tomko 2016-11-28 17:37:39 +01:00
parent a69f3c9b63
commit 723fef99c0
3 changed files with 31 additions and 0 deletions

View File

@ -3005,6 +3005,9 @@ qemuDomainShmemDefPostParse(virDomainShmemDefPtr shm)
}
#define QEMU_USB_NEC_XHCI_MAXPORTS 15
static int
qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
const virDomainDef *def,
@ -3159,6 +3162,15 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER) {
virDomainControllerDefPtr cont = dev->data.controller;
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI &&
cont->opts.usbopts.ports > QEMU_USB_NEC_XHCI_MAXPORTS) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("nec-xhci controller only supports up to %u ports"),
QEMU_USB_NEC_XHCI_MAXPORTS);
goto cleanup;
}
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS &&
!qemuDomainMachineIsI440FX(def)) {

View File

@ -0,0 +1,16 @@
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<devices>
<emulator>/usr/bin/qemu</emulator>
<controller type='usb' index='0' model='nec-xhci' ports='16'/>
<memballoon model='none'/>
</devices>
</domain>

View File

@ -1418,6 +1418,9 @@ mymain(void)
QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PIIX3_USB_UHCI,
QEMU_CAPS_NEC_USB_XHCI, QEMU_CAPS_NEC_USB_XHCI_PORTS,
QEMU_CAPS_USB_HUB);
DO_TEST_PARSE_ERROR("usb-controller-xhci-limit",
QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PIIX3_USB_UHCI,
QEMU_CAPS_NEC_USB_XHCI, QEMU_CAPS_NEC_USB_XHCI_PORTS);
DO_TEST("smbios", QEMU_CAPS_SMBIOS_TYPE);
DO_TEST_PARSE_ERROR("smbios-date", QEMU_CAPS_SMBIOS_TYPE);