]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Add --print-xml flag for 'vol-clone' command
authorPeter Krempa <pkrempa@redhat.com>
Wed, 30 Nov 2022 15:48:23 +0000 (16:48 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 2 Dec 2022 15:49:25 +0000 (16:49 +0100)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
docs/manpages/virsh.rst
tools/virsh-volume.c

index 14ed9cd5a06f44cb70da2dd3f56405f17a67e7b9..c85bc8151d255a8fb953a6b45776b0ed75073ac7 100644 (file)
@@ -6719,7 +6719,7 @@ vol-clone
 ::
 
    vol-clone vol-name-or-key-or-path name
-      [--pool pool-or-uuid] [--prealloc-metadata] [--reflink]
+      [--pool pool-or-uuid] [--prealloc-metadata] [--reflink] [--print-xml]
 
 Clone an existing volume within the parent pool.  Less powerful,
 but easier to type, version of ``vol-create-from``.
@@ -6743,6 +6743,9 @@ When *--reflink* is specified, perform a COW lightweight copy,
 where the data blocks are copied only when modified.
 If this is not possible, the copy fails.
 
+If *--print-xml* is specified, then the XML used to clone the volume is
+printed instead.
+
 
 vol-delete
 ----------
index 508c620cd3a655816a8b1df4f85dbfc8ea1388d9..fbbeddd8f334ff0fd7206bd7b9e77717624d959d 100644 (file)
@@ -559,6 +559,10 @@ static const vshCmdOptDef opts_vol_clone[] = {
      .type = VSH_OT_BOOL,
      .help = N_("use btrfs COW lightweight copy")
     },
+    {.name = "print-xml",
+     .type = VSH_OT_BOOL,
+     .help = N_("print XML document rather than clone the volume")
+    },
     {.name = NULL}
 };
 
@@ -599,6 +603,11 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
+    if (vshCommandOptBool(cmd, "print-xml")) {
+        vshPrint(ctl, "%s", newxml);
+        return true;
+    }
+
     if (!(newvol = virStorageVolCreateXMLFrom(origpool, (char *) newxml,
                                               origvol, flags))) {
         vshError(ctl, _("Failed to clone vol from %s"),