]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Allow USB hostdev product to be 0x0000
authorCole Robinson <crobinso@redhat.com>
Tue, 16 Jun 2009 18:46:06 +0000 (18:46 +0000)
committerCole Robinson <crobinso@redhat.com>
Tue, 16 Jun 2009 18:46:06 +0000 (18:46 +0000)
Product = 0 is a valid value based on this bug report:

https://www.redhat.com/archives/libvir-list/2009-May/msg00368.html

Also, throw a less ambiguous error if vendor = 0.

ChangeLog
src/domain_conf.c
tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args
tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.xml

index 8dd22edf9d6393cc0ea6a386d45fd2d09c5b3564..957cbfef5d40d741870b1e26468debc03bcb14a2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Jun 16 14:30:05 EDT 2009 Cole Robinson <crobinso@redhat.com>
+
+       * src/domain_conf.c
+       tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args
+       tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.xml:
+       Allow USB hostdev product to be 0x0000
+
 Tue Jun 16 11:43:17 EDT 2009 Cole Robinson <crobinso@redhat.com>
 
        * src/storage_backend_fs.c: Fix FS volume creation with backing stores.
index c6958206190061537c4eaf36ab2c4cc9ae5bb02e..e7523f586cc809c79024246332e0e0302be342a1 100644 (file)
@@ -1660,8 +1660,14 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
                                      int flags ATTRIBUTE_UNUSED) {
 
     int ret = -1;
+    int got_product, got_vendor;
     xmlNodePtr cur;
 
+    /* Product can validly be 0, so we need some extra help to determine
+     * if it is uninitialized*/
+    got_product = 0;
+    got_vendor = 0;
+
     cur = node->children;
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
@@ -1669,6 +1675,7 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
                 char *vendor = virXMLPropString(cur, "id");
 
                 if (vendor) {
+                    got_vendor = 1;
                     if (virStrToLong_ui(vendor, NULL, 0,
                                     &def->source.subsys.u.usb.vendor) < 0) {
                         virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
@@ -1686,6 +1693,7 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
                 char* product = virXMLPropString(cur, "id");
 
                 if (product) {
+                    got_product = 1;
                     if (virStrToLong_ui(product, NULL, 0,
                                         &def->source.subsys.u.usb.product) < 0) {
                         virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
@@ -1745,14 +1753,18 @@ virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
         cur = cur->next;
     }
 
-    if (def->source.subsys.u.usb.vendor == 0 &&
-        def->source.subsys.u.usb.product != 0) {
+    if (got_vendor && def->source.subsys.u.usb.vendor == 0) {
+        virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+            "%s", _("vendor cannot be 0."));
+        goto out;
+    }
+
+    if (!got_vendor && got_product) {
         virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
             "%s", _("missing vendor"));
         goto out;
     }
-    if (def->source.subsys.u.usb.vendor != 0 &&
-        def->source.subsys.u.usb.product == 0) {
+    if (got_vendor && !got_product) {
         virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
             "%s", _("missing product"));
         goto out;
index e207871a7554ddcdb118c2b77f2d75c17b05af98..f4c8f60c6e5434e91270ea1574155cab9f25f3d5 100644 (file)
@@ -1 +1 @@
-LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice host:0204:6025
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice host:0204:6025 -usbdevice host:1234:0000
index b86166563ed39338460a4ad83794490e7d694757..6cb1ba18ff5010852d21beb662e690897d1a65e5 100644 (file)
         <product id='0x6025'/>
       </source>
     </hostdev>
+    <hostdev mode='subsystem' type='usb' managed='no'>
+      <source>
+        <vendor id='0x1234'/>
+        <product id='0x0000'/>
+      </source>
+    </hostdev>
   </devices>
 </domain>