[libvirt] [PATCH] conf: Use UNIT_MAX for checking max value of unsigned int

Nitesh Konkar niteshkonkar.libvirt at gmail.com
Mon Nov 14 17:13:55 UTC 2016


In the current scenario the controller parsing fails
when no index is specified .As the docs point out
that specifying index is optional, libvirt is expected
to fill the index without erroring out.

Signed-off-by: Nitesh Konkar <nitkon12 at linux.vnet.ibm.com>
---
Before the Patch:
cat controller.xml
<controller model="virtio-scsi" type="scsi" />

virsh attach-device vm1 controller.xml  --persistent
error: Failed to attach device from controller.xml
error: internal error: Cannot parse controller index -1

After the patch:
virsh attach-device vm1 controller.xml  --persistent
Device attached successfully
---
 src/conf/domain_conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6e008e2..c52e67f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8374,7 +8374,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
     if (idx) {
         unsigned int idxVal;
         if (virStrToLong_ui(idx, NULL, 10, &idxVal) < 0 ||
-            idxVal > INT_MAX) {
+            idxVal > UINT_MAX) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Cannot parse controller index %s"), idx);
             goto error;
-- 
2.1.0




More information about the libvir-list mailing list