The shutdown handler may restart a domain when handling a reboot
event or when <on_*> is set to 'restart'. Restarting consists of
calling libxlVmCleanup followed by libxlVmStart. libxlVmStart will
emit a VIR_DOMAIN_EVENT_STARTED event, but the SHUTDOWN event is
not emitted until exiting the shutdown handler, after the STARTED
event. Queue the event immediately after creation to avoid emitting
it after the start event.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_driver.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 721577d..e600de7 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -376,6 +376,8 @@ libxlDomainShutdownThread(void *opaque)
dom_event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
+ if (dom_event)
+ libxlDomainEventQueue(driver, dom_event);
switch (vm->def->onPoweroff) {
case VIR_DOMAIN_LIFECYCLE_DESTROY:
reason = VIR_DOMAIN_SHUTOFF_SHUTDOWN;
@@ -390,6 +392,8 @@ libxlDomainShutdownThread(void *opaque)
dom_event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_CRASHED);
+ if (dom_event)
+ libxlDomainEventQueue(driver, dom_event);
switch (vm->def->onCrash) {
case VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY:
reason = VIR_DOMAIN_SHUTOFF_CRASHED;
@@ -404,6 +408,8 @@ libxlDomainShutdownThread(void *opaque)
dom_event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
+ if (dom_event)
+ libxlDomainEventQueue(driver, dom_event);
switch (vm->def->onReboot) {
case VIR_DOMAIN_LIFECYCLE_DESTROY:
reason = VIR_DOMAIN_SHUTOFF_SHUTDOWN;
@@ -437,8 +443,6 @@ restart:
cleanup:
if (vm)
virObjectUnlock(vm);
- if (dom_event)
- libxlDomainEventQueue(driver, dom_event);
libxl_event_free(ctx, ev);
VIR_FREE(shutdown_info);
}
--
1.8.1.4