mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
lxc: Use new connection close callbacks API
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@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
cb195c19b7
commit
e74bb402e4
@ -184,12 +184,19 @@ virCaps *virLXCDriverGetCapabilities(virLXCDriver *driver,
|
|||||||
virDomainXMLOption *
|
virDomainXMLOption *
|
||||||
lxcDomainXMLConfInit(virLXCDriver *driver, const char *defsecmodel)
|
lxcDomainXMLConfInit(virLXCDriver *driver, const char *defsecmodel)
|
||||||
{
|
{
|
||||||
|
virDomainXMLOption *ret = NULL;
|
||||||
|
|
||||||
virLXCDriverDomainDefParserConfig.priv = driver;
|
virLXCDriverDomainDefParserConfig.priv = driver;
|
||||||
virLXCDriverDomainDefParserConfig.defSecModel = defsecmodel;
|
virLXCDriverDomainDefParserConfig.defSecModel = defsecmodel;
|
||||||
return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig,
|
|
||||||
&virLXCDriverPrivateDataCallbacks,
|
ret = virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig,
|
||||||
&virLXCDriverDomainXMLNamespace,
|
&virLXCDriverPrivateDataCallbacks,
|
||||||
NULL, NULL, NULL);
|
&virLXCDriverDomainXMLNamespace,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
|
virDomainXMLOptionSetCloseCallbackAlloc(ret, virCloseCallbacksDomainAlloc);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,9 +93,6 @@ struct _virLXCDriver {
|
|||||||
|
|
||||||
/* Immutable pointer. self-locking APIs */
|
/* Immutable pointer. self-locking APIs */
|
||||||
virSecurityManager *securityManager;
|
virSecurityManager *securityManager;
|
||||||
|
|
||||||
/* Immutable pointer, self-locking APIs */
|
|
||||||
virCloseCallbacks *closeCallbacks;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virLXCDriverConfig, virObjectUnref);
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virLXCDriverConfig, virObjectUnref);
|
||||||
|
@ -161,7 +161,8 @@ static int lxcConnectClose(virConnectPtr conn)
|
|||||||
{
|
{
|
||||||
virLXCDriver *driver = conn->privateData;
|
virLXCDriver *driver = conn->privateData;
|
||||||
|
|
||||||
virCloseCallbacksRun(driver->closeCallbacks, conn, driver->domains);
|
virCloseCallbacksDomainRunForConn(driver->domains, conn);
|
||||||
|
|
||||||
conn->privateData = NULL;
|
conn->privateData = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1496,9 +1497,6 @@ static int lxcStateInitialize(bool privileged,
|
|||||||
if (!(lxc_driver->xmlopt = lxcDomainXMLConfInit(lxc_driver, defsecmodel)))
|
if (!(lxc_driver->xmlopt = lxcDomainXMLConfInit(lxc_driver, defsecmodel)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(lxc_driver->closeCallbacks = virCloseCallbacksNew()))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (g_mkdir_with_parents(cfg->stateDir, 0777) < 0) {
|
if (g_mkdir_with_parents(cfg->stateDir, 0777) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Failed to mkdir %s"),
|
_("Failed to mkdir %s"),
|
||||||
@ -1586,8 +1584,6 @@ static int lxcStateCleanup(void)
|
|||||||
virObjectUnref(lxc_driver->domains);
|
virObjectUnref(lxc_driver->domains);
|
||||||
virObjectUnref(lxc_driver->domainEventState);
|
virObjectUnref(lxc_driver->domainEventState);
|
||||||
|
|
||||||
virObjectUnref(lxc_driver->closeCallbacks);
|
|
||||||
|
|
||||||
virSysinfoDefFree(lxc_driver->hostsysinfo);
|
virSysinfoDefFree(lxc_driver->hostsysinfo);
|
||||||
|
|
||||||
virObjectUnref(lxc_driver->hostdevMgr);
|
virObjectUnref(lxc_driver->hostdevMgr);
|
||||||
|
@ -188,7 +188,7 @@ static void virLXCProcessCleanup(virLXCDriver *driver,
|
|||||||
|
|
||||||
/* Stop autodestroy in case guest is restarted */
|
/* Stop autodestroy in case guest is restarted */
|
||||||
if (flags & VIR_LXC_PROCESS_CLEANUP_AUTODESTROY) {
|
if (flags & VIR_LXC_PROCESS_CLEANUP_AUTODESTROY) {
|
||||||
virCloseCallbacksUnset(driver->closeCallbacks, vm, lxcProcessAutoDestroy);
|
virCloseCallbacksDomainRemove(vm, NULL, lxcProcessAutoDestroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->monitor) {
|
if (priv->monitor) {
|
||||||
@ -1504,10 +1504,8 @@ int virLXCProcessStart(virLXCDriver * driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (autoDestroyConn &&
|
if (autoDestroyConn)
|
||||||
virCloseCallbacksSet(driver->closeCallbacks, vm,
|
virCloseCallbacksDomainAdd(vm, autoDestroyConn, lxcProcessAutoDestroy);
|
||||||
autoDestroyConn, lxcProcessAutoDestroy) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/* We don't need the temporary NIC names anymore, clear them */
|
/* We don't need the temporary NIC names anymore, clear them */
|
||||||
virLXCProcessCleanInterfaces(vm->def);
|
virLXCProcessCleanInterfaces(vm->def);
|
||||||
|
Loading…
Reference in New Issue
Block a user