[Libvir] [PATCH] increase storage domains of a definition file

S.Sakamoto fj0588di at aa.jp.fujitsu.com
Fri Apr 20 05:43:31 UTC 2007


Hi,

When I install by virt-intall with long command
(e.g."# /usr/sbin/virt-install --name testvm --ram 350 --vcpus 2 --file /root/test.img --file-size 1 --file /root/tmp02.img --
file-size 1 --file /root/tmp03.img --file-size 1 --file /root/tmp04.img --file-size 1 --file /root/tmp05.img --file-size 
1 --file /root/tmp06.img --file-size 1 --file /root/tmp07.img --file-size 1 --file /root/tmp08.img --file-size 1 --file 
/root/tmp09.img --file-size 1 --file /root/tmp10.img --file-size 1 --file /root/tmp11.img --file-size 1 --file 
/root/tmp12.img --file-size 1 --file /root/tmp13.img --file-size 1 --file /root/tmp14.img --file-size 1 --file 
/root/tmp15.img --file-size 1 --file /root/tmp16.img --file-size 1 --vnc --paravirt --location ftp://xx.xx.xx.xx/rhel5ga_x86 --noautoconsole --
debug"),
put out "abort".
Because a definition file is long, it overflows from buffer.

So, this patch increase buffer size.


Signed-off-by: Shigeki Sakamoto <fj0588di at aa.jp.fujitsu.com>


Thanks,
Shigeki Sakamoto.


Index: src/internal.h
===================================================================
RCS file: /data/cvs/libvirt/src/internal.h,v
retrieving revision 1.37
diff -u -p -r1.37 internal.h
--- src/internal.h	4 Apr 2007 14:19:49 -0000	1.37
+++ src/internal.h	19 Apr 2007 11:01:12 -0000
@@ -106,6 +106,11 @@ extern "C" {
 #define VIR_CONNECT_RO 1
 
 /**
+ * buffer size for definition file
+ */
+#define VIR_XML_STRING_BUFLEN (1024 + PATH_MAX * 16 + FILENAME_MAX * 16)
+
+/**
  * _virConnect:
  *
  * Internal structure associated to a connection
Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.109
diff -u -p -r1.109 xend_internal.c
--- src/xend_internal.c	13 Apr 2007 14:08:38 -0000	1.109
+++ src/xend_internal.c	19 Apr 2007 11:01:16 -0000
@@ -587,7 +587,7 @@ static int
 xend_op_ext2(virConnectPtr xend, const char *path, char *error,
              size_t n_error, const char *key, va_list ap)
 {
-    char ops[1024];
+    char ops[VIR_XML_STRING_BUFLEN];
     const char *k = key, *v;
     int offset = 0;
 
Index: src/xml.c
===================================================================
RCS file: /data/cvs/libvirt/src/xml.c,v
retrieving revision 1.72
diff -u -p -r1.72 xml.c
--- src/xml.c	13 Apr 2007 00:43:57 -0000	1.72
+++ src/xml.c	19 Apr 2007 11:01:20 -0000
@@ -1165,7 +1165,7 @@ virDomainParseXMLDesc(virConnectPtr conn
 {
     xmlDocPtr xml = NULL;
     xmlNodePtr node;
-    char *ret = NULL, *nam = NULL;
+    char *nam = NULL;
     virBuffer buf;
     xmlChar *prop;
     xmlParserCtxtPtr pctxt;
@@ -1182,10 +1182,9 @@ virDomainParseXMLDesc(virConnectPtr conn
 
     if (name != NULL)
         *name = NULL;
-    ret = malloc(1000);
-    if (ret == NULL)
+    buf.content = malloc(1000);
+    if (buf.content == NULL)
         return (NULL);
-    buf.content = ret;
     buf.size = 1000;
     buf.use = 0;
 
@@ -1376,7 +1375,7 @@ virDomainParseXMLDesc(virConnectPtr conn
     else
         free(nam);
 
-    return (ret);
+    return (buf.content);
 
  error:
     if (nam != NULL)
@@ -1389,8 +1388,8 @@ virDomainParseXMLDesc(virConnectPtr conn
         xmlFreeDoc(xml);
     if (pctxt != NULL)
         xmlFreeParserCtxt(pctxt);
-    if (ret != NULL)
-        free(ret);
+    if (buf.content != NULL)
+        free(buf.content);
     return (NULL);
 }
 




More information about the libvir-list mailing list