mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
lib: autostart objects exactly once
https://bugzilla.redhat.com/show_bug.cgi?id=1755303 With the recent work in daemon split and socket activation daemons can come and go. They can and will be started many times during a session which results in objects being autostarted multiple times. This is not optimal. Use virDriverShouldAutostart() to determine if autostart should be done or not. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
ee16a195d9
commit
bab464f8ea
@ -1218,6 +1218,8 @@ bhyveStateInitialize(bool privileged,
|
|||||||
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
|
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
|
||||||
void *opaque ATTRIBUTE_UNUSED)
|
void *opaque ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
|
bool autostart = true;
|
||||||
|
|
||||||
if (!privileged) {
|
if (!privileged) {
|
||||||
VIR_INFO("Not running privileged, disabling driver");
|
VIR_INFO("Not running privileged, disabling driver");
|
||||||
return VIR_DRV_STATE_INIT_SKIPPED;
|
return VIR_DRV_STATE_INIT_SKIPPED;
|
||||||
@ -1301,7 +1303,11 @@ bhyveStateInitialize(bool privileged,
|
|||||||
|
|
||||||
virBhyveProcessReconnectAll(bhyve_driver);
|
virBhyveProcessReconnectAll(bhyve_driver);
|
||||||
|
|
||||||
bhyveAutostartDomains(bhyve_driver);
|
if (virDriverShouldAutostart(BHYVE_STATE_DIR, &autostart) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (autostart)
|
||||||
|
bhyveAutostartDomains(bhyve_driver);
|
||||||
|
|
||||||
return VIR_DRV_STATE_INIT_COMPLETE;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
|
@ -655,6 +655,7 @@ libxlStateInitialize(bool privileged,
|
|||||||
libxlDriverConfigPtr cfg;
|
libxlDriverConfigPtr cfg;
|
||||||
char *driverConf = NULL;
|
char *driverConf = NULL;
|
||||||
char ebuf[1024];
|
char ebuf[1024];
|
||||||
|
bool autostart = true;
|
||||||
|
|
||||||
if (!libxlDriverShouldLoad(privileged))
|
if (!libxlDriverShouldLoad(privileged))
|
||||||
return VIR_DRV_STATE_INIT_SKIPPED;
|
return VIR_DRV_STATE_INIT_SKIPPED;
|
||||||
@ -800,9 +801,14 @@ libxlStateInitialize(bool privileged,
|
|||||||
NULL, NULL) < 0)
|
NULL, NULL) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
virDomainObjListForEach(libxl_driver->domains, false,
|
if (virDriverShouldAutostart(cfg->stateDir, &autostart) < 0)
|
||||||
libxlAutostartDomain,
|
goto error;
|
||||||
libxl_driver);
|
|
||||||
|
if (autostart) {
|
||||||
|
virDomainObjListForEach(libxl_driver->domains, false,
|
||||||
|
libxlAutostartDomain,
|
||||||
|
libxl_driver);
|
||||||
|
}
|
||||||
|
|
||||||
virDomainObjListForEach(libxl_driver->domains, false,
|
virDomainObjListForEach(libxl_driver->domains, false,
|
||||||
libxlDomainManagedSaveLoad,
|
libxlDomainManagedSaveLoad,
|
||||||
|
@ -1541,6 +1541,7 @@ static int lxcStateInitialize(bool privileged,
|
|||||||
{
|
{
|
||||||
virCapsPtr caps = NULL;
|
virCapsPtr caps = NULL;
|
||||||
virLXCDriverConfigPtr cfg = NULL;
|
virLXCDriverConfigPtr cfg = NULL;
|
||||||
|
bool autostart = true;
|
||||||
|
|
||||||
/* Check that the user is root, silently disable if not */
|
/* Check that the user is root, silently disable if not */
|
||||||
if (!privileged) {
|
if (!privileged) {
|
||||||
@ -1630,7 +1631,11 @@ static int lxcStateInitialize(bool privileged,
|
|||||||
NULL, NULL) < 0)
|
NULL, NULL) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virLXCProcessAutostartAll(lxc_driver);
|
if (virDriverShouldAutostart(cfg->stateDir, &autostart) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (autostart)
|
||||||
|
virLXCProcessAutostartAll(lxc_driver);
|
||||||
|
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
return VIR_DRV_STATE_INIT_COMPLETE;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
@ -715,6 +715,7 @@ networkStateInitialize(bool privileged,
|
|||||||
int ret = VIR_DRV_STATE_INIT_ERROR;
|
int ret = VIR_DRV_STATE_INIT_ERROR;
|
||||||
char *configdir = NULL;
|
char *configdir = NULL;
|
||||||
char *rundir = NULL;
|
char *rundir = NULL;
|
||||||
|
bool autostart = true;
|
||||||
#ifdef WITH_FIREWALLD
|
#ifdef WITH_FIREWALLD
|
||||||
DBusConnection *sysbus = NULL;
|
DBusConnection *sysbus = NULL;
|
||||||
#endif
|
#endif
|
||||||
@ -815,9 +816,14 @@ networkStateInitialize(bool privileged,
|
|||||||
networkReloadFirewallRules(network_driver, true);
|
networkReloadFirewallRules(network_driver, true);
|
||||||
networkRefreshDaemons(network_driver);
|
networkRefreshDaemons(network_driver);
|
||||||
|
|
||||||
virNetworkObjListForEach(network_driver->networks,
|
if (virDriverShouldAutostart(network_driver->stateDir, &autostart) < 0)
|
||||||
networkAutostartConfig,
|
goto error;
|
||||||
network_driver);
|
|
||||||
|
if (autostart) {
|
||||||
|
virNetworkObjListForEach(network_driver->networks,
|
||||||
|
networkAutostartConfig,
|
||||||
|
network_driver);
|
||||||
|
}
|
||||||
|
|
||||||
network_driver->networkEventState = virObjectEventStateNew();
|
network_driver->networkEventState = virObjectEventStateNew();
|
||||||
|
|
||||||
|
@ -673,6 +673,7 @@ qemuStateInitialize(bool privileged,
|
|||||||
gid_t run_gid = -1;
|
gid_t run_gid = -1;
|
||||||
char *hugepagePath = NULL;
|
char *hugepagePath = NULL;
|
||||||
char *memoryBackingPath = NULL;
|
char *memoryBackingPath = NULL;
|
||||||
|
bool autostart = true;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (VIR_ALLOC(qemu_driver) < 0)
|
if (VIR_ALLOC(qemu_driver) < 0)
|
||||||
@ -1035,7 +1036,11 @@ qemuStateInitialize(bool privileged,
|
|||||||
|
|
||||||
qemuProcessReconnectAll(qemu_driver);
|
qemuProcessReconnectAll(qemu_driver);
|
||||||
|
|
||||||
qemuAutostartDomains(qemu_driver);
|
if (virDriverShouldAutostart(cfg->stateDir, &autostart) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (autostart)
|
||||||
|
qemuAutostartDomains(qemu_driver);
|
||||||
|
|
||||||
return VIR_DRV_STATE_INIT_COMPLETE;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
|
@ -258,6 +258,7 @@ storageStateInitialize(bool privileged,
|
|||||||
{
|
{
|
||||||
VIR_AUTOFREE(char *) configdir = NULL;
|
VIR_AUTOFREE(char *) configdir = NULL;
|
||||||
VIR_AUTOFREE(char *) rundir = NULL;
|
VIR_AUTOFREE(char *) rundir = NULL;
|
||||||
|
bool autostart = true;
|
||||||
|
|
||||||
if (VIR_ALLOC(driver) < 0)
|
if (VIR_ALLOC(driver) < 0)
|
||||||
return VIR_DRV_STATE_INIT_ERROR;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
@ -319,7 +320,11 @@ storageStateInitialize(bool privileged,
|
|||||||
|
|
||||||
storagePoolUpdateAllState();
|
storagePoolUpdateAllState();
|
||||||
|
|
||||||
storageDriverAutostart();
|
if (virDriverShouldAutostart(driver->stateDir, &autostart) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (autostart)
|
||||||
|
storageDriverAutostart();
|
||||||
|
|
||||||
driver->storageEventState = virObjectEventStateNew();
|
driver->storageEventState = virObjectEventStateNew();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user