qemuDomainBlockJobAbort: use sync block job helpers
The !modern code path needs to call qemuBlockJobEventProcess directly. the modern code path will call it via qemuBlockJobSyncWait. Signed-off-by: Michael Chapman <mike@very.puzzling.org>
This commit is contained in:
parent
1ec03c8772
commit
1e106fee57
@ -16663,7 +16663,7 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
|
|||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = dom->conn->privateData;
|
virQEMUDriverPtr driver = dom->conn->privateData;
|
||||||
char *device = NULL;
|
char *device = NULL;
|
||||||
virDomainDiskDefPtr disk;
|
virDomainDiskDefPtr disk = NULL;
|
||||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||||
bool save = false;
|
bool save = false;
|
||||||
int idx;
|
int idx;
|
||||||
@ -16698,14 +16698,6 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
disk = vm->def->disks[idx];
|
disk = vm->def->disks[idx];
|
||||||
|
|
||||||
if (modern && !async) {
|
|
||||||
/* prepare state for event delivery. Since qemuDomainBlockPivot is
|
|
||||||
* synchronous, but the event is delivered asynchronously we need to
|
|
||||||
* wait too */
|
|
||||||
disk->blockJobStatus = -1;
|
|
||||||
disk->blockJobSync = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_NONE &&
|
if (disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_NONE &&
|
||||||
disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_READY) {
|
disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_READY) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
@ -16714,11 +16706,14 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (modern && !async) {
|
||||||
|
/* prepare state for event delivery */
|
||||||
|
qemuBlockJobSyncBegin(disk);
|
||||||
|
}
|
||||||
|
|
||||||
if (pivot) {
|
if (pivot) {
|
||||||
if ((ret = qemuDomainBlockPivot(driver, vm, device, disk)) < 0) {
|
if ((ret = qemuDomainBlockPivot(driver, vm, device, disk)) < 0)
|
||||||
disk->blockJobSync = false;
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (disk->mirror) {
|
if (disk->mirror) {
|
||||||
disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_ABORT;
|
disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_ABORT;
|
||||||
@ -16758,36 +16753,25 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
|
|||||||
* blockcopy and active commit, so we can hardcode the
|
* blockcopy and active commit, so we can hardcode the
|
||||||
* event to pull and let qemuBlockJobEventProcess() handle
|
* event to pull and let qemuBlockJobEventProcess() handle
|
||||||
* the rest as usual */
|
* the rest as usual */
|
||||||
disk->blockJobType = VIR_DOMAIN_BLOCK_JOB_TYPE_PULL;
|
qemuBlockJobEventProcess(driver, vm, disk,
|
||||||
disk->blockJobStatus = VIR_DOMAIN_BLOCK_JOB_CANCELED;
|
VIR_DOMAIN_BLOCK_JOB_TYPE_PULL,
|
||||||
|
VIR_DOMAIN_BLOCK_JOB_CANCELED);
|
||||||
} else {
|
} else {
|
||||||
while (disk->blockJobStatus == -1 && disk->blockJobSync) {
|
virConnectDomainEventBlockJobStatus status = -1;
|
||||||
if (virCondWait(&disk->blockJobSyncCond, &vm->parent.lock) < 0) {
|
if (qemuBlockJobSyncWait(driver, vm, disk, &status) < 0) {
|
||||||
virReportSystemError(errno, "%s",
|
ret = -1;
|
||||||
_("Unable to wait on block job sync "
|
} else if (status == VIR_DOMAIN_BLOCK_JOB_FAILED) {
|
||||||
"condition"));
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
disk->blockJobSync = false;
|
_("failed to terminate block job on disk '%s'"),
|
||||||
goto endjob;
|
disk->dst);
|
||||||
}
|
ret = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuBlockJobEventProcess(driver, vm, disk,
|
|
||||||
disk->blockJobType,
|
|
||||||
disk->blockJobStatus);
|
|
||||||
|
|
||||||
/* adjust the return code if we've got an explicit failure */
|
|
||||||
if (disk->blockJobStatus == VIR_DOMAIN_BLOCK_JOB_FAILED) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
||||||
_("failed to terminate block job on disk '%s'"),
|
|
||||||
disk->dst);
|
|
||||||
ret = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
disk->blockJobSync = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
endjob:
|
endjob:
|
||||||
|
if (disk && disk->blockJobSync)
|
||||||
|
qemuBlockJobSyncEnd(driver, vm, disk, NULL);
|
||||||
qemuDomainObjEndJob(driver, vm);
|
qemuDomainObjEndJob(driver, vm);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user