]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libxl: queue domain event earlier in shutdown handler
authorJim Fehlig <jfehlig@suse.com>
Wed, 19 Feb 2014 22:39:19 +0000 (15:39 -0700)
committerJim Fehlig <jfehlig@suse.com>
Tue, 25 Feb 2014 17:54:04 +0000 (10:54 -0700)
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.

This patch changes the logic a bit to queue the event at the start
of the shutdown action, ensuring it is queued before any subsequent
events that may be generated while executing the shutdown action.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
src/libxl/libxl_driver.c

index f7379b554c7403f37ee873223ab5be88df7fdfa4..a79efcb807d9ee3be013cdfb67e162c088ff975b 100644 (file)
@@ -473,6 +473,10 @@ libxlDomainShutdownThread(void *opaque)
     }
 
 destroy:
+    if (dom_event) {
+        libxlDomainEventQueue(driver, dom_event);
+        dom_event = NULL;
+    }
     libxl_domain_destroy(ctx, vm->def->id, NULL);
     if (libxlVmCleanupJob(driver, vm, reason)) {
         if (!vm->persistent) {
@@ -483,6 +487,10 @@ destroy:
     goto cleanup;
 
 restart:
+    if (dom_event) {
+        libxlDomainEventQueue(driver, dom_event);
+        dom_event = NULL;
+    }
     libxl_domain_destroy(ctx, vm->def->id, NULL);
     libxlVmCleanupJob(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
     libxlVmStart(driver, vm, 0, -1);