c313de
From 799c9dd37390878a54be303b3e3e27445049bf2b Mon Sep 17 00:00:00 2001
c313de
Message-Id: <799c9dd37390878a54be303b3e3e27445049bf2b@dist-git>
c313de
From: Michal Privoznik <mprivozn@redhat.com>
c313de
Date: Thu, 27 Jun 2019 15:18:16 +0200
c313de
Subject: [PATCH] Revert "virStateDriver - Separate AutoStart from Initialize"
c313de
MIME-Version: 1.0
c313de
Content-Type: text/plain; charset=UTF-8
c313de
Content-Transfer-Encoding: 8bit
c313de
c313de
This reverts commit cefb97fb815c81fc882da752f45effd23bcb9b4b.
c313de
c313de
The stateAutoStart callback will be removed in the next commit.
c313de
Therefore move autostarting of domains, networks and storage
c313de
pools back into stateInitialize callbacks.
c313de
c313de
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
(cherry picked from commit fc380c2e018ae15347d4c281a7e74896c48cac4a)
c313de
c313de
https://bugzilla.redhat.com/show_bug.cgi?id=1685151
c313de
c313de
The difference to the upstream commit is uml driver change. In
c313de
upstream, the uml driver was dropped, but it's still kept around
c313de
in downstream.
c313de
c313de
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c313de
Message-Id: <a8e69f65b397c81c2a68597cca6c8ac04df24153.1561641375.git.mprivozn@redhat.com>
c313de
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
c313de
---
c313de
 src/libxl/libxl_driver.c     | 14 +++-----------
c313de
 src/lxc/lxc_driver.c         | 16 ++--------------
c313de
 src/network/bridge_driver.c  | 22 ++++------------------
c313de
 src/qemu/qemu_driver.c       | 17 ++---------------
c313de
 src/storage/storage_driver.c | 19 ++-----------------
c313de
 src/uml/uml_driver.c         | 17 ++---------------
c313de
 6 files changed, 15 insertions(+), 90 deletions(-)
c313de
c313de
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
c313de
index 5a5e792957..99bb010af4 100644
c313de
--- a/src/libxl/libxl_driver.c
c313de
+++ b/src/libxl/libxl_driver.c
c313de
@@ -773,6 +773,9 @@ libxlStateInitialize(bool privileged,
c313de
                                        NULL, NULL) < 0)
c313de
         goto error;
c313de
 
c313de
+    virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain,
c313de
+                            libxl_driver);
c313de
+
c313de
     virDomainObjListForEach(libxl_driver->domains, libxlDomainManagedSaveLoad,
c313de
                             libxl_driver);
c313de
 
c313de
@@ -784,16 +787,6 @@ libxlStateInitialize(bool privileged,
c313de
     return -1;
c313de
 }
c313de
 
c313de
-static void
c313de
-libxlStateAutoStart(void)
c313de
-{
c313de
-    if (!libxl_driver)
c313de
-        return;
c313de
-
c313de
-    virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain,
c313de
-                            libxl_driver);
c313de
-}
c313de
-
c313de
 static int
c313de
 libxlStateReload(void)
