From b221973a11e2f490a9e8e10bc598e7c2ddbaf2d8 Mon Sep 17 00:00:00 2001 From: Justin Clift Date: Mon, 31 May 2010 00:24:45 +1000 Subject: [PATCH] Add --source-format argument to virsh pool-define-as and pool-create-as 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/virsh.c b/tools/virsh.c index 4930ad7ad6..1279f41859 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -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, "\n", type); @@ -4501,6 +4503,8 @@ static int buildPoolXML(const vshCmd *cmd, char **retname, char **xml) { virBufferVSprintf(&buf, " \n", srcPath); if (srcDev) virBufferVSprintf(&buf, " \n", srcDev); + if (srcFormat) + virBufferVSprintf(&buf, " \n", srcFormat); if (srcName) virBufferVSprintf(&buf, " %s\n", srcName);