Split out the 'shallow' and 'reuse' flags as booleans rather than passing
in flags and constructing them in irrelevant APIs.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_driver.c | 4 +++-
src/qemu/qemu_migration.c | 6 +-----
src/qemu/qemu_monitor.c | 9 +++++----
src/qemu/qemu_monitor.h | 3 ++-
src/qemu/qemu_monitor_json.c | 5 ++---
src/qemu/qemu_monitor_json.h | 3 ++-
tests/qemumonitorjsontest.c | 3 +--
7 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9c0796b0a4..95c84b46ae 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17764,7 +17764,9 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
/* qemuMonitorDriveMirror needs to honor the REUSE_EXT flag as specified
* by the user regardless of how @reuse was modified */
ret = qemuMonitorDriveMirror(priv->mon, device, mirror->path, format,
- bandwidth, granularity, buf_size, flags);
+ bandwidth, granularity, buf_size,
+ flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW,
+ flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT);
virDomainAuditDisk(vm, NULL, mirror, "mirror", ret >= 0);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 832f98346d..32b3040473 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -866,10 +866,6 @@ qemuMigrationSrcNBDStorageCopyDriveMirror(virQEMUDriverPtr driver,
char *nbd_dest = NULL;
int mon_ret;
int ret = -1;
- unsigned int mirror_flags = VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT;
-
- if (mirror_shallow)
- mirror_flags |= VIR_DOMAIN_BLOCK_REBASE_SHALLOW;
if (strchr(host, ':')) {
if (virAsprintf(&nbd_dest, "nbd:[%s]:%d:exportname=%s",
@@ -887,7 +883,7 @@ qemuMigrationSrcNBDStorageCopyDriveMirror(virQEMUDriverPtr driver,
mon_ret = qemuMonitorDriveMirror(qemuDomainGetMonitor(vm),
diskAlias, nbd_dest, "raw",
- mirror_speed, 0, 0, mirror_flags);
+ mirror_speed, 0, 0, mirror_shallow, true);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || mon_ret < 0)
goto cleanup;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 9a796db3cb..6b731cd91a 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3244,17 +3244,18 @@ qemuMonitorDriveMirror(qemuMonitorPtr mon,
const char *device, const char *file,
const char *format, unsigned long long bandwidth,
unsigned int granularity, unsigned long long buf_size,
- unsigned int flags)
+ bool shallow,
+ bool reuse)
{
VIR_DEBUG("device=%s, file=%s, format=%s, bandwidth=%lld, "
- "granularity=%#x, buf_size=%lld, flags=0x%x",
+ "granularity=%#x, buf_size=%lld, shallow=%d, reuse=%d",
device, file, NULLSTR(format), bandwidth, granularity,
- buf_size, flags);
+ buf_size, shallow, reuse);
QEMU_CHECK_MONITOR(mon);
return qemuMonitorJSONDriveMirror(mon, device, file, format, bandwidth,
- granularity, buf_size, flags);
+ granularity, buf_size, shallow, reuse);
}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 438c3c38ed..dee594fa66 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -884,7 +884,8 @@ int qemuMonitorDriveMirror(qemuMonitorPtr mon,
unsigned long long bandwidth,
unsigned int granularity,
unsigned long long buf_size,
- unsigned int flags)
+ bool shallow,
+ bool reuse)
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int qemuMonitorBlockdevMirror(qemuMonitorPtr mon,
const char *jobname,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index a75e660d07..4152d44331 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4277,13 +4277,12 @@ qemuMonitorJSONDriveMirror(qemuMonitorPtr mon,
const char *format, unsigned long long speed,
unsigned int granularity,
unsigned long long buf_size,
- unsigned int flags)
+ bool shallow,
+ bool reuse)
{
int ret = -1;
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
- bool shallow = (flags & VIR_DOMAIN_BLOCK_REBASE_SHALLOW) != 0;
- bool reuse = (flags & VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT) != 0;
cmd = qemuMonitorJSONMakeCommand("drive-mirror",
"s:device", device,
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 174db7a2e9..acef1a0a79 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -250,7 +250,8 @@ int qemuMonitorJSONDriveMirror(qemuMonitorPtr mon,
unsigned long long speed,
unsigned int granularity,
unsigned long long buf_size,
- unsigned int flags)
+ bool shallow,
+ bool reuse)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon,
const char *jobname,
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index c2bb3a6c4f..0894e748ae 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1341,8 +1341,7 @@ GEN_TEST_FUNC(qemuMonitorJSONAddNetdev,
"id=net0,type=test")
GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0")
GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0")
GEN_TEST_FUNC(qemuMonitorJSONAddDevice, "some_dummy_devicestr")
-GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar",
"formatstr", 1024, 1234, 31234,
- VIR_DOMAIN_BLOCK_REBASE_SHALLOW | VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT)
+GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar",
"formatstr", 1024, 1234, 31234, true, true)
GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", "vdb",
"targetnode", 1024, 1234, 31234, true)
GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "/foo/bar1",
"backingfilename", 1024)
GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "/foo/bar1",
"/foo/bar2", "backingfilename", 1024)
--
2.21.0