Instead of unlocking and locking the domain object every 50ms
lets just wait on blockJob condition and run the loop body if and
BLOCK_JOB even occurred.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_migration.c | 15 +++++----------
src/qemu/qemu_process.c | 4 ++++
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 14a4ec6..998e8f5 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1768,9 +1768,6 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
/* wait for completion */
while (true) {
- /* Poll every 500ms for progress & to allow cancellation */
- struct timespec ts = { .tv_sec = 0, .tv_nsec = 500 * 1000 * 1000ull };
-
/* Explicitly check if domain is still alive. Maybe qemu
* died meanwhile so we won't see any event at all. */
if (!virDomainObjIsActive(vm)) {
@@ -1800,13 +1797,11 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
goto error;
}
- /* XXX Turn this into virCond someday. */
-
- virObjectUnlock(vm);
-
- nanosleep(&ts, NULL);
-
- virObjectLock(vm);
+ if (virCondWait(&priv->blockJob, &vm->parent.lock) < 0) {
+ virReportSystemError(errno, "%s",
+ _("Unable to wait on blockJob
condition"));
+ goto error;
+ }
}
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 9cfc0f3..7b87cdb 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1017,6 +1017,7 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
void *opaque)
{
virQEMUDriverPtr driver = opaque;
+ qemuDomainObjPrivatePtr priv;
virObjectEventPtr event = NULL;
virObjectEventPtr event2 = NULL;
const char *path;
@@ -1026,6 +1027,7 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
bool save = false;
virObjectLock(vm);
+ priv = vm->privateData;
disk = qemuProcessFindDomainDiskByAlias(vm, diskAlias);
if (disk) {
@@ -1112,6 +1114,8 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
case VIR_DOMAIN_BLOCK_JOB_LAST:
break;
}
+
+ virCondSignal(&priv->blockJob);
}
if (save) {
--
2.0.5