mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: support configuring usb3 controller port count
This adds a ports= attribute to usb controller XML, like <controller type='usb' model='nec-xhci' ports='8'/> 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
This commit is contained in:
parent
48e12de51e
commit
600977e293
@ -3028,8 +3028,10 @@
|
||||
<span class="since">since 0.10.0</span>, if the USB bus needs to be
|
||||
explicitly disabled for the guest, <code>model='none'</code> may be
|
||||
used. <span class="since">Since 1.0.5</span>, 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. <span class="since">Since 1.3.5</span>, USB
|
||||
controllers accept a <code>ports</code> attribute to configure how
|
||||
many devices can be connected to the controller. The PowerPC64
|
||||
"spapr-vio" addresses do not have an associated controller.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
@ -1743,7 +1743,8 @@
|
||||
</attribute>
|
||||
</optional>
|
||||
</group>
|
||||
<!-- usb has an optional attribute "model", and optional subelement "master" -->
|
||||
<!-- usb has an optional attribute "model",
|
||||
and optional subelements "master" and "ports" -->
|
||||
<group>
|
||||
<attribute name="type">
|
||||
<value>usb</value>
|
||||
@ -1768,6 +1769,11 @@
|
||||
<optional>
|
||||
<ref name="usbmaster"/>
|
||||
</optional>
|
||||
<optional>
|
||||
<attribute name="ports">
|
||||
<ref name="unsignedInt"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
</group>
|
||||
<!-- pci has an optional attribute "model" -->
|
||||
<group>
|
||||
|
@ -1655,6 +1655,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;
|
||||
@ -1667,7 +1670,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;
|
||||
}
|
||||
@ -7837,6 +7839,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;
|
||||
|
||||
@ -7949,20 +7953,19 @@ virDomainControllerDefParseXML(xmlNodePtr node,
|
||||
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) {
|
||||
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"), ports);
|
||||
VIR_FREE(ports);
|
||||
_("Invalid ports: %s"), portsStr);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
VIR_FREE(ports);
|
||||
|
||||
switch (def->type) {
|
||||
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: {
|
||||
def->opts.vioserial.ports = ports;
|
||||
|
||||
char *vectors = virXMLPropString(node, "vectors");
|
||||
if (vectors) {
|
||||
@ -7998,6 +8001,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:
|
||||
@ -8125,6 +8130,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
|
||||
VIR_FREE(port);
|
||||
VIR_FREE(busNr);
|
||||
VIR_FREE(ioeventfd);
|
||||
VIR_FREE(portsStr);
|
||||
|
||||
return def;
|
||||
|
||||
@ -17219,6 +17225,13 @@ virDomainControllerDefCheckABIStability(virDomainControllerDefPtr src,
|
||||
dst->opts.vioserial.vectors, src->opts.vioserial.vectors);
|
||||
return false;
|
||||
}
|
||||
} else if (src->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) {
|
||||
if (src->opts.usbopts.ports != dst->opts.usbopts.ports) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Target controller ports %d does not match source %d"),
|
||||
dst->opts.usbopts.ports, src->opts.usbopts.ports);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
|
||||
@ -19448,6 +19461,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;
|
||||
|
@ -846,6 +846,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;
|
||||
@ -858,6 +864,7 @@ struct _virDomainControllerDef {
|
||||
union {
|
||||
virDomainVirtioSerialOpts vioserial;
|
||||
virDomainPCIControllerOpts pciopts;
|
||||
virDomainUSBControllerOpts usbopts;
|
||||
} opts;
|
||||
virDomainDeviceInfo info;
|
||||
};
|
||||
|
@ -2152,6 +2152,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);
|
||||
|
22
tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci.args
Normal file
22
tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci.args
Normal file
@ -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
|
16
tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci.xml
Normal file
16
tests/qemuxml2argvdata/qemuxml2argv-usb-controller-xhci.xml
Normal 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='8'/>
|
||||
<memballoon model='none'/>
|
||||
</devices>
|
||||
</domain>
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user