[libvirt] [PATCH 4/5]: Make dumpXML more idempotent with defineXML

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

 



Currently, you can define a logical storage pool with something like the following:

<pool type='logical'>
	<source>
		<name>MyVG</name>
		<device name='/dev/sdb'/>
...

However, dumping out the XML for this same storage pool (with, say, virsh
pool-dumpxml), gives:

<pool type='logical'>
	<source>
		<name>MyVG</name>
		<device name='/dev/sdb'>
		</device>


To make this more idempotent, do the <device name='/dev/sdb'/> form by default,
and only do the <device>...</device> form if .nfreeExtent is defined for the
storage pool.

Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx>
diff -up ./src/storage_conf.c.p3 ./src/storage_conf.c
--- ./src/storage_conf.c.p3	2008-10-21 14:55:14.000000000 +0200
+++ ./src/storage_conf.c	2008-10-21 14:56:59.000000000 +0200
@@ -466,7 +466,7 @@ virStoragePoolDefFormat(virConnectPtr co
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     const char *type;
     char uuid[VIR_UUID_STRING_BUFLEN];
-    int i;
+    int i, j;
 
     options = virStorageBackendPoolOptionsForType(def->type);
     if (options == NULL)
@@ -499,16 +499,19 @@ virStoragePoolDefFormat(virConnectPtr co
     if ((options->flags & VIR_STORAGE_BACKEND_POOL_SOURCE_DEVICE) &&
         def->source.ndevice) {
         for (i = 0 ; i < def->source.ndevice ; i++) {
-            virBufferVSprintf(&buf,"    <device path='%s'>\n", def->source.devices[i].path);
             if (def->source.devices[i].nfreeExtent) {
-                int j;
+                virBufferVSprintf(&buf,"    <device path='%s'>\n",
+                                  def->source.devices[i].path);
                 for (j = 0 ; j < def->source.devices[i].nfreeExtent ; j++) {
                     virBufferVSprintf(&buf, "    <freeExtent start='%llu' end='%llu'/>\n",
                                       def->source.devices[i].freeExtents[j].start,
                                       def->source.devices[i].freeExtents[j].end);
                 }
+                virBufferAddLit(&buf,"    </device>\n");
             }
-            virBufferAddLit(&buf,"    </device>\n");
+            else
+                virBufferVSprintf(&buf, "    <device path='%s'/>\n",
+                                  def->source.devices[i].path);
         }
     }
     if ((options->flags & VIR_STORAGE_BACKEND_POOL_SOURCE_DIR) &&
--
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]