]> xenbits.xensource.com Git - libvirt.git/commitdiff
virStateInitialize: Propagate whether running in monolithic daemon mode to stateful...
authorPeter Krempa <pkrempa@redhat.com>
Fri, 9 Sep 2022 11:16:42 +0000 (13:16 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 13 Sep 2022 08:50:02 +0000 (10:50 +0200)
Upcoming patch which is fixing the opening of drivers in monolithic mode
needs to know whether we are inside 'libvirtd' but the code where the
decision needs to happen is not re-compiled per daemon. Thus we need to
pass this information to the stateful driver init function so that it
can be remebered.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 files changed:
src/bhyve/bhyve_driver.c
src/ch/ch_driver.c
src/driver-state.h
src/interface/interface_backend_netcf.c
src/interface/interface_backend_udev.c
src/libvirt.c
src/libvirt_internal.h
src/libxl/libxl_driver.c
src/lxc/lxc_driver.c
src/network/bridge_driver.c
src/node_device/node_device_udev.c
src/nwfilter/nwfilter_driver.c
src/qemu/qemu_driver.c
src/remote/remote_daemon.c
src/remote/remote_driver.c
src/secret/secret_driver.c
src/storage/storage_driver.c
src/vz/vz_driver.c

index 09ba52483ae149a3165ee9672a4833afc5906f20..e0bf2a19a6967cf6b0b36455e00abc1d8b452f69 100644 (file)
@@ -1178,6 +1178,7 @@ bhyveStateCleanup(void)
 static int
 bhyveStateInitialize(bool privileged,
                      const char *root,
+                     bool monolithic G_GNUC_UNUSED,
                      virStateInhibitCallback callback G_GNUC_UNUSED,
                      void *opaque G_GNUC_UNUSED)
 {
index c6e92efb2c27a211f0e779b42061da2d71804a9c..db2a66d13112555c5190a5f87d85a961d66b8597 100644 (file)
@@ -861,6 +861,7 @@ static int chStateCleanup(void)
 
 static int chStateInitialize(bool privileged,
                              const char *root,
+                             bool monolithic G_GNUC_UNUSED,
                              virStateInhibitCallback callback G_GNUC_UNUSED,
                              void *opaque G_GNUC_UNUSED)
 {
index f3a0638e90f8bf42b2cbda32a80cf2c8e5b9db45..7f8b61fa1c905a052921e079a187065df30e151f 100644 (file)
@@ -33,6 +33,7 @@ typedef enum {
 typedef virDrvStateInitResult
 (*virDrvStateInitialize)(bool privileged,
                          const char *root,
+                         bool monolithic,
                          virStateInhibitCallback callback,
                          void *opaque);
 
index 90514692e2397241d72296a2203faf43acfe575a..5964720e0fac92b636c7efe207a86712c5ffd3db 100644 (file)
@@ -89,6 +89,7 @@ virNetcfDriverStateDispose(void *obj)
 static int
 netcfStateInitialize(bool privileged,
                      const char *root,
+                     bool monolithic G_GNUC_UNUSED,
                      virStateInhibitCallback callback G_GNUC_UNUSED,
                      void *opaque G_GNUC_UNUSED)
 {
index 32318d8d50153173a13167462a104af9f5529ddd..979f187d874be5df0fff3a763b69a0b7594cffe3 100644 (file)
@@ -1110,6 +1110,7 @@ udevStateCleanup(void);
 static int
 udevStateInitialize(bool privileged,
                     const char *root,
+                    bool monolithic G_GNUC_UNUSED,
                     virStateInhibitCallback callback G_GNUC_UNUSED,
                     void *opaque G_GNUC_UNUSED)
 {
index 9db9ba326e47768b0effd6bfbd1fd30abbfd95cb..748f2d8ba0e830bdc169ea97017308a950a92de0 100644 (file)
@@ -604,6 +604,7 @@ virRegisterStateDriver(virStateDriver *driver)
  * @privileged: set to true if running with root privilege, false otherwise
  * @mandatory: set to true if all drivers must report success, not skipped
  * @root: directory to use for embedded mode
+ * @monolithic: set to true if running in monolithic mode (daemon is libvirtd)
  * @callback: callback to invoke to inhibit shutdown of the daemon
  * @opaque: data to pass to @callback
  *
@@ -633,6 +634,7 @@ int
 virStateInitialize(bool privileged,
                    bool mandatory,
                    const char *root,
+                   bool monolithic,
                    virStateInhibitCallback callback,
                    void *opaque)
 {
@@ -650,6 +652,7 @@ virStateInitialize(bool privileged,
             virStateDriverTab[i]->initialized = true;
             ret = virStateDriverTab[i]->stateInitialize(privileged,
                                                         root,
+                                                        monolithic,
                                                         callback,
                                                         opaque);
             VIR_DEBUG("State init result %d (mandatory=%d)", ret, mandatory);
@@ -1016,7 +1019,7 @@ virConnectOpenInternal(const char *name,
                 virAccessManagerSetDefault(acl);
             }
 
-            if (virStateInitialize(geteuid() == 0, true, root, NULL, NULL) < 0)
+            if (virStateInitialize(geteuid() == 0, true, root, false, NULL, NULL) < 0)
                 return NULL;
 
             embed = true;
index f4e592922d0537567a0ece1193545a779090092e..1ae3e2b2e0f7bc623e39a1c4a54b94855803571d 100644 (file)
@@ -32,6 +32,7 @@ typedef void (*virStateInhibitCallback)(bool inhibit,
 int virStateInitialize(bool privileged,
                        bool mandatory,
                        const char *root,
+                       bool monolithic,
                        virStateInhibitCallback inhibit,
                        void *opaque);
 int virStateShutdownPrepare(void);
index 79af2f44414de031c93cff7cbd0c9541fdbc5147..1b8b40e9e0b68c7a02da53f8906c901c5da3534e 100644 (file)
@@ -648,6 +648,7 @@ libxlAddDom0(libxlDriverPrivate *driver)
 static int
 libxlStateInitialize(bool privileged,
                      const char *root,
+                     bool monolithic G_GNUC_UNUSED,
                      virStateInhibitCallback callback,
                      void *opaque)
 {
index f2a358805aaf20565cf18c72f068851e27698c38..d66c26221c959899f08abf449cd56590ef06a088 100644 (file)
@@ -1430,6 +1430,7 @@ lxcSecurityInit(virLXCDriverConfig *cfg)
 
 static int lxcStateInitialize(bool privileged,
                               const char *root,
+                              bool monolithic G_GNUC_UNUSED,
                               virStateInhibitCallback callback G_GNUC_UNUSED,
                               void *opaque G_GNUC_UNUSED)
 {
index 7c7812e2769c8dd2483f46f40ff582751c2a0a8b..7c6430b4e3e373a69ff56e81069d8e4fccdedca4 100644 (file)
@@ -575,6 +575,7 @@ firewalld_dbus_signal_callback(GDBusConnection *connection G_GNUC_UNUSED,
 static int
 networkStateInitialize(bool privileged,
                        const char *root,
+                       bool monolithic G_GNUC_UNUSED,
                        virStateInhibitCallback callback G_GNUC_UNUSED,
                        void *opaque G_GNUC_UNUSED)
 {
index a06eaade5d8214cae2854cf97b77d5ede07bc468..07c10f0d88be9c816c8d4e9c83f98c54641d17c1 100644 (file)
@@ -2226,6 +2226,7 @@ mdevctlEventHandleCallback(GFileMonitor *monitor G_GNUC_UNUSED,
 static int
 nodeStateInitialize(bool privileged,
                     const char *root,
+                    bool monolithic G_GNUC_UNUSED,
                     virStateInhibitCallback callback G_GNUC_UNUSED,
                     void *opaque G_GNUC_UNUSED)
 {
index d1bdd806fc539f82d819f644e2bd4f885ec5195c..9cb306909c192cfe1da8de40e1cf34408b1f55b3 100644 (file)
@@ -211,6 +211,7 @@ nwfilterStateCleanup(void)
 static int
 nwfilterStateInitialize(bool privileged,
                         const char *root,
+                        bool monolithic G_GNUC_UNUSED,
                         virStateInhibitCallback callback G_GNUC_UNUSED,
                         void *opaque G_GNUC_UNUSED)
 {
index 6931f0670db205924643ff6727449376a7cd60a6..94b70872d4f8f0525c00cb0b3024d3f3d4c10978 100644 (file)
@@ -549,6 +549,7 @@ qemuDomainFindMaxID(virDomainObj *vm,
 static int
 qemuStateInitialize(bool privileged,
                     const char *root,
+                    bool monolithic G_GNUC_UNUSED,
                     virStateInhibitCallback callback,
                     void *opaque)
 {
index 36d95de83d5d71c55c3fa75f69939e4a6fcb0acb..f369d09d35cd3306f0cde90e8b444abb2c5a893b 100644 (file)
@@ -591,6 +591,11 @@ static void daemonRunStateInit(void *opaque)
 #else /* ! MODULE_NAME */
     bool mandatory = false;
 #endif /* ! MODULE_NAME */
+#ifdef LIBVIRTD
+    bool monolithic = true;
+#else /* ! LIBVIRTD */
+    bool monolithic = false;
+#endif /* ! LIBVIRTD */
 
     virIdentitySetCurrent(sysident);
 
@@ -605,6 +610,7 @@ static void daemonRunStateInit(void *opaque)
     if (virStateInitialize(virNetDaemonIsPrivileged(dmn),
                            mandatory,
                            NULL,
+                           monolithic,
                            daemonInhibitCallback,
                            dmn) < 0) {
         VIR_ERROR(_("Driver state initialization failed"));
index 25c80a09c792590339a6ea461d8ff71c41540d9c..33cc6b1fceade4652ba577de4e416ce5398ee0a8 100644 (file)
@@ -168,6 +168,7 @@ static void make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapsho
 static int
 remoteStateInitialize(bool privileged G_GNUC_UNUSED,
                       const char *root G_GNUC_UNUSED,
+                      bool monolithic G_GNUC_UNUSED,
                       virStateInhibitCallback callback G_GNUC_UNUSED,
                       void *opaque G_GNUC_UNUSED)
 {
index 080ed962a942db5310d748da92e6a3dbdec760e4..6328589fa4528ff2940576711332539edfc2e1cf 100644 (file)
@@ -462,6 +462,7 @@ secretStateCleanup(void)
 static int
 secretStateInitialize(bool privileged,
                       const char *root,
+                      bool monolithic G_GNUC_UNUSED,
                       virStateInhibitCallback callback G_GNUC_UNUSED,
                       void *opaque G_GNUC_UNUSED)
 {
index 8dc2cfa7c90470903024ebe657c0debfb81b53de..fccf0fcf5282512b56d8738ae9c5569eca791c90 100644 (file)
@@ -242,6 +242,7 @@ storageDriverAutostart(void)
 static int
 storageStateInitialize(bool privileged,
                        const char *root,
+                       bool monolithic G_GNUC_UNUSED,
                        virStateInhibitCallback callback G_GNUC_UNUSED,
                        void *opaque G_GNUC_UNUSED)
 {
index 571d895167b6ef06be5d212dc00c37c7a6e6d4bc..4f5e340d536c69d88049aa59205170c7e5606524 100644 (file)
@@ -4077,6 +4077,7 @@ vzStateCleanup(void)
 static int
 vzStateInitialize(bool privileged,
                   const char *root,
+                  bool monolithic G_GNUC_UNUSED,
                   virStateInhibitCallback callback G_GNUC_UNUSED,
                   void *opaque G_GNUC_UNUSED)
 {