]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Tweak USB hostdevice XML handling
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 1 Feb 2010 17:21:05 +0000 (17:21 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 2 Feb 2010 16:31:47 +0000 (16:31 +0000)
When attaching a USB host device based on vendor/product, libvirt
will resolve the vendor/product into a device/bus pair. This means
that when printing XML we should allow device/bus info to be printed
at any time if present

* src/conf/domain_conf.c, docs/schemas/domain.rng: Allow USB device
  bus info alongside vendor/product

docs/schemas/domain.rng
src/conf/domain_conf.c

index 827ff6f19126fe768c72b69df0da85e088a87066..bb6d00d7c1f42285e3d93436447764dbda41b645 100644 (file)
       <group>
         <element name="source">
           <choice>
-            <ref name="usbproduct"/>
+           <group>
+              <ref name="usbproduct"/>
+             <optional>
+               <ref name="usbaddress"/>
+             </optional>
+           </group>
             <ref name="usbaddress"/>
             <element name="address">
               <ref name="pciaddress"/>
index b434fc5d00cc3a90392c92b30c2d9813b3a25b08..766993c58678ecc169b04723ac4e9f5fac23f1cb 100644 (file)
@@ -5244,11 +5244,12 @@ virDomainHostdevDefFormat(virConnectPtr conn,
                               def->source.subsys.u.usb.vendor);
             virBufferVSprintf(buf, "        <product id='0x%.4x'/>\n",
                               def->source.subsys.u.usb.product);
-        } else {
+        }
+        if (def->source.subsys.u.usb.bus ||
+            def->source.subsys.u.usb.device)
             virBufferVSprintf(buf, "        <address bus='%d' device='%d'/>\n",
                               def->source.subsys.u.usb.bus,
                               def->source.subsys.u.usb.device);
-        }
     } else if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
         virBufferVSprintf(buf, "        <address domain='0x%.4x' bus='0x%.2x' slot='0x%.2x' function='0x%.1x'/>\n",
                           def->source.subsys.u.pci.domain,