[PATCHv2 14/15] 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   |   25 ++++++++++++++++++++-----
 tools/virsh.pod |   10 +++++-----
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 99f3d22..e855951 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -7527,6 +7527,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))
@@ -7568,14 +7569,27 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
     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:
@@ -7598,6 +7612,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 50a495d..1e5ce12 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -639,7 +639,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<--reuse-external>] { [I<--raw>] | I<format> }

 Copy a disk backing image chain to I<dest>. By default, this command
 flattens the entire chain; but if I<--shallow> is specified, the copy
@@ -652,10 +652,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.

 The copy runs in the background; initially, the job must copy all data
 from the source, and during this phase, the job can only be canceled to
-- 
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]