]> xenbits.xensource.com Git - libvirt.git/commitdiff
Currently, you can define a logical storage pool with something like:
authorChris Lalancette <clalance@redhat.com>
Tue, 21 Oct 2008 17:23:38 +0000 (17:23 +0000)
committerChris Lalancette <clalance@redhat.com>
Tue, 21 Oct 2008 17:23:38 +0000 (17:23 +0000)
<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@redhat.com>
ChangeLog
src/storage_conf.c

index 97acbd041ac8c4a80076a65866034d4a93acfd57..58cb909db541cf105286283cb81d7a2bb002247e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Oct 21 19:22:00 CEST 2008 Chris Lalancette <clalance@redhat.com>
+       * src/storage_conf.c: Make logical pool dumpXML more idempotent with
+         defineXML by outputting <device name='/dev/sdb' /> when we are
+         dumping XML.  We only use the longer <device
+         name='/dev/sdb'>foo</device> when a pool has .nfreeExtent defined.
+
 Tue Oct 21 19:18:00 CEST 2008 Chris Lalancette <clalance@redhat.com>
        * src/storage_conf.c: Make sure to set errors on paths where
          ->formatToString() or ->formatFromString() fail.
index 792e740ff48dd506825998f1772be62b2d56927b..2ab5467841415b580ec623e1df91c255e726641c 100644 (file)
@@ -466,7 +466,7 @@ virStoragePoolDefFormat(virConnectPtr conn,
     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 conn,
     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) &&