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

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

 



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@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]