[Libvir] [PATCH]check NULL of mac

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) {

+1. I'll apply this today if no one else objects. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top

On Tue, Feb 26, 2008 at 09:44:33AM +0000, Richard W.M. Jones wrote:
+1. I'll apply this today if no one else objects.
looks fine to me too +1 Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

Committed. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
participants (4)
-
Daniel Veillard
-
Jim Meyering
-
Richard W.M. Jones
-
S.Sakamoto