mirror of https://gitee.com/openkylin/libvirt.git
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. <redirdev bus='usb' type='spicevmc'> <address type='usb' bus='0' port='4'/> </redirdev>
This commit is contained in:
parent
59e22b7258
commit
2e0dbaad9b
|
@ -1449,14 +1449,21 @@
|
|||
tunnel; <code>type='tcp'</code>
|
||||
or <code>type='spicevmc'</code> (which uses the usbredir
|
||||
channel of a <a href="#elementsGraphics">SPICE graphics
|
||||
device</a>) are typical. Further sub-elements, such
|
||||
as <code><source></code>, may be required according to
|
||||
the given type, although a <code><target></code>
|
||||
sub-element is not required (since the consumer of the
|
||||
character device is the hypervisor itself, rather than a
|
||||
device visible in the guest).</dd>
|
||||
device</a>) are typical.</dd>
|
||||
|
||||
</dl>
|
||||
<p>
|
||||
The redirdev element has an optional sub-element
|
||||
<code><address></code> which can tie the device to a
|
||||
particular controller.
|
||||
</p>
|
||||
<p>
|
||||
Further sub-elements, such as <code><source></code>, may
|
||||
be required according to the given type, although
|
||||
a <code><target></code> sub-element is not required (since
|
||||
the consumer of the character device is the hypervisor itself,
|
||||
rather than a device visible in the guest).
|
||||
</p>
|
||||
|
||||
<h4><a name="elementsSmartcard">Smartcard devices</a></h4>
|
||||
|
||||
|
|
|
@ -2008,6 +2008,9 @@
|
|||
<ref name="qemucdevSrcTypeChoice"/>
|
||||
</attribute>
|
||||
<ref name="qemucdevSrcDef"/>
|
||||
<optional>
|
||||
<ref name="address"/>
|
||||
</optional>
|
||||
</element>
|
||||
</define>
|
||||
<define name="hostdev">
|
||||
|
|
|
@ -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, " <redirdev bus='%s'", bus);
|
||||
if (virDomainChrSourceDefFormat(buf, &def->source.chr, false, flags) < 0)
|
||||
return -1;
|
||||
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
||||
return -1;
|
||||
virBufferAddLit(buf, " </redirdev>\n");
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
<protocol type='raw'/>
|
||||
</redirdev>
|
||||
<redirdev bus='usb' type='spicevmc'>
|
||||
<address type='usb' bus='0' port='4'/>
|
||||
</redirdev>
|
||||
<memballoon model='virtio'/>
|
||||
</devices>
|
||||
|
|
Loading…
Reference in New Issue