On Tue, May 24, 2011 at 18:06:42 +0100, Daniel P. Berrange wrote:
Currently whenever there is any failure with parsing the monitor,
this is treated in the same was as end-of-file (ie QEMU quit).
The domain is terminated, if not already dead.
With this change, failures in parsing the monitor stream do not
result in the death of QEMU. The guest continues running unchanged,
but all further use of the monitor will be disabled.
The VMM_FAILURE event will be emitted, and the mgmt application
can decide when to kill/restart the guest to re-gain control
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Run a
different callback for monitor EOF vs error conditions.
* src/qemu/qemu_process.c: Emit VMM_FAILURE event when monitor
fails
---
src/qemu/qemu_monitor.c | 45 +++++++++++++++++++++++++----------------
src/qemu/qemu_monitor.h | 7 +++--
src/qemu/qemu_process.c | 50 ++++++++++++++++++++++++++++++++++------------
3 files changed, 68 insertions(+), 34 deletions(-)
...
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 01b15e0..4eca63b 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -100,12 +100,13 @@ extern struct qemud_driver *qemu_driver;
*/
static void
qemuProcessHandleMonitorEOF(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
- virDomainObjPtr vm,
- int hasError)
+ virDomainObjPtr vm)
{
struct qemud_driver *driver = qemu_driver;
virDomainEventPtr event = NULL;
qemuDomainObjPrivatePtr priv;
+ int eventReason = VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN;
+ const char *auditReason = "shutdown";
VIR_DEBUG("Received EOF on %p '%s'", vm, vm->def->name);
@@ -120,32 +121,54 @@ qemuProcessHandleMonitorEOF(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
}
priv = vm->privateData;
- if (!hasError && priv->monJSON && !priv->gotShutdown) {
+ if (priv->monJSON && !priv->gotShutdown) {
VIR_DEBUG("Monitor connection to '%s' closed without SHUTDOWN
event; "
"assuming the domain crashed", vm->def->name);
- hasError = 1;
+ eventReason = VIR_DOMAIN_EVENT_STOPPED_FAILED;
+ auditReason = "failed";
}
event = virDomainEventNewFromObj(vm,
- VIR_DOMAIN_EVENT_STOPPED,
- hasError ?
- VIR_DOMAIN_EVENT_STOPPED_FAILED :
- VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
+ VIR_DOMAIN_EVENT_STOPPED, eventReason);
qemuProcessStop(driver, vm, 0,
- hasError ?
- VIR_DOMAIN_SHUTOFF_CRASHED :
VIR_DOMAIN_SHUTOFF_SHUTDOWN);
I don't think this change is correct. Wee need to correct reason to be passed
to qemuProcessStop so that virDomainGetState can report it. This way we would
always report normal shutdown.
Jirka