[PATCH 05/13] libxl: move libxlDomEventsRegister to libxl_domain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move libxlDomEventsRegister from libxl_driver to libxl_domain for
use by other libxl modules.  For consistency, rename to
libxlDomainEventsRegister.

Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
---
 src/libxl/libxl_domain.c | 24 ++++++++++++++++++++++++
 src/libxl/libxl_domain.h |  4 +++-
 src/libxl/libxl_driver.c | 30 +++---------------------------
 3 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index f123b89..5ffa9dd 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -718,3 +718,27 @@ libxlDomainCleanupJob(libxlDriverPrivatePtr driver,
 
     return libxlDomainObjEndJob(driver, vm);
 }
+
+/*
+ * Register for domain events emitted by libxl.
+ */
+int
+libxlDomainEventsRegister(virDomainObjPtr vm)
+{
+    libxlDomainObjPrivatePtr priv = vm->privateData;
+
+    libxl_event_register_callbacks(priv->ctx, &ev_hooks, vm);
+
+    /* Always enable domain death events */
+    if (libxl_evenable_domain_death(priv->ctx, vm->def->id, 0, &priv->deathW))
+        goto error;
+
+    return 0;
+
+error:
+    if (priv->deathW) {
+        libxl_evdisable_domain_death(priv->ctx, priv->deathW);
+        priv->deathW = NULL;
+    }
+    return -1;
+}
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index 949e1c2..1ac9174 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -75,7 +75,7 @@ struct _libxlDomainObjPrivate {
 
 extern virDomainXMLPrivateDataCallbacks libxlDomainXMLPrivateDataCallbacks;
 extern virDomainDefParserConfig libxlDomainDefParserConfig;
-
+extern const struct libxl_event_hooks ev_hooks;
 
 int
 libxlDomainObjPrivateInitCtx(virDomainObjPtr vm);
@@ -116,5 +116,7 @@ bool
 libxlDomainCleanupJob(libxlDriverPrivatePtr driver,
                       virDomainObjPtr vm,
                       virDomainShutoffReason reason);
+int
+libxlDomainEventsRegister(virDomainObjPtr vm);
 
 #endif /* LIBXL_DOMAIN_H */
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index dc91958..7451726 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -379,36 +379,12 @@ error:
     libxl_event_free(priv->ctx, (libxl_event *)event);
 }
 
-static const struct libxl_event_hooks ev_hooks = {
+const struct libxl_event_hooks ev_hooks = {
     .event_occurs_mask = LIBXL_EVENTMASK_ALL,
     .event_occurs = libxlEventHandler,
     .disaster = NULL,
 };
 
-/*
- * Register for domain events emitted by libxl.
- */
-static int
-libxlDomEventsRegister(virDomainObjPtr vm)
-{
-    libxlDomainObjPrivatePtr priv = vm->privateData;
-
-    libxl_event_register_callbacks(priv->ctx, &ev_hooks, vm);
-
-    /* Always enable domain death events */
-    if (libxl_evenable_domain_death(priv->ctx, vm->def->id, 0, &priv->deathW))
-        goto error;
-
-    return 0;
-
-error:
-    if (priv->deathW) {
-        libxl_evdisable_domain_death(priv->ctx, priv->deathW);
-        priv->deathW = NULL;
-    }
-    return -1;
-}
-
 static int
 libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
 {
@@ -621,7 +597,7 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
      * be cleaned up if there are any subsequent failures.
      */
     vm->def->id = domid;
-    if (libxlDomEventsRegister(vm) < 0)
+    if (libxlDomainEventsRegister(vm) < 0)
         goto cleanup_dom;
 
     if ((dom_xml = virDomainDefFormat(vm->def, 0)) == NULL)
@@ -722,7 +698,7 @@ libxlReconnectDomain(virDomainObjPtr vm,
         driver->inhibitCallback(true, driver->inhibitOpaque);
 
     /* Re-register domain death et. al. events */
-    libxlDomEventsRegister(vm);
+    libxlDomainEventsRegister(vm);
     virObjectUnlock(vm);
     return 0;
 
-- 
1.8.1.4

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]