1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-26 03:21:44 +03:00

qemu: take current async job into account in qemuBlockNodeNamesDetect

Becase it can be called during migration out (namely on cancelling
blockjobs).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Nikolay Shirokovskiy 2017-04-07 14:06:24 +03:00 committed by Jiri Denemark
parent 135c56e2b8
commit dd8e40790b
7 changed files with 40 additions and 24 deletions

View File

@ -336,7 +336,8 @@ qemuBlockDiskDetectNodes(virDomainDiskDefPtr disk,
int
qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
virDomainObjPtr vm)
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virHashTablePtr disktable = NULL;
@ -350,7 +351,8 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_NAMED_BLOCK_NODES))
return 0;
qemuDomainObjEnterMonitor(driver, vm);
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
return -1;
disktable = qemuMonitorGetBlockInfo(qemuDomainGetMonitor(vm));
data = qemuMonitorQueryNamedBlockNodes(qemuDomainGetMonitor(vm));

View File

@ -22,6 +22,7 @@
# include "internal.h"
# include "qemu_conf.h"
# include "qemu_domain.h"
# include "virhash.h"
# include "virjson.h"
@ -46,7 +47,8 @@ qemuBlockNodeNameGetBackingChain(virJSONValuePtr data);
int
qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
virDomainObjPtr vm);
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob);
virHashTablePtr
qemuBlockGetNodeData(virJSONValuePtr data);

View File

