The domain might disappear during the time in monitor when the virDomainObjPtr is unlocked, so the caller needs to check if it's still alive. Introduce a helper function for the callers that want to report an error in this case. --- src/qemu/qemu_domain.c | 17 +++++++++++++++++ src/qemu/qemu_domain.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8dd427a..d074429 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1606,6 +1606,23 @@ void qemuDomainObjExitMonitor(virQEMUDriverPtr driver, qemuDomainObjExitMonitorInternal(driver, obj); } +/* obj must NOT be locked before calling + * + * Same as qemuDomainObjExitMonitor, but reports an error and + * returns -1 if the domain is no longer alive after exiting the monitor + */ +int qemuDomainObjExitMonitorAlive(virQEMUDriverPtr driver, + virDomainObjPtr obj) +{ + qemuDomainObjExitMonitorInternal(driver, obj); + if (!virDomainObjIsActive(obj)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("domain is no longer running")); + return -1; + } + return 0; +} + /* * obj must be locked before calling * diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index ce5eba3..b8fec34 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -250,6 +250,9 @@ void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver, void qemuDomainObjExitMonitor(virQEMUDriverPtr driver, virDomainObjPtr obj) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); +int qemuDomainObjExitMonitorAlive(virQEMUDriverPtr driver, + virDomainObjPtr obj) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver, virDomainObjPtr obj, qemuDomainAsyncJob asyncJob) -- 2.0.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list