Commit Graph

125 Commits

Author SHA1 Message Date
Michal Privoznik
a785186446 tools: Enable warnings for more binaries/libs
Because WARN_CFLAGS and COVERAGE_CFLAGS are not set globally, we
rely on each binary built to include WARN_CFLAGS/COVERAGE_CFLAGS.
But it is easy to forget those - e.g. libvirt_shell.la. However,
don't enable WARN_FLAGS (i.e. don't include AM_CFLAGS) for
wireshark plugin - parts of that code are generated and trigger
some warnings.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2017-11-21 12:52:39 +01:00
Michal Privoznik
15e661d558 tools: Set CFLAGS for wireshark properly
We want to set CFLAGS not CPPFLAGS.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2017-11-21 12:50:11 +01:00
Martin Kletzander
74a13be4a4 build: Use XDR_CFLAGS in more places
Since update to glibc-2.26 removed the /usr/include/rpc/rpc.h we used until now,
it showed us a problem with not using XDR_CFLAGS properly.  On linux that
variable has usually -I/usr/include/tirpc because we already probe for it
properly, we just don't use it everywhere we need.  It is needed by wireshark
dissector as well as testutilsqemu.c (through includes) so the build fails with:

wireshark/src/packet-libvirt.c:33:10: fatal error: rpc/xdr.h: No such file or directory
 #include <rpc/xdr.h>
          ^~~~~~~~~~~

and

In file included from ../src/logging/log_manager.h:29:0,
                 from ../src/qemu/qemu_domain.h:40,
                 from testutilsqemu.c:11:
../src/logging/log_protocol.h:9:10: fatal error: rpc/rpc.h: No such file or directory
 #include <rpc/rpc.h>
          ^~~~~~~~~~~

Since lot of tests use testutilsqemu.c it is easier to add XDR_CFLAGS to
AM_CFLAGS than adding it to all $binary_CFLAGS.  It's just for tests and we
already have bunch of CFLAGS there anyway.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-11-18 10:45:10 +01:00
Andrea Bolognani
3e7db8d3e8 Remove backslash alignment attempts
Right-aligning backslashes when defining macros or using complex
commands in Makefiles looks cute, but as soon as any changes is
required to the code you end up with either distractingly broken
alignment or unnecessarily big diffs where most of the changes
are just pushing all backslashes a few characters to one side.

Generated using

  $ git grep -El '[[:blank:]][[:blank:]]\\$' | \
    grep -E '*\.([chx]|am|mk)$$' | \
    while read f; do \
      sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \
    done

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2017-11-03 13:24:12 +01:00
Daniel P. Berrange
addcebc7d0 tools: make wireshark build quiet
Use $(AM_V_GEN) when running wireshark related tools

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-08-07 09:28:12 +01:00
Roman Bogorodskiy
9ea3424a17 virsh: workaround readline prototypes warnings
When building with clang 4.0.0, virsh build fails like this:

gmake[3]: Entering directory '/usr/home/novel/code/libvirt/tools'
  CC       virsh-virsh.o
In file included from virsh.c:45:
In file included from /usr/local/include/readline/readline.h:31:
/usr/local/include/readline/rltypedefs.h:35:22: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
typedef int Function () __attribute__ ((deprecated));
                     ^
                      void
/usr/local/include/readline/rltypedefs.h:36:24: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
typedef void VFunction () __attribute__ ((deprecated));
                       ^
                        void
/usr/local/include/readline/rltypedefs.h:37:26: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
typedef char *CPFunction () __attribute__ ((deprecated));
                         ^
                          void
/usr/local/include/readline/rltypedefs.h:38:28: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
typedef char **CPPFunction () __attribute__ ((deprecated));
                           ^
                            void
In file included from virsh.c:45:
/usr/local/include/readline/readline.h:385:23: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
extern int rl_message ();
                      ^
                       void
5 errors generated.
gmake[3]: *** [Makefile:2823: virsh-virsh.o] Error 1

Fix that by adding -D_FUNCTION_DEF to READLINE_CFLAGS to fix *Function
related warnings and add a check for stdarg.h so we have HAVE_STDARG_H
defined that's needed by the readline headers to use proper rl_message
declaration.

Bug report on the readline mailing list:

 http://lists.gnu.org/archive/html/bug-readline/2017-05/msg00004.html
