[PATCHv5 16/23] blockjob: enhance virsh 'blockcopy'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Expose the full abilities of virDomainBlockCopy.

* tools/virsh.c (blockJobImpl): Add --format option for block copy.
* tools/virsh.pod (blockcopy): Document this.
---
 tools/virsh.c   |   26 ++++++++++++++++++++------
 tools/virsh.pod |   10 +++++-----
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 0f79022..e521933 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -7530,6 +7530,7 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
     unsigned long bandwidth = 0;
     int ret = -1;
     const char *base = NULL;
+    const char *format = NULL;
     unsigned int flags = 0;

     if (!vshConnectionUsability(ctl, ctl->conn))
@@ -7569,16 +7570,28 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
             ret = virDomainBlockPull(dom, path, bandwidth, 0);
         break;
     case VSH_CMD_BLOCK_JOB_COPY:
-        flags |= VIR_DOMAIN_BLOCK_REBASE_COPY;
         if (vshCommandOptBool(cmd, "shallow"))
-            flags |= VIR_DOMAIN_BLOCK_REBASE_SHALLOW;
+            flags |= VIR_DOMAIN_BLOCK_COPY_SHALLOW;
         if (vshCommandOptBool(cmd, "reuse-external"))
-            flags |= VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT;
-        if (vshCommandOptBool(cmd, "raw"))
-            flags |= VIR_DOMAIN_BLOCK_REBASE_COPY_RAW;
+            flags |= VIR_DOMAIN_BLOCK_COPY_REUSE_EXT;
         if (vshCommandOptString(cmd, "dest", &base) < 0)
             goto cleanup;
-        ret = virDomainBlockRebase(dom, path, base, bandwidth, flags);
+        if (vshCommandOptString(cmd, "format", &format) < 0)
+            goto cleanup;
+        if (!format) {
+            if (vshCommandOptBool(cmd, "raw"))
+                flags |= VIR_DOMAIN_BLOCK_REBASE_COPY_RAW;
+            flags |= VIR_DOMAIN_BLOCK_REBASE_COPY;
+            ret = virDomainBlockRebase(dom, path, base, bandwidth, flags);
+        } else {
+            if (vshCommandOptBool(cmd, "raw")) {
+                vshError(ctl, "%s",
+                         _("--raw and --format are mutually exclusive"));
+                goto cleanup;
+            }
+            ret = virDomainBlockCopy(dom, path, base, format,
+                                     bandwidth, flags);
+        }
     }

 cleanup:
@@ -7603,6 +7616,7 @@ static const vshCmdOptDef opts_block_copy[] = {
     {"path", VSH_OT_DATA, VSH_OFLAG_REQ, N_("fully-qualified path of disk")},
     {"dest", VSH_OT_DATA, VSH_OFLAG_REQ, N_("path of the copy to create")},
     {"bandwidth", VSH_OT_DATA, VSH_OFLAG_NONE, N_("bandwidth limit in MB/s")},
+    {"format", VSH_OT_DATA, VSH_OFLAG_NONE, N_("file format of dest")},
     {"shallow", VSH_OT_BOOL, 0, N_("make the copy share a backing chain")},
     {"reuse-external", VSH_OT_BOOL, 0, N_("reuse existing destination")},
     {"raw", VSH_OT_BOOL, 0, N_("use raw destination file")},
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 23324b2..0e7617b 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -640,7 +640,7 @@ address of virtual interface (such as I<detach-interface> or
 I<domif-setlink>) will accept the MAC address printed by this command.

 =item B<blockcopy> I<domain> I<path> I<dest> [I<bandwidth>] [I<--shallow>]
-[I<--reuse-external>] [I<--raw>] [I<--wait> [I<--verbose]
+[I<--reuse-external>] { [I<--raw>] | I<format> } [I<--wait> [I<--verbose]
 [{I<--pivot> | I<--finish>}] [I<--timeout> B<seconds>] [I<--async>]]

 Copy a disk backing image chain to I<dest>. By default, this command
@@ -654,10 +654,10 @@ is used, otherwise it must start empty); this option is typically used
 to set up a relative backing file name in the destination.

 The format of the destination is determined by the first match in the
-following list: if I<--raw> is specified, it will be raw; if
-I<--reuse-external> is specified, the existing destination is probed
-for a format; and in all other cases, the destination format will
-match the source format.
+following list: if I<--raw> is specified, it will be raw; if I<format>
+is specified, it will have that format; if I<--reuse-external> is
+specified, the existing destination is probed for a format; and in
+all other cases, the destination format will match the source format.

 By default, the copy job runs in the background, and consists of two
 phases.  Initially, the job must copy all data from the source, and
-- 
1.7.7.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]