[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 04/11] vz: build driver as module and don't register it on client's side



Make it possible to build vz driver as a module and don't link it with
libvirt.so statically.
Remove registering it on client's side as far as we start relying on daemon

Signed-off-by: Maxim Nestratov <mnestratov virtuozzo com>
---
 daemon/Makefile.am |  4 ++++
 daemon/libvirtd.c  |  9 +++++++++
 src/Makefile.am    | 21 ++++++++++++++++-----
 src/libvirt.c      |  7 -------
 src/vz/vz_driver.c | 27 +++++++++++++++++++++++++--
 5 files changed, 54 insertions(+), 14 deletions(-)

diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 2dbe81b..78d7d21 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -233,6 +233,10 @@ if WITH_VBOX
     libvirtd_LDADD += ../src/libvirt_driver_vbox.la
 endif WITH_VBOX
 
+if WITH_VZ
+    libvirtd_LDADD += ../src/libvirt_driver_vz.la
+endif WITH_VZ
+
 if WITH_STORAGE
     libvirtd_LDADD += ../src/libvirt_driver_storage.la
 endif WITH_STORAGE
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 3d38a46..92b4080 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -102,6 +102,9 @@
 #  include "nwfilter/nwfilter_driver.h"
 # endif
 #endif
+#ifdef WITH_VZ
+# include "vz/vz_driver.h"
+#endif
 
 #include "configmake.h"
 
@@ -390,6 +393,9 @@ static void daemonInitialize(void)
 # ifdef WITH_BHYVE
     virDriverLoadModule("bhyve");
 # endif
+# ifdef WITH_VZ
+    virDriverLoadModule("vz");
+# endif
 #else
 # ifdef WITH_NETWORK
     networkRegister();
@@ -430,6 +436,9 @@ static void daemonInitialize(void)
 # ifdef WITH_BHYVE
     bhyveRegister();
 # endif
+# ifdef WITH_VZ
+    vzRegister();
+# endif
 #endif
 }
 
diff --git a/src/Makefile.am b/src/Makefile.am
index dad7bab..b26be1b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -629,6 +629,7 @@ DRIVER_SOURCE_FILES = \
 	$(NULL)
 
 STATEFUL_DRIVER_SOURCE_FILES = \
+	$(VZ_DRIVER_SOURCES) \
 	$(BHYVE_DRIVER_SOURCES) \
 	$(INTERFACE_DRIVER_SOURCES) \
 	$(LIBXL_DRIVER_SOURCES) \
@@ -885,7 +886,9 @@ HYPERV_DRIVER_EXTRA_DIST =							\
 		hyperv/hyperv_wmi_generator.py					\
 		$(HYPERV_DRIVER_GENERATED)
 
-VZ_DRIVER_SOURCES =					\
+VZ_DRIVER_SOURCES =				\
+		datatypes.c             	\
+		util/vircommand.c		\
 		vz/vz_driver.h			\
 		vz/vz_driver.c			\
 		vz/vz_utils.c			\
@@ -1478,13 +1481,21 @@ libvirt_driver_hyperv_la_SOURCES = $(HYPERV_DRIVER_SOURCES)
 endif WITH_HYPERV
 
 if WITH_VZ
+noinst_LTLIBRARIES += libvirt_driver_vz_impl.la
+libvirt_driver_vz_la_SOURCES =
+libvirt_driver_vz_la_LIBADD = libvirt_driver_vz_impl.la
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_vz.la
+libvirt_driver_vz_la_LIBADD += ../gnulib/lib/libgnu.la
+libvirt_driver_vz_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
+else ! WITH_DRIVER_MODULES
 noinst_LTLIBRARIES += libvirt_driver_vz.la
-libvirt_la_BUILT_LIBADD += libvirt_driver_vz.la
-libvirt_driver_vz_la_CFLAGS = \
+endif ! WITH_DRIVER_MODULES
+libvirt_driver_vz_impl_la_CFLAGS = \
 		-I$(srcdir)/conf $(AM_CFLAGS) \
 		$(PARALLELS_SDK_CFLAGS) $(LIBNL_CFLAGS)
-libvirt_driver_vz_la_LIBADD = $(PARALLELS_SDK_LIBS) $(LIBNL_LIBS)
-libvirt_driver_vz_la_SOURCES = $(VZ_DRIVER_SOURCES)
+libvirt_driver_vz_impl_la_SOURCES = $(VZ_DRIVER_SOURCES)
+libvirt_driver_vz_impl_la_LIBADD =  $(PARALLELS_SDK_LIBS) $(LIBNL_LIBS)
 endif WITH_VZ
 
 if WITH_BHYVE
diff --git a/src/libvirt.c b/src/libvirt.c
index dd58e9c..a21d00e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -92,9 +92,6 @@
 #ifdef WITH_XENAPI
 # include "xenapi/xenapi_driver.h"
 #endif
-#ifdef WITH_VZ
-# include "vz/vz_driver.h"
-#endif
 #ifdef WITH_BHYVE
 # include "bhyve/bhyve_driver.h"
 #endif
@@ -433,10 +430,6 @@ virGlobalInit(void)
     if (xenapiRegister() == -1)
         goto error;
 # endif
-# ifdef WITH_VZ
-    if (vzRegister() == -1)
-        goto error;
-# endif
 #endif
 #ifdef WITH_REMOTE
     if (remoteRegister() == -1)
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 9de88cd..d3dcf3d 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -1561,6 +1561,26 @@ static virConnectDriver vzConnectDriver = {
     .hypervisorDriver = &vzDriver,
 };
 
+static int
+vzStateCleanup(void)
+{
+    return 0;
+}
+
+static int
+vzStateInitialize(bool privileged ATTRIBUTE_UNUSED,
+                  virStateInhibitCallback callback ATTRIBUTE_UNUSED,
+                  void *opaque ATTRIBUTE_UNUSED)
+{
+    return 0;
+}
+
+static virStateDriver vzStateDriver = {
+    .name = "vz",
+    .stateInitialize = vzStateInitialize,
+    .stateCleanup = vzStateCleanup,
+};
+
 /* Parallels domain type backward compatibility*/
 static virHypervisorDriver parallelsDriver;
 static virConnectDriver parallelsConnectDriver;
@@ -1588,10 +1608,13 @@ vzRegister(void)
     parallelsDriver.name = "Parallels";
     parallelsConnectDriver = vzConnectDriver;
     parallelsConnectDriver.hypervisorDriver = &parallelsDriver;
-    if (virRegisterConnectDriver(&parallelsConnectDriver, false) < 0)
+    if (virRegisterConnectDriver(&parallelsConnectDriver, true) < 0)
+        return -1;
+
+    if (virRegisterConnectDriver(&vzConnectDriver, true) < 0)
         return -1;
 
-    if (virRegisterConnectDriver(&vzConnectDriver, false) < 0)
+    if (virRegisterStateDriver(&vzStateDriver) < 0)
         return -1;
 
     return 0;
-- 
2.4.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]