render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From 799c9dd37390878a54be303b3e3e27445049bf2b Mon Sep 17 00:00:00 2001
Message-Id: <799c9dd37390878a54be303b3e3e27445049bf2b@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 27 Jun 2019 15:18:16 +0200
Subject: [PATCH] Revert "virStateDriver - Separate AutoStart from Initialize"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit cefb97fb815c81fc882da752f45effd23bcb9b4b.

The stateAutoStart callback will be removed in the next commit.
Therefore move autostarting of domains, networks and storage
pools back into stateInitialize callbacks.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit fc380c2e018ae15347d4c281a7e74896c48cac4a)

https://bugzilla.redhat.com/show_bug.cgi?id=1685151

The difference to the upstream commit is uml driver change. In
upstream, the uml driver was dropped, but it's still kept around
in downstream.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <a8e69f65b397c81c2a68597cca6c8ac04df24153.1561641375.git.mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/libxl/libxl_driver.c     | 14 +++-----------
 src/lxc/lxc_driver.c         | 16 ++--------------
 src/network/bridge_driver.c  | 22 ++++------------------
 src/qemu/qemu_driver.c       | 17 ++---------------
 src/storage/storage_driver.c | 19 ++-----------------
 src/uml/uml_driver.c         | 17 ++---------------
 6 files changed, 15 insertions(+), 90 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 5a5e792957..99bb010af4 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -773,6 +773,9 @@ libxlStateInitialize(bool privileged,
                                        NULL, NULL) < 0)
         goto error;
 
+    virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain,
+                            libxl_driver);
+
     virDomainObjListForEach(libxl_driver->domains, libxlDomainManagedSaveLoad,
                             libxl_driver);
 
@@ -784,16 +787,6 @@ libxlStateInitialize(bool privileged,
     return -1;
 }
 