2017-06-08 21:03:34 +04:00
Peter Krempa
e8a61ae4bd virsh: Add new file for utility functions and move a few
Don't accumulate helpers in virsh.c
2017-04-12 13:23:10 +02:00
Ján Tomko
e73889b631 Split out -Wframe-larger-than warning from WARN_CLFAGS
Introduce STRICT_FRAME_LIMIT_CFLAGS that will be used for
production code and RELAXED_FRAME_LIMIT_CFLAGS for tests.

Raising the limit for tests allows building them with clang
with optimizations disabled.
2017-04-06 12:29:35 +02:00
Roman Bogorodskiy
321ff4087c virt-host-validate: add bhyve support
Add bhyve support to virt-host-validate(1). It checks for the
essential kernel modules to be available so that user can actually
start VMs, have networking and console access.

It uses the kldnext(2)/kldstat(2) routines to retrieve modules list.
As bhyve is only available on FreeBSD and these routines were available
long before bhyve appeared, not adding any specific configure checks
for that.

Also, update tools/Makefile.am to add
virt-host-validate-$driver.[hc] to the build only if the
appropriate driver is enabled.
2017-03-11 21:22:58 +04:00
Michal Privoznik
22f7ceb695 nss: Introduce libvirt-guest module
So far the NSS module looks up only hostnames as provided by
guests themselves. However, there are some cases where this is
not enough: e.g. when there's a fresh new guest being installed
(with some generic hostname) say from a live ISO image; or some
(older) systems don't advertise their hostname in DHCP
transactions at all.
In cases like that it would be helpful if we translate domain
name as seen by libvirt too so that users can:

  # virsh start $dom && ssh $dom

In order to achieve that new libvirt-guest module is introduced,
while older libvirt module maintains its current behaviour (that
is translating guest provided names into IP addresses).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-12-06 13:34:00 +01:00
Andrea Bolognani
3abb8b6969 wireshark: Don't redefine ws_plugindir
autoconf already defines the variable for us, and prints out
a warning if we try to do it a second time. So let's not :)
2016-11-07 10:16:06 +01:00
Andrea Bolognani
3cbf054995 wireshark: Rename plugindir to ws_plugindir
Since we're using autoconf to substitute the right value in
Makefile.am now, we can use a less generic name without running
into circular dependencies.
2016-10-26 17:00:21 +02:00
Andrea Bolognani
c587c73549 wireshark: Inject $(prefix) at the right time
Adding $(prefix) in Makefile.am, as we were doing, means that
it would be prepended even when using --with-ws-plugindir,
which is something we don't want to happen.

Instead, we add it beforehand but take care that it doesn't
get expanded until make is called.
2016-10-26 17:00:21 +02:00
Michal Privoznik
35e45760ee virt-wireshark.m4: Defer $(prefix) substitution
The autoconf manual says we shouldn't be using this variable (and
some others) outside of Makefiles as it prevents users providing
their own prefix at the installation phase.

https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Installation-Directory-Variables.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-21 09:27:33 +08:00
Michal Privoznik
8540301b78 tools: Don't list virsh-* under EXTRA_DIST
When we wanted to break huge and unmaintainable virsh into
smaller files first thing we did was to just move funcs into
virsh-.c files and then #include them from virsh. Having it done
this way we also needed to have them listed under EXTRA_DIST.
However, things got changed since then and now all the virsh-*.c
files are proper source files. Therefore they are listed under
virsh_SOURCES too. But for some reason we forgot to remove them
from EXTRA_DIST.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-31 12:52:11 +02:00
Michal Privoznik
90bf5f5cb2 tools: Introduce install-nss targets
We do have something similar for installing init system files.
Basically I'm trying to avoid the following warning produced by
automake:

tools/Makefile.am:429: warning: uninstall-local was already defined in condition TRUE, which includes condition WITH_BSD_NSS ...
tools/Makefile.am:292: ... 'uninstall-local' previously defined here

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-04-25 18:56:48 +02:00
Andrea Bolognani
6e742c7f18 build: Always ship virt-login-shell.conf
No need to special-case this one: we can add it to EXTRA_DIST so
that it will be shipped in any case, and if WITH_LOGIN_SHELL
happens to be enabled we mark it for installation as well.
2016-04-25 15:40:44 +02:00
Andrea Bolognani
49ba028aed build: Replace variables in man pages
We can't use eg. @sysconfdir@ directly in the .pod file, because
pod2man(1) will interpret that as a variable name and format it
accordingly.

