]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add --source-format argument to virsh pool-define-as and pool-create-as
authorJustin Clift <justin@salasaga.org>
Sun, 30 May 2010 14:24:45 +0000 (00:24 +1000)
committerEric Blake <eblake@redhat.com>
Tue, 1 Jun 2010 22:57:17 +0000 (16:57 -0600)
When creating pools from dedicated disks, the existing pool-define-as
and pool-create-as commands are a bit non-optimal.

Ideally, a person would be able to specify all of the required options
directly on the command line instead of having to edit the XML.

At the moment, there is no way to specify the format type (ie gpt) so it
gets included in the XML the pool is constructed with.

Please find attached a simple (tested) patch to add an optional
"--source-format 'type'" to virsh.  This is patched against current git
master and will apply cleanly.

Also created a Red Hat BZ ticket for this (#597790) for tracking.

tools/virsh.c

index 4930ad7ad6c698b3311426ccc8efe16fe66d42d4..1279f41859cc3c6035e09f9429ea698a27bb18a0 100644 (file)
@@ -4468,13 +4468,14 @@ static const vshCmdOptDef opts_pool_X_as[] = {
     {"source-dev", VSH_OT_DATA, 0, N_("source device for underlying storage")},
     {"source-name", VSH_OT_DATA, 0, N_("source name for underlying storage")},
     {"target", VSH_OT_DATA, 0, N_("target for underlying storage")},
+    {"source-format", VSH_OT_STRING, 0, N_("format for underlying storage")},
     {NULL, 0, 0, NULL}
 };
 
 static int buildPoolXML(const vshCmd *cmd, char **retname, char **xml) {
 
     int found;
-    char *name, *type, *srcHost, *srcPath, *srcDev, *srcName, *target;
+    char *name, *type, *srcHost, *srcPath, *srcDev, *srcName, *srcFormat, *target;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
 
     name = vshCommandOptString(cmd, "name", &found);
@@ -4488,6 +4489,7 @@ static int buildPoolXML(const vshCmd *cmd, char **retname, char **xml) {
     srcPath = vshCommandOptString(cmd, "source-path", &found);
     srcDev = vshCommandOptString(cmd, "source-dev", &found);
     srcName = vshCommandOptString(cmd, "source-name", &found);
+    srcFormat = vshCommandOptString(cmd, "source-format", &found);
     target = vshCommandOptString(cmd, "target", &found);
 
     virBufferVSprintf(&buf, "<pool type='%s'>\n", type);
@@ -4501,6 +4503,8 @@ static int buildPoolXML(const vshCmd *cmd, char **retname, char **xml) {
             virBufferVSprintf(&buf, "    <dir path='%s'/>\n", srcPath);
         if (srcDev)
             virBufferVSprintf(&buf, "    <device path='%s'/>\n", srcDev);
+        if (srcFormat)
+            virBufferVSprintf(&buf, "    <format type='%s'/>\n", srcFormat);
         if (srcName)
             virBufferVSprintf(&buf, "    <name>%s</name>\n", srcName);