virsh: enhance snapshot-create-as

Similar to pool-create-as.

* tools/virsh.c (cmdSnapshotCreateAs): Add --print-xml.
* tools/virsh.pod: Document it.
This commit is contained in:
Eric Blake 2011-06-15 16:24:40 -06:00
parent 1546dcf866
commit 9256ad84fc
2 changed files with 11 additions and 2 deletions

View File

@ -11142,6 +11142,7 @@ 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")},
{"print-xml", VSH_OT_BOOL, 0, N_("print XML document rather than create")},
{NULL, 0, 0, NULL}
};
@ -11186,6 +11187,12 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
if (vshCommandOptBool(cmd, "print-xml")) {
vshPrint(ctl, "%s\n", buffer);
ret = true;
goto cleanup;
}
snapshot = virDomainSnapshotCreateXML(dom, buffer, 0);
if (snapshot == NULL)
goto cleanup;

View File

@ -1422,11 +1422,13 @@ I<xmlfile>. The only properties settable for a domain snapshot are the
automatically filled in by libvirt. If I<xmlfile> is completely omitted,
then libvirt will choose a value for all fields.
=item B<snapshot-create-as> I<domain> optional I<name> I<description>
=item B<snapshot-create-as> I<domain> optional I<--print-xml>
I<name> I<description>
Create a snapshot for domain I<domain> with the given <name> and
<description>; if either value is omitted, libvirt will choose a
value.
value. If I<--print-xml> is specified, then XML appropriate for
I<snapshot-create> is output, rather than actually creating a snapshot.
=item B<snapshot-current> I<domain>