[libvirt] [PATCH] qemu: enforce maximum ports value for nec-xhci
John Ferlan
jferlan at redhat.com
Thu Feb 2 11:52:03 UTC 2017
On 01/31/2017 09:08 AM, Ján Tomko wrote:
> This controller only allows up to 15 ports.
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1375417
> ---
> src/qemu/qemu_domain.c | 8 ++++++++
> .../qemuxml2argv-usb-controller-xhci-limit.xml | 16 ++++++++++++++++
> tests/qemuxml2argvtest.c | 3 +++
> 3 files changed, 27 insertions(+)
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci-limit.xml
>
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index c6ce090..61489e0 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -3147,6 +3147,14 @@ 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 > 15) {
> + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> + _("nec-xhci controller only supports up to 15 ports"));
> + goto cleanup;
> + }
> +
15 is a magic number it seems... Perhaps a #define in domain_conf.h
somewhere to declare the max number of ports. Although yes, I do see
that virDomainUSBAddressControllerModelToPorts also uses magic numbers.
I looked at the QEMU code for nec-usb-xhci - too bad it's not query-able
as a property. The MAXPORTS_2 and MAXPORTS_3 values being defined as 15
and the uports as the max of those two values.
I see tha the QUSB{1|2} ports for the libxl code could have a similar
issue, but who knows what their maximum is...
ACK - w/ a #define somewhere.
John
> if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
> if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS &&
> !qemuDomainMachineIsI440FX(def)) {
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci-limit.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci-limit.xml
> new file mode 100644
> index 0000000..5ff2de7
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci-limit.xml
> @@ -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>
> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 3532cb5..78cb609 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -1415,6 +1415,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);
>
More information about the libvir-list
mailing list