[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [libvirt] [PATCH] introducing <source> <name> (for logical storage pools)
- From: David Lively <dlively virtualiron com>
- To: Jim Meyering <jim meyering net>
- Cc: libvir-list <libvir-list redhat com>
- Subject: Re: [libvirt] [PATCH] introducing <source> <name> (for logical storage pools)
- Date: Fri, 29 Aug 2008 15:49:27 -0400
Hi Jim -
I've attached a (very) small incremental patch (i.e., to be applied
after the one you've already merged) that addresses a couple things I
noticed missing:
(a) documents the new <source> <name> element in formatstorage.html.in
(b) adds --source-name to the (optional) args for virsh pool-define-as
I've also attached a new version of the full patch containing this
change, in case that's easier.
Thanks,
Dave
On Thu, 2008-08-21 at 20:55 +0200, Jim Meyering wrote:
> David Lively <dlively virtualiron com> wrote:
> > Oops - that was against an old base. Sorry. Here's the new one.
>
> Good timing.
> I was in the process of replying,
> after having done the merge and add-conn-arg bit.
>
> > Also fixed a few other issues ...
>
> ACK.
> I compared the result of my merge/tweaks and your new patch
> and see you fixed everything I saw. The only difference was
> that when I inserted "conn, " and it pushed past the 80-col
> limit, I split the line:
>
> diff --git a/src/storage_conf.c b/src/storage_conf.c
> index e49f684..74c3f1e 100644
> --- a/src/storage_conf.c
> +++ b/src/storage_conf.c
> @@ -328,3 +329,4 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
> if (options->flags & VIR_STORAGE_BACKEND_POOL_SOURCE_NAME) {
> - ret->source.name = virXPathString(conn, "string(/pool/source/name)", ctxt);
> + ret->source.name = virXPathString(conn, "string(/pool/source/name)",
> + ctxt);
> if (ret->source.name == NULL) {
commit 5b422577cb532a95f79d7458bd21d37efdf3a9ff
Author: David Lively <dlively virtualiron com>
Date: Fri Aug 29 15:03:59 2008 -0400
vi-patch: storage-source-name
Document new pool/source/name element in storage pool XML.
Added optional --source-name arg to virsh define-pool-as command.
diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index 7ee7bb8..7cd4731 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -91,6 +91,11 @@
which is the hostname or IP address of the server. May optionally
contain a <code>port</code> attribute for the protocol specific
port number. <span class="since">Since 0.4.1</span></dd>
+ <dt><code>name</code></dt>
+ <dd>Provides the source for pools backed by storage from a
+ named element (e.g., a logical volume group name).
+ remote server. Contains a string identifier.
+ <span class="since">Since 0.4.5</span></dd>
<dt><code>format</code></dt>
<dd>Provides information about the format of the pool. This
contains a single attribute <code>type</code> whose value is
diff --git a/src/virsh.c b/src/virsh.c
index eb5c659..1fb07ad 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -3024,6 +3024,7 @@ static const vshCmdOptDef opts_pool_define_as[] = {
{"source-host", VSH_OT_DATA, 0, gettext_noop("source-host for underlying storage")},
{"source-path", VSH_OT_DATA, 0, gettext_noop("source path for underlying storage")},
{"source-dev", VSH_OT_DATA, 0, gettext_noop("source device for underlying storage")},
+ {"source-name", VSH_OT_DATA, 0, gettext_noop("source name for underlying storage")},
{"target", VSH_OT_DATA, 0, gettext_noop("target for underlying storage")},
{NULL, 0, 0, NULL}
};
@@ -3035,7 +3036,7 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
virStoragePoolPtr pool;
int found;
char *xml;
- char *name, *type, *srcHost, *srcPath, *srcDev, *target;
+ char *name, *type, *srcHost, *srcPath, *srcDev, *srcName, *target;
virBuffer buf = VIR_BUFFER_INITIALIZER;
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
@@ -3051,11 +3052,12 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
srcHost = vshCommandOptString(cmd, "source-host", &found);
srcPath = vshCommandOptString(cmd, "source-path", &found);
srcDev = vshCommandOptString(cmd, "source-dev", &found);
+ srcName = vshCommandOptString(cmd, "source-name", &found);
target = vshCommandOptString(cmd, "target", &found);
virBufferVSprintf(&buf, "<pool type='%s'>\n", type);
virBufferVSprintf(&buf, " <name>%s</name>\n", name);
- if (srcHost || srcPath || srcDev) {
+ if (srcHost || srcPath || srcDev || srcName) {
virBufferAddLit(&buf, " <source>\n");
if (srcHost)
virBufferVSprintf(&buf, " <host>%s</host>\n", srcHost);
@@ -3063,6 +3065,8 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
virBufferVSprintf(&buf, " <path>%s</path>\n", srcPath);
if (srcDev)
virBufferVSprintf(&buf, " <device>%s</device>\n", srcDev);
+ if (srcName)
+ virBufferVSprintf(&buf, " <name>%s</name>\n", srcName);
virBufferAddLit(&buf, " </source>\n");
}
diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index 7ee7bb8..7cd4731 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -91,6 +91,11 @@
which is the hostname or IP address of the server. May optionally
contain a <code>port</code> attribute for the protocol specific
port number. <span class="since">Since 0.4.1</span></dd>
+ <dt><code>name</code></dt>
+ <dd>Provides the source for pools backed by storage from a
+ named element (e.g., a logical volume group name).
+ remote server. Contains a string identifier.
+ <span class="since">Since 0.4.5</span></dd>
<dt><code>format</code></dt>
<dd>Provides information about the format of the pool. This
contains a single attribute <code>type</code> whose value is
diff --git a/src/storage_backend.h b/src/storage_backend.h
index a06746b..5ca5d27 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 c30323a..d182b5e 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;
@@ -357,7 +357,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn,
}
vgargv[n++] = VGCREATE;
- vgargv[n++] = pool->def->name;
+ vgargv[n++] = pool->def->source.name;
pvargv[0] = PVCREATE;
pvargv[2] = NULL;
@@ -434,7 +434,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;
@@ -488,7 +488,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)
@@ -618,6 +618,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..e49f684 100644
--- a/src/storage_conf.c
+++ b/src/storage_conf.c
@@ -96,6 +96,7 @@ virStoragePoolDefFree(virStoragePoolDefPtr def) {
}
VIR_FREE(def->source.devices);
VIR_FREE(def->source.dir);
+ VIR_FREE(def->source.name);
if (def->source.authType == VIR_STORAGE_POOL_AUTH_CHAP) {
VIR_FREE(def->source.auth.chap.login);
@@ -248,7 +249,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 +325,15 @@ 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 = strdup(ret->name);
+ if (ret->source.name == NULL)
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("pool name"));
+ }
+ }
authType = virXPathString(conn, "string(/pool/source/auth/@type)", ctxt);
@@ -499,6 +513,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;
diff --git a/src/virsh.c b/src/virsh.c
index eb5c659..1fb07ad 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -3024,6 +3024,7 @@ static const vshCmdOptDef opts_pool_define_as[] = {
{"source-host", VSH_OT_DATA, 0, gettext_noop("source-host for underlying storage")},
{"source-path", VSH_OT_DATA, 0, gettext_noop("source path for underlying storage")},
{"source-dev", VSH_OT_DATA, 0, gettext_noop("source device for underlying storage")},
+ {"source-name", VSH_OT_DATA, 0, gettext_noop("source name for underlying storage")},
{"target", VSH_OT_DATA, 0, gettext_noop("target for underlying storage")},
{NULL, 0, 0, NULL}
};
@@ -3035,7 +3036,7 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
virStoragePoolPtr pool;
int found;
char *xml;
- char *name, *type, *srcHost, *srcPath, *srcDev, *target;
+ char *name, *type, *srcHost, *srcPath, *srcDev, *srcName, *target;
virBuffer buf = VIR_BUFFER_INITIALIZER;
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
@@ -3051,11 +3052,12 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
srcHost = vshCommandOptString(cmd, "source-host", &found);
srcPath = vshCommandOptString(cmd, "source-path", &found);
srcDev = vshCommandOptString(cmd, "source-dev", &found);
+ srcName = vshCommandOptString(cmd, "source-name", &found);
target = vshCommandOptString(cmd, "target", &found);
virBufferVSprintf(&buf, "<pool type='%s'>\n", type);
virBufferVSprintf(&buf, " <name>%s</name>\n", name);
- if (srcHost || srcPath || srcDev) {
+ if (srcHost || srcPath || srcDev || srcName) {
virBufferAddLit(&buf, " <source>\n");
if (srcHost)
virBufferVSprintf(&buf, " <host>%s</host>\n", srcHost);
@@ -3063,6 +3065,8 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
virBufferVSprintf(&buf, " <path>%s</path>\n", srcPath);
if (srcDev)
virBufferVSprintf(&buf, " <device>%s</device>\n", srcDev);
+ if (srcName)
+ virBufferVSprintf(&buf, " <name>%s</name>\n", srcName);
virBufferAddLit(&buf, " </source>\n");
}
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]