[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[libvirt] [PATCH] introducing <source> <name> (for logical storage pools)
- From: David Lively <dlively virtualiron com>
- To: libvir-list <libvir-list redhat com>
- Subject: [libvirt] [PATCH] introducing <source> <name> (for logical storage pools)
- Date: Fri, 08 Aug 2008 15:17:52 -0400
Hi Folks -
This small patch is a proposed prerequisite for the storage pool
discovery patch I submitted last week.
Daniel B proposed having storage pool discovery return a bunch of XML
storage <source> elements, rather than full <pool> elements (which
contain "target-dependent" details like the local pool name and device
or mount path -- things which don't need to be decided unless/until the
pool is defined).
I like his suggestion a lot, and I think it addresses the final
API-definition problem keeping storage pool discovery out of libvirt.
But ... it doesn't quite work for logical storage pools because those
are created from the <pool> <name> element (which is the same as the
volume group name).
This patch introduces a new <source> element <name>, which is
distinct
from the pool name. <name> is used only by the logical storage
backend, and represents the volume group name. For convenience and
back-compatibility, <source> <name> defaults to the pool name if not
specified when the pool is defined, and <pool> <name> defaults to the
source name if not specified. There is no requirement that pool and
source name be the same, though.
While admittedly it seems a little weird, it does allow more
flexibility (pool name not tied to vol group name), and allows <source>
to fully specify a logical pool source, as it does for the other pool
types[*]. Defaulting the source name from the pool name means all
existing pool XML definitions continue to work. Defaulting the pool
name from the source name is simply a matter of convenience (but perhaps
a step too far?)
If this is accepted, logical pool discovery can then return a bunch of
sources like:
<source><name>VolGroup00</name></source>
<source><name>VolGroup01</name></source>
Please note I'll be on vacation next week (Aug 11-15), so I may not be
responding until the following week.
Thanks,
Dave
[*] Well ... almost. Note that directory pools have a similar issue --
the "source" of the pool is given by the <target> <path> -- there's no
<source>. I suppose implementing directory pool discovery (for the sake
of completeness) means addressing this as well, maybe via some similar
mechanism ...
This patch introduces a new <source> element <name>, which is distinct
from the pool name. <name> is used only by the logical storage
backend, and represents the volume group name. For convenience and
back-compatibility, <source> <name> defaults to the pool name if not
specified when the pool is defined, and <pool> <name> defaults to the
source name if not specified. There is no requirement that pool and
source name be the same, though.
Signed-off-by: David Lively <dlively virtualiron com>
diff --git a/src/storage_backend.h b/src/storage_backend.h
index 797ca01..422f26c 100644
--- a/src/storage_backend.h
+++ b/src/storage_backend.h
@@ -53,6 +53,7 @@ enum {
VIR_STORAGE_BACKEND_POOL_SOURCE_DEVICE = (1<<1),
VIR_STORAGE_BACKEND_POOL_SOURCE_DIR = (1<<2),
VIR_STORAGE_BACKEND_POOL_SOURCE_ADAPTER = (1<<3),
+ VIR_STORAGE_BACKEND_POOL_SOURCE_NAME = (1<<4),
};
typedef struct _virStorageBackendPoolOptions virStorageBackendPoolOptions;
diff --git a/src/storage_backend_logical.c b/src/storage_backend_logical.c
index 0c4f6a5..382078b 100644
--- a/src/storage_backend_logical.c
+++ b/src/storage_backend_logical.c
@@ -80,7 +80,7 @@ virStorageBackendLogicalSetActive(virConnectPtr conn,
cmdargv[0] = VGCHANGE;
cmdargv[1] = on ? "-ay" : "-an";
- cmdargv[2] = pool->def->name;
+ cmdargv[2] = pool->def->source.name;
cmdargv[3] = NULL;
if (virRun(conn, cmdargv, NULL) < 0)
@@ -213,7 +213,7 @@ virStorageBackendLogicalFindLVs(virConnectPtr conn,
LVS, "--separator", ":", "--noheadings", "--units", "b",
"--unbuffered", "--nosuffix", "--options",
"lv_name,uuid,devices,seg_size,vg_extent_size",
- pool->def->name, NULL
+ pool->def->source.name, NULL
};
int exitstatus;
@@ -288,7 +288,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn,
}
vgargv[n++] = VGCREATE;
- vgargv[n++] = pool->def->name;
+ vgargv[n++] = pool->def->source.name;
pvargv[0] = PVCREATE;
pvargv[2] = NULL;
@@ -365,7 +365,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn,
const char *prog[] = {
VGS, "--separator", ":", "--noheadings", "--units", "b", "--unbuffered",
"--nosuffix", "--options", "vg_size,vg_free",
- pool->def->name, NULL
+ pool->def->source.name, NULL
};
int exitstatus;
@@ -419,7 +419,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn,
unsigned int flags ATTRIBUTE_UNUSED)
{
const char *cmdargv[] = {
- VGREMOVE, "-f", pool->def->name, NULL
+ VGREMOVE, "-f", pool->def->source.name, NULL
};
if (virRun(conn, cmdargv, NULL) < 0)
@@ -535,6 +535,7 @@ virStorageBackend virStorageBackendLogical = {
.deleteVol = virStorageBackendLogicalDeleteVol,
.poolOptions = {
+ .flags = VIR_STORAGE_BACKEND_POOL_SOURCE_NAME,
.formatFromString = virStorageBackendLogicalPoolFormatFromString,
.formatToString = virStorageBackendLogicalPoolFormatToString,
},
diff --git a/src/storage_conf.c b/src/storage_conf.c
index 05b68af..c6dbde6 100644
--- a/src/storage_conf.c
+++ b/src/storage_conf.c
@@ -248,7 +248,11 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
goto cleanup;
}
- if ((ret->name = virXPathString(conn, "string(/pool/name)", ctxt)) == NULL) {
+ ret->name = virXPathString(conn, "string(/pool/name)", ctxt);
+ if (ret->name == NULL &&
+ options->flags & VIR_STORAGE_BACKEND_POOL_SOURCE_NAME)
+ ret->name = virXPathString(conn, "string(/pool/source/name)", ctxt);
+ if (ret->name == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
"%s", _("missing name element"));
goto cleanup;
@@ -320,6 +324,13 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
goto cleanup;
}
}
+ if (options->flags & VIR_STORAGE_BACKEND_POOL_SOURCE_NAME) {
+ ret->source.name = virXPathString(conn, "string(/pool/source/name)", ctxt);
+ if (ret->source.name == NULL) {
+ /* source name defaults to pool name */
+ ret->source.name = ret->name;
+ }
+ }
authType = virXPathString(conn, "string(/pool/source/auth/@type)", ctxt);
@@ -499,6 +510,9 @@ virStoragePoolDefFormat(virConnectPtr conn,
if ((options->flags & VIR_STORAGE_BACKEND_POOL_SOURCE_ADAPTER) &&
def->source.adapter)
virBufferVSprintf(&buf," <adapter name='%s'/>\n", def->source.adapter);
+ if ((options->flags & VIR_STORAGE_BACKEND_POOL_SOURCE_NAME) &&
+ def->source.name)
+ virBufferVSprintf(&buf," <name>%s</name>\n", def->source.name);
if (options->formatToString) {
const char *format = (options->formatToString)(conn, def->source.format);
diff --git a/src/storage_conf.h b/src/storage_conf.h
index e3577b5..3500039 100644
--- a/src/storage_conf.h
+++ b/src/storage_conf.h
@@ -174,6 +174,9 @@ struct _virStoragePoolSource {
/* Or an adapter */
char *adapter;
+ /* Or a name */
+ char *name;
+
int authType; /* virStoragePoolAuthType */
union {
virStoragePoolAuthChap chap;
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]