From patchwork Wed Apr 27 18:29:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 66822 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2345803qge; Wed, 27 Apr 2016 11:32:27 -0700 (PDT) X-Received: by 10.194.9.201 with SMTP id c9mr10777863wjb.7.1461781947160; Wed, 27 Apr 2016 11:32:27 -0700 (PDT) Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com. [209.132.183.24]) by mx.google.com with ESMTPS id dh8si3494526wjc.67.2016.04.27.11.32.26 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Apr 2016 11:32:27 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u3RITfWG025102; Wed, 27 Apr 2016 14:29:41 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u3RITUh3004054 for ; Wed, 27 Apr 2016 14:29:30 -0400 Received: from colepc.redhat.com (ovpn-113-44.phx2.redhat.com [10.3.113.44]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3RITRjQ002489; Wed, 27 Apr 2016 14:29:29 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 27 Apr 2016 14:29:23 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] qemu: support configuring usb3 controller port count X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com This adds a ports= attribute to usb controller XML, like This maps to: qemu -device nec-usb-xhci,p2=8,p3=8 Meaning, 8 ports that support both usb2 and usb3 devices. Gerd suggested to just expose them as one knob. https://bugzilla.redhat.com/show_bug.cgi?id=1271408 --- docs/formatdomain.html.in | 6 ++-- docs/schemas/domaincommon.rng | 8 ++++- src/conf/domain_conf.c | 39 ++++++++++++++-------- src/conf/domain_conf.h | 7 ++++ src/qemu/qemu_command.c | 13 ++++++++ .../qemuxml2argv-usb-controller-xhci.args | 22 ++++++++++++ .../qemuxml2argv-usb-controller-xhci.xml | 16 +++++++++ tests/qemuxml2argvtest.c | 3 ++ 8 files changed, 98 insertions(+), 16 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci.xml -- 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index d2db53b..dc15664 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3028,8 +3028,10 @@ since 0.10.0, if the USB bus needs to be explicitly disabled for the guest, model='none' may be used. Since 1.0.5, no default USB controller - will be built on s390. The PowerPC64 "spapr-vio" addresses do not have an - associated controller. + will be built on s390. Since 1.3.5, USB + controllers accept a ports attribute to configure how + many devices can be connected to the controller. The PowerPC64 + "spapr-vio" addresses do not have an associated controller.

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index f77bbcf..2deea34 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1743,7 +1743,8 @@ - + usb @@ -1768,6 +1769,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 04817bd..fa560f3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1654,6 +1654,9 @@ virDomainControllerDefNew(virDomainControllerType type) def->opts.vioserial.ports = -1; def->opts.vioserial.vectors = -1; break; + case VIR_DOMAIN_CONTROLLER_TYPE_USB: + def->opts.usbopts.ports = -1; + break; case VIR_DOMAIN_CONTROLLER_TYPE_PCI: def->opts.pciopts.chassisNr = -1; def->opts.pciopts.chassis = -1; @@ -1666,7 +1669,6 @@ virDomainControllerDefNew(virDomainControllerType type) case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: case VIR_DOMAIN_CONTROLLER_TYPE_SATA: case VIR_DOMAIN_CONTROLLER_TYPE_CCID: - case VIR_DOMAIN_CONTROLLER_TYPE_USB: case VIR_DOMAIN_CONTROLLER_TYPE_LAST: break; } @@ -7824,6 +7826,8 @@ virDomainControllerDefParseXML(xmlNodePtr node, char *busNr = NULL; int numaNode = -1; char *ioeventfd = NULL; + char *portsStr = NULL; + int ports = -1; xmlNodePtr saved = ctxt->node; int rc; @@ -7936,20 +7940,19 @@ virDomainControllerDefParseXML(xmlNodePtr node, goto error; } + portsStr = virXMLPropString(node, "ports"); + if (portsStr) { + int r = virStrToLong_i(portsStr, NULL, 10, &ports); + if (r != 0 || ports < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid ports: %s"), portsStr); + goto error; + } + } + switch (def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: { - char *ports = virXMLPropString(node, "ports"); - if (ports) { - int r = virStrToLong_i(ports, NULL, 10, - &def->opts.vioserial.ports); - if (r != 0 || def->opts.vioserial.ports < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid ports: %s"), ports); - VIR_FREE(ports); - goto error; - } - } - VIR_FREE(ports); + def->opts.vioserial.ports = ports; char *vectors = virXMLPropString(node, "vectors"); if (vectors) { @@ -7985,6 +7988,8 @@ virDomainControllerDefParseXML(xmlNodePtr node, def->info.mastertype = VIR_DOMAIN_CONTROLLER_MASTER_USB; def->info.master.usb.startport = masterPort; } + + def->opts.usbopts.ports = ports; break; } case VIR_DOMAIN_CONTROLLER_TYPE_PCI: @@ -8112,6 +8117,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, VIR_FREE(port); VIR_FREE(busNr); VIR_FREE(ioeventfd); + VIR_FREE(portsStr); return def; @@ -19429,6 +19435,13 @@ virDomainControllerDefFormat(virBufferPtr buf, } break; + case VIR_DOMAIN_CONTROLLER_TYPE_USB: + if (def->opts.usbopts.ports != -1) { + virBufferAsprintf(buf, " ports='%d'", + def->opts.usbopts.ports); + } + break; + case VIR_DOMAIN_CONTROLLER_TYPE_PCI: if (def->opts.pciopts.pcihole64) pcihole64 = true; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d98f052..9071fe0 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -845,6 +845,12 @@ struct _virDomainPCIControllerOpts { int numaNode; }; +typedef struct _virDomainUSBControllerOpts virDomainUSBControllerOpts; +typedef virDomainUSBControllerOpts *virDomainUSBControllerOptsPtr; +struct _virDomainUSBControllerOpts { + int ports; /* -1 == undef */ +}; + /* Stores the virtual disk controller configuration */ struct _virDomainControllerDef { int type; @@ -857,6 +863,7 @@ struct _virDomainControllerDef { union { virDomainVirtioSerialOpts vioserial; virDomainPCIControllerOpts pciopts; + virDomainUSBControllerOpts usbopts; } opts; virDomainDeviceInfo info; }; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9597b30..7530c4a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2180,6 +2180,19 @@ qemuBuildUSBControllerDevStr(const virDomainDef *domainDef, virBufferAsprintf(buf, "%s", smodel); + if (def->opts.usbopts.ports != -1) { + if (model != VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI || + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI_PORTS)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("usb controller type %s doesn't support 'ports' " + "with this QEMU binary"), smodel); + return -1; + } + + virBufferAsprintf(buf, ",p2=%d,p3=%d", + def->opts.usbopts.ports, def->opts.usbopts.ports); + } + if (def->info.mastertype == VIR_DOMAIN_CONTROLLER_MASTER_USB) virBufferAsprintf(buf, ",masterbus=%s.0,firstport=%d", def->info.alias, def->info.master.usb.startport); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci.args new file mode 100644 index 0000000..b91adc4 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci.args @@ -0,0 +1,22 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefconfig \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-no-acpi \ +-boot c \ +-device nec-usb-xhci,p2=8,p3=8,id=usb,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci.xml new file mode 100644 index 0000000..f5b7c56 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci.xml @@ -0,0 +1,16 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + /usr/bin/qemu + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 8842b2f..31a0ce1 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1172,6 +1172,9 @@ mymain(void) QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_PCI_OHCI, QEMU_CAPS_PIIX3_USB_UHCI); + DO_TEST("usb-controller-xhci", + 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);