[Libvir] [PATCH] Fix strange message on virsh attach-device

Hi Virsh attach-device outputs a strange message, when XML whose top element is not <device> or <interface>. ---------------------------------------------------------------------- libvir: Xen Daemon error : POST operation failed: (xend.err "object of type 'NoneType' has no len()") error: Failed to attach device from test.xml ---------------------------------------------------------------------- This patch fixes it by not calling Xen in this case. Signed-off-by: Masayuki Sunou <fj1826dm@aa.jp.fujitsu.com> Thanks, Masayuki Sunou. ---------------------------------------------------------------------- Index: libvirt/src/xml.c =================================================================== RCS file: /data/cvs/libvirt/src/xml.c,v retrieving revision 1.81 diff -u -p -r1.81 xml.c --- libvirt/src/xml.c 11 Jul 2007 08:41:11 -0000 1.81 +++ libvirt/src/xml.c 13 Jul 2007 02:48:04 -0000 @@ -1337,6 +1337,8 @@ virParseXMLDevice(virConnectPtr conn, ch else if (xmlStrEqual(node->name, BAD_CAST "interface")) { if (virDomainParseXMLIfDesc(conn, node, &buf, hvm, xendConfigVersion) != 0) goto error; + } else { + goto error; } cleanup: if (xml != NULL)

Masayuki Sunou wrote:
+ } else { + goto error;
It'd be better to add a call to virXMLError in there, but other than that the patch is fine. Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

On Fri, Jul 13, 2007 at 12:29:40PM +0100, Richard W.M. Jones wrote:
Masayuki Sunou wrote:
+ } else { + goto error;
It'd be better to add a call to virXMLError in there, but other than that the patch is fine.
I needed to check first who called that routine, but it is only used by xenDaemonAttachDevice(), so it's only used for devices attach and detach, so it should be safe. I'm commiting the following so we have a reasonable error message: --- xml.c 13 Jul 2007 08:26:58 -0000 1.82 +++ xml.c 13 Jul 2007 12:23:35 -0000 @@ -1351,6 +1351,9 @@ virParseXMLDevice(virConnectPtr conn, ch else if (xmlStrEqual(node->name, BAD_CAST "interface")) { if (virDomainParseXMLIfDesc(conn, node, &buf, hvm, xendConfigVersion) != 0) goto error; + } else { + virXMLError(conn, VIR_ERR_XML_ERROR, (const char *) node->name, 0); + goto error; } cleanup: if (xml != NULL) thanks ! 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/
participants (3)
-
Daniel Veillard
-
Masayuki Sunou
-
Richard W.M. Jones