[libvirt] [PATCH 13/13] Tweak USB hostdevice XML handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 |    7 ++++++-
 src/conf/domain_conf.c  |    5 +++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 827ff6f..bb6d00d 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1179,7 +1179,12 @@
       <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"/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b434fc5..766993c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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,
-- 
1.6.5.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]