c313de
 {
c313de
@@ -6479,7 +6472,6 @@ static virConnectDriver libxlConnectDriver = {
c313de
 static virStateDriver libxlStateDriver = {
c313de
     .name = "LIBXL",
c313de
     .stateInitialize = libxlStateInitialize,
c313de
-    .stateAutoStart = libxlStateAutoStart,
c313de
     .stateCleanup = libxlStateCleanup,
c313de
     .stateReload = libxlStateReload,
c313de
 };
c313de
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
c313de
index f9794e0655..527fa72083 100644
c313de
--- a/src/lxc/lxc_driver.c
c313de
+++ b/src/lxc/lxc_driver.c
c313de
@@ -1646,6 +1646,8 @@ static int lxcStateInitialize(bool privileged,
c313de
                                        NULL, NULL) < 0)
c313de
         goto cleanup;
c313de
 
c313de
+    virLXCProcessAutostartAll(lxc_driver);
c313de
+
c313de
     virObjectUnref(caps);
c313de
     return 0;
c313de
 
c313de
@@ -1655,19 +1657,6 @@ static int lxcStateInitialize(bool privileged,
c313de
     return -1;
c313de
 }
c313de
 
c313de
-/**
c313de
- * lxcStateAutoStart:
c313de
- *
c313de
- * Function to autostart the LXC daemons
c313de
- */
c313de
-static void lxcStateAutoStart(void)
c313de
-{
c313de
-    if (!lxc_driver)
c313de
-        return;
c313de
-
c313de
-    virLXCProcessAutostartAll(lxc_driver);
c313de
-}
c313de
-
c313de
 static void lxcNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
c313de
 {
c313de
     virLXCDriverPtr driver = opaque;
c313de
@@ -5550,7 +5539,6 @@ static virConnectDriver lxcConnectDriver = {
c313de
 static virStateDriver lxcStateDriver = {
c313de
     .name = LXC_DRIVER_NAME,
c313de
     .stateInitialize = lxcStateInitialize,
c313de
-    .stateAutoStart = lxcStateAutoStart,
c313de
     .stateCleanup = lxcStateCleanup,
c313de
     .stateReload = lxcStateReload,
c313de
 };
c313de
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
c313de
index d153a8cdb6..a60d7db685 100644
c313de
--- a/src/network/bridge_driver.c
c313de
+++ b/src/network/bridge_driver.c
c313de
@@ -755,6 +755,10 @@ networkStateInitialize(bool privileged,
c313de
     networkReloadFirewallRules(network_driver);
c313de
     networkRefreshDaemons(network_driver);
c313de
 
c313de
+    virNetworkObjListForEach(network_driver->networks,
c313de
+                             networkAutostartConfig,
c313de
+                             network_driver);
c313de
+
c313de
     network_driver->networkEventState = virObjectEventStateNew();
c313de
 
c313de
 #ifdef WITH_FIREWALLD
c313de
@@ -794,23 +798,6 @@ networkStateInitialize(bool privileged,
c313de
 }
c313de
 
c313de
 
c313de
-/**
c313de
- * networkStateAutoStart:
c313de
- *
c313de
- * Function to AutoStart the bridge configs
c313de
- */
c313de
-static void
c313de
-networkStateAutoStart(void)
c313de
-{
c313de
-    if (!network_driver)
c313de
-        return;
c313de
-
c313de
-    virNetworkObjListForEach(network_driver->networks,
c313de
-                             networkAutostartConfig,
c313de
-                             network_driver);
c313de
-}
c313de
-
c313de
-
c313de
 /**
c313de
  * networkStateReload:
c313de
  *
c313de
@@ -5616,7 +5603,6 @@ static virConnectDriver networkConnectDriver = {
c313de
 static virStateDriver networkStateDriver = {
c313de
     .name = "bridge",
c313de
     .stateInitialize  = networkStateInitialize,
c313de
-    .stateAutoStart  = networkStateAutoStart,
c313de
     .stateCleanup = networkStateCleanup,
c313de
     .stateReload = networkStateReload,
c313de
 };
c313de
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
c313de
index 2da87992fd..056d324a62 100644
c313de
--- a/src/qemu/qemu_driver.c
c313de
+++ b/src/qemu/qemu_driver.c
c313de
@@ -911,6 +911,8 @@ qemuStateInitialize(bool privileged,
c313de
 
c313de
     qemuProcessReconnectAll(qemu_driver);
c313de
 
c313de
+    qemuAutostartDomains(qemu_driver);
c313de
+
c313de
     return 0;
c313de
 
c313de
  error:
c313de
@@ -921,20 +923,6 @@ qemuStateInitialize(bool privileged,
c313de
     return -1;
c313de
 }
c313de
 
c313de
-/**
c313de
- * qemuStateAutoStart:
c313de
- *
c313de
- * Function to auto start the QEMU daemons
c313de
- */
c313de
-static void
c313de
-qemuStateAutoStart(void)
c313de
-{
c313de
-    if (!qemu_driver)
c313de
-        return;
c313de
-
c313de
-    qemuAutostartDomains(qemu_driver);
c313de
-}
c313de
-
c313de
 static void qemuNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
c313de
 {
c313de
     virQEMUDriverPtr driver = opaque;
c313de
@@ -21846,7 +21834,6 @@ static virConnectDriver qemuConnectDriver = {
c313de
 static virStateDriver qemuStateDriver = {
c313de
     .name = QEMU_DRIVER_NAME,
c313de
     .stateInitialize = qemuStateInitialize,
c313de
-    .stateAutoStart = qemuStateAutoStart,
c313de
     .stateCleanup = qemuStateCleanup,
c313de
     .stateReload = qemuStateReload,
c313de
     .stateStop = qemuStateStop,
c313de
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
c313de
index 254818e308..f61fb074e6 100644
c313de
--- a/src/storage/storage_driver.c
c313de
+++ b/src/storage/storage_driver.c
c313de
@@ -291,6 +291,8 @@ storageStateInitialize(bool privileged,
c313de
 
c313de
     storagePoolUpdateAllState();
c313de
 
c313de
+    storageDriverAutostart();
c313de
+
c313de
     driver->storageEventState = virObjectEventStateNew();
c313de
 
c313de
     storageDriverUnlock();
c313de
@@ -307,22 +309,6 @@ storageStateInitialize(bool privileged,
c313de
     goto cleanup;
c313de
 }
c313de
 
c313de
-/**
c313de
- * storageStateAutoStart:
c313de
- *
c313de
- * Function to auto start the storage driver
c313de
- */
c313de
-static void
c313de
-storageStateAutoStart(void)
c313de
-{
c313de
-    if (!driver)
c313de
-        return;
c313de
-
c313de
-    storageDriverLock();
c313de
-    storageDriverAutostart();
c313de
-    storageDriverUnlock();
c313de
-}
c313de
-
c313de
 /**
c313de
  * storageStateReload:
c313de
  *
c313de
@@ -2843,7 +2829,6 @@ static virConnectDriver storageConnectDriver = {
c313de
 static virStateDriver stateDriver = {
c313de
     .name = "storage",
c313de
     .stateInitialize = storageStateInitialize,
c313de
-    .stateAutoStart = storageStateAutoStart,
c313de
     .stateCleanup = storageStateCleanup,
c313de
     .stateReload = storageStateReload,
c313de
 };
c313de
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
c313de
index c77988f01e..296adf55d1 100644
c313de
--- a/src/uml/uml_driver.c
c313de
+++ b/src/uml/uml_driver.c
c313de
@@ -575,6 +575,8 @@ umlStateInitialize(bool privileged,
c313de
 
c313de
     umlDriverUnlock(uml_driver);
c313de
 
c313de
+    umlAutostartConfigs(uml_driver);
c313de
+
c313de
     VIR_FREE(userdir);
c313de
 
c313de
     return 0;
c313de
@@ -590,20 +592,6 @@ umlStateInitialize(bool privileged,
c313de
     return -1;
c313de
 }
c313de
 
c313de
-/**
c313de
- * umlStateAutoStart:
c313de
- *
c313de
- * Function to autostart the Uml daemons
c313de
- */
c313de
-static void
c313de
-umlStateAutoStart(void)
c313de
-{
c313de
-    if (!uml_driver)
c313de
-        return;
c313de
-
c313de
-    umlAutostartConfigs(uml_driver);
c313de
-}
c313de
-
c313de
 static void umlNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
c313de
 {
c313de
     struct uml_driver *driver = opaque;
c313de
@@ -2826,7 +2814,6 @@ static virConnectDriver umlConnectDriver = {
c313de
 static virStateDriver umlStateDriver = {
c313de
     .name = "UML",
c313de
     .stateInitialize = umlStateInitialize,
c313de
-    .stateAutoStart = umlStateAutoStart,
c313de
     .stateCleanup = umlStateCleanup,
c313de
     .stateReload = umlStateReload,
c313de
 };
c313de
-- 
c313de
2.22.0
c313de