diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index c52def7607eeabe806ec262ff8ed38ae89b35d56..fb0996bd2a77109a7b2d24fc75a510755927be47 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1218,6 +1218,8 @@ bhyveStateInitialize(bool privileged, virStateInhibitCallback callback ATTRIBUTE_UNUSED, void *opaque ATTRIBUTE_UNUSED) { + bool autostart = true; + if (!privileged) { VIR_INFO("Not running privileged, disabling driver"); return VIR_DRV_STATE_INIT_SKIPPED; @@ -1301,7 +1303,11 @@ bhyveStateInitialize(bool privileged, 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; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 45de6b24c68c4e18454384219e421fb690e6620c..ea643b8a3f7c6d2d2ca4203cadbb8c7859503b58 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -655,6 +655,7 @@ libxlStateInitialize(bool privileged, libxlDriverConfigPtr cfg; char *driverConf = NULL; char ebuf[1024]; + bool autostart = true; if (!libxlDriverShouldLoad(privileged)) return VIR_DRV_STATE_INIT_SKIPPED; @@ -800,9 +801,14 @@ libxlStateInitialize(bool privileged, NULL, NULL) < 0) goto error; - virDomainObjListForEach(libxl_driver->domains, false, - libxlAutostartDomain, - libxl_driver); + if (virDriverShouldAutostart(cfg->stateDir, &autostart) < 0) + goto error; + + if (autostart) { + virDomainObjListForEach(libxl_driver->domains, false, + libxlAutostartDomain, + libxl_driver); + } virDomainObjListForEach(libxl_driver->domains, false, libxlDomainManagedSaveLoad, diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index cf1dd1428e48035bb0a67043b109bdc3048a71f5..a69589e50c0239bbd77caa81afb5c16c08f9b0c0 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1541,6 +1541,7 @@ static int lxcStateInitialize(bool privileged, { virCapsPtr caps = NULL; virLXCDriverConfigPtr cfg = NULL; + bool autostart = true; /* Check that the user is root, silently disable if not */ if (!privileged) { @@ -1630,7 +1631,11 @@ static int lxcStateInitialize(bool privileged, NULL, NULL) < 0) goto cleanup; - virLXCProcessAutostartAll(lxc_driver); + if (virDriverShouldAutostart(cfg->stateDir, &autostart) < 0) + goto cleanup; + + if (autostart) + virLXCProcessAutostartAll(lxc_driver); virObjectUnref(caps); return VIR_DRV_STATE_INIT_COMPLETE; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index ae2e4f09f8a64e44a8917f113994c8206ba00f74..c05157c3ca99b4da55af8a0b267a25960862e119 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -715,6 +715,7 @@ networkStateInitialize(bool privileged, int ret = VIR_DRV_STATE_INIT_ERROR; char *configdir = NULL; char *rundir = NULL; + bool autostart = true; #ifdef WITH_FIREWALLD DBusConnection *sysbus = NULL; #endif @@ -815,9 +816,14 @@ networkStateInitialize(bool privileged, networkReloadFirewallRules(network_driver, true); networkRefreshDaemons(network_driver); - virNetworkObjListForEach(network_driver->networks, - networkAutostartConfig, - network_driver); + if (virDriverShouldAutostart(network_driver->stateDir, &autostart) < 0) + goto error; + + if (autostart) { + virNetworkObjListForEach(network_driver->networks, + networkAutostartConfig, + network_driver); + } network_driver->networkEventState = virObjectEventStateNew(); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 99db99e23a2802b8b37394e04303331fac18ffdb..bc0ede2fb0c56b78947ddddae9faeefead6446b0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -673,6 +673,7 @@ qemuStateInitialize(bool privileged, gid_t run_gid = -1; char *hugepagePath = NULL; char *memoryBackingPath = NULL; + bool autostart = true; size_t i; if (VIR_ALLOC(qemu_driver) < 0) @@ -1035,7 +1036,11 @@ qemuStateInitialize(bool privileged, 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; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index d160ff34fe7ea90e0d40ae64d325ce6dafad80c3..c536535c6c291ffee263152283060de2c9f8e3e7 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -258,6 +258,7 @@ storageStateInitialize(bool privileged, { VIR_AUTOFREE(char *) configdir = NULL; VIR_AUTOFREE(char *) rundir = NULL; + bool autostart = true; if (VIR_ALLOC(driver) < 0) return VIR_DRV_STATE_INIT_ERROR; @@ -319,7 +320,11 @@ storageStateInitialize(bool privileged, storagePoolUpdateAllState(); - storageDriverAutostart(); + if (virDriverShouldAutostart(driver->stateDir, &autostart) < 0) + goto error; + + if (autostart) + storageDriverAutostart(); driver->storageEventState = virObjectEventStateNew();