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(a)suse.com>
---
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 39577ef..3608fbb 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -731,3 +731,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 3b3c878..ed1d6b2 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -382,36 +382,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)
{
@@ -629,7 +605,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)
@@ -737,7 +713,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