[PATCH]check NULL of mac

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

 



Hi,

"attach-device" become the segmentation fault,
when it uses following xml. (There is no "address='xx'")
+----------------------------------------------------+
|    <interface type='bridge'>                       |
|      <source bridge='xenbr0'/>                     |
|      <mac/>                                        |
|      <script path='/etc/xen/scripts/vif-bridge'/>  |
|    </interface>                                    |
+----------------------------------------------------+
Libxml gives back NULL when there is not an attribute. 
"xenXMAttachInterface" compares it in strcmp as NULL.

So, I make the patch which solved this problem.

Thanks,
Shigeki Sakamoto.


Index: src/xm_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xm_internal.c,v
retrieving revision 1.64
diff -u -p -r1.64 xm_internal.c
--- src/xm_internal.c	20 Feb 2008 15:29:13 -0000	1.64
+++ src/xm_internal.c	26 Feb 2008 06:39:05 -0000
@@ -2769,12 +2769,13 @@ xenXMAttachInterface(virDomainPtr domain
     }
     source = xmlGetProp(node, BAD_CAST type);
 
-    if (!(node = virXPathNode("/interface/mac", ctxt))) {
+    if ((node = virXPathNode("/interface/mac", ctxt)))
+        mac = xmlGetProp(node, BAD_CAST "address");
+    if (!node || !mac) {
         if (!(mac = (xmlChar *)xenXMAutoAssignMac()))
             goto cleanup;
         autoassign = 1;
-    } else
-        mac = xmlGetProp(node, BAD_CAST "address");
+    }
 
     list_item = virConfGetValue(entry->conf, "vif");
     if (list_item && list_item->type == VIR_CONF_LIST) {

--
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]