]> xenbits.xensource.com Git - libvirt.git/commitdiff
redirdev: allows to specify device address
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 6 Sep 2011 07:06:59 +0000 (15:06 +0800)
committerDaniel Veillard <veillard@redhat.com>
Tue, 6 Sep 2011 07:12:52 +0000 (15:12 +0800)
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>

docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args
tests/qemuxml2argvdata/qemuxml2argv-usb-redir.xml

index b6e6de3994ee0a4a37b6e74030061a84f0cad54c..54e81b0d9e25368417289ca90eb0febd09bb5212 100644 (file)
         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>&lt;source&gt;</code>, may be required according to
-        the given type, although a <code>&lt;target&gt;</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>&lt;address&gt;</code> which can tie the device to a
+      particular controller.
+    </p>
+    <p>
+      Further sub-elements, such as <code>&lt;source&gt;</code>, may
+      be required according to the given type, although
+      a <code>&lt;target&gt;</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>
 
index e2269d004ce31b2a6064499fecba80c842b50182..d0da41c5837b1293f750b6043dff320e6c2e1d30 100644 (file)
         <ref name="qemucdevSrcTypeChoice"/>
       </attribute>
       <ref name="qemucdevSrcDef"/>
+      <optional>
+        <ref name="address"/>
+      </optional>
     </element>
   </define>
   <define name="hostdev">
index 77428f5aa7b992f91f9eda1558419140e5ad176c..5d95ee71368e45718f011c7f859cf3022317ed7a 100644 (file)
@@ -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;
index 4d4f30a1f6d8fe5b0b7ef5c0a4a63150a7cb41ab..f6270d504bb162c971365676459ff2a333016515 100644 (file)
@@ -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
index c73e569f2b3b60d5a6b5df98e2b81899c5734329..1dac3fbc937df48da71ccf2abc66ae0a72cd48d6 100644 (file)
@@ -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>