@ -55,13 +55,14 @@ VIR_LOG_INIT("qemu.qemu_blockjob");
int
qemuBlockJobUpdate(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
virDomainDiskDefPtr disk)
{
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
int status = diskPriv->blockJobStatus;
if (status != -1) {
qemuBlockJobEventProcess(driver, vm, disk,
qemuBlockJobEventProcess(driver, vm, disk, asyncJob,
diskPriv->blockJobType,
diskPriv->blockJobStatus);
diskPriv->blockJobStatus = -1;
@ -87,6 +88,7 @@ void
qemuBlockJobEventProcess(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainDiskDefPtr disk,
qemuDomainAsyncJob asyncJob,
int type,
int status)
{
@ -167,7 +169,7 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk,
true, true));
ignore_value(qemuBlockNodeNamesDetect(driver, vm));
ignore_value(qemuBlockNodeNamesDetect(driver, vm, asyncJob));
diskPriv->blockjob = false;
break;
@ -247,9 +249,10 @@ qemuBlockJobSyncBegin(virDomainDiskDefPtr disk)
void
qemuBlockJobSyncEnd(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
virDomainDiskDefPtr disk)
{
VIR_DEBUG("disk=%s", disk->dst);
qemuBlockJobUpdate(driver, vm, disk);
qemuBlockJobUpdate(driver, vm, asyncJob, disk);
QEMU_DOMAIN_DISK_PRIVATE(disk)->blockJobSync = false;
}

View File

@ -24,19 +24,23 @@
# include "internal.h"
# include "qemu_conf.h"
# include "qemu_domain.h"
int qemuBlockJobUpdate(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
virDomainDiskDefPtr disk);
void qemuBlockJobEventProcess(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainDiskDefPtr disk,
qemuDomainAsyncJob asyncJob,
int type,
int status);
void qemuBlockJobSyncBegin(virDomainDiskDefPtr disk);
void qemuBlockJobSyncEnd(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
virDomainDiskDefPtr disk);
#endif /* __QEMU_BLOCKJOB_H__ */

View File

@ -4513,7 +4513,7 @@ processBlockJobEvent(virQEMUDriverPtr driver,
}
if ((disk = qemuProcessFindDomainDiskByAlias(vm, diskAlias)))
qemuBlockJobEventProcess(driver, vm, disk, type, status);
qemuBlockJobEventProcess(driver, vm, disk, QEMU_ASYNC_JOB_NONE, type, status);
endjob:
qemuDomainObjEndJob(driver, vm);
@ -16239,24 +16239,25 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
* event to pull and let qemuBlockJobEventProcess() handle
* the rest as usual */
qemuBlockJobEventProcess(driver, vm, disk,
QEMU_ASYNC_JOB_NONE,
VIR_DOMAIN_BLOCK_JOB_TYPE_PULL,
VIR_DOMAIN_BLOCK_JOB_CANCELED);
} else {
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
qemuBlockJobUpdate(driver, vm, disk);
qemuBlockJobUpdate(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
while (diskPriv->blockjob) {
if (virDomainObjWait(vm) < 0) {
ret = -1;
goto endjob;
}
qemuBlockJobUpdate(driver, vm, disk);
qemuBlockJobUpdate(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
}
}
}
endjob:
if (disk)
qemuBlockJobSyncEnd(driver, vm, disk);
qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
qemuDomainObjEndJob(driver, vm);
cleanup:
@ -20404,7 +20405,7 @@ qemuDomainSetBlockThreshold(virDomainPtr dom,
goto endjob;
if (!src->nodebacking &&
qemuBlockNodeNamesDetect(driver, vm) < 0)
qemuBlockNodeNamesDetect(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
goto endjob;
if (!src->nodebacking) {

View File

@ -601,7 +601,8 @@ qemuMigrationStopNBDServer(virQEMUDriverPtr driver,
*/
static int
qemuMigrationDriveMirrorReady(virQEMUDriverPtr driver,
virDomainObjPtr vm)
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob)
{
size_t i;
size_t notReady = 0;
@ -614,7 +615,7 @@ qemuMigrationDriveMirrorReady(virQEMUDriverPtr driver,
if (!diskPriv->migrating)
continue;
status = qemuBlockJobUpdate(driver, vm, disk);
status = qemuBlockJobUpdate(driver, vm, asyncJob, disk);
if (status == VIR_DOMAIN_BLOCK_JOB_FAILED) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("migration of disk %s failed"),
@ -649,6 +650,7 @@ qemuMigrationDriveMirrorReady(virQEMUDriverPtr driver,
static int
qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
bool check)
{
size_t i;
@ -663,7 +665,7 @@ qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
if (!diskPriv->migrating)
continue;
status = qemuBlockJobUpdate(driver, vm, disk);
status = qemuBlockJobUpdate(driver, vm, asyncJob, disk);
switch (status) {
case VIR_DOMAIN_BLOCK_JOB_FAILED:
if (check) {
@ -675,7 +677,7 @@ qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
/* fallthrough */
case VIR_DOMAIN_BLOCK_JOB_CANCELED:
case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
qemuBlockJobSyncEnd(driver, vm, disk);
qemuBlockJobSyncEnd(driver, vm, asyncJob, disk);
diskPriv->migrating = false;
break;
@ -723,7 +725,7 @@ qemuMigrationCancelOneDriveMirror(virQEMUDriverPtr driver,
int status;
int rv;
status = qemuBlockJobUpdate(driver, vm, disk);
status = qemuBlockJobUpdate(driver, vm, asyncJob, disk);
switch (status) {
case VIR_DOMAIN_BLOCK_JOB_FAILED:
case VIR_DOMAIN_BLOCK_JOB_CANCELED:
@ -800,12 +802,13 @@ qemuMigrationCancelDriveMirror(virQEMUDriverPtr driver,
err = virSaveLastError();
failed = true;
}
qemuBlockJobSyncEnd(driver, vm, disk);
qemuBlockJobSyncEnd(driver, vm, asyncJob, disk);
diskPriv->migrating = false;
}
}
while ((rv = qemuMigrationDriveMirrorCancelled(driver, vm, check)) != 1) {
while ((rv = qemuMigrationDriveMirrorCancelled(driver, vm, asyncJob,
check)) != 1) {
if (check && !failed &&
dconn && virConnectIsAlive(dconn) <= 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
@ -931,7 +934,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
VIR_FREE(nbd_dest);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || mon_ret < 0) {
qemuBlockJobSyncEnd(driver, vm, disk);
qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, disk);
goto cleanup;
}
diskPriv->migrating = true;
@ -942,7 +945,8 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
}
}
while ((rv = qemuMigrationDriveMirrorReady(driver, vm)) != 1) {
while ((rv = qemuMigrationDriveMirrorReady(driver, vm,
QEMU_ASYNC_JOB_MIGRATION_OUT)) != 1) {
if (rv < 0)
goto cleanup;
@ -1487,7 +1491,7 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
goto error;
if (flags & QEMU_MIGRATION_COMPLETED_CHECK_STORAGE &&
qemuMigrationDriveMirrorReady(driver, vm) < 0)
qemuMigrationDriveMirrorReady(driver, vm, asyncJob) < 0)
goto error;
if (flags & QEMU_MIGRATION_COMPLETED_ABORT_ON_ERROR &&
@ -5573,7 +5577,7 @@ qemuMigrationCancel(virQEMUDriverPtr driver,
VIR_DEBUG("Drive mirror on disk %s is still running", disk->dst);
} else {
VIR_DEBUG("Drive mirror on disk %s is gone", disk->dst);
qemuBlockJobSyncEnd(driver, vm, disk);
qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
diskPriv->migrating = false;
}
}
@ -5595,7 +5599,7 @@ qemuMigrationCancel(virQEMUDriverPtr driver,
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
if (diskPriv->migrating) {
qemuBlockJobSyncEnd(driver, vm, disk);
qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
diskPriv->migrating = false;
}
}

View File

@ -3489,7 +3489,7 @@ qemuProcessReconnect(void *opaque)
if (qemuProcessRefreshDisks(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
goto error;
if (qemuBlockNodeNamesDetect(driver, obj) < 0)
if (qemuBlockNodeNamesDetect(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
goto error;
if (qemuRefreshVirtioChannelState(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)