diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index fd79390a7a..fb766d0776 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6127,3 +6127,23 @@ qemuDomainVcpuPersistOrder(virDomainDefPtr def) } } } + + +int +qemuDomainCheckMonitor(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivatePtr priv = vm->privateData; + int ret; + + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; + + ret = qemuMonitorCheck(priv->mon); + + if (qemuDomainObjExitMonitor(driver, vm) < 0) + return -1; + + return ret; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 13c03729f3..a1404d0378 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -728,4 +728,8 @@ bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def) void qemuDomainVcpuPersistOrder(virDomainDefPtr def) ATTRIBUTE_NONNULL(1); +int qemuDomainCheckMonitor(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob); + #endif /* __QEMU_DOMAIN_H__ */ diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 07f18db635..e734816c4e 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -6208,14 +6208,10 @@ qemuMigrationFinish(virQEMUDriverPtr driver, } if (retcode != 0) { - qemuDomainJobInfo info; - /* Check for a possible error on the monitor in case Finish was called * earlier than monitor EOF handler got a chance to process the error */ - qemuMigrationFetchJobStatus(driver, vm, - QEMU_ASYNC_JOB_MIGRATION_IN, - &info); + qemuDomainCheckMonitor(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN); goto endjob; } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 4171914a07..1fdee3a6f4 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1616,6 +1616,14 @@ qemuMonitorStopCPUs(qemuMonitorPtr mon) } +int +qemuMonitorCheck(qemuMonitorPtr mon) +{ + bool running; + return qemuMonitorGetStatus(mon, &running, NULL); +} + + int qemuMonitorGetStatus(qemuMonitorPtr mon, bool *running, diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index b838725d7e..255fff2eae 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -382,6 +382,7 @@ typedef enum { VIR_ENUM_DECL(qemuMonitorVMStatus) int qemuMonitorVMStatusToPausedReason(const char *status); +int qemuMonitorCheck(qemuMonitorPtr mon); int qemuMonitorGetStatus(qemuMonitorPtr mon, bool *running, virDomainPausedReason *reason)