render / rpms / libvirt

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