|
|
9119d9 |
From 1b93c4b30e7b0b7df7a61cf6a759a4b0ccccca20 Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <1b93c4b30e7b0b7df7a61cf6a759a4b0ccccca20@dist-git>
|
|
|
9119d9 |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
|
9119d9 |
Date: Mon, 19 Jan 2015 10:48:27 +0100
|
|
|
9119d9 |
Subject: [PATCH] Check for domain liveness in qemuDomainObjExitMonitor
|
|
|
9119d9 |
MIME-Version: 1.0
|
|
|
9119d9 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9119d9 |
Content-Transfer-Encoding: 8bit
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1161024
|
|
|
9119d9 |
|
|
|
9119d9 |
The domain might disappear during the time in monitor when
|
|
|
9119d9 |
the virDomainObjPtr is unlocked, so the caller needs to check
|
|
|
9119d9 |
if it's still alive.
|
|
|
9119d9 |
|
|
|
9119d9 |
Since most of the callers are going to need it, put the
|
|
|
9119d9 |
check inside qemuDomainObjExitMonitor and return -1 if
|
|
|
9119d9 |
the domain died in the meantime.
|
|
|
9119d9 |
|
|
|
9119d9 |
(cherry picked from commit dc2fd51fd727bbb6de172e0ca4b7dd307bb99180)
|
|
|
9119d9 |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/qemu/THREADS.txt | 5 +++++
|
|
|
9119d9 |
src/qemu/qemu_domain.c | 16 ++++++++++++++--
|
|
|
9119d9 |
src/qemu/qemu_domain.h | 4 ++--
|
|
|
9119d9 |
3 files changed, 21 insertions(+), 4 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/THREADS.txt b/src/qemu/THREADS.txt
|
|
|
9119d9 |
index 50a0cf9..b081bdb 100644
|
|
|
9119d9 |
--- a/src/qemu/THREADS.txt
|
|
|
9119d9 |
+++ b/src/qemu/THREADS.txt
|
|
|
9119d9 |
@@ -156,6 +156,11 @@ To acquire the QEMU monitor lock
|
|
|
9119d9 |
- Acquires the virDomainObjPtr lock
|
|
|
9119d9 |
|
|
|
9119d9 |
These functions must not be used by an asynchronous job.
|
|
|
9119d9 |
+ Note that the virDomainObj is unlocked during the time in
|
|
|
9119d9 |
+ monitor and it can be changed, e.g. if QEMU dies, qemuProcessStop
|
|
|
9119d9 |
+ may free the live domain definition and put the persistent
|
|
|
9119d9 |
+ definition back in vm->def. The callers should check the return
|
|
|
9119d9 |
+ value of ExitMonitor to see if the domain is still alive.
|
|
|
9119d9 |
|
|
|
9119d9 |
|
|
|
9119d9 |
To acquire the QEMU monitor lock as part of an asynchronous job
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
9119d9 |
index 03ca663..0c3d21f 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_domain.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_domain.c
|
|
|
9119d9 |
@@ -1609,11 +1609,23 @@ void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver,
|
|
|
9119d9 |
/* obj must NOT be locked before calling
|
|
|
9119d9 |
*
|
|
|
9119d9 |
* Should be paired with an earlier qemuDomainObjEnterMonitor() call
|
|
|
9119d9 |
+ *
|
|
|
9119d9 |
+ * Returns -1 if the domain is no longer alive after exiting the monitor.
|
|
|
9119d9 |
+ * In that case, the caller should be careful when using obj's data,
|
|
|
9119d9 |
+ * e.g. the live definition in vm->def has been freed by qemuProcessStop
|
|
|
9119d9 |
+ * and replaced by the persistent definition, so pointers stolen
|
|
|
9119d9 |
+ * from the live definition could no longer be valid.
|
|
|
9119d9 |
*/
|
|
|
9119d9 |
-void qemuDomainObjExitMonitor(virQEMUDriverPtr driver,
|
|
|
9119d9 |
- virDomainObjPtr obj)
|
|
|
9119d9 |
+int qemuDomainObjExitMonitor(virQEMUDriverPtr driver,
|
|
|
9119d9 |
+ virDomainObjPtr obj)
|
|
|
9119d9 |
{
|
|
|
9119d9 |
qemuDomainObjExitMonitorInternal(driver, obj);
|
|
|
9119d9 |
+ if (!virDomainObjIsActive(obj)) {
|
|
|
9119d9 |
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
|
|
9119d9 |
+ _("domain is no longer running"));
|
|
|
9119d9 |
+ return -1;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
+ return 0;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
/*
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
|
|
|
9119d9 |
index 53501f9..bf37e26 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_domain.h
|
|
|
9119d9 |
+++ b/src/qemu/qemu_domain.h
|
|
|
9119d9 |
@@ -248,8 +248,8 @@ void qemuDomainObjReleaseAsyncJob(virDomainObjPtr obj);
|
|
|
9119d9 |
void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver,
|
|
|
9119d9 |
virDomainObjPtr obj)
|
|
|
9119d9 |
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
9119d9 |
-void qemuDomainObjExitMonitor(virQEMUDriverPtr driver,
|
|
|
9119d9 |
- virDomainObjPtr obj)
|
|
|
9119d9 |
+int qemuDomainObjExitMonitor(virQEMUDriverPtr driver,
|
|
|
9119d9 |
+ virDomainObjPtr obj)
|
|
|
9119d9 |
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
9119d9 |
int qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver,
|
|
|
9119d9 |
virDomainObjPtr obj,
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.2.1
|
|
|
9119d9 |
|