Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- meson.build | 1 + scripts/check-remote-protocol.py | 75 +++++++++++--------------------- src/Makefile.am | 61 -------------------------- src/admin/meson.build | 7 +++ src/locking/meson.build | 7 +++ src/lxc/meson.build | 7 +++ src/meson.build | 23 ++++++++++ src/remote/meson.build | 21 +++++++++ src/rpc/meson.build | 14 ++++++ 9 files changed, 106 insertions(+), 110 deletions(-) diff --git a/meson.build b/meson.build index 457d752ffb5..eb659c64aa0 100644 --- a/meson.build +++ b/meson.build @@ -920,6 +920,7 @@ optional_programs = [ 'mm-ctl', 'modprobe', 'ovs-vsctl', + 'pdwtags', 'radvd', 'rmmod', 'scrub', diff --git a/scripts/check-remote-protocol.py b/scripts/check-remote-protocol.py index e28fb80cdd1..00b8570f9bb 100644 --- a/scripts/check-remote-protocol.py +++ b/scripts/check-remote-protocol.py @@ -31,55 +31,32 @@ import re import subprocess import sys -cc = sys.argv[1] -proto_lo = sys.argv[2] -expected = sys.argv[3] - -proto_lo = proto_lo.replace("/", "/.libs/") - -ccargv = cc.split(" ") -ccargv.append("-v") -ccproc = subprocess.Popen(ccargv, stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) -out, err = ccproc.communicate() -out = out.decode("utf-8") -if out.find("clang") != -1: - print("WARNING: skipping pdwtags test with Clang", file=sys.stderr) - sys.exit(0) - - -def which(program): - def is_exe(fpath): - return (os.path.isfile(fpath) and - os.access(fpath, os.X_OK)) - - fpath, fname = os.path.split(program) - if fpath: - if is_exe(program): - return program - else: - for path in os.environ["PATH"].split(os.pathsep): - exe_file = os.path.join(path, program) - if is_exe(exe_file): - return exe_file - - return None - - -pdwtags = which("pdwtags") -if pdwtags is None: - print("WARNING: you lack pdwtags; skipping the protocol test", - file=sys.stderr) - print("WARNING: install the dwarves package to get pdwtags", - file=sys.stderr) - sys.exit(0) - -proto_o = proto_lo.replace(".lo", ".o") - -if not os.path.exists(proto_o): - raise Exception("Missing %s", proto_o) - -pdwtagsproc = subprocess.Popen(["pdwtags", "--verbose", proto_o], +name = sys.argv[1] +libname = sys.argv[2] +builddir = sys.argv[3] +pdwtags = sys.argv[4] +expected = sys.argv[5] + + +def get_subdir(dirname, subdir): + objectdir = "" + reg = re.compile(subdir) + for d in os.listdir(path=dirname): + if reg.match(d): + objectdir = d + break + + if objectdir == "": + raise Exception("Failed to find '{0}' in '{1}'".format(subdir, dirname)) + + return os.path.join(dirname, objectdir) + + +objectdir = get_subdir(builddir, r'.*@{0}@.*'.format(libname)) + +proto_o = get_subdir(objectdir, r'.*{0}\.c\.o'.format(name)) + +pdwtagsproc = subprocess.Popen([pdwtags, "--verbose", proto_o], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = pdwtagsproc.communicate() out = out.decode("utf-8") diff --git a/src/Makefile.am b/src/Makefile.am index 7289f247362..33e32506525 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,65 +20,4 @@ # here. List them against the individual XXX_la_CFLAGS targets # that actually use them. -RPC_PROBE_FILES = - include admin/Makefile.inc.am - - -# Keep this list synced with RPC_PROBE_FILES -PROTOCOL_STRUCTS = \ - $(srcdir)/remote_protocol-structs \ - $(srcdir)/lxc_protocol-structs \ - $(srcdir)/qemu_protocol-structs \ - $(srcdir)/virnetprotocol-structs \ - $(srcdir)/virkeepaliveprotocol-structs \ - $(srcdir)/lxc_monitor_protocol-structs \ - $(srcdir)/lock_protocol-structs \ - $(srcdir)/admin_protocol-structs \ - $(NULL) - -if WITH_REMOTE -check-protocol: $(PROTOCOL_STRUCTS) $(PROTOCOL_STRUCTS:structs=struct) - -# Ensure that we don't change the struct or member names or member ordering -# in remote_protocol.x The check-remote-protocol.py script post-processes -# output to extract the bits we want. - -CHECK_REMOTE_PROTOCOL = $(top_srcdir)/scripts/check-remote-protocol.py - -# The .o file that pdwtags parses is created as a side effect of running -# libtool; but from make's perspective we depend on the .lo file. -$(srcdir)/remote_protocol-struct \ - $(srcdir)/qemu_protocol-struct \ - $(srcdir)/lxc_protocol-struct: \ - $(srcdir)/%-struct: remote/libvirt_driver_remote_la-%.lo - $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(CHECK_REMOTE_PROTOCOL) \ - "$(CC)" $< $(@)s -$(srcdir)/virnetprotocol-struct $(srcdir)/virkeepaliveprotocol-struct: \ - $(srcdir)/%-struct: rpc/libvirt_net_rpc_la-%.lo - $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(CHECK_REMOTE_PROTOCOL) \ - "$(CC)" $< $(@)s -if WITH_LXC -$(srcdir)/lxc_monitor_protocol-struct: \ - $(srcdir)/%-struct: lxc/libvirt_driver_lxc_impl_la-%.lo - $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(CHECK_REMOTE_PROTOCOL) \ - "$(CC)" $< $(@)s -endif WITH_LXC -$(srcdir)/lock_protocol-struct: \ - $(srcdir)/%-struct: locking/lockd_la-%.lo - $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(CHECK_REMOTE_PROTOCOL) \ - "$(CC)" $< $(@)s -$(srcdir)/admin_protocol-struct: \ - $(srcdir)/%-struct: admin/libvirt_admin_la-%.lo - $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(CHECK_REMOTE_PROTOCOL) \ - "$(CC)" $< $(@)s - -else !WITH_REMOTE -# The $(PROTOCOL_STRUCTS) files must live in git, because they cannot be -# re-generated when configured --without-remote. -check-protocol: -endif !WITH_REMOTE - -check-local: check-protocol \ - check-admin -.PHONY: check-protocol $(PROTOCOL_STRUCTS:structs=struct) diff --git a/src/admin/meson.build b/src/admin/meson.build index 330fe2f98d1..5652a58e0fb 100644 --- a/src/admin/meson.build +++ b/src/admin/meson.build @@ -94,6 +94,13 @@ admin_driver_lib = static_library( libvirt_libs += admin_driver_lib +check_protocols += { + 'name': 'admin_protocol', + 'libname': 'virt_admin_driver', + 'builddir': meson.current_build_dir(), + 'depends': admin_driver_lib, +} + virt_conf_files += files('libvirt-admin.conf') admin_inc_dir = include_directories('.') diff --git a/src/locking/meson.build b/src/locking/meson.build index 5c49bc641f8..4c30acb2eb9 100644 --- a/src/locking/meson.build +++ b/src/locking/meson.build @@ -90,6 +90,13 @@ if conf.has('WITH_LIBVIRTD') ], ) + check_protocols += { + 'name': 'lock_protocol', + 'libname': 'lockd_impl', + 'builddir': meson.current_build_dir(), + 'depends': lockd_lib_impl, + } + lockdriver_dir = libdir / 'libvirt' / 'lock-driver' virt_modules += { diff --git a/src/lxc/meson.build b/src/lxc/meson.build index 0999e1c96b8..093ad809029 100644 --- a/src/lxc/meson.build +++ b/src/lxc/meson.build @@ -99,6 +99,13 @@ if conf.has('WITH_LXC') ], ) + check_protocols += { + 'name': 'lxc_monitor_protocol', + 'libname': 'virt_driver_lxc_impl', + 'builddir': meson.current_build_dir(), + 'depends': lxc_driver_impl_lib, + } + virt_modules += { 'name': 'virt_driver_lxc', 'link_whole': [ diff --git a/src/meson.build b/src/meson.build index 7965c5fb18a..3f1c456245a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -217,6 +217,14 @@ driver_source_files = [] # stateful driver source files to check stateful_driver_source_files = [] +# check_protocols: +# check if $name.x is in sync with $name-structs +# name - name of the protocol (required) +# libname - name of the meson library (required) +# builddir - build directory for the library (required) +# depends - library that this test depends on (required) +check_protocols = [] + # list subdirectories @@ -887,3 +895,18 @@ if augparse_prog.found() ], ) endif + +if pdwtags_prog.found() + foreach proto : check_protocols + test( + 'check-@0@'.format(proto['name']), + python3_prog, + args: [ + check_remote_protocol_prog.path(), proto['name'], proto['libname'], + proto['builddir'], pdwtags_prog.path(), files('@0@-structs'.format(proto['name'])), + ], + env: runutf8, + depends: proto['depends'], + ) + endforeach +endif diff --git a/src/remote/meson.build b/src/remote/meson.build index fa7ce7ce5be..130d246fcec 100644 --- a/src/remote/meson.build +++ b/src/remote/meson.build @@ -126,6 +126,27 @@ if conf.has('WITH_REMOTE') ], ) + check_protocols += { + 'name': 'remote_protocol', + 'libname': 'virt_remote_driver', + 'builddir': meson.current_build_dir(), + 'depends': remote_driver_lib, + } + + check_protocols += { + 'name': 'qemu_protocol', + 'libname': 'virt_remote_driver', + 'builddir': meson.current_build_dir(), + 'depends': remote_driver_lib, + } + + check_protocols += { + 'name': 'lxc_protocol', + 'libname': 'virt_remote_driver', + 'builddir': meson.current_build_dir(), + 'depends': remote_driver_lib, + } + libvirt_libs += remote_driver_lib if conf.has('WITH_LIBVIRTD') diff --git a/src/rpc/meson.build b/src/rpc/meson.build index d759fa21aec..18ea0602602 100644 --- a/src/rpc/meson.build +++ b/src/rpc/meson.build @@ -81,6 +81,20 @@ virt_rpc_lib = static_library( ], ) +check_protocols += { + 'name': 'virnetprotocol', + 'libname': 'virt_net_rpc', + 'builddir': meson.current_build_dir(), + 'depends': virt_rpc_lib, +} + +check_protocols += { + 'name': 'virkeepaliveprotocol', + 'libname': 'virt_net_rpc', + 'builddir': meson.current_build_dir(), + 'depends': virt_rpc_lib, +} + virt_rpc_server_lib = static_library( 'virt_net_rpc_server', [ -- 2.26.2