From 2e0dbaad9bef29c0687032a21c57e8d5c67ab55e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 6 Sep 2011 15:06:59 +0800 Subject: [PATCH] redirdev: allows to specify device address It is important to be able to attach USB redirected devices to a particular controller (one that supports USB2 for instance). Without this patch, only the default bus was used.
--- docs/formatdomain.html.in | 19 +++++++++++++------ docs/schemas/domaincommon.rng | 3 +++ src/conf/domain_conf.c | 14 ++++++++++++++ .../qemuxml2argv-usb-redir.args | 2 +- .../qemuxml2argv-usb-redir.xml | 1 + 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index b6e6de3994..54e81b0d9e 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1449,14 +1449,21 @@ tunnel; type='tcp' or type='spicevmc' (which uses the usbredir channel of a SPICE graphics - device) are typical. Further sub-elements, such - as <source>, may be required according to - the given type, although a <target> - sub-element is not required (since the consumer of the - character device is the hypervisor itself, rather than a - device visible in the guest). + device) are typical. +

+ The redirdev element has an optional sub-element + <address> which can tie the device to a + particular controller. +

+

+ Further sub-elements, such as <source>, may + be required according to the given type, although + a <target> sub-element is not required (since + the consumer of the character device is the hypervisor itself, + rather than a device visible in the guest). +

Smartcard devices

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index e2269d004c..d0da41c583 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2008,6 +2008,9 @@ + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 77428f5aa7..5d95ee7136 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5553,6 +5553,18 @@ virDomainRedirdevDefParseXML(const xmlNodePtr node, def->source.chr.data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_USBREDIR; } + if (virDomainDeviceInfoParseXML(node, &def->info, flags) < 0) + goto error; + + if (def->bus == VIR_DOMAIN_REDIRDEV_BUS_USB && + def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { + virDomainReportError(VIR_ERR_XML_ERROR, "%s", + _("Invalid address for a USB device")); + goto error; + } + + cleanup: VIR_FREE(bus); VIR_FREE(type); @@ -10343,6 +10355,8 @@ virDomainRedirdevDefFormat(virBufferPtr buf, virBufferAsprintf(buf, " source.chr, false, flags) < 0) return -1; + if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + return -1; virBufferAddLit(buf, " \n"); return 0; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args index 4d4f30a1f6..f6270d504b 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args @@ -6,5 +6,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -chardev socket,id=charredir0,host=localhost,port=4000 \ -device usb-redir,chardev=charredir0,id=redir0 \ -chardev spicevmc,id=charredir1,name=usbredir \ --device usb-redir,chardev=charredir1,id=redir1 \ +-device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=4 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,multifunction=on,addr=0x3.0x0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.xml index c73e569f2b..1dac3fbc93 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.xml @@ -34,6 +34,7 @@ +
-- 2.39.5