mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
block rebase: initial qemu implementation
This is a trivial implementation, which works with the current released qemu 1.0 with backports of preliminary block pull but no partial rebase. Future patches will update the monitor handling to support an optional parameter for partial rebase; but as qemu 1.1 is unreleased, it can be in later patches, designed to be backported on top of the supported API. * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Add parameter, and adjust callers. Drop redundant check. (qemuDomainBlockPull): Move guts... (qemuDomainBlockRebase): ...to new function.
This commit is contained in:
parent
8ee8fd6555
commit
9f902a2ed5
@ -11296,7 +11296,7 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainBlockJobImpl(virDomainPtr dom, const char *path,
|
qemuDomainBlockJobImpl(virDomainPtr dom, const char *path, const char *base,
|
||||||
unsigned long bandwidth, virDomainBlockJobInfoPtr info,
|
unsigned long bandwidth, virDomainBlockJobInfoPtr info,
|
||||||
int mode)
|
int mode)
|
||||||
{
|
{
|
||||||
@ -11316,16 +11316,18 @@ qemuDomainBlockJobImpl(virDomainPtr dom, const char *path,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
|
||||||
qemuReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
"%s", _("domain is not running"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
device = qemuDiskPathToAlias(vm, path);
|
device = qemuDiskPathToAlias(vm, path);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
/* XXX - add a qemu capability check; if qemu 1.1 or newer, then
|
||||||
|
* validate and convert non-NULL base into something that can
|
||||||
|
* be passed as optional base argument. */
|
||||||
|
if (base) {
|
||||||
|
qemuReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
||||||
|
_("partial block pull is not supported with this QEMU binary"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
|
if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -11359,7 +11361,7 @@ static int
|
|||||||
qemuDomainBlockJobAbort(virDomainPtr dom, const char *path, unsigned int flags)
|
qemuDomainBlockJobAbort(virDomainPtr dom, const char *path, unsigned int flags)
|
||||||
{
|
{
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
return qemuDomainBlockJobImpl(dom, path, 0, NULL, BLOCK_JOB_ABORT);
|
return qemuDomainBlockJobImpl(dom, path, NULL, 0, NULL, BLOCK_JOB_ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -11367,7 +11369,7 @@ qemuDomainGetBlockJobInfo(virDomainPtr dom, const char *path,
|
|||||||
virDomainBlockJobInfoPtr info, unsigned int flags)
|
virDomainBlockJobInfoPtr info, unsigned int flags)
|
||||||
{
|
{
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
return qemuDomainBlockJobImpl(dom, path, 0, info, BLOCK_JOB_INFO);
|
return qemuDomainBlockJobImpl(dom, path, NULL, 0, info, BLOCK_JOB_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -11375,21 +11377,30 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom, const char *path,
|
|||||||
unsigned long bandwidth, unsigned int flags)
|
unsigned long bandwidth, unsigned int flags)
|
||||||
{
|
{
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
return qemuDomainBlockJobImpl(dom, path, bandwidth, NULL, BLOCK_JOB_SPEED);
|
return qemuDomainBlockJobImpl(dom, path, NULL, bandwidth, NULL,
|
||||||
|
BLOCK_JOB_SPEED);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainBlockRebase(virDomainPtr dom, const char *path, const char *base,
|
||||||
|
unsigned long bandwidth, unsigned int flags)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
ret = qemuDomainBlockJobImpl(dom, path, base, bandwidth, NULL,
|
||||||
|
BLOCK_JOB_PULL);
|
||||||
|
if (ret == 0 && bandwidth != 0)
|
||||||
|
ret = qemuDomainBlockJobImpl(dom, path, NULL, bandwidth, NULL,
|
||||||
|
BLOCK_JOB_SPEED);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainBlockPull(virDomainPtr dom, const char *path, unsigned long bandwidth,
|
qemuDomainBlockPull(virDomainPtr dom, const char *path, unsigned long bandwidth,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
int ret;
|
return qemuDomainBlockRebase(dom, path, NULL, bandwidth, flags);
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
|
||||||
ret = qemuDomainBlockJobImpl(dom, path, bandwidth, NULL, BLOCK_JOB_PULL);
|
|
||||||
if (ret == 0 && bandwidth != 0)
|
|
||||||
ret = qemuDomainBlockJobImpl(dom, path, bandwidth, NULL,
|
|
||||||
BLOCK_JOB_SPEED);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -12130,6 +12141,7 @@ static virDriver qemuDriver = {
|
|||||||
.domainGetBlockJobInfo = qemuDomainGetBlockJobInfo, /* 0.9.4 */
|
.domainGetBlockJobInfo = qemuDomainGetBlockJobInfo, /* 0.9.4 */
|
||||||
.domainBlockJobSetSpeed = qemuDomainBlockJobSetSpeed, /* 0.9.4 */
|
.domainBlockJobSetSpeed = qemuDomainBlockJobSetSpeed, /* 0.9.4 */
|
||||||
.domainBlockPull = qemuDomainBlockPull, /* 0.9.4 */
|
.domainBlockPull = qemuDomainBlockPull, /* 0.9.4 */
|
||||||
|
.domainBlockRebase = qemuDomainBlockRebase, /* 0.9.10 */
|
||||||
.isAlive = qemuIsAlive, /* 0.9.8 */
|
.isAlive = qemuIsAlive, /* 0.9.8 */
|
||||||
.nodeSuspendForDuration = nodeSuspendForDuration, /* 0.9.8 */
|
.nodeSuspendForDuration = nodeSuspendForDuration, /* 0.9.8 */
|
||||||
.domainSetBlockIoTune = qemuDomainSetBlockIoTune, /* 0.9.8 */
|
.domainSetBlockIoTune = qemuDomainSetBlockIoTune, /* 0.9.8 */
|
||||||
|
Loading…
Reference in New Issue
Block a user