]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Read SCSI address attributes bus, target, unit as positive integer
authorEric Farman <farman@linux.vnet.ibm.com>
Wed, 17 Jun 2015 03:29:51 +0000 (23:29 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 22 Jun 2015 20:03:33 +0000 (16:03 -0400)
The SCSI address element attributes bus, target, and unit are expected
to be positive values, so make sure no one provides a negative value since
the value is stored as an unsigned.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
src/conf/domain_conf.c
tools/virsh-domain.c

index bda0514b02a11b4ef5d8454db77cbb2d941f28b9..0a871ac8daecce34d371ea60afe75a98aa344c3a 100644 (file)
@@ -5024,20 +5024,20 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,
                     goto cleanup;
                 }
 
-                if (virStrToLong_ui(bus, NULL, 0, &scsihostsrc->bus) < 0) {
+                if (virStrToLong_uip(bus, NULL, 0, &scsihostsrc->bus) < 0) {
                     virReportError(VIR_ERR_INTERNAL_ERROR,
                                    _("cannot parse bus '%s'"), bus);
                     goto cleanup;
                 }
 
-                if (virStrToLong_ui(target, NULL, 0,
+                if (virStrToLong_uip(target, NULL, 0,
                                     &scsihostsrc->target) < 0) {
                     virReportError(VIR_ERR_INTERNAL_ERROR,
                                    _("cannot parse target '%s'"), target);
                     goto cleanup;
                 }
 
-                if (virStrToLong_ui(unit, NULL, 0, &scsihostsrc->unit) < 0) {
+                if (virStrToLong_uip(unit, NULL, 0, &scsihostsrc->unit) < 0) {
                     virReportError(VIR_ERR_INTERNAL_ERROR,
                                    _("cannot parse unit '%s'"), unit);
                     goto cleanup;
index 4e890f406306cc47361d00a8fff947856780d235..afdc61eef69ca5e88f8052b741541a8c723eb08b 100644 (file)
@@ -480,15 +480,15 @@ static int str2SCSIAddress(const char *str, struct SCSIAddress *scsiAddr)
 
     controller = (char *)str;
 
-    if (virStrToLong_ui(controller, &bus, 0, &scsiAddr->controller) != 0)
+    if (virStrToLong_uip(controller, &bus, 0, &scsiAddr->controller) != 0)
         return -1;
 
     bus++;
-    if (virStrToLong_ui(bus, &unit, 0, &scsiAddr->bus) != 0)
+    if (virStrToLong_uip(bus, &unit, 0, &scsiAddr->bus) != 0)
         return -1;
 
     unit++;
-    if (virStrToLong_ui(unit, NULL, 0, &scsiAddr->unit) != 0)
+    if (virStrToLong_uip(unit, NULL, 0, &scsiAddr->unit) != 0)
         return -1;
 
     return 0;