Instead, we use eg. SYSCONFDIR and use a subsequent sed(1) call
to turn it into the expected @sysconfdir@.
2016-04-25 15:40:44 +02:00
Andrea Bolognani
f806febbdf build: Ensure intermediate files are cleaned up properly
All $(MANINFILES) should be deleted on distclean.
2016-04-25 15:40:44 +02:00
Andrea Bolognani
7351f7fe68 build: Group files
Define $(PODFILES) and $(MANINFILES) so that adding a new man
page only requires changes in a few, well defined spots.
2016-04-25 15:40:44 +02:00
Andrea Bolognani
378338ba28 build: Never ship man pages
The generated man pages may contain information that depend on
the build configuration, so they should not be shipped but
rather always built on the user's machine.
2016-04-25 15:40:44 +02:00
Andrea Bolognani
5b479f3b5b build: Standardize on .pod -> .x.in -> .x
After this commit, all man pages are generated using the same two
steps:

  1. Process a source $command.pod file with pod2man(1) to obtain
     a valid man page in $command.$section.in

  2. Process $command.$section.in with sed(1) to obtain the final
     man page in $command.$section
2016-04-25 15:40:44 +02:00
Andrea Bolognani
9b77ce63f1 build: Perform post-processing on all man pages
Man pages in daemon/ and src/ are being already subjected to this
post-processing step: make it so those in tools/ are as well.
2016-04-25 15:40:44 +02:00
Andrea Bolognani
90709d8d22 build: Build man pages in $(builddir)
No file should be created inside $(srcdir) during build.
2016-04-25 15:40:43 +02:00
Andrea Bolognani
94bf7e5d84 build: Extract pod from source files
Instead of embedding the pod information inside the respective
source files, store them in separate files.

This allows us to reduce the number of custom build rules as
most of the information can be inferred for the file name;
moreover, text editors are more likely to use proper syntax
highlighting for standalone pod files.
2016-04-25 15:40:43 +02:00
Andrea Bolognani
2d1269605c build: Ship virt-admin.pod
This is the source file for the virt-admin(1) manual page, so
it should be shipped.
2016-04-25 15:40:43 +02:00
Andrea Bolognani
d0062fb9b5 dist: ln(1) is not guaranteed to have a '-f' option
According to the autoconf manual, using '$(LN_S) -f' is not
portable; remove the target explicitly beforehand to work around
this limitation.

Adjust some slightly awkward indentation while at it.
2016-04-21 15:36:14 +02:00
Andrea Bolognani
ed5c929777 build: Use $(LN_S) safely
The autoconf documentation recommends to always use this
construct when creating symbolic links with $(LN_S) to avoid
unexpected behavior.
2016-04-21 10:02:36 +02:00
Andrea Bolognani
ce8379eedc build: Overwrite existing symbolic links
The current rule fails if the target already exists:

  cd /home/jenkins/build/libvirt/lib && \
    ln -s libnss_libvirt.so.1 nss_libvirt.so.1
  ln: nss_libvirt.so.1: File exists
  Makefile:3357: recipe for target 'install-exec-hook' failed

However, all other rules concerned with installation are
idempotent and will happily overwrite an existing target,
so this one should as well.
2016-04-21 10:02:36 +02:00
Michal Privoznik
2f3c89fbbb nss: Try harder to uninstall
On BSD we are creating this symlink to libnss_libvirt.so called
nss_libvirt.so. That's just the way it is on BSD. However, when
uninstalling, we try to remove libnss_libvirt.so instead of the
symlink. Moreover, if file we are trying to remove does not exist
we error out instead of ignoring the error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-04-20 17:33:48 +02:00
Andrea Bolognani
edebc16607 configure: Make virt-host-validate optional
virt-host-validate, just like virt-login-shell, doesn't make sense
on Windows, so we should avoid building it.

