On Wed, Jun 15, 2011 at 04:26:26PM -0600, Eric Blake wrote:
Similar to pool-create-as.
* tools/virsh.c (cmdSnapshotCreateAs): Add --print-xml.
* tools/virsh.pod: Document it.
---
tools/virsh.c | 7 +++++++
tools/virsh.pod | 6 ++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 3a59acd..97f7cf8 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -11054,6 +11054,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}
};
@@ -11098,6 +11099,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;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 44f2e25..567e7de 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1402,11 +1402,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>
ACK,
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/