[Libvir] [PATCH] Fix strange error message in virsh attach-device

Masayuki Sunou fj1826dm at aa.jp.fujitsu.com
Fri Jun 1 09:02:17 UTC 2007


Would you give me a comment on this patch?
If not, please apply it.

Masayuki Sunou.

In message <200705251942.EHG12443.279NEGK3 at aa.jp.fujitsu.com>
   "[Libvir] [PATCH] Fix strange error message in virsh attach-device"
   "Masayuki Sunou <fj1826dm at aa.jp.fujitsu.com>" wrote:


Now, virsh attach-device displays the following messages when "device"
attribute of "disk" element is "floppy" in XML.

# virsh attach-device HVM_RH4_file floppy.xml
libvir: Xen Daemon error : POST operation failed: (xend.err 'Invalid Configuration: XendConfig: @\x14\xce not a valid device type')
error: Failed to attach device from floppy.xml

This patch fixes this strange error message displaying "@\x14\xce".

Description of this patch 
  VirDomainParseXMLDiskDesc() returns 0 without putting data in virBuffer,
  when "floppy" is set.
  Therefore, virParseXMLDevice() returns no initialized data, and
  xenDaemonAttachDevice() passes Xen this data. 
  Because virDomainParseXMLDesc() works wrong when this patch changes
  return value of VirDomainParseXMLDiskDesc(),this patch fixes
  virParseXMLDevice() as follows.
    - Initialize data
    - Return error if data does not change.
  As a result, xenDaemonAttachDevice() doesn't pass strange data to Xen,
  and Xen doesn't return strange error message.

Signed-off-by: Masayuki Sunou <fj1826dm at aa.jp.fujitsu.com>

Masayuki Sunou.

Index: src/xml.c
RCS file: /data/cvs/libvirt/src/xml.c,v
retrieving revision 1.73
diff -u -p -r1.73 xml.c
--- src/xml.c   23 Apr 2007 07:41:23 -0000      1.73
+++ src/xml.c   25 May 2007 09:46:56 -0000
@@ -1481,6 +1481,7 @@ virParseXMLDevice(virConnectPtr conn, ch
         return (NULL);
     buf.size = 1000;
     buf.use = 0;
+    memset(buf.content, 0, (size_t)buf.size);
     xml = xmlReadDoc((const xmlChar *) xmldesc, "domain.xml", NULL,
                      XML_PARSE_NOENT | XML_PARSE_NONET |
@@ -1492,6 +1493,9 @@ virParseXMLDevice(virConnectPtr conn, ch
     if (xmlStrEqual(node->name, BAD_CAST "disk")) {
         if (virDomainParseXMLDiskDesc(conn, node, &buf, hvm, xendConfigVersion) != 0)
             goto error;
+         /* SXP is not created when device is "floppy". */
+        else if (!strlen(buf.content))
+            goto error;
     else if (xmlStrEqual(node->name, BAD_CAST "interface")) {
         if (virDomainParseXMLIfDesc(conn, node, &buf, hvm) != 0)

Libvir-list mailing list
Libvir-list at redhat.com

More information about the libvir-list mailing list