Make the tool optional and build it by default on all platforms
except Windows, erroring out if the user attempts to build it
anyway.
2016-04-13 10:06:29 +02:00
Andrea Bolognani
0b431fa0e6 tools: Reorganize conditional bits
Instead of having separate handling for programs and man pages,
deal with both in the same place.
2016-04-13 10:06:29 +02:00
Roman Bogorodskiy
ec5b9331c4 nss: properly include syms files to dist
Explicitly add Linux and BSD syms files for nss to EXTRA_DIST
instead of using the LIBVIRT_NSS_SYMBOL_FILE variable, because its value
will point to either Linux or BSD syms file, but we need to ship both.
2016-04-09 08:27:50 +03:00
Roman Bogorodskiy
45408cd892 nss: FreeBSD support
* tools/nss/libvirt_nss.[ch]: add BSD-comptabile wrappers and
   register via the nss_module_register() interface
 * m4/virt-nss.m4: add checks if we're building NSS for FreeBSD
 * tools/Makefile.am: handle target library name differences, as
   Linux needs libnss_libvirt.so.2 and FreeBSD needs
   nss_libvirt.so.1. Also, different syms files have to be used
   as Linux needs to export all the methods while FreeBSD
   only needs to have nss_module_register()
 * tests/nsstest.c, tests/nssmock.c: s/__linux__/NSS/
 * tests/nssmock.c: pass int instead of mode_t to va_arg() to please
   gcc 4.8
 * libvirt_nss_bsd.syms: FreeBSD syms file
2016-03-30 10:21:44 +03:00
Roman Bogorodskiy
ae33a7b336 nss: don't try to build nss plugin when disabled
Even if nss is disabled, the build system tries to build some
targets like libnss_libvirt_impl.la and nsstest. Hide those
under the "if WITH_NSS" block like the rest of NSS plugin bits.
2016-03-20 18:44:35 +03:00
Michal Privoznik
7dbcb26f7f nss: Implement _nss_libvirt_gethostbyname3_r
The implementation is pretty straightforward. Moreover, because
of the nature of things, gethostbyname_r and gethostbyname2_r can
be implemented at the same time too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 17:29:53 +01:00
Michal Privoznik
859cb18d54 Initial support for NSS plugin skeleton
Name Service Switch is a glibc feature responsible for many
things. Translating domain names into IP addresses and vice versa
is just one of them. However, currently it's the only
functionality that this commit is tickling. Well, in this commit
the plugin skeleton is introduced. Implementation to come in next
patches.
Because of the future testing, where the implementation is to be
linked with a test, this needs to go into static library. Linking
a program with an .so statically is not portable. Therefore a
dummy libnss_libvirt_impl library is being introduced too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 17:29:53 +01:00
Michal Privoznik
f99f79e380 wireshark: Drop DESTDIR from install path
In 50078cfbcb I've tried to fix distcheck but accidentally
broke rpm build. The problem is that rpm build not only sets
DESTDIR but also passes plugindir path. This results in double
DESTDIR being in the plugin path, Drop one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-01-14 08:05:28 +01:00
Cole Robinson
e20dd2a4fd build: fix distdir with wireshark disabled
Even though the Makefile has WITH_WIRESHARK guards, the _SOURCES
variables are still processed when adding bits to the dist archive.

plugin.c is a generated file that is only built when wireshark is
enabled and it shouldn't be distributed, so use 'nodist'
2016-01-13 09:41:35 -05:00
Michal Privoznik
50078cfbcb wireshark: Install into DESTDIR
Like everything we install, it should be prefixed with DESTDIR.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-01-12 18:51:38 +01:00
Cole Robinson
3445acdbaa build: Kill tools/wireshark Makefiles
Just handle it all in tools/Makefile.am. I verified the generated output
looks similar to the pre patch output, but I didn't test it.
2016-01-12 11:30:08 -05:00
Michal Privoznik
0059848e9e tools: Include PIE_LDFLAGS at the correct place
This is no functional change, but I find it disturbing that
something_LDADD contains PIE_LDFLAGS while something_LDFLAGS
doesn't.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-12-24 18:03:50 +01:00
Cédric Bosdonnat
bec787ee9d Allow building lxc without virt-login-shell
Add a configure option to disable virt-login-shell build even if lxc is
enabled.
2015-12-17 15:49:06 +01:00
Erik Skultety
163a781e63 virt-admin: Provide a man page for virt-admin 2015-11-30 09:44:28 +01:00
Erik Skultety
6409578790 virt-admin: Introduce first working skeleton
This patch introduces virt-admin client which is based on virsh client,
but had to reimplement several methods to meet virt-admin specific needs
or remove unnecessary virsh specific logic.
2015-11-30 09:44:28 +01:00
Michal Privoznik
1fb8ac4c79 tools: Link libvirt.la and readline to libvirt_shell.a
So, our mingw build is broken. It's because while libvirt_shell
library is using some of our internal APIs, e.g. virStrndup, and
readline API but it's not being linked with nor libvirt.la nor
libreadline.  Only subsequent users of the library, like virsh,
do link to the needed libraries. In fact, I'm surprised Linux
linker doesn't care, because how can it make a static library
with missing symbols is mystery to me.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-09-25 14:33:06 +02:00
Erik Skultety
2d9fcb3102 vsh: create a noinstall libvirt_shell library
Instead of referencing vsh sources in all relevant client targets,
create a library that the client can link against.
2015-09-24 16:58:28 +02:00
Erik Skultety
834c5720e4 tools: Introduce new client generic module vsh
In order to share as much virsh' logic as possible with upcomming
virt-admin client we need to split virsh logic into virsh specific and
client generic features.

Since majority of virsh methods should be generic enough to be used by
other clients, it's much easier to rename virsh specific data to virshX
than doing this vice versa. It moved generic virsh commands (including info
and opts structures) to generic module vsh.c.

Besides renaming methods and structures, this patch also involves introduction
of a client specific control structure being referenced as private data in the
original control structure, introduction of a new global vsh Initializer,
which currently doesn't do much, but there is a potential for added
functionality in the future.
Lastly it introduced client hooks which are especially necessary during
client connecting phase.
2015-08-14 15:45:44 +02:00
Eric Blake
8a20e227f6 conf: move storage source type to util/
With this patch, all information related to a host resource in
a storage file backing chain now lives in util/virstoragefile.h.
The next step will be to consolidate various places that have
been tracking backing chain details to all use a common struct.

The changes to tools/Makefile.am were made necessary by the
fact that virstorageencryption includes uses of libxml, and is
now pulled in by inclusion from virstoragefile.h.  No
additional libraries are linked into the final image, and in
comparison, the build of the setuid library in src/Makefile.am
already was using LIBXML_CFLAGS via AM_CFLAGS.

* src/conf/domain_conf.h (virDomainDiskSourceDef): Move...
* src/util/virstoragefile.h (virStorageSource): ...and rename.
* src/conf/domain_conf.c (virDomainDiskSourceDefClear)
(virDomainDiskAuthClear): Adjust clients.
* tools/Makefile.am (virt_login_shell_CFLAGS)
(virt_host_validate_CFLAGS): Add libxml headers.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-04-01 10:38:14 -06:00
Laine Stump
00e9d6071b build: add $(prefix) to SYSTEMD_UNIT_DIR
I noticed this problem when adding systemd support to netcf, because I
setup the configure.ac to automatically prefer using systemd over
initscripts when possible - although I had copied the
install-data-local target from the example of libvirt's
"libvirt-guests" service more or less verbatim, "make distcheck" would
fail because it was trying to install the service file directly into
/lib/systemd/system rather than into
/home/user/some/unimportant/name/lib/systemd/system.

This is caused by the install/uninstall rules for the systemd unit
files relying on $(DESTDIR) pointing the installed files to the right
place, but in reality $(DESTDIR) is empty during this part of make
distcheck - it instead sets $(prefix) with the toplevel directory used
for its test build/install/uninstall cycle.

(This problem hasn't been seen when running "make distcheck" in
libvirt because libvirt will never build/install systemd support
unless explicitly told to do so on the configure commandline, and
"make distcheck" doesn't put the "--with-initscript=..." option on the
configure commandline.)

I verified that the same problem does exist in libvirt by modifying
libvirt's configure.ac to set:

  init_systemd=yes
  with_init_script=systemd+redhat

This forces a build/install of the systemd unit files during
distcheck, which yields an error like this:

/usr/bin/install -c -m 644 virtlockd.service \
  /lib/systemd/system/
libtool: install: warning: relinking `libvirt-qemu.la'
/usr/bin/install: cannot remove '/lib/systemd/system/virtlockd.service': Permission denied
make[4]: *** [install-systemd] Error 1

After adding $(prefix) to all the definitions of SYSTEMD_UNIT_DIR,
make distcheck now completes successfully with the modified
configure.ac, and the above lines change to something like this:

/usr/bin/install -c -m 644 virtlockd.service \
  /home/laine/devel/libvirt/libvirt-1.2.1/_inst/lib/systemd/system/
2014-01-21 13:19:46 +02:00