-static void
-libxlStateAutoStart(void)
-{
-    if (!libxl_driver)
-        return;
-
-    virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain,
-                            libxl_driver);
-}
-
 static int
 libxlStateReload(void)
 {
@@ -6479,7 +6472,6 @@ static virConnectDriver libxlConnectDriver = {
 static virStateDriver libxlStateDriver = {
     .name = "LIBXL",
     .stateInitialize = libxlStateInitialize,
-    .stateAutoStart = libxlStateAutoStart,
     .stateCleanup = libxlStateCleanup,
     .stateReload = libxlStateReload,
 };
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index f9794e0655..527fa72083 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1646,6 +1646,8 @@ static int lxcStateInitialize(bool privileged,
                                        NULL, NULL) < 0)
         goto cleanup;
 
+    virLXCProcessAutostartAll(lxc_driver);
+
     virObjectUnref(caps);
     return 0;
 
@@ -1655,19 +1657,6 @@ static int lxcStateInitialize(bool privileged,
     return -1;
 }
 
-/**
- * lxcStateAutoStart:
- *
- * Function to autostart the LXC daemons
- */
-static void lxcStateAutoStart(void)
-{
-    if (!lxc_driver)
-        return;
-
-    virLXCProcessAutostartAll(lxc_driver);
-}
-
 static void lxcNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
 {
     virLXCDriverPtr driver = opaque;
@@ -5550,7 +5539,6 @@ static virConnectDriver lxcConnectDriver = {
 static virStateDriver lxcStateDriver = {
     .name = LXC_DRIVER_NAME,
     .stateInitialize = lxcStateInitialize,
-    .stateAutoStart = lxcStateAutoStart,
     .stateCleanup = lxcStateCleanup,
     .stateReload = lxcStateReload,
 };
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index d153a8cdb6..a60d7db685 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -755,6 +755,10 @@ networkStateInitialize(bool privileged,
     networkReloadFirewallRules(network_driver);
     networkRefreshDaemons(network_driver);
 
+    virNetworkObjListForEach(network_driver->networks,
+                             networkAutostartConfig,
+                             network_driver);
+
     network_driver->networkEventState = virObjectEventStateNew();
 
 #ifdef WITH_FIREWALLD
@@ -794,23 +798,6 @@ networkStateInitialize(bool privileged,
 }
 
 
-/**
- * networkStateAutoStart:
- *
- * Function to AutoStart the bridge configs
- */
-static void
-networkStateAutoStart(void)
-{
-    if (!network_driver)
-        return;
-
-    virNetworkObjListForEach(network_driver->networks,
-                             networkAutostartConfig,
-                             network_driver);
-}
-
-
 /**
  * networkStateReload:
  *
@@ -5616,7 +5603,6 @@ static virConnectDriver networkConnectDriver = {
 static virStateDriver networkStateDriver = {
     .name = "bridge",
     .stateInitialize  = networkStateInitialize,
-    .stateAutoStart  = networkStateAutoStart,
     .stateCleanup = networkStateCleanup,
     .stateReload = networkStateReload,
 };
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2da87992fd..056d324a62 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -911,6 +911,8 @@ qemuStateInitialize(bool privileged,
 
     qemuProcessReconnectAll(qemu_driver);
 
+    qemuAutostartDomains(qemu_driver);
+
     return 0;
 
  error:
@@ -921,20 +923,6 @@ qemuStateInitialize(bool privileged,
     return -1;
 }
 
-/**
- * qemuStateAutoStart:
- *
- * Function to auto start the QEMU daemons
- */
-static void
-qemuStateAutoStart(void)
-{
-    if (!qemu_driver)
-        return;
-
-    qemuAutostartDomains(qemu_driver);
-}
-
 static void qemuNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
 {
     virQEMUDriverPtr driver = opaque;
@@ -21846,7 +21834,6 @@ static virConnectDriver qemuConnectDriver = {
 static virStateDriver qemuStateDriver = {
     .name = QEMU_DRIVER_NAME,
     .stateInitialize = qemuStateInitialize,
-    .stateAutoStart = qemuStateAutoStart,
     .stateCleanup = qemuStateCleanup,
     .stateReload = qemuStateReload,
     .stateStop = qemuStateStop,
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 254818e308..f61fb074e6 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -291,6 +291,8 @@ storageStateInitialize(bool privileged,
 
     storagePoolUpdateAllState();
 
+    storageDriverAutostart();
+
     driver->storageEventState = virObjectEventStateNew();
 
     storageDriverUnlock();
@@ -307,22 +309,6 @@ storageStateInitialize(bool privileged,
     goto cleanup;
 }
 
-/**
- * storageStateAutoStart:
- *
- * Function to auto start the storage driver
- */
-static void
-storageStateAutoStart(void)
-{
-    if (!driver)
-        return;
-
-    storageDriverLock();
-    storageDriverAutostart();
-    storageDriverUnlock();
-}
-
 /**
  * storageStateReload:
  *
@@ -2843,7 +2829,6 @@ static virConnectDriver storageConnectDriver = {
 static virStateDriver stateDriver = {
     .name = "storage",
     .stateInitialize = storageStateInitialize,
-    .stateAutoStart = storageStateAutoStart,
     .stateCleanup = storageStateCleanup,
     .stateReload = storageStateReload,
 };
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index c77988f01e..296adf55d1 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -575,6 +575,8 @@ umlStateInitialize(bool privileged,
 
     umlDriverUnlock(uml_driver);
 
+    umlAutostartConfigs(uml_driver);
+
     VIR_FREE(userdir);
 
     return 0;
@@ -590,20 +592,6 @@ umlStateInitialize(bool privileged,
     return -1;
 }
 
-/**
- * umlStateAutoStart:
- *
- * Function to autostart the Uml daemons
- */
-static void
-umlStateAutoStart(void)
-{
-    if (!uml_driver)
-        return;
-
-    umlAutostartConfigs(uml_driver);
-}
-
 static void umlNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
 {
     struct uml_driver *driver = opaque;
@@ -2826,7 +2814,6 @@ static virConnectDriver umlConnectDriver = {
 static virStateDriver umlStateDriver = {
     .name = "UML",
     .stateInitialize = umlStateInitialize,
-    .stateAutoStart = umlStateAutoStart,
     .stateCleanup = umlStateCleanup,
     .stateReload = umlStateReload,
 };
-- 
2.22.0