Useful for knowing how to construct the XML and debugging. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- docs/manpages/virsh.rst | 4 +++- tools/virsh-domain.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index e8568559fa..e73e590754 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -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 -------- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index df8df9c2f3..452e518156 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -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 { -- 2.35.1