+Tue Sep 2 16:12:20 CEST 2008 Daniel Veillard <veillard@redhat.com>
+
+ * src/storage_backend.h src/storage_backend_logical.c
+ src/storage_conf.c src/storage_conf.h src/virsh.c:
+ Applied patches from David Lively to add storage source
+ elements needed for storage pool
+ * docs/formatstorage.html docs/formatstorage.html.in: associated
+ documentation
+
Tue Sep 2 12:28:54 CEST 2008 Jim Meyering <meyering@redhat.com>
qemu_conf.c: use new function, virFileReadLimFD
or <code>device</code> element. Contains an attribute <code>name</code>
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>format</code></dt><dd>Provides information about the format of the pool. This
+ 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
backend specific. This is typically used to indicate filesystem
type, or network filesystem type, or partition table type, or
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
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;
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)
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;
}
vgargv[n++] = VGCREATE;
- vgargv[n++] = pool->def->name;
+ vgargv[n++] = pool->def->source.name;
pvargv[0] = PVCREATE;
pvargv[2] = NULL;
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;
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)
.deleteVol = virStorageBackendLogicalDeleteVol,
.poolOptions = {
+ .flags = VIR_STORAGE_BACKEND_POOL_SOURCE_NAME,
.formatFromString = virStorageBackendLogicalPoolFormatFromString,
.formatToString = virStorageBackendLogicalPoolFormatToString,
},
}
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);
if (STRNEQ((const char *)root->name, "pool")) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("unknown root element"));
+ "%s", _("unknown root elementi for storage pool"));
goto cleanup;
}
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"));
+ "%s", _("missing pool source name element"));
goto cleanup;
}
if (options->flags & VIR_STORAGE_BACKEND_POOL_SOURCE_HOST) {
if ((ret->source.host.name = virXPathString(conn, "string(/pool/source/host/@name)", ctxt)) == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("missing source host name"));
+ "%s", _("missing storage pool source host name"));
goto cleanup;
}
}
if ((nsource = virXPathNodeSet(conn, "/pool/source/device", ctxt, &nodeset)) <= 0) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("cannot extract source devices"));
+ "%s", _("cannot extract storage pool source devices"));
goto cleanup;
}
if (VIR_ALLOC_N(ret->source.devices, nsource) < 0) {
if (path == NULL) {
VIR_FREE(nodeset);
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("missing source device path"));
+ "%s", _("missing storage pool source device path"));
goto cleanup;
}
ret->source.devices[i].path = (char *)path;
if (options->flags & VIR_STORAGE_BACKEND_POOL_SOURCE_DIR) {
if ((ret->source.dir = virXPathString(conn, "string(/pool/source/dir/@path)", ctxt)) == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("missing source path"));
+ "%s", _("missing storage pool source path"));
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);
+ }
+ }
authType = virXPathString(conn, "string(/pool/source/auth/@type)", ctxt);
if ((ret->target.path = virXPathString(conn, "string(/pool/target/path)", ctxt)) == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("missing target path"));
+ "%s", _("missing storage pool target path"));
goto cleanup;
}
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);
ret->name = virXPathString(conn, "string(/volume/name)", ctxt);
if (ret->name == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("missing name element"));
+ "%s", _("missing volume name element"));
goto cleanup;
}
/* Or an adapter */
char *adapter;
+ /* Or a name */
+ char *name;
+
int authType; /* virStoragePoolAuthType */
union {
virStoragePoolAuthChap chap;
{"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}
};
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))
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);
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");
}