The admin server functionality is a generic concept that should be wired
up into all libvirt daemons, but is currently integrated with the
libvirtd code. Move it all into the src/admin directory to prepare for
broader reuse.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
.gitignore | 1 +
cfg.mk | 9 +++---
daemon/Makefile.am | 33 +---------------------
daemon/libvirtd.c | 2 +-
daemon/libvirtd.h | 10 -------
po/POTFILES.in | 6 ++--
src/Makefile.am | 31 +++++++++++++++++++-
{daemon => src/admin}/admin_server.c | 4 +--
{daemon => src/admin}/admin_server.h | 6 ++--
.../admin.c => src/admin/admin_server_dispatch.c | 21 +++++++++-----
.../admin.h => src/admin/admin_server_dispatch.h | 9 +++---
11 files changed, 65 insertions(+), 67 deletions(-)
rename {daemon => src/admin}/admin_server.c (99%)
rename {daemon => src/admin}/admin_server.h (96%)
rename daemon/admin.c => src/admin/admin_server_dispatch.c (96%)
rename daemon/admin.h => src/admin/admin_server_dispatch.h (83%)
diff --git a/.gitignore b/.gitignore
index e2eaff1724..189116a3d0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -123,6 +123,7 @@
/src/access/viraccessapicheckqemu.h
/src/admin/admin_client.h
/src/admin/admin_protocol.[ch]
+/src/admin/admin_server_dispatch_stubs.h
/src/esx/*.generated.*
/src/hyperv/*.generated.*
/src/libvirt*.def
diff --git a/cfg.mk b/cfg.mk
index 5cdeb7c650..1a5de2b154 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -33,6 +33,7 @@ gnulib_dir = $(srcdir)/.gnulib
# This is all gnulib files, as well as generated files for RPC code.
generated_files = \
$(srcdir)/daemon/*_dispatch.h \
+ $(srcdir)/src/*/*_dispatch_stubs.h \
$(srcdir)/src/*/*_dispatch.h \
$(srcdir)/src/remote/*_client_bodies.h \
$(srcdir)/src/*/*_protocol.[ch] \
@@ -768,7 +769,7 @@ sc_prohibit_gettext_markup:
# lower-level code must not include higher-level headers.
cross_dirs=$(patsubst $(srcdir)/src/%.,%,$(wildcard $(srcdir)/src/*/.))
cross_dirs_re=($(subst / ,/|,$(cross_dirs)))
-mid_dirs=access|conf|cpu|locking|logging|network|node_device|rpc|security|storage
+mid_dirs=access|admin|conf|cpu|locking|logging|network|node_device|rpc|security|storage
sc_prohibit_cross_inclusion:
@for dir in $(cross_dirs); do \
case $$dir in \
@@ -1119,7 +1120,7 @@ sc_po_check: \
$(srcdir)/daemon/remote_dispatch.h \
$(srcdir)/daemon/qemu_dispatch.h \
$(srcdir)/src/remote/remote_client_bodies.h \
- $(srcdir)/daemon/admin_dispatch.h \
+ $(srcdir)/src/admin/admin_server_dispatch_stubs.h \
$(srcdir)/src/admin/admin_client.h
$(srcdir)/daemon/remote_dispatch.h: $(srcdir)/src/remote/remote_protocol.x
$(MAKE) -C daemon remote_dispatch.h
@@ -1127,8 +1128,8 @@ $(srcdir)/daemon/qemu_dispatch.h:
$(srcdir)/src/remote/qemu_protocol.x
$(MAKE) -C daemon qemu_dispatch.h
$(srcdir)/src/remote/remote_client_bodies.h: $(srcdir)/src/remote/remote_protocol.x
$(MAKE) -C src remote/remote_client_bodies.h
-$(srcdir)/daemon/admin_dispatch.h: $(srcdir)/src/admin/admin_protocol.x
- $(MAKE) -C daemon admin_dispatch.h
+$(srcdir)/src/admin/admin_server_dispatch_stubs.h: $(srcdir)/src/admin/admin_protocol.x
+ $(MAKE) -C src admin/admin_server_dispatch_stubs.h
$(srcdir)/src/admin/admin_client.h: $(srcdir)/src/admin/admin_protocol.x
$(MAKE) -C src admin/admin_client.h
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index b0c28d2313..efd5ff19f5 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -37,7 +37,6 @@ DAEMON_GENERATED = \
remote_dispatch.h \
lxc_dispatch.h \
qemu_dispatch.h \
- admin_dispatch.h \
$(NULL)
DAEMON_SOURCES = \
@@ -61,7 +60,6 @@ EXTRA_DIST = \
remote_dispatch.h \
lxc_dispatch.h \
qemu_dispatch.h \
- admin_dispatch.h \
libvirtd.conf \
libvirtd.init.in \
libvirtd.upstart \
@@ -111,12 +109,6 @@ qemu_dispatch.h: $(top_srcdir)/src/rpc/gendispatch.pl \
--mode=server qemu QEMU $(QEMU_PROTOCOL) \
$(srcdir)/qemu_dispatch.h
-admin_dispatch.h: $(top_srcdir)/src/rpc/gendispatch.pl \
- $(ADMIN_PROTOCOL)
- $(AM_V_GEN)$(PERL) -w $(top_srcdir)/src/rpc/gendispatch.pl \
- --mode=server admin ADMIN $(ADMIN_PROTOCOL) \
- > $(srcdir)/admin_dispatch.h
-
if WITH_LIBVIRTD
# Build a convenience library, for reuse in tests/libvirtdconftest
@@ -136,27 +128,6 @@ libvirtd_conf_la_LDFLAGS = \
$(NULL)
libvirtd_conf_la_LIBADD = $(LIBXML_LIBS)
-noinst_LTLIBRARIES += libvirtd_admin.la
-libvirtd_admin_la_SOURCES = \
- admin.c admin.h admin_server.c admin_server.h
-
-libvirtd_admin_la_CFLAGS = \
- $(AM_CFLAGS) \
- $(XDR_CFLAGS) \
- $(PIE_CFLAGS) \
- $(WARN_CFLAGS) \
- $(LIBXML_CFLAGS) \
- $(COVERAGE_CFLAGS) \
- $(NULL)
-libvirtd_admin_la_LDFLAGS = \
- $(PIE_LDFLAGS) \
- $(RELRO_LDFLAGS) \
- $(COVERAGE_LDFLAGS) \
- $(NO_INDIRECT_LDFLAGS) \
- $(NULL)
-libvirtd_admin_la_LIBADD = \
- ../src/libvirt-admin.la
-
man8_MANS = libvirtd.8
sbin_PROGRAMS = libvirtd
@@ -202,7 +173,7 @@ endif WITH_DTRACE_PROBES
libvirtd_LDADD += \
libvirtd_conf.la \
- libvirtd_admin.la \
+ ../src/libvirt_driver_admin.la \
../src/libvirt-lxc.la \
../src/libvirt-qemu.la \
../src/libvirt_driver_remote.la \
@@ -269,8 +240,6 @@ endif ! WITH_POLKIT
remote.c: $(DAEMON_GENERATED)
remote.h: $(DAEMON_GENERATED)
-admin.c: $(DAEMON_GENERATED)
-admin.h: $(DAEMON_GENERATED)
LOGROTATE_CONFS = libvirtd.qemu.logrotate libvirtd.lxc.logrotate \
libvirtd.libxl.logrotate libvirtd.uml.logrotate \
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 6d3b83355b..48bdc27a5f 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -43,7 +43,7 @@
#include "libvirtd.h"
#include "libvirtd-config.h"
-#include "admin.h"
+#include "admin/admin_server_dispatch.h"
#include "viruuid.h"
#include "remote_driver.h"
#include "viralloc.h"
diff --git a/daemon/libvirtd.h b/daemon/libvirtd.h
index b5707461fe..082c4bc4df 100644
--- a/daemon/libvirtd.h
+++ b/daemon/libvirtd.h
@@ -30,7 +30,6 @@
# include <rpc/types.h>
# include <rpc/xdr.h>
# include "remote_protocol.h"
-# include "admin_protocol.h"
# include "lxc_protocol.h"
# include "qemu_protocol.h"
# include "virthread.h"
@@ -44,8 +43,6 @@ typedef struct daemonClientStream daemonClientStream;
typedef daemonClientStream *daemonClientStreamPtr;
typedef struct daemonClientPrivate daemonClientPrivate;
typedef daemonClientPrivate *daemonClientPrivatePtr;
-typedef struct daemonAdmClientPrivate daemonAdmClientPrivate;
-typedef daemonAdmClientPrivate *daemonAdmClientPrivatePtr;
typedef struct daemonClientEventCallback daemonClientEventCallback;
typedef daemonClientEventCallback *daemonClientEventCallbackPtr;
@@ -81,13 +78,6 @@ struct daemonClientPrivate {
daemonClientStreamPtr streams;
};
-/* Separate private data for admin connection */
-struct daemonAdmClientPrivate {
- /* Just a placeholder, not that there is anything to be locked */
- virMutex lock;
-
- virNetDaemonPtr dmn;
-};
# if WITH_SASL
extern virNetSASLContextPtr saslCtxt;
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c1fa23427e..daf9a78a1d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,3 @@
-daemon/admin.c
-daemon/admin_dispatch.h
-daemon/admin_server.c
daemon/libvirtd-config.c
daemon/libvirtd.c
daemon/qemu_dispatch.h
@@ -12,6 +9,9 @@ gnulib/lib/getopt.c
gnulib/lib/regcomp.c
src/access/viraccessdriverpolkit.c
src/access/viraccessmanager.c
+src/admin/admin_server.c
+src/admin/admin_server_dispatch.c
+src/admin/admin_server_dispatch_stubs.h
src/bhyve/bhyve_capabilities.c
src/bhyve/bhyve_command.c
src/bhyve/bhyve_device.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 166c9a8e91..fd8756f10c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -546,7 +546,9 @@ ADMIN_PROTOCOL = $(srcdir)/admin/admin_protocol.x
ADMIN_PROTOCOL_GENERATED = \
admin/admin_protocol.c \
admin/admin_protocol.h \
- admin/admin_client.h
+ admin/admin_client.h \
+ admin/admin_server_dispatch_stubs.h \
+ $(NULL)
admin/admin_client.h: $(srcdir)/rpc/gendispatch.pl \
$(ADMIN_PROTOCOL) Makefile.am
@@ -554,6 +556,12 @@ admin/admin_client.h: $(srcdir)/rpc/gendispatch.pl \
admin ADMIN $(ADMIN_PROTOCOL) \
$(srcdir)/admin/admin_client.h
+admin/admin_server_dispatch_stubs.h: $(srcdir)/rpc/gendispatch.pl \
+ $(ADMIN_PROTOCOL) Makefile.am
+ $(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=server \
+ admin ADMIN $(ADMIN_PROTOCOL) \
+ > $(srcdir)/admin/admin_server_dispatch_stubs.h
+
EXTRA_DIST += $(ADMIN_PROTOCOL) $(ADMIN_PROTOCOL_GENERATED)
BUILT_SOURCES += $(ADMIN_PROTOCOL_GENERATED)
MAINTAINERCLEANFILES += $(ADMIN_PROTOCOL_GENERATED)
@@ -2314,6 +2322,27 @@ libvirt_admin.syms: libvirt_admin_public.syms $(ADMIN_SYM_FILES) \
chmod a-w $@-tmp && \
mv $@-tmp libvirt_admin.syms
+
+admin/admin_server_dispatch.c: admin/admin_server_dispatch_stubs.h
+
+noinst_LTLIBRARIES += libvirt_driver_admin.la
+libvirt_driver_admin_la_SOURCES = \
+ admin/admin_protocol.c \
+ admin/admin_protocol.h \
+ admin/admin_server.c \
+ admin/admin_server.h \
+ admin/admin_server_dispatch.c \
+ admin/admin_server_dispatch.h \
+ admin/admin_server_dispatch_stubs.h \
+ $(NULL)
+libvirt_driver_admin_la_CFLAGS = \
+ $(AM_CFLAGS) \
+ -I$(top_srcdir)/src/util \
+ -I$(top_srcdir)/src/admin \
+ $(NULL)
+libvirt_driver_admin_la_LIBADD = ../gnulib/lib/libgnu.la
+libvirt_driver_admin_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
+
# admin/admin_remote.c is being included in libvirt-admin.c, so we
# need to include it in the dist
EXTRA_DIST += admin/admin_remote.c
diff --git a/daemon/admin_server.c b/src/admin/admin_server.c
similarity index 99%
rename from daemon/admin_server.c
rename to src/admin/admin_server.c
index d8a3323e39..f2c1a8f8ec 100644
--- a/daemon/admin_server.c
+++ b/src/admin/admin_server.c
@@ -29,8 +29,8 @@
#include "virerror.h"
#include "viridentity.h"
#include "virlog.h"
-#include "virnetdaemon.h"
-#include "virnetserver.h"
+#include "rpc/virnetdaemon.h"
+#include "rpc/virnetserver.h"
#include "virstring.h"
#include "virthreadpool.h"
#include "virtypedparam.h"
diff --git a/daemon/admin_server.h b/src/admin/admin_server.h
similarity index 96%
rename from daemon/admin_server.h
rename to src/admin/admin_server.h
index 0baffa7ece..3e0c35fa29 100644
--- a/daemon/admin_server.h
+++ b/src/admin/admin_server.h
@@ -21,8 +21,8 @@
* Martin Kletzander <mkletzan(a)redhat.com>
*/
-#ifndef __LIBVIRTD_ADMIN_SERVER_H__
-# define __LIBVIRTD_ADMIN_SERVER_H__
+#ifndef __ADMIN_SERVER_H__
+# define __ADMIN_SERVER_H__
# include "rpc/virnetdaemon.h"
# include "rpc/virnetserver.h"
@@ -72,4 +72,4 @@ int adminServerSetClientLimits(virNetServerPtr srv,
int nparams,
unsigned int flags);
-#endif /* __LIBVIRTD_ADMIN_SERVER_H__ */
+#endif /* __ADMIN_SERVER_H__ */
diff --git a/daemon/admin.c b/src/admin/admin_server_dispatch.c
similarity index 96%
rename from daemon/admin.c
rename to src/admin/admin_server_dispatch.c
index baf310c7bb..068358b049 100644
--- a/daemon/admin.c
+++ b/src/admin/admin_server_dispatch.c
@@ -1,5 +1,5 @@
/*
- * admin.c: handlers for admin RPC method calls
+ * admin_server_dispatch.c: handlers for admin RPC method calls
*
* Copyright (C) 2014-2016 Red Hat, Inc.
*
@@ -23,18 +23,16 @@
#include <config.h>
#include "internal.h"
-#include "libvirtd.h"
#include "libvirt_internal.h"
-#include "admin_protocol.h"
-#include "admin.h"
+#include "admin_server_dispatch.h"
#include "admin_server.h"
#include "datatypes.h"
#include "viralloc.h"
#include "virerror.h"
#include "virlog.h"
-#include "virnetdaemon.h"
-#include "virnetserver.h"
+#include "rpc/virnetdaemon.h"
+#include "rpc/virnetserver.h"
#include "virstring.h"
#include "virthreadjob.h"
#include "virtypedparam.h"
@@ -43,6 +41,15 @@
VIR_LOG_INIT("daemon.admin");
+typedef struct daemonAdmClientPrivate daemonAdmClientPrivate;
+typedef daemonAdmClientPrivate *daemonAdmClientPrivatePtr;
+/* Separate private data for admin connection */
+struct daemonAdmClientPrivate {
+ /* Just a placeholder, not that there is anything to be locked */
+ virMutex lock;
+
+ virNetDaemonPtr dmn;
+};
void
remoteAdmClientFreeFunc(void *data)
@@ -487,4 +494,4 @@ adminDispatchConnectGetLoggingFilters(virNetServerPtr server
ATTRIBUTE_UNUSED,
return 0;
}
-#include "admin_dispatch.h"
+#include "admin_server_dispatch_stubs.h"
diff --git a/daemon/admin.h b/src/admin/admin_server_dispatch.h
similarity index 83%
rename from daemon/admin.h
rename to src/admin/admin_server_dispatch.h
index c869cc7aab..01723e5c43 100644
--- a/daemon/admin.h
+++ b/src/admin/admin_server_dispatch.h
@@ -1,5 +1,5 @@
/*
- * admin.h: handlers for admin RPC method calls
+ * admin_server_dispatch.h: handlers for admin RPC method calls
*
* Copyright (C) 2014-2016 Red Hat, Inc.
*
@@ -20,11 +20,12 @@
* Author: Martin Kletzander <mkletzan(a)redhat.com>
*/
-#ifndef __LIBVIRTD_ADMIN_H__
-# define __LIBVIRTD_ADMIN_H__
+#ifndef __ADMIN_SERVER_DISPATCH_H__
+# define __ADMIN_SERVER_DISPATCH_H__
# include "rpc/virnetserverprogram.h"
# include "rpc/virnetserverclient.h"
+# include "admin/admin_protocol.h"
extern virNetServerProgramProc adminProcs[];
@@ -33,4 +34,4 @@ extern size_t adminNProcs;
void remoteAdmClientFreeFunc(void *data);
void *remoteAdmClientInitHook(virNetServerClientPtr client, void *opaque);
-#endif /* __ADMIN_REMOTE_H__ */
+#endif /* __ADMIN_SERVER_DISPATCH_H__ */
--
2.14.3