提交 a448713a 编写于 作者: P Peter Krempa

qemu: monitor: Add support for backing name specification for block-stream

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.
上级 c29b6529
...@@ -14873,7 +14873,7 @@ qemuDomainBlockPivot(virConnectPtr conn, ...@@ -14873,7 +14873,7 @@ qemuDomainBlockPivot(virConnectPtr conn,
/* Probe the status, if needed. */ /* Probe the status, if needed. */
if (!disk->mirroring) { if (!disk->mirroring) {
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
rc = qemuMonitorBlockJob(priv->mon, device, NULL, 0, &info, rc = qemuMonitorBlockJob(priv->mon, device, NULL, NULL, 0, &info,
BLOCK_JOB_INFO, true); BLOCK_JOB_INFO, true);
qemuDomainObjExitMonitor(driver, vm); qemuDomainObjExitMonitor(driver, vm);
if (rc < 0) if (rc < 0)
...@@ -15090,7 +15090,7 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm, ...@@ -15090,7 +15090,7 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorBlockJob(priv->mon, device, ret = qemuMonitorBlockJob(priv->mon, device,
baseIndex ? baseSource->path : base, baseIndex ? baseSource->path : base,
bandwidth, info, mode, async); NULL, bandwidth, info, mode, async);
qemuDomainObjExitMonitor(driver, vm); qemuDomainObjExitMonitor(driver, vm);
if (ret < 0) if (ret < 0)
goto endjob; goto endjob;
...@@ -15135,8 +15135,8 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm, ...@@ -15135,8 +15135,8 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
virDomainBlockJobInfo dummy; virDomainBlockJobInfo dummy;
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorBlockJob(priv->mon, device, NULL, 0, &dummy, ret = qemuMonitorBlockJob(priv->mon, device, NULL, NULL, 0,
BLOCK_JOB_INFO, async); &dummy, BLOCK_JOB_INFO, async);
qemuDomainObjExitMonitor(driver, vm); qemuDomainObjExitMonitor(driver, vm);
if (ret <= 0) if (ret <= 0)
......
...@@ -1305,7 +1305,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver, ...@@ -1305,7 +1305,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
_("canceled by client")); _("canceled by client"));
goto error; goto error;
} }
mon_ret = qemuMonitorBlockJob(priv->mon, diskAlias, NULL, 0, mon_ret = qemuMonitorBlockJob(priv->mon, diskAlias, NULL, NULL, 0,
&info, BLOCK_JOB_INFO, true); &info, BLOCK_JOB_INFO, true);
qemuDomainObjExitMonitor(driver, vm); qemuDomainObjExitMonitor(driver, vm);
...@@ -1357,7 +1357,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver, ...@@ -1357,7 +1357,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
continue; continue;
if (qemuDomainObjEnterMonitorAsync(driver, vm, if (qemuDomainObjEnterMonitorAsync(driver, vm,
QEMU_ASYNC_JOB_MIGRATION_OUT) == 0) { 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) { NULL, BLOCK_JOB_ABORT, true) < 0) {
VIR_WARN("Unable to cancel block-job on '%s'", diskAlias); VIR_WARN("Unable to cancel block-job on '%s'", diskAlias);
} }
...@@ -1423,7 +1423,7 @@ qemuMigrationCancelDriveMirror(qemuMigrationCookiePtr mig, ...@@ -1423,7 +1423,7 @@ qemuMigrationCancelDriveMirror(qemuMigrationCookiePtr mig,
QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
goto cleanup; goto cleanup;
if (qemuMonitorBlockJob(priv->mon, diskAlias, NULL, 0, if (qemuMonitorBlockJob(priv->mon, diskAlias, NULL, NULL, 0,
NULL, BLOCK_JOB_ABORT, true) < 0) NULL, BLOCK_JOB_ABORT, true) < 0)
VIR_WARN("Unable to stop block job on %s", diskAlias); VIR_WARN("Unable to stop block job on %s", diskAlias);
qemuDomainObjExitMonitor(driver, vm); qemuDomainObjExitMonitor(driver, vm);
......
...@@ -3362,6 +3362,7 @@ int qemuMonitorScreendump(qemuMonitorPtr mon, ...@@ -3362,6 +3362,7 @@ int qemuMonitorScreendump(qemuMonitorPtr mon,
int qemuMonitorBlockJob(qemuMonitorPtr mon, int qemuMonitorBlockJob(qemuMonitorPtr mon,
const char *device, const char *device,
const char *base, const char *base,
const char *backingName,
unsigned long bandwidth, unsigned long bandwidth,
virDomainBlockJobInfoPtr info, virDomainBlockJobInfoPtr info,
qemuMonitorBlockJobCmd mode, qemuMonitorBlockJobCmd mode,
...@@ -3370,9 +3371,10 @@ int qemuMonitorBlockJob(qemuMonitorPtr mon, ...@@ -3370,9 +3371,10 @@ int qemuMonitorBlockJob(qemuMonitorPtr mon,
int ret = -1; int ret = -1;
unsigned long long speed; unsigned long long speed;
VIR_DEBUG("mon=%p, device=%s, base=%s, bandwidth=%luM, info=%p, mode=%o, " VIR_DEBUG("mon=%p, device=%s, base=%s, backingName=%s, bandwidth=%luM, "
"modern=%d", mon, device, NULLSTR(base), bandwidth, info, mode, "info=%p, mode=%o, modern=%d",
modern); mon, device, NULLSTR(base), NULLSTR(backingName),
bandwidth, info, mode, modern);
/* Convert bandwidth MiB to bytes - unfortunately the JSON QMP protocol is /* Convert bandwidth MiB to bytes - unfortunately the JSON QMP protocol is
* limited to LLONG_MAX also for unsigned values */ * limited to LLONG_MAX also for unsigned values */
...@@ -3386,8 +3388,8 @@ int qemuMonitorBlockJob(qemuMonitorPtr mon, ...@@ -3386,8 +3388,8 @@ int qemuMonitorBlockJob(qemuMonitorPtr mon,
speed <<= 20; speed <<= 20;
if (mon->json) if (mon->json)
ret = qemuMonitorJSONBlockJob(mon, device, base, speed, info, mode, ret = qemuMonitorJSONBlockJob(mon, device, base, backingName,
modern); speed, info, mode, modern);
else else
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("block jobs require JSON monitor")); _("block jobs require JSON monitor"));
......
...@@ -692,7 +692,8 @@ typedef enum { ...@@ -692,7 +692,8 @@ typedef enum {
int qemuMonitorBlockJob(qemuMonitorPtr mon, int qemuMonitorBlockJob(qemuMonitorPtr mon,
const char *device, const char *device,
const char *back, const char *base,
const char *backingName,
unsigned long bandwidth, unsigned long bandwidth,
virDomainBlockJobInfoPtr info, virDomainBlockJobInfoPtr info,
qemuMonitorBlockJobCmd mode, qemuMonitorBlockJobCmd mode,
......
...@@ -3789,6 +3789,7 @@ int ...@@ -3789,6 +3789,7 @@ int
qemuMonitorJSONBlockJob(qemuMonitorPtr mon, qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
const char *device, const char *device,
const char *base, const char *base,
const char *backingName,
unsigned long long speed, unsigned long long speed,
virDomainBlockJobInfoPtr info, virDomainBlockJobInfoPtr info,
qemuMonitorBlockJobCmd mode, qemuMonitorBlockJobCmd mode,
...@@ -3804,6 +3805,19 @@ qemuMonitorJSONBlockJob(qemuMonitorPtr mon, ...@@ -3804,6 +3805,19 @@ qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
_("only modern block pull supports base: %s"), base); _("only modern block pull supports base: %s"), base);
return -1; 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) { if (speed && mode == BLOCK_JOB_PULL && !modern) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("only modern block pull supports speed: %llu"), _("only modern block pull supports speed: %llu"),
...@@ -3838,6 +3852,7 @@ qemuMonitorJSONBlockJob(qemuMonitorPtr mon, ...@@ -3838,6 +3852,7 @@ qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
"s:device", device, "s:device", device,
"P:speed", speed, "P:speed", speed,
"S:base", base, "S:base", base,
"S:backing-file", backingName,
NULL); NULL);
break; break;
} }
......
...@@ -283,6 +283,7 @@ int qemuMonitorJSONScreendump(qemuMonitorPtr mon, ...@@ -283,6 +283,7 @@ int qemuMonitorJSONScreendump(qemuMonitorPtr mon,
int qemuMonitorJSONBlockJob(qemuMonitorPtr mon, int qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
const char *device, const char *device,
const char *base, const char *base,
const char *backingName,
unsigned long long speed, unsigned long long speed,
virDomainBlockJobInfoPtr info, virDomainBlockJobInfoPtr info,
qemuMonitorBlockJobCmd mode, qemuMonitorBlockJobCmd mode,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册