[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 2/3] virsh: add snapshot-create-as command



On Wed, Jun 15, 2011 at 04:26:25PM -0600, Eric Blake wrote:
> Producing an xml file just for name and description fields is
> overkill; this makes life easier from virsh.
> 
> * tools/virsh.c (cmdSnapshotCreateAs): New command.
> (snapshotCmds): Install it.
> * tools/virsh.pod: Document it.
> ---
>  tools/virsh.c   |  102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tools/virsh.pod |    8 ++++-
>  2 files changed, 109 insertions(+), 1 deletions(-)
> 
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 6b5f3d9..3a59acd 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -11042,6 +11042,106 @@ cleanup:
>  }
> 
>  /*
> + * "snapshot-create-as" command
> + */
> +static const vshCmdInfo info_snapshot_create_as[] = {
> +    {"help", N_("Create a snapshot from a set of args")},
> +    {"desc", N_("Create a snapshot (disk and RAM) from arguments")},
> +    {NULL, NULL}
> +};
> +
> +static const vshCmdOptDef opts_snapshot_create_as[] = {
> +    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
> +    {"name", VSH_OT_DATA, 0, N_("name of snapshot")},
> +    {"description", VSH_OT_DATA, 0, N_("description of snapshot")},
> +    {NULL, 0, 0, NULL}
> +};
> +
> +static bool
> +cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
> +{
> +    virDomainPtr dom = NULL;
> +    bool ret = false;
> +    char *buffer = NULL;
> +    virDomainSnapshotPtr snapshot = NULL;
> +    xmlDocPtr xml = NULL;
> +    xmlXPathContextPtr ctxt = NULL;
> +    char *doc = NULL;
> +    const char *name = NULL;
> +    const char *desc = NULL;
> +    char *parsed_name = NULL;
> +    virBuffer buf = VIR_BUFFER_INITIALIZER;
> +
> +    if (!vshConnectionUsability(ctl, ctl->conn))
> +        goto cleanup;
> +
> +    dom = vshCommandOptDomain(ctl, cmd, NULL);
> +    if (dom == NULL)
> +        goto cleanup;
> +
> +    if (vshCommandOptString(cmd, "name", &name) < 0 ||
> +        vshCommandOptString(cmd, "description", &desc) < 0) {
> +        vshError(ctl, _("argument must not be argument"));

  ??? if that's right that's a very cryptic one :-)

> +        goto cleanup;
> +    }
> +
> +    virBufferAddLit(&buf, "<domainsnapshot>\n");
> +    if (name)
> +        virBufferAsprintf(&buf, "  <name>%s</name>\n", name);
> +    if (desc)
> +        virBufferAsprintf(&buf, "  <description>%s</description>\n", desc);
> +    virBufferAddLit(&buf, "</domainsnapshot>\n");

ACK with this fixed :-)

  Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]