3e5111
From b6a3d1447dd99d7c766c27c56305e7b9c6e83972 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <b6a3d1447dd99d7c766c27c56305e7b9c6e83972@dist-git>
3e5111
From: Peter Krempa <pkrempa@redhat.com>
3e5111
Date: Wed, 7 Jun 2017 13:31:22 +0200
3e5111
Subject: [PATCH] virsh: Add support for VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB
3e5111
3e5111
Allow using the new flag with virsh.
3e5111
3e5111
(cherry picked from commit 880b1a2e25fc7b76581b1115a5ab538d74193159)
3e5111
3e5111
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1459113
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 tools/virsh-domain.c | 10 +++++++++-
3e5111
 tools/virsh.pod      |  6 ++++++
3e5111
 2 files changed, 15 insertions(+), 1 deletion(-)
3e5111
3e5111
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
3e5111
index 3374f2c8b6..da9f7c16ed 100644
3e5111
--- a/tools/virsh-domain.c
3e5111
+++ b/tools/virsh-domain.c
3e5111
@@ -2249,6 +2249,10 @@ static const vshCmdOptDef opts_block_copy[] = {
3e5111
      .type = VSH_OT_BOOL,
3e5111
      .help = N_("the bandwidth limit is in bytes/s rather than MiB/s")
3e5111
     },
3e5111
+    {.name = "transient-job",
3e5111
+     .type = VSH_OT_BOOL,
3e5111
+     .help = N_("the copy job is not persisted if VM is turned off")
3e5111
+    },
3e5111
     {.name = NULL}
3e5111
 };
3e5111
 
3e5111
@@ -2270,6 +2274,7 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
3e5111
     bool blocking = vshCommandOptBool(cmd, "wait") || finish || pivot;
3e5111
     bool async = vshCommandOptBool(cmd, "async");
3e5111
     bool bytes = vshCommandOptBool(cmd, "bytes");
3e5111
+    bool transientjob = vshCommandOptBool(cmd, "transient-job");
3e5111
     int timeout = 0;
3e5111
     const char *path = NULL;
3e5111
     int abort_flags = 0;
3e5111
@@ -2299,6 +2304,8 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
3e5111
         flags |= VIR_DOMAIN_BLOCK_REBASE_SHALLOW;
3e5111
     if (vshCommandOptBool(cmd, "reuse-external"))
3e5111
         flags |= VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT;
3e5111
+    if (transientjob)
3e5111
+        flags |= VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB;
3e5111
     if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
3e5111
         return false;
3e5111
 
3e5111
@@ -2347,7 +2354,8 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
3e5111
         }
3e5111
     }
3e5111
 
3e5111
-    if (granularity || buf_size || (format && STRNEQ(format, "raw")) || xml) {
3e5111
+    if (granularity || buf_size || (format && STRNEQ(format, "raw")) || xml ||
3e5111
+        transientjob) {
3e5111
         /* New API */
3e5111
         if (bandwidth || granularity || buf_size) {
3e5111
             params = vshCalloc(ctl, 3, sizeof(*params));
3e5111
diff --git a/tools/virsh.pod b/tools/virsh.pod
3e5111
index 11bacefa9a..0315f1f265 100644
3e5111
--- a/tools/virsh.pod
3e5111
+++ b/tools/virsh.pod
3e5111
@@ -1077,6 +1077,7 @@ command.
3e5111
 | I<--xml> B<file> } [I<--shallow>] [I<--reuse-external>] [I<bandwidth>]
3e5111
 [I<--wait> [I<--async>] [I<--verbose>]] [{I<--pivot> | I<--finish>}]
3e5111
 [I<--timeout> B<seconds>] [I<granularity>] [I<buf-size>] [I<--bytes>]
3e5111
+[I<--transient-job>]
3e5111
 
3e5111
 Copy a disk backing image chain to a destination.  Either I<dest> as
3e5111
 the destination file name, or I<--xml> with the name of an XML file containing
3e5111
@@ -1131,6 +1132,11 @@ within a certain range. Specifying I<buf-size> will control how much data can
3e5111
 be simultaneously in-flight during the copy; larger values use more memory but
3e5111
 may allow faster completion (the default value is usually correct).
3e5111
 
3e5111
+I<--transient-job> allows to specify that the user does not require the job to
3e5111
+be recovered if the VM crashes or is turned off before the job completes. This
3e5111
+flag removes the restriction of copy jobs to transient domains if that
3e5111
+restriction is applied by the hypervisor.
3e5111
+
3e5111
 =item B<blockpull> I<domain> I<path> [I<bandwidth>] [I<--bytes>] [I<base>]
3e5111
 [I<--wait> [I<--verbose>] [I<--timeout> B<seconds>] [I<--async>]]
3e5111
 [I<--keep-relative>]
3e5111
-- 
3e5111
2.13.1
3e5111