mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
lib: Share common protocol and errnostring libraries with the library and daemon.
This commit, which is just code motion, moves the common XDR protocol code (libprotocol) and the common errno handling (liberrnostring) into libraries which are each built once and shared between the library and daemon.
This commit is contained in:
20
.gitignore
vendored
20
.gitignore
vendored
@@ -116,6 +116,13 @@ Makefile.in
|
||||
/cat/virt-tail
|
||||
/cat/virt-tail.1
|
||||
/ChangeLog
|
||||
/common/errnostring/errnostring.c
|
||||
/common/errnostring/errnostring-gperf.c
|
||||
/common/errnostring/errnostring-gperf.gperf
|
||||
/common/errnostring/errnostring.h
|
||||
/common/protocol/guestfs_protocol.c
|
||||
/common/protocol/guestfs_protocol.h
|
||||
/common/protocol/guestfs_protocol.x
|
||||
/compile
|
||||
/config.cache
|
||||
/config.guess
|
||||
@@ -139,15 +146,9 @@ Makefile.in
|
||||
/customize/virt-customize.1
|
||||
/daemon/actions.h
|
||||
/daemon/dispatch.c
|
||||
/daemon/errnostring.c
|
||||
/daemon/errnostring-gperf.c
|
||||
/daemon/errnostring-gperf.gperf
|
||||
/daemon/errnostring.h
|
||||
/daemon/guestfsd
|
||||
/daemon/guestfsd.8
|
||||
/daemon/guestfsd.exe
|
||||
/daemon/guestfs_protocol.c
|
||||
/daemon/guestfs_protocol.h
|
||||
/daemon/install-sh
|
||||
/daemon/missing
|
||||
/daemon/names.c
|
||||
@@ -495,10 +496,6 @@ Makefile.in
|
||||
/src/actions-?.c
|
||||
/src/actions-variants.c
|
||||
/src/bindtests.c
|
||||
/src/errnostring.c
|
||||
/src/errnostring-gperf.c
|
||||
/src/errnostring-gperf.gperf
|
||||
/src/errnostring.h
|
||||
/src/event-string.c
|
||||
/src/guestfs.3
|
||||
/src/guestfs-actions.pod
|
||||
@@ -506,9 +503,6 @@ Makefile.in
|
||||
/src/guestfs.h
|
||||
/src/guestfs-internal-actions.h
|
||||
/src/guestfs-internal-frontend-cleanups.h
|
||||
/src/guestfs_protocol.c
|
||||
/src/guestfs_protocol.h
|
||||
/src/guestfs_protocol.x
|
||||
/src/guestfs-structs.pod
|
||||
/src/libguestfs.3
|
||||
/src/libguestfs.pc
|
||||
|
||||
@@ -38,6 +38,7 @@ SUBDIRS += gnulib/tests
|
||||
endif
|
||||
|
||||
# Basic source for the library.
|
||||
SUBDIRS += common/errnostring common/protocol
|
||||
SUBDIRS += src docs examples po
|
||||
|
||||
# The daemon and the appliance.
|
||||
|
||||
45
common/errnostring/Makefile.am
Normal file
45
common/errnostring/Makefile.am
Normal file
@@ -0,0 +1,45 @@
|
||||
# libguestfs
|
||||
# Copyright (C) 2017 Red Hat Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
include $(top_srcdir)/subdir-rules.mk
|
||||
|
||||
generator_built = \
|
||||
errnostring-gperf.gperf \
|
||||
errnostring.c \
|
||||
errnostring.h
|
||||
|
||||
BUILT_SOURCES = \
|
||||
$(generator_built) \
|
||||
errnostring-gperf.c
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(BUILT_SOURCES)
|
||||
|
||||
noinst_LTLIBRARIES = liberrnostring.la
|
||||
|
||||
# Build the errnostring perfect hash code. The generated code has lots
|
||||
# of warnings so we must compile it in a separate mini-library.
|
||||
liberrnostring_la_SOURCES = \
|
||||
errnostring-gperf.c \
|
||||
errnostring.h \
|
||||
errnostring.c
|
||||
liberrnostring_la_CFLAGS = $(GCC_VISIBILITY_HIDDEN)
|
||||
|
||||
errnostring-gperf.c: errnostring-gperf.gperf
|
||||
rm -f $@
|
||||
$(GPERF) -t $< > $@-t
|
||||
mv $@-t $@
|
||||
60
common/protocol/Makefile.am
Normal file
60
common/protocol/Makefile.am
Normal file
@@ -0,0 +1,60 @@
|
||||
# libguestfs
|
||||
# Copyright (C) 2017 Red Hat Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
include $(top_srcdir)/subdir-rules.mk
|
||||
|
||||
generator_built = \
|
||||
guestfs_protocol.x
|
||||
|
||||
BUILT_SOURCES = \
|
||||
$(generator_built) \
|
||||
guestfs_protocol.c \
|
||||
guestfs_protocol.h
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(BUILT_SOURCES)
|
||||
|
||||
noinst_LTLIBRARIES = libprotocol.la
|
||||
|
||||
# Because rpcgen generates archaic code, we cannot use ordinary
|
||||
# warnings here.
|
||||
libprotocol_la_SOURCES = guestfs_protocol.c guestfs_protocol.h
|
||||
libprotocol_la_CFLAGS = \
|
||||
-Wall -Wno-unused -fno-strict-aliasing $(GCC_VISIBILITY_HIDDEN)
|
||||
|
||||
if HAVE_RPCGEN
|
||||
RPCGEN_DEFS =
|
||||
if HAVE_XDR_U_INT64_T
|
||||
RPCGEN_DEFS += -DHAVE_XDR_U_INT64_T=1
|
||||
else
|
||||
if HAVE_XDR_UINT64_T
|
||||
RPCGEN_DEFS += -DHAVE_XDR_UINT64_T=1
|
||||
endif
|
||||
endif
|
||||
|
||||
guestfs_protocol.c: guestfs_protocol.x
|
||||
rm -f $@-t $@-t2
|
||||
$(RPCGEN) $(RPCGEN_DEFS) -c -o $@-t $<
|
||||
$(SED) 's,\.\./\(\.\./\)*src,.,' < $@-t > $@-t2
|
||||
rm $@-t
|
||||
mv $@-t2 $@
|
||||
|
||||
guestfs_protocol.h: guestfs_protocol.x
|
||||
rm -f $@-t
|
||||
$(RPCGEN) $(RPCGEN_DEFS) -h -o $@-t $<
|
||||
mv $@-t $@
|
||||
endif
|
||||
@@ -180,6 +180,8 @@ AC_CONFIG_FILES([Makefile
|
||||
builder/test-simplestreams/virt-builder/repos.d/cirros.conf
|
||||
builder/test-website/virt-builder/repos.d/libguestfs.conf
|
||||
cat/Makefile
|
||||
common/errnostring/Makefile
|
||||
common/protocol/Makefile
|
||||
csharp/Makefile
|
||||
customize/Makefile
|
||||
daemon/Makefile
|
||||
|
||||
@@ -30,52 +30,13 @@ generator_built = \
|
||||
stubs-5.c \
|
||||
stubs-6.c
|
||||
|
||||
shared_with_library = \
|
||||
guestfs_protocol.c \
|
||||
guestfs_protocol.h \
|
||||
errnostring-gperf.gperf \
|
||||
errnostring.c \
|
||||
errnostring.h
|
||||
|
||||
BUILT_SOURCES = \
|
||||
$(generator_built) \
|
||||
$(shared_with_library) \
|
||||
errnostring-gperf.c
|
||||
$(generator_built)
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(BUILT_SOURCES) \
|
||||
guestfsd.pod
|
||||
|
||||
$(shared_with_library): %: $(top_srcdir)/src/%
|
||||
rm -f $@
|
||||
ln $< $@
|
||||
|
||||
noinst_LIBRARIES = libprotocol.a
|
||||
|
||||
# This convenience library is solely to compile its generated sources with
|
||||
# custom flags.
|
||||
libprotocol_a_SOURCES = guestfs_protocol.c guestfs_protocol.h
|
||||
libprotocol_a_CFLAGS = -Wall -Wno-unused -fno-strict-aliasing
|
||||
|
||||
$(top_builddir)/src/guestfs_protocol.c: force
|
||||
$(MAKE) -C $(top_builddir)/src guestfs_protocol.c
|
||||
$(top_builddir)/src/guestfs_protocol.h: force
|
||||
$(MAKE) -C $(top_builddir)/src guestfs_protocol.h
|
||||
|
||||
# Build the errnostring perfect hash code. The generated code has lots
|
||||
# of warnings so we must compile it in a separate mini-library.
|
||||
noinst_LIBRARIES += liberrnostring.a
|
||||
liberrnostring_a_SOURCES = \
|
||||
errnostring-gperf.c \
|
||||
errnostring.h \
|
||||
errnostring.c
|
||||
liberrnostring_a_CFLAGS =
|
||||
|
||||
errnostring-gperf.c: errnostring-gperf.gperf
|
||||
rm -f $@
|
||||
$(GPERF) -t $< > $@-t
|
||||
mv $@-t $@
|
||||
|
||||
if INSTALL_DAEMON
|
||||
sbin_PROGRAMS = guestfsd
|
||||
else
|
||||
@@ -83,6 +44,8 @@ noinst_PROGRAMS = guestfsd
|
||||
endif
|
||||
|
||||
guestfsd_SOURCES = \
|
||||
../common/errnostring/errnostring.h \
|
||||
../common/protocol/guestfs_protocol.h \
|
||||
9p.c \
|
||||
acl.c \
|
||||
actions.h \
|
||||
@@ -204,8 +167,8 @@ guestfsd_SOURCES = \
|
||||
zerofree.c
|
||||
|
||||
guestfsd_LDADD = \
|
||||
liberrnostring.a \
|
||||
libprotocol.a \
|
||||
../common/errnostring/liberrnostring.la \
|
||||
../common/protocol/libprotocol.la \
|
||||
$(ACL_LIBS) \
|
||||
$(CAP_LIBS) \
|
||||
$(YAJL_LIBS) \
|
||||
@@ -228,7 +191,11 @@ guestfsd_CPPFLAGS = \
|
||||
-I$(top_srcdir)/gnulib/lib \
|
||||
-I$(top_builddir)/gnulib/lib \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_builddir)/src
|
||||
-I$(top_builddir)/src \
|
||||
-I$(top_srcdir)/common/errnostring \
|
||||
-I$(top_builddir)/common/errnostring \
|
||||
-I$(top_srcdir)/common/protocol \
|
||||
-I$(top_builddir)/common/protocol
|
||||
guestfsd_CFLAGS = \
|
||||
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
|
||||
$(AUGEAS_CFLAGS) \
|
||||
|
||||
@@ -76,6 +76,26 @@ L<virt-builder(1)> command and documentation.
|
||||
The L<virt-cat(1)>, L<virt-filesystems(1)>, L<virt-log(1)>,
|
||||
L<virt-ls(1)> and L<virt-tail(1)> commands and documentation.
|
||||
|
||||
=item F<common>
|
||||
|
||||
Various libraries of internal code can be found in the F<common>
|
||||
subdirectory:
|
||||
|
||||
=over 4
|
||||
|
||||
=item F<common/errnostring>
|
||||
|
||||
The communication protocol used between the library and the daemon
|
||||
running inside the appliance has to encode errnos as strings, which is
|
||||
handled by this library.
|
||||
|
||||
=item F<common/protocol>
|
||||
|
||||
The XDR-based communication protocol used between the library
|
||||
and the daemon running inside the appliance is defined here.
|
||||
|
||||
=back
|
||||
|
||||
=item F<contrib>
|
||||
|
||||
Outside contributions, experimental parts.
|
||||
|
||||
@@ -209,7 +209,7 @@ The protocol used to talk between the library and the daemon running
|
||||
inside the qemu virtual machine is a simple RPC mechanism built on top
|
||||
of XDR (RFC 1014, RFC 1832, RFC 4506).
|
||||
|
||||
The detailed format of structures is in F<src/guestfs_protocol.x>
|
||||
The detailed format of structures is in F<common/protocol/guestfs_protocol.x>
|
||||
(note: this file is automatically generated).
|
||||
|
||||
There are two broad cases, ordinary functions that don't have any
|
||||
|
||||
@@ -94,7 +94,11 @@ Run it from the top source directory using the command
|
||||
perror "lock: BUGS" exn;
|
||||
exit 1);
|
||||
|
||||
output_to "src/guestfs_protocol.x" generate_xdr;
|
||||
output_to "common/errnostring/errnostring-gperf.gperf"
|
||||
generate_errnostring_gperf;
|
||||
output_to "common/errnostring/errnostring.c" generate_errnostring_c;
|
||||
output_to "common/errnostring/errnostring.h" generate_errnostring_h;
|
||||
output_to "common/protocol/guestfs_protocol.x" generate_xdr;
|
||||
output_to "src/guestfs.h" generate_guestfs_h;
|
||||
output_to "src/guestfs-internal-actions.h" generate_internal_actions_h;
|
||||
output_to "src/guestfs-internal-frontend-cleanups.h"
|
||||
@@ -103,9 +107,6 @@ Run it from the top source directory using the command
|
||||
output_to "src/guestfs-structs.pod" generate_structs_pod;
|
||||
output_to "src/guestfs-actions.pod" generate_actions_pod;
|
||||
output_to "src/guestfs-availability.pod" generate_availability_pod;
|
||||
output_to "src/errnostring-gperf.gperf" generate_errnostring_gperf;
|
||||
output_to "src/errnostring.c" generate_errnostring_c;
|
||||
output_to "src/errnostring.h" generate_errnostring_h;
|
||||
output_to "src/event-string.c" generate_event_string_c;
|
||||
output_to "src/MAX_PROC_NR" generate_max_proc_nr;
|
||||
output_to "src/libguestfs.syms" generate_linker_script;
|
||||
|
||||
@@ -50,7 +50,7 @@ AM_CONDITIONAL([HAVE_OCAMLDOC],
|
||||
|
||||
dnl OCaml is required if we need to run the generator.
|
||||
AS_IF([test "x$OCAMLC" = "xno" || test "x$OCAMLFIND" = "xno"],[
|
||||
AS_IF([! test -f $srcdir/src/guestfs_protocol.x],[
|
||||
AS_IF([! test -f $srcdir/common/protocol/guestfs_protocol.x],[
|
||||
AC_MSG_FAILURE([OCaml compiler and findlib is required to build from git.
|
||||
If you don't have OCaml available, you should build from a tarball from
|
||||
http://libguestfs.org/download])
|
||||
|
||||
@@ -13,6 +13,8 @@ cat/log.c
|
||||
cat/ls.c
|
||||
cat/tail.c
|
||||
cat/visit.c
|
||||
common/errnostring/errnostring-gperf.c
|
||||
common/errnostring/errnostring.c
|
||||
customize/crypt-c.c
|
||||
customize/dummy.c
|
||||
customize/perl_edit-c.c
|
||||
@@ -46,8 +48,6 @@ daemon/dmesg.c
|
||||
daemon/dropcaches.c
|
||||
daemon/du.c
|
||||
daemon/echo-daemon.c
|
||||
daemon/errnostring-gperf.c
|
||||
daemon/errnostring.c
|
||||
daemon/ext2.c
|
||||
daemon/fallocate.c
|
||||
daemon/file.c
|
||||
@@ -395,8 +395,6 @@ src/copy-in-out.c
|
||||
src/create.c
|
||||
src/dbdump.c
|
||||
src/drives.c
|
||||
src/errnostring-gperf.c
|
||||
src/errnostring.c
|
||||
src/errors.c
|
||||
src/event-string.c
|
||||
src/events.c
|
||||
|
||||
@@ -20,7 +20,6 @@ include $(top_srcdir)/subdir-rules.mk
|
||||
noinst_PROGRAMS =
|
||||
|
||||
generator_built = \
|
||||
guestfs_protocol.x \
|
||||
guestfs.h \
|
||||
guestfs-internal-actions.h \
|
||||
guestfs-internal-frontend-cleanups.h \
|
||||
@@ -33,9 +32,6 @@ generator_built = \
|
||||
actions-6.c \
|
||||
actions-variants.c \
|
||||
bindtests.c \
|
||||
errnostring-gperf.gperf \
|
||||
errnostring.c \
|
||||
errnostring.h \
|
||||
event-string.c \
|
||||
guestfs-actions.pod \
|
||||
guestfs-availability.pod \
|
||||
@@ -49,10 +45,7 @@ generator_built = \
|
||||
structs-print.h
|
||||
|
||||
BUILT_SOURCES = \
|
||||
$(generator_built) \
|
||||
guestfs_protocol.c \
|
||||
guestfs_protocol.h \
|
||||
errnostring-gperf.c
|
||||
$(generator_built)
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(BUILT_SOURCES) \
|
||||
@@ -65,12 +58,13 @@ include_HEADERS = guestfs.h
|
||||
lib_LTLIBRARIES = libguestfs.la
|
||||
|
||||
libguestfs_la_SOURCES = \
|
||||
../common/errnostring/errnostring.h \
|
||||
../common/protocol/guestfs_protocol.h \
|
||||
guestfs.h \
|
||||
guestfs-internal.h \
|
||||
guestfs-internal-all.h \
|
||||
guestfs-internal-frontend.h \
|
||||
guestfs-internal-frontend-cleanups.h \
|
||||
guestfs_protocol.h \
|
||||
actions-0.c \
|
||||
actions-1.c \
|
||||
actions-2.c \
|
||||
@@ -143,6 +137,8 @@ libguestfs_la_CPPFLAGS = \
|
||||
-DGUESTFS_WARN_DEPRECATED=1 \
|
||||
-DGUESTFS_PRIVATE=1 \
|
||||
-DLIBOSINFO_DB_PATH='"$(datadir)/libosinfo/db"' \
|
||||
-I$(top_srcdir)/common/errnostring -I$(top_builddir)/common/errnostring \
|
||||
-I$(top_srcdir)/common/protocol -I$(top_builddir)/common/protocol \
|
||||
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib
|
||||
|
||||
libguestfs_la_CFLAGS = \
|
||||
@@ -154,8 +150,8 @@ libguestfs_la_CFLAGS = \
|
||||
$(YAJL_CFLAGS)
|
||||
|
||||
libguestfs_la_LIBADD = \
|
||||
liberrnostring.la \
|
||||
libprotocol.la \
|
||||
../common/errnostring/liberrnostring.la \
|
||||
../common/protocol/libprotocol.la \
|
||||
libutils.la \
|
||||
$(PCRE_LIBS) $(MAGIC_LIBS) \
|
||||
$(LIBVIRT_LIBS) $(LIBXML2_LIBS) \
|
||||
@@ -184,53 +180,10 @@ libguestfs_la_CFLAGS += $(FUSE_CFLAGS)
|
||||
libguestfs_la_LIBADD += $(FUSE_LIBS)
|
||||
endif
|
||||
|
||||
# Convenience libraries.
|
||||
noinst_LTLIBRARIES = liberrnostring.la libprotocol.la libutils.la
|
||||
|
||||
# Build the errnostring perfect hash code. The generated code has lots
|
||||
# of warnings so we must compile it in a separate mini-library.
|
||||
liberrnostring_la_SOURCES = \
|
||||
errnostring-gperf.c \
|
||||
errnostring.h \
|
||||
errnostring.c
|
||||
liberrnostring_la_CFLAGS = $(GCC_VISIBILITY_HIDDEN)
|
||||
|
||||
errnostring-gperf.c: errnostring-gperf.gperf
|
||||
rm -f $@
|
||||
$(GPERF) -t $< > $@-t
|
||||
mv $@-t $@
|
||||
|
||||
# This convenience library is solely to compile its generated sources with
|
||||
# custom flags.
|
||||
libprotocol_la_SOURCES = guestfs_protocol.c guestfs_protocol.h
|
||||
libprotocol_la_CFLAGS = \
|
||||
-Wall -Wno-unused -fno-strict-aliasing $(GCC_VISIBILITY_HIDDEN)
|
||||
|
||||
if HAVE_RPCGEN
|
||||
RPCGEN_DEFS =
|
||||
if HAVE_XDR_U_INT64_T
|
||||
RPCGEN_DEFS += -DHAVE_XDR_U_INT64_T=1
|
||||
else
|
||||
if HAVE_XDR_UINT64_T
|
||||
RPCGEN_DEFS += -DHAVE_XDR_UINT64_T=1
|
||||
endif
|
||||
endif
|
||||
|
||||
guestfs_protocol.c: guestfs_protocol.x
|
||||
rm -f $@-t $@-t2
|
||||
$(RPCGEN) $(RPCGEN_DEFS) -c -o $@-t $<
|
||||
$(SED) 's,\.\./\(\.\./\)*src,.,' < $@-t > $@-t2
|
||||
rm $@-t
|
||||
mv $@-t2 $@
|
||||
|
||||
guestfs_protocol.h: guestfs_protocol.x
|
||||
rm -f $@-t
|
||||
$(RPCGEN) $(RPCGEN_DEFS) -h -o $@-t $<
|
||||
mv $@-t $@
|
||||
endif
|
||||
|
||||
# libutils.la contains code outside libguestfs which is also
|
||||
# included in tools and bindings.
|
||||
noinst_LTLIBRARIES = libutils.la
|
||||
|
||||
libutils_la_SOURCES = \
|
||||
cleanup.c \
|
||||
structs-cleanup.c \
|
||||
|
||||
@@ -41,10 +41,12 @@ TESTS = \
|
||||
check_PROGRAMS = test-error-messages
|
||||
|
||||
test_error_messages_SOURCES = \
|
||||
../../common/protocol/guestfs_protocol.h \
|
||||
test-error-messages.c
|
||||
test_error_messages_CPPFLAGS = \
|
||||
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
|
||||
-I$(top_srcdir)/src -I$(top_builddir)/src
|
||||
-I$(top_srcdir)/src -I$(top_builddir)/src \
|
||||
-I$(top_srcdir)/common/protocol -I$(top_builddir)/common/protocol
|
||||
test_error_messages_CFLAGS = \
|
||||
$(WARN_CFLAGS) $(WERROR_CFLAGS)
|
||||
test_error_messages_LDADD = \
|
||||
|
||||
Reference in New Issue
Block a user