The rewrite is straightforward as LXC registers only the
'lxcProcessAutoDestroy' callback which by design doesn't need any
special handling (there's just one caller which can start the VM thus
implicitly there's only one possible registration for that function).
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/lxc/lxc_conf.c | 15 +++++++++++----
src/lxc/lxc_conf.h | 3 ---
src/lxc/lxc_driver.c | 8 ++------
src/lxc/lxc_process.c | 8 +++-----
4 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index fefe63bf20..146e43c5d5 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -184,12 +184,19 @@ virCaps *virLXCDriverGetCapabilities(virLXCDriver *driver,
virDomainXMLOption *
lxcDomainXMLConfInit(virLXCDriver *driver, const char *defsecmodel)
{
+ virDomainXMLOption *ret = NULL;
+
virLXCDriverDomainDefParserConfig.priv = driver;
virLXCDriverDomainDefParserConfig.defSecModel = defsecmodel;
- return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig,
- &virLXCDriverPrivateDataCallbacks,
- &virLXCDriverDomainXMLNamespace,
- NULL, NULL, NULL);
+
+ ret = virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig,
+ &virLXCDriverPrivateDataCallbacks,
+ &virLXCDriverDomainXMLNamespace,
+ NULL, NULL, NULL);
+
+ virDomainXMLOptionSetCloseCallbackAlloc(ret, virCloseCallbacksDomainAlloc);
+
+ return ret;
}
diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h
index 6b9004aa3c..c0967ac63b 100644
--- a/src/lxc/lxc_conf.h
+++ b/src/lxc/lxc_conf.h
@@ -93,9 +93,6 @@ struct _virLXCDriver {
/* Immutable pointer. self-locking APIs */
virSecurityManager *securityManager;
-
- /* Immutable pointer, self-locking APIs */
- virCloseCallbacks *closeCallbacks;
};
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virLXCDriverConfig, virObjectUnref);
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 5a16e7375e..f49964285b 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -161,7 +161,8 @@ static int lxcConnectClose(virConnectPtr conn)
{
virLXCDriver *driver = conn->privateData;
- virCloseCallbacksRun(driver->closeCallbacks, conn, driver->domains);
+ virCloseCallbacksDomainRunForConn(driver->domains, conn);
+
conn->privateData = NULL;
return 0;
}
@@ -1496,9 +1497,6 @@ static int lxcStateInitialize(bool privileged,
if (!(lxc_driver->xmlopt = lxcDomainXMLConfInit(lxc_driver, defsecmodel)))
goto cleanup;
- if (!(lxc_driver->closeCallbacks = virCloseCallbacksNew()))
- goto cleanup;
-
if (g_mkdir_with_parents(cfg->stateDir, 0777) < 0) {
virReportSystemError(errno,
_("Failed to mkdir %s"),
@@ -1586,8 +1584,6 @@ static int lxcStateCleanup(void)
virObjectUnref(lxc_driver->domains);
virObjectUnref(lxc_driver->domainEventState);
- virObjectUnref(lxc_driver->closeCallbacks);
-
virSysinfoDefFree(lxc_driver->hostsysinfo);
virObjectUnref(lxc_driver->hostdevMgr);
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 2a753ae1da..14fe60b074 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -188,7 +188,7 @@ static void virLXCProcessCleanup(virLXCDriver *driver,
/* Stop autodestroy in case guest is restarted */
if (flags & VIR_LXC_PROCESS_CLEANUP_AUTODESTROY) {
- virCloseCallbacksUnset(driver->closeCallbacks, vm, lxcProcessAutoDestroy);
+ virCloseCallbacksDomainRemove(vm, NULL, lxcProcessAutoDestroy);
}
if (priv->monitor) {
@@ -1504,10 +1504,8 @@ int virLXCProcessStart(virLXCDriver * driver,
goto cleanup;
}
- if (autoDestroyConn &&
- virCloseCallbacksSet(driver->closeCallbacks, vm,
- autoDestroyConn, lxcProcessAutoDestroy) < 0)
- goto cleanup;
+ if (autoDestroyConn)
+ virCloseCallbacksDomainAdd(vm, autoDestroyConn, lxcProcessAutoDestroy);
/* We don't need the temporary NIC names anymore, clear them */
virLXCProcessCleanInterfaces(vm->def);
--
2.38.1