[Devel] Q: libvzctl-simfs
Dmitry V. Levin
ldv at altlinux.org
Mon Aug 7 12:32:19 PDT 2006
On Thu, Jul 27, 2006 at 07:37:54PM +0400, Kir Kolyshkin wrote:
> Dmitry V. Levin wrote:
> >On Thu, Jun 22, 2006 at 11:44:15AM +0400, Kirill Korotaev wrote:
> >
> >>It was a try to split vzctl and make it plugin based.
> >>however, due to lack of time and low prio it was stopped
> >>on the early stages... :/ Rudiments...
> >>
> >
> >I see. Anyway, if shared library references to symbols defined in another
> >shared library, then it should link with that library. That is, I suggest
> >to merge libvzctl-simfs back to libvzctl. Also, I suggest to move "g_log"
> >symbol from vzcfgvalidate binary to libvzctl. After that, libvzctl will
> >be self-contained, thus enabling both --as-needed and prelink support.
> >
> >At least, I had to apply these changes to package vzctl for Sisyphus.
> Dmitry,
>
> Can you please send your patches (if you have those) -- we'll take a
> look and possibly commit them.
The patch I made to package vzctl for Sisyphus just merges libvzctl-simfs
back to libvzctl. Since you want to implement plugin support some day,
I reworked the change, this patch may be more appropriate.
---
Rework libraries to support ld --as-needed.
Makefile:
Relocate libraries from /usr/lib/vzctl/lib to /usr/lib.
Drop rpath.
Move logger to separate libvzlogger library.
Add sonames to all shared libraries.
Link libvzctl-simfs with libvzlogger.
Link libvzctl with libvzctl-simfs and libvzlogger.
Link vzctl, vzlist, vzmemcheck and vzcfgvalidate with libvzlogger.
Raise LIB_VER.
logger.c:
Define export g_log variable.
vzcalc.c, vzcfgvalidate.c, vzctl.c, vzlist.c, vzmemcheck.c:
Use g_log variable from libvzlogger.
vzctl.spec:
Relocate libraries from /usr/lib/vzctl/lib to /usr/lib.
Signed-off-by: Dmitry V. Levin <ldv at altlinux.org>
---
src/Makefile | 41 +++++++++++++++++++++++------------------
src/lib/logger.c | 2 +-
src/vzcalc.c | 2 --
src/vzcfgvalidate.c | 2 --
src/vzctl.c | 2 --
src/vzlist.c | 1 -
src/vzmemcheck.c | 2 --
vzctl.spec | 29 +++++++++++++++++------------
8 files changed, 41 insertions(+), 40 deletions(-)
2d2c39b960e0a61ff7122210dc75c70ef189a25a
diff --git a/src/Makefile b/src/Makefile
index 3008f1c..97e17a1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -17,7 +17,7 @@ #
INSTALL = install
PREFIX = /usr
SBINDIR = $(PREFIX)/sbin
- LIBDIR = $(PREFIX)/lib/vzctl/lib
+ LIBDIR = $(PREFIX)/lib
CONFDIR = /etc/vz
GLBCONFIG = $(CONFDIR)/vz.conf
VPSCONFDIR = $(CONFDIR)/conf
@@ -33,7 +33,7 @@ NETSCRIPTDIR = /etc/sysconfig/network-sc
VZDUMPDIR = $(VZDIR)/dump
VEIPDUMPDIR = /var/lib/vzctl/veip
LOGRDIR = /etc/logrotate.d
- LIB_VER = 0.0.2
+ LIB_VER = 0.0.3
export LD_LIBRARY_PATH=.
CC = gcc
@@ -43,13 +43,14 @@ #VZKERNEL_HEADERS ?= /lib/modules/$(shel
INC = -I ../include
ARCH ?= $(shell uname -m)
-OBJ_libvzctl = lib/env.lo lib/ub.lo lib/net.lo lib/logger.lo lib/exec.lo \
+OBJ_libvzctl = lib/env.lo lib/ub.lo lib/net.lo lib/exec.lo \
lib/cap.lo lib/cpu.lo lib/res.lo lib/util.lo lib/dist.lo lib/list.lo \
lib/script.lo lib/dev.lo lib/config.lo lib/lock.lo lib/quota.lo \
lib/modules.lo lib/iptables.lo lib/fs.lo lib/create.lo lib/readelf.lo \
lib/cpt.lo lib/destroy.lo lib/vps_configure.lo lib/meminfo.lo \
lib/veth.lo
OBJ_simfs=lib/fs_simfs.lo
+OBJ_logger = lib/logger.lo
OBJ_vzctl = vzctl.o vzctl-actions.o modules.o enter.o
OBJ_vzlist = vzlist.o
OBJ_arp = arpsend.o
@@ -59,17 +60,17 @@ OBJ_cfgvalidate = vzcfgvalidate.o valida
OBJ_calc = vzcalc.o
OBJ = $(OBJ_vzctl) $(OBJ_vzlist) $(OBJ_arp) $(OBJ_split) $(OBJ_memcheck) \
$(OBJ_cfgvalidate) $(OBJ_calc)
-LOBJ = $(OBJ_libvzctl) $(OBJ_simfs)
+LOBJ = $(OBJ_libvzctl) $(OBJ_simfs) $(OBJ_logger)
LIB_vzctl = libvzctl.so.$(LIB_VER)
LIB_simfs = libvzctl-simfs.so.$(LIB_VER)
+LIB_logger = libvzlogger.so.$(LIB_VER)
LIB_fs = $(LIB_simfs)
-LDFLAGS += -Wl,-rpath=$(LIBDIR)
LIBSCRIPTS = vps-create vps-postcreate vps-net_add vps-net_del vps-stop \
vps-functions
PROGS = vzctl vzlist arpsend vzsplit vzcfgvalidate vzmemcheck vzcalc
-LIBS = $(LIB_vzctl) $(LIB_fs)
+LIBS = $(LIB_vzctl) $(LIB_fs) $(LIB_logger)
INITSCRIPTS = vz
CRONSCRIPTS = vpsreboot vpsnetclean
@@ -102,23 +103,26 @@ check-version:
%.lo: %.c
$(CC) -c $(CFLAGS) $(SHAREDLIB_CFLAGS) $(INC) $< -o $@
-$(LIB_fs) : $(OBJ_simfs) lib/logger.lo
- $(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -shared -o $@
+$(LIB_logger) : $(OBJ_logger)
+ $(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -shared -Wl,-soname,$@ -o $@
-libvzctl.a: $(OBJ_libvzctl) $(LIB_fs)
+$(LIB_fs) : $(OBJ_simfs) $(LIB_logger)
+ $(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -shared -Wl,-soname,$@ -o $@
+
+$(LIB_vzctl) : $(OBJ_libvzctl) $(LIB_fs) $(LIB_logger)
+ $(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ $(LD_FLAGS) -shared -Wl,-soname,$@ -o $@
+
+libvzctl.a: $(OBJ_libvzctl) $(OBJ_simfs) $(OBJ_logger)
ar scq $@ $+
ranlib $@
-$(LIB_vzctl) : $(LIB_fs) $(OBJ_libvzctl)
- $(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ $(LD_FLAGS) -shared -o $@
-
vzctl-static: $(OBJ_vzctl) libvzctl.a
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -rdynamic -ldl -lutil -o $@
-vzctl: check-version $(OBJ_vzctl) $(LIB_vzctl) $(LIB_fs)
- $(CC) $(CFLAGS) $(INC) $(LDFLAGS) $(OBJ_vzctl) $(LIB_vzctl) $(LIB_fs) -ldl -lutil -o $@
+vzctl: check-version $(OBJ_vzctl) $(LIB_vzctl) $(LIB_fs) $(LIB_logger)
+ $(CC) $(CFLAGS) $(INC) $(LDFLAGS) $(OBJ_vzctl) $(LIB_vzctl) $(LIB_fs) $(LIB_logger) -ldl -lutil -o $@
-vzlist: $(OBJ_vzlist) $(LIB_vzctl) $(LIB_fs)
+vzlist: $(OBJ_vzlist) $(LIB_vzctl) $(LIB_logger)
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -o $@
arpsend: $(OBJ_arp)
@@ -127,10 +131,10 @@ arpsend: $(OBJ_arp)
vzsplit: $(OBJ_split)
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -o $@
-vzmemcheck: $(OBJ_memcheck) $(LIB_vzctl)
+vzmemcheck: $(OBJ_memcheck) $(LIB_vzctl) $(LIB_logger)
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -o $@
-vzcfgvalidate: $(OBJ_cfgvalidate) $(LIB_vzctl)
+vzcfgvalidate: $(OBJ_cfgvalidate) $(LIB_vzctl) $(LIB_logger)
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -o $@
vzcalc: $(OBJ_calc) $(LIB_vzctl)
@@ -145,6 +149,7 @@ install-lib: $(LIB_vzctl) $(LIB_fs)
$(INSTALL) -d $(DESTDIR)$(LIBSCRIPTSDIR)
$(INSTALL) $(LIB_vzctl) $(DESTDIR)$(LIBDIR)/$(LIB_vzctl)
$(INSTALL) $(LIB_fs) $(DESTDIR)$(LIBDIR)/$(LIB_fs)
+ $(INSTALL) $(LIB_logger) $(DESTDIR)$(LIBDIR)/$(LIB_logger)
for file in $(LIBSCRIPTS); do \
$(INSTALL) -m 755 ../etc/$$file $(DESTDIR)$(LIBSCRIPTSDIR)/$$file; \
done
@@ -208,7 +213,7 @@ inst-dirs:
install: $(PROGS) inst-dirs install-lib inst-sbin inst-scripts \
inst-netscripts inst-configs inst-initd inst-cron
clean:
- rm -f *.o lib/*.lo $(PROGS) $(LIB_vzctl) $(LIB_fs) $(LIB_fs) .depend
+ rm -f *.o lib/*.lo $(PROGS) $(LIB_vzctl) $(LIB_fs) $(LIB_logger) .depend
.depend:: $(OBJ:.o=.c) $(LOBJ:.lo=.c)
$(CC) -M $(FLAGS) $(DEPFLAGS) $(INC) $^ >.depend
diff --git a/src/lib/logger.c b/src/lib/logger.c
index 1b18e8e..8432069 100644
--- a/src/lib/logger.c
+++ b/src/lib/logger.c
@@ -30,7 +30,7 @@ #include <sys/file.h>
#include "types.h"
#include "logger.h"
-extern log_param g_log;
+LOG_DATA
static inline void get_date(char *buf, int len)
{
diff --git a/src/vzcalc.c b/src/vzcalc.c
index 71ff02b..5e09809 100644
--- a/src/vzcalc.c
+++ b/src/vzcalc.c
@@ -27,8 +27,6 @@ #include "ub.h"
#include "config.h"
#include "util.h"
-LOG_DATA
-
void usage()
{
printf("Usage: vzcalc [-v] <veid>\n");
diff --git a/src/vzcfgvalidate.c b/src/vzcfgvalidate.c
index 57f3d92..764b0f0 100644
--- a/src/vzcfgvalidate.c
+++ b/src/vzcfgvalidate.c
@@ -26,8 +26,6 @@ #include "config.h"
#include "validate.h"
#include "logger.h"
-log_param g_log;
-
void usage()
{
printf("Usage: vzcfgvalidate [-r|-i] <configfile>\n");
diff --git a/src/vzctl.c b/src/vzctl.c
index 255f20e..62b36cb 100644
--- a/src/vzctl.c
+++ b/src/vzctl.c
@@ -32,8 +32,6 @@ #include "types.h"
#include "util.h"
#include "modules.h"
-LOG_DATA
-
struct mod_action g_action;
char *_proc_title;
int _proc_title_len;
diff --git a/src/vzlist.c b/src/vzlist.c
index 3e631ea..53bfc5c 100644
--- a/src/vzlist.c
+++ b/src/vzlist.c
@@ -42,7 +42,6 @@ #include "logger.h"
#include "util.h"
#include "types.h"
-LOG_DATA
static struct Cveinfo *veinfo = NULL;
static int n_veinfo = 0;
diff --git a/src/vzmemcheck.c b/src/vzmemcheck.c
index cadeab7..bfe1632 100644
--- a/src/vzmemcheck.c
+++ b/src/vzmemcheck.c
@@ -29,8 +29,6 @@ #include "ub.h"
#include "util.h"
#include "logger.h"
-LOG_DATA
-
void usage()
{
printf("Usage: vzmemcheck [-v] [-A]\n");
diff --git a/vzctl.spec b/vzctl.spec
index 0e3f166..793bd20 100644
--- a/vzctl.spec
+++ b/vzctl.spec
@@ -5,9 +5,10 @@
%define _dumpdir %{_vzdir}/dump
%define _cachedir %{_vzdir}/template/cache
%define _veipdir /var/lib/vzctl/veip
-%define _libdir /usr/lib/vzctl
+%define _libvzdir /usr/lib/vzctl
+%define _libscriptdir %{_libvzdir}/scripts
%define _configdir /etc/vz
-%define _scriptdir /usr/share/vzctl//scripts
+%define _scriptdir /usr/share/vzctl/scripts
%define _vpsconfdir /etc/sysconfig/vz-scripts
%define _netdir /etc/sysconfig/network-scripts
%define _logrdir /etc/logrotate.d
@@ -156,13 +157,17 @@ Virtual Private Servers control API libr
%files lib
%defattr(-,root,root)
-%dir %{_libdir}/lib
-%attr(755,root,root) %{_libdir}/lib/libvzctl.so.*
-%attr(755,root,root) %{_libdir}/lib/libvzctl-simfs.so.*
-%attr(755,root,root) %{_libdir}/scripts/vps-stop
-%attr(755,root,root) %{_libdir}/scripts/vps-functions
-%attr(755,root,root) %{_libdir}/scripts/vps-net_add
-%attr(755,root,root) %{_libdir}/scripts/vps-net_del
-%attr(755,root,root) %{_libdir}/scripts/vps-create
-%attr(755,root,root) %{_libdir}/scripts/vps-postcreate
-
+%attr(755,root,root) %{_libdir}/libvzlogger.so.*
+%attr(755,root,root) %{_libdir}/libvzctl.so.*
+%attr(755,root,root) %{_libdir}/libvzctl-simfs.so.*
+%dir %{_libvzdir}
+%dir %{_libscriptdir}
+%attr(755,root,root) %{_libscriptdir}/vps-stop
+%attr(755,root,root) %{_libscriptdir}/vps-functions
+%attr(755,root,root) %{_libscriptdir}/vps-net_add
+%attr(755,root,root) %{_libscriptdir}/vps-net_del
+%attr(755,root,root) %{_libscriptdir}/vps-create
+%attr(755,root,root) %{_libscriptdir}/vps-postcreate
+
+%post lib -p /sbin/ldconfig
+%postun lib -p /sbin/ldconfig
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/devel/attachments/20060807/d09f6b70/attachment-0001.sig>
More information about the Devel
mailing list