[libvirt] [PATCH 1/2] Add --source-format argument to virsh pool-define-as and pool-create-as
Cole Robinson
crobinso at redhat.com
Tue Jun 1 15:50:21 UTC 2010
On 05/30/2010 10:24 AM, Justin Clift wrote:
> Hi all,
>
> 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.
>
> Regards and best wishes,
>
> Justin Clift
>
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 4930ad7..1279f41 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, "<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);
>
ACK
- Cole
More information about the libvir-list
mailing list