Expose the full abilities of virDomainBlockCopy.
* tools/virsh.c (blockJobImpl): Support more options for block
copy.
* tools/virsh.pod (blockcopy): Document these.
---
tools/virsh.c | 23 +++++++++++++++++++----
tools/virsh.pod | 10 ++++++----
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index d01d31d..8f8b3b7 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -7527,6 +7527,8 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
unsigned long bandwidth = 0;
int ret = -1;
const char *base = NULL;
+ const char *dest = NULL;
+ const char *format = NULL;
unsigned int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
@@ -7568,12 +7570,22 @@ 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 (vshCommandOptString(cmd, "dest", &base) < 0)
+ flags |= VIR_DOMAIN_BLOCK_COPY_REUSE_EXT;
+ if (vshCommandOptString(cmd, "base", &base) < 0)
+ goto cleanup;
+ if (vshCommandOptString(cmd, "dest", &dest) < 0)
+ goto cleanup;
+ if (vshCommandOptString(cmd, "format", &format) < 0)
goto cleanup;
- ret = virDomainBlockRebase(dom, path, base, bandwidth, flags);
+ if (!base && !format) {
+ flags |= VIR_DOMAIN_BLOCK_REBASE_COPY;
+ ret = virDomainBlockRebase(dom, path, dest, bandwidth, flags);
+ } else {
+ ret = virDomainBlockCopy(dom, path, base, dest, format,
+ bandwidth, flags);
+ }
}
cleanup:
@@ -7596,6 +7608,9 @@ 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")},
+ {"base", VSH_OT_DATA, VSH_OFLAG_NONE,
+ N_("path of backing file in chain for a partial pull")},
{"shallow", VSH_OT_BOOL, 0, N_("make the copy share a backing
chain")},
{"reuse-external", VSH_OT_BOOL, 0, N_("reuse existing
destination")},
{NULL, 0, 0, NULL}
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 112be22..d3be071 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -637,16 +637,18 @@ currently in use by a running domain. Other contexts that require a
MAC
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>]
+=item B<blockcopy> I<domain> I<path> I<dest> [I<bandwidth>]
[I<format>]
+{ [I<--shallow>] | [I<base>] } [I<--reuse-external>]
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
-shares the backing chain.
+shares the backing chain, or I<base> can be used to determine the new
+base file of the copy for a partial pull.
If I<--reuse-external> is specified, then I<dest> must exist and have
contents identical to I<disk> (typically used to set up a relative
-backing file name).
+backing file name). I<format> can be used to specify a different
+file format on the copy as compared to the source.
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