To allow changing the name that is recorded in the top of the current
image chain used in a block pull/rebase operation, we need to specify
the backing name to qemu. This is done via the "backing-file" attribute
to the block-stream commad.
---
src/qemu/qemu_driver.c | 8 ++++----
src/qemu/qemu_migration.c | 6 +++---
src/qemu/qemu_monitor.c | 12 +++++++-----
src/qemu/qemu_monitor.h | 3 ++-
src/qemu/qemu_monitor_json.c | 15 +++++++++++++++
src/qemu/qemu_monitor_json.h | 1 +
6 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 61f2beb..88d44d3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14883,7 +14883,7 @@ qemuDomainBlockPivot(virConnectPtr conn,
/* Probe the status, if needed. */
if (!disk->mirroring) {
qemuDomainObjEnterMonitor(driver, vm);
- rc = qemuMonitorBlockJob(priv->mon, device, NULL, 0, &info,
+ rc = qemuMonitorBlockJob(priv->mon, device, NULL, NULL, 0, &info,
BLOCK_JOB_INFO, true);
qemuDomainObjExitMonitor(driver, vm);
if (rc < 0)
@@ -15100,7 +15100,7 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorBlockJob(priv->mon, device,
baseIndex ? baseSource->path : base,
- bandwidth, info, mode, async);
+ NULL, bandwidth, info, mode, async);
qemuDomainObjExitMonitor(driver, vm);
if (ret < 0)
goto endjob;
@@ -15142,8 +15142,8 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
virDomainBlockJobInfo dummy;
qemuDomainObjEnterMonitor(driver, vm);
- ret = qemuMonitorBlockJob(priv->mon, device, NULL, 0, &dummy,
- BLOCK_JOB_INFO, async);
+ ret = qemuMonitorBlockJob(priv->mon, device, NULL, NULL, 0,
+ &dummy, BLOCK_JOB_INFO, async);
qemuDomainObjExitMonitor(driver, vm);
if (ret <= 0)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 842f782..30175f2 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1308,7 +1308,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
_("canceled by client"));
goto error;
}
- mon_ret = qemuMonitorBlockJob(priv->mon, diskAlias, NULL, 0,
+ mon_ret = qemuMonitorBlockJob(priv->mon, diskAlias, NULL, NULL, 0,
&info, BLOCK_JOB_INFO, true);
qemuDomainObjExitMonitor(driver, vm);
@@ -1360,7 +1360,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
continue;
if (qemuDomainObjEnterMonitorAsync(driver, vm,
QEMU_ASYNC_JOB_MIGRATION_OUT) == 0) {
- if (qemuMonitorBlockJob(priv->mon, diskAlias, NULL, 0,
+ if (qemuMonitorBlockJob(priv->mon, diskAlias, NULL, NULL, 0,
NULL, BLOCK_JOB_ABORT, true) < 0) {
VIR_WARN("Unable to cancel block-job on '%s'",
diskAlias);
}
@@ -1426,7 +1426,7 @@ qemuMigrationCancelDriveMirror(qemuMigrationCookiePtr mig,
QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
goto cleanup;
- if (qemuMonitorBlockJob(priv->mon, diskAlias, NULL, 0,
+ if (qemuMonitorBlockJob(priv->mon, diskAlias, NULL, NULL, 0,
NULL, BLOCK_JOB_ABORT, true) < 0)
VIR_WARN("Unable to stop block job on %s", diskAlias);
qemuDomainObjExitMonitor(driver, vm);
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 2c9e738..ed6368e 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3354,6 +3354,7 @@ int qemuMonitorScreendump(qemuMonitorPtr mon,
int qemuMonitorBlockJob(qemuMonitorPtr mon,
const char *device,
const char *base,
+ const char *backingName,
unsigned long bandwidth,
virDomainBlockJobInfoPtr info,
qemuMonitorBlockJobCmd mode,
@@ -3362,9 +3363,10 @@ int qemuMonitorBlockJob(qemuMonitorPtr mon,
int ret = -1;
unsigned long long speed;
- VIR_DEBUG("mon=%p, device=%s, base=%s, bandwidth=%luM, info=%p, mode=%o, "
- "modern=%d", mon, device, NULLSTR(base), bandwidth, info, mode,
- modern);
+ VIR_DEBUG("mon=%p, device=%s, base=%s, backingName=%s, bandwidth=%luM, "
+ "info=%p, mode=%o, modern=%d",
+ mon, device, NULLSTR(base), NULLSTR(backingName),
+ bandwidth, info, mode, modern);
/* Convert bandwidth MiB to bytes - unfortunately the JSON QMP protocol is
* limited to LLONG_MAX also for unsigned values */
@@ -3378,8 +3380,8 @@ int qemuMonitorBlockJob(qemuMonitorPtr mon,
speed <<= 20;
if (mon->json)
- ret = qemuMonitorJSONBlockJob(mon, device, base, speed, info, mode,
- modern);
+ ret = qemuMonitorJSONBlockJob(mon, device, base, backingName,
+ speed, info, mode, modern);
else
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("block jobs require JSON monitor"));
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 71b7d3c..460239c 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -691,7 +691,8 @@ typedef enum {
int qemuMonitorBlockJob(qemuMonitorPtr mon,
const char *device,
- const char *back,
+ const char *base,
+ const char *backingName,
unsigned long bandwidth,
virDomainBlockJobInfoPtr info,
qemuMonitorBlockJobCmd mode,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index b4cdd6d..dfe57f1 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3766,6 +3766,7 @@ int
qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
const char *device,
const char *base,
+ const char *backingName,
unsigned long long speed,
virDomainBlockJobInfoPtr info,
qemuMonitorBlockJobCmd mode,
@@ -3781,6 +3782,19 @@ qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
_("only modern block pull supports base: %s"), base);
return -1;
}
+
+ if (backingName && mode != BLOCK_JOB_PULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("backing name is supported only for block pull"));
+ return -1;
+ }
+
+ if (backingName && !base) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("backing name requires a base image"));
+ return -1;
+ }
+
if (speed && mode == BLOCK_JOB_PULL && !modern) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("only modern block pull supports speed: %llu"),
@@ -3815,6 +3829,7 @@ qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
"s:device", device,
"P:speed", speed,
"S:base", base,
+ "S:backing-file", backingName,
NULL);
break;
}
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 37ab325..7c9297c 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -284,6 +284,7 @@ int qemuMonitorJSONScreendump(qemuMonitorPtr mon,
int qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
const char *device,
const char *base,
+ const char *backingName,
unsigned long long speed,
virDomainBlockJobInfoPtr info,
qemuMonitorBlockJobCmd mode,
--
1.9.3