提交 ea88cc76 编写于 作者: J Jim Fehlig

libxl: move libxlDomEventsRegister to libxl_domain

Move libxlDomEventsRegister from libxl_driver to libxl_domain for
use by other libxl modules.  For consistency, rename to
libxlDomainEventsRegister.
Signed-off-by: NJim Fehlig <jfehlig@suse.com>
上级 a0407e63
......@@ -732,3 +732,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;
}
......@@ -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 */
......@@ -386,36 +386,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)
{
......@@ -633,7 +609,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)
......@@ -741,7 +717,7 @@ libxlReconnectDomain(virDomainObjPtr vm,
driver->inhibitCallback(true, driver->inhibitOpaque);
/* Re-register domain death et. al. events */
libxlDomEventsRegister(vm);
libxlDomainEventsRegister(vm);
virObjectUnlock(vm);
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册