Almost trivial; the trick was dealing with the fact that we're
stuck with 'unsigned long bandwidth' due to earlier design
decisions. Also, prefer the correct flag names (although we
intentionally chose the _SHALLOW and _REUSE_EXT values to be
equal, to allow for loose handling in our code).
* src/remote/remote_protocol.x (remote_domain_block_copy_args):
New struct.
* src/remote/remote_driver.c (remote_driver): Use it.
* src/rpc/gendispatch.pl (name_to_ProcName): Cater to legacy
bandwidth type.
* src/remote_protocol-structs: Regenerate.
* src/qemu/qemu_driver.c (qemuDriver): Wire up driver callback.
(qemuDomainBlockCopy): Use preferred flag names.
---
src/qemu/qemu_driver.c | 21 +++++++++++----------
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 12 +++++++++++-
src/remote_protocol-structs | 9 +++++++++
src/rpc/gendispatch.pl | 1 +
5 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0e9ea41..7ba41ee 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11889,8 +11889,8 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *path,
struct stat st;
/* Preliminaries: find the disk we are editing, sanity checks */
- virCheckFlags(VIR_DOMAIN_BLOCK_REBASE_SHALLOW |
- VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT, -1);
+ virCheckFlags(VIR_DOMAIN_BLOCK_COPY_SHALLOW |
+ VIR_DOMAIN_BLOCK_COPY_REUSE_EXT, -1);
qemuDriverLock(driver);
virUUIDFormat(dom->uuid, uuidstr);
@@ -11935,7 +11935,7 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *path,
goto endjob;
}
- if ((flags & VIR_DOMAIN_BLOCK_REBASE_SHALLOW) &&
+ if ((flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW) &&
STREQ_NULLABLE(format, "raw") &&
STRNEQ_NULLABLE(disk->driverType, "raw")) {
qemuReportError(VIR_ERR_INVALID_ARG,
@@ -11946,8 +11946,8 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *path,
/* XXX this is pessimistic; we could use 'query-block' or even
* keep track of the backing chain ourselves, rather than assuming
* that all non-raw source files have a current backing image */
- if ((flags & VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT) &&
- !(flags & VIR_DOMAIN_BLOCK_REBASE_SHALLOW) &&
+ if ((flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT) &&
+ !(flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW) &&
STRNEQ_NULLABLE(disk->driverType, "raw")) {
qemuReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
_("non-shallow copy of non-raw disk '%s' to existing
"
@@ -11962,14 +11962,14 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *path,
virReportSystemError(errno, _("unable to stat for disk %s: %s"),
disk->dst, dest);
goto endjob;
- } else if (flags & VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT) {
+ } else if (flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT) {
virReportSystemError(errno,
_("missing destination file for disk %s:
%s"),
disk->dst, dest);
goto endjob;
}
} else if (!(S_ISBLK(st.st_mode) || !st.st_size ||
- (flags & VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT))) {
+ (flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT))) {
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("external destination file for disk %s already "
"exists and is not a block device: %s"),
@@ -11979,16 +11979,16 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *path,
/* XXX We also need to add security labeling, lock manager lease,
* and auditing of those events. */
- if (!format && !(flags & VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT))
+ if (!format && !(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT))
format = disk->driverType;
if ((format && !(disk->mirrorFormat = strdup(format))) ||
!(disk->mirror = strdup(dest))) {
virReportOOMError();
goto endjob;
}
- if (flags & VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT)
+ if (flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT)
mode = QEMU_MONITOR_DRIVE_MIRROR_EXISTING;
- else if (flags & VIR_DOMAIN_BLOCK_REBASE_SHALLOW)
+ else if (flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW)
mode = QEMU_MONITOR_DRIVE_MIRROR_ABSOLUTE;
else
mode = QEMU_MONITOR_DRIVE_MIRROR_NO_BACKING;
@@ -13143,6 +13143,7 @@ static virDriver qemuDriver = {
.domainBlockJobSetSpeed = qemuDomainBlockJobSetSpeed, /* 0.9.4 */
.domainBlockPull = qemuDomainBlockPull, /* 0.9.4 */
.domainBlockRebase = qemuDomainBlockRebase, /* 0.9.10 */
+ .domainBlockCopy = qemuDomainBlockCopy, /* 0.9.12 */
.isAlive = qemuIsAlive, /* 0.9.8 */
.nodeSuspendForDuration = nodeSuspendForDuration, /* 0.9.8 */
.domainSetBlockIoTune = qemuDomainSetBlockIoTune, /* 0.9.8 */
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index af46384..b431779 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5095,6 +5095,7 @@ static virDriver remote_driver = {
.domainBlockJobSetSpeed = remoteDomainBlockJobSetSpeed, /* 0.9.4 */
.domainBlockPull = remoteDomainBlockPull, /* 0.9.4 */
.domainBlockRebase = remoteDomainBlockRebase, /* 0.9.10 */
+ .domainBlockCopy = remoteDomainBlockCopy, /* 0.9.12 */
.setKeepAlive = remoteSetKeepAlive, /* 0.9.8 */
.isAlive = remoteIsAlive, /* 0.9.8 */
.nodeSuspendForDuration = remoteNodeSuspendForDuration, /* 0.9.8 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 2d57247..65b4a1d 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1188,6 +1188,14 @@ struct remote_domain_block_rebase_args {
unsigned hyper bandwidth;
unsigned int flags;
};
+struct remote_domain_block_copy_args {
+ remote_nonnull_domain dom;
+ remote_nonnull_string path;
+ remote_nonnull_string dest;
+ remote_string format;
+ unsigned hyper bandwidth;
+ unsigned int flags;
+};
struct remote_domain_set_block_io_tune_args {
remote_nonnull_domain dom;
@@ -2782,7 +2790,9 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_PM_WAKEUP = 267, /* autogen autogen */
REMOTE_PROC_DOMAIN_EVENT_TRAY_CHANGE = 268, /* autogen autogen */
REMOTE_PROC_DOMAIN_EVENT_PMWAKEUP = 269, /* autogen autogen */
- REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND = 270 /* autogen autogen */
+ REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND = 270, /* autogen autogen */
+
+ REMOTE_PROC_DOMAIN_BLOCK_COPY = 271 /* autogen autogen */
/*
* Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 9b2414f..dd2aa72 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -845,6 +845,14 @@ struct remote_domain_block_rebase_args {
uint64_t bandwidth;
u_int flags;
};
+struct remote_domain_block_copy_args {
+ remote_nonnull_domain dom;
+ remote_nonnull_string path;
+ remote_nonnull_string dest;
+ remote_string format;
+ uint64_t bandwidth;
+ u_int flags;
+};
struct remote_domain_set_block_io_tune_args {
remote_nonnull_domain dom;
remote_nonnull_string disk;
@@ -2192,4 +2200,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_EVENT_TRAY_CHANGE = 268,
REMOTE_PROC_DOMAIN_EVENT_PMWAKEUP = 269,
REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND = 270,
+ REMOTE_PROC_DOMAIN_BLOCK_COPY = 271,
};
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index f161ee0..e5e28e0 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -232,6 +232,7 @@ my $long_legacy = {
NodeGetInfo => { ret => { memory => 1 } },
DomainBlockPull => { arg => { bandwidth => 1 } },
DomainBlockRebase => { arg => { bandwidth => 1 } },
+ DomainBlockCopy => { arg => { bandwidth => 1 } },
DomainBlockJobSetSpeed => { arg => { bandwidth => 1 } },
DomainMigrateGetMaxSpeed => { ret => { bandwidth => 1 } },
};
--
1.7.7.6