]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: cmdBlockcopy: Add '--print-xml' flag
authorPeter Krempa <pkrempa@redhat.com>
Mon, 25 Apr 2022 07:47:26 +0000 (09:47 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 25 Apr 2022 14:37:05 +0000 (16:37 +0200)
Useful for knowing how to construct the XML and debugging.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/manpages/virsh.rst
tools/virsh-domain.c

index e8568559fa89fd0b38f1545101545d006a256ca6..e73e590754294bbfa90761795e38a43185552eaa 100644 (file)
@@ -1232,7 +1232,7 @@ blockcopy
       [--shallow] [--reuse-external] [bandwidth]
       [--wait [--async] [--verbose]] [{--pivot | --finish}]
       [--timeout seconds] [granularity] [buf-size] [--bytes]
-      [--transient-job] [--synchronous-writes]
+      [--transient-job] [--synchronous-writes] [--print-xml]
 
 Copy a disk backing image chain to a destination.  Either *dest* as
 the destination file name, or *--xml* with the name of an XML file containing
@@ -1297,6 +1297,8 @@ to be propagated both to the original image and to the destination of the copy
 so that it's guaranteed that the job converges if the destination storage is
 slower. This may impact performance of writes while the blockjob is running.
 
+If *--print-xml* is specified, then the XML used to start the block copy job
+is printed instead of starting the job.
 
 blockjob
 --------
index df8df9c2f33b73053bc02248e2210f041a542903..452e518156f5bf9e689eb3debd1bda3b124b4c40 100644 (file)
@@ -2332,6 +2332,10 @@ static const vshCmdOptDef opts_blockcopy[] = {
      .type = VSH_OT_BOOL,
      .help = N_("the copy job forces guest writes to be synchronously written to the destination")
     },
+    {.name = "print-xml",
+     .type = VSH_OT_BOOL,
+     .help = N_("print the XML used to start the copy job instead of starting the job")
+    },
     {.name = NULL}
 };
 
@@ -2360,6 +2364,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
     int abort_flags = 0;
     const char *xml = NULL;
     char *xmlstr = NULL;
+    bool print_xml = vshCommandOptBool(cmd, "print-xml");
     virTypedParameterPtr params = NULL;
     virshBlockJobWaitData *bjWait = NULL;
     int nparams = 0;
@@ -2437,7 +2442,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
     }
 
     if (granularity || buf_size || (format && STRNEQ(format, "raw")) || xml ||
-        transientjob || syncWrites) {
+        transientjob || syncWrites || print_xml) {
         /* New API */
         if (bandwidth || granularity || buf_size) {
             params = g_new0(virTypedParameter, 3);
@@ -2492,6 +2497,12 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
             xmlstr = virBufferContentAndReset(&buf);
         }
 
+        if (print_xml) {
+            vshPrint(ctl, "%s", xmlstr);
+            ret = true;
+            goto cleanup;
+        }
+
         if (virDomainBlockCopy(dom, path, xmlstr, params, nparams, flags) < 0)
             goto cleanup;
     } else {