diff --git a/tools/virsh.c b/tools/virsh.c index a719aabfc5..a315f05c87 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -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; diff --git a/tools/virsh.pod b/tools/virsh.pod index b9c54de80c..023ab42d44 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1422,11 +1422,13 @@ I. The only properties settable for a domain snapshot are the automatically filled in by libvirt. If I is completely omitted, then libvirt will choose a value for all fields. -=item B I optional I I +=item B I optional I<--print-xml> +I I Create a snapshot for domain I with the given and ; if either value is omitted, libvirt will choose a -value. +value. If I<--print-xml> is specified, then XML appropriate for +I is output, rather than actually creating a snapshot. =item B I