Include a pointer to the libxl driver in libxlDomainObjPrivate
object so it can be used in the domain event handler and
shutdown thread.

Signed-off-by: Jim Fehlig <jfeh...@suse.com>
---
 src/libxl/libxl_domain.c | 5 +++--
 src/libxl/libxl_domain.h | 4 +++-
 src/libxl/libxl_driver.c | 4 ++--
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index c5b18a1..606469e 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -736,10 +736,11 @@ libxlDomainCleanupJob(libxlDriverPrivatePtr driver,
  * Register for domain events emitted by libxl.
  */
 int
-libxlDomainEventsRegister(virDomainObjPtr vm)
+libxlDomainEventsRegister(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
 {
     libxlDomainObjPrivatePtr priv = vm->privateData;
 
+    priv->driver = driver;
     libxl_event_register_callbacks(priv->ctx, &ev_hooks, vm);
 
     /* Always enable domain death events */
@@ -1017,7 +1018,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, 
virDomainObjPtr vm,
      * be cleaned up if there are any subsequent failures.
      */
     vm->def->id = domid;
-    if (libxlDomainEventsRegister(vm) < 0)
+    if (libxlDomainEventsRegister(driver, vm) < 0)
         goto cleanup_dom;
 
     if ((dom_xml = virDomainDefFormat(vm->def, 0)) == NULL)
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index 4b5767a..979ce2a 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -68,6 +68,7 @@ struct _libxlDomainObjPrivate {
     /* console */
     virChrdevsPtr devs;
     libxl_evgen_domain_death *deathW;
+    libxlDriverPrivatePtr driver;
 
     struct libxlDomainJobObj job;
 };
@@ -117,7 +118,8 @@ libxlDomainCleanupJob(libxlDriverPrivatePtr driver,
                       virDomainObjPtr vm,
                       virDomainShutoffReason reason);
 int
-libxlDomainEventsRegister(virDomainObjPtr vm);
+libxlDomainEventsRegister(libxlDriverPrivatePtr driver,
+                          virDomainObjPtr vm);
 
 int
 libxlDomainAutoCoreDump(libxlDriverPrivatePtr driver,
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index af7317b..8a34821 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -148,11 +148,11 @@ struct libxlShutdownThreadInfo
 static void
 libxlDomainShutdownThread(void *opaque)
 {
-    libxlDriverPrivatePtr driver = libxl_driver;
     struct libxlShutdownThreadInfo *shutdown_info = opaque;
     virDomainObjPtr vm = shutdown_info->vm;
     libxlDomainObjPrivatePtr priv = vm->privateData;
     libxl_event *ev = shutdown_info->event;
+    libxlDriverPrivatePtr driver = priv->driver;
     libxl_ctx *ctx = priv->ctx;
     virObjectEventPtr dom_event = NULL;
     libxl_shutdown_reason xl_reason = ev->u.domain_shutdown.shutdown_reason;
@@ -353,7 +353,7 @@ libxlReconnectDomain(virDomainObjPtr vm,
         driver->inhibitCallback(true, driver->inhibitOpaque);
 
     /* Re-register domain death et. al. events */
-    libxlDomainEventsRegister(vm);
+    libxlDomainEventsRegister(driver, vm);
     virObjectUnlock(vm);
     return 0;
 
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to