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

<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>
This commit is contained in:
Chris Lalancette 2008-10-21 17:23:38 +00:00
parent 46db2b2968
commit c6f0a7b2db
2 changed files with 13 additions and 4 deletions

View File

@ -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.

View 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) &&