[libvirt] [PATCH 0/3] Fix mingw build

We have a build failure on mingw platform:4 https://ci.centos.org/job/libvirt-mingw/899/console Michal Privoznik (3): sysconf: Include unistd.h tools: Include PIE_LDFLAGS at the correct place tools: Disable virt-login-shell on mingw m4/virt-login-shell.m4 | 18 +++++++++++++++--- src/nodeinfo.c | 1 + src/qemu/qemu_conf.h | 2 ++ src/util/vircgroup.c | 1 + src/util/vircommand.c | 1 + tools/Makefile.am | 4 ++-- tools/virt-login-shell.c | 1 + 7 files changed, 23 insertions(+), 5 deletions(-) -- 2.4.10

The manpage for sysconf() suggest including unistd.h as the function is declared there. Even though we are not hitting any compile issues currently, let's include the correct header file instead of relying on some hidden include chain. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/nodeinfo.c | 1 + src/qemu/qemu_conf.h | 2 ++ src/util/vircgroup.c | 1 + src/util/vircommand.c | 1 + tools/virt-login-shell.c | 1 + 5 files changed, 6 insertions(+) diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 6ccada5..77ea155 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -33,6 +33,7 @@ #include "conf/domain_conf.h" #include <fcntl.h> #include <sys/ioctl.h> +#include <unistd.h> #if HAVE_LINUX_KVM_H # include <linux/kvm.h> diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 4b33770..a714b84 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -24,6 +24,8 @@ #ifndef __QEMUD_CONF_H # define __QEMUD_CONF_H +# include <unistd.h> + # include "virebtables.h" # include "internal.h" # include "capabilities.h" diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index a07f3c2..e39c4d1 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -38,6 +38,7 @@ #include <sys/types.h> #include <signal.h> #include <dirent.h> +#include <unistd.h> #define __VIR_CGROUP_ALLOW_INCLUDE_PRIV_H__ #include "vircgrouppriv.h" diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 1993bc6..fe7bf34 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -29,6 +29,7 @@ #include <sys/stat.h> #include <sys/wait.h> #include <fcntl.h> +#include <unistd.h> #if WITH_CAPNG # include <cap-ng.h> diff --git a/tools/virt-login-shell.c b/tools/virt-login-shell.c index ceb271d..ec759dc 100644 --- a/tools/virt-login-shell.c +++ b/tools/virt-login-shell.c @@ -29,6 +29,7 @@ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include "internal.h" #include "virerror.h" -- 2.4.10

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> --- tools/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Makefile.am b/tools/Makefile.am index d39f2ba..73cad50 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -185,11 +185,11 @@ virt_login_shell_SOURCES = \ virt_login_shell_LDFLAGS = \ $(AM_LDFLAGS) \ + $(PIE_LDFLAGS) \ $(COVERAGE_LDFLAGS) \ $(NULL) virt_login_shell_LDADD = \ $(STATIC_BINARIES) \ - $(PIE_LDFLAGS) \ ../src/libvirt-setuid-rpc-client.la \ ../gnulib/lib/libgnu.la @@ -218,11 +218,11 @@ virsh_SOURCES = \ virsh_LDFLAGS = \ $(AM_LDFLAGS) \ + $(PIE_LDFLAGS) \ $(COVERAGE_LDFLAGS) \ $(NULL) virsh_LDADD = \ $(STATIC_BINARIES) \ - $(PIE_LDFLAGS) \ ../src/libvirt-lxc.la \ ../src/libvirt-qemu.la \ libvirt_shell.la -- 2.4.10

So, after bec787ee9da we are building virt-login-shell independent of LXC driver. This is nice, but the binary is enabled by default which makes no sense on mingw. In fact, it triggers some compilation errors there: CC virt_login_shell-virt-login-shell.o ../../tools/virt-login-shell.c: In function 'main': ../../tools/virt-login-shell.c:289:15: error: implicit declaration of function 'sysconf' [-Werror=implicit-function-declaration] openmax = sysconf(_SC_OPEN_MAX); ^ ../../tools/virt-login-shell.c:289:5: error: nested extern declaration of 'sysconf' [-Werror=nested-externs] openmax = sysconf(_SC_OPEN_MAX); ^ ../../tools/virt-login-shell.c:289:23: error: '_SC_OPEN_MAX' undeclared (first use in this function) openmax = sysconf(_SC_OPEN_MAX); ^ ../../tools/virt-login-shell.c:289:23: note: each undeclared identifier is reported only once for each function it appears in cc1: all warnings being treated as errors While we could workaround sysconf(_SC_OPEN_MAX) issue, the binary itself makes no sense on systems where no LXC can be spawned. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- m4/virt-login-shell.m4 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/m4/virt-login-shell.m4 b/m4/virt-login-shell.m4 index 0701054..c77ffb5 100644 --- a/m4/virt-login-shell.m4 +++ b/m4/virt-login-shell.m4 @@ -17,10 +17,22 @@ dnl <http://www.gnu.org/licenses/>. AC_DEFUN([LIBVIRT_CHECK_LOGIN_SHELL], [ AC_ARG_WITH([login_shell], [AS_HELP_STRING([--with-login-shell], - [build virt-login-shell @<:@default=yes@:>@])]) - m4_divert_text([DEFAULTS], [with_login_shell=yes]) + [build virt-login-shell @<:@default=check@:>@])]) + m4_divert_text([DEFAULTS], [with_login_shell=check]) - if test "$with_login_shell" ; then + if test "x$with_login_shell" != "xno"; then + if test "x$with_win" = "xyes"; then + if "x$with_login_shell" = "yes"; then + AC_MSG_ERROR([virt-login-shell is not supported on Windows]) + else + with_login_shell=no; + fi + else + with_login_shell=yes; + fi + fi + + if test "x$with_login_shell" = "xyes" ; then AC_DEFINE_UNQUOTED([WITH_LOGIN_SHELL], 1, [whether virt-login-shell is built]) fi AM_CONDITIONAL([WITH_LOGIN_SHELL], [test "$with_login_shell" = "yes"]) -- 2.4.10

On Mon, Dec 21, 2015 at 09:31:46AM +0100, Michal Privoznik wrote:
We have a build failure on mingw platform:4
https://ci.centos.org/job/libvirt-mingw/899/console
Michal Privoznik (3): sysconf: Include unistd.h tools: Include PIE_LDFLAGS at the correct place tools: Disable virt-login-shell on mingw
ACK. I've found some files calling sysconf() without including unistd.h, but they probably take it from their own header files (like virutil.c from virutil.h), and I didn't want to create yet another script for that =)
m4/virt-login-shell.m4 | 18 +++++++++++++++--- src/nodeinfo.c | 1 + src/qemu/qemu_conf.h | 2 ++ src/util/vircgroup.c | 1 + src/util/vircommand.c | 1 + tools/Makefile.am | 4 ++-- tools/virt-login-shell.c | 1 + 7 files changed, 23 insertions(+), 5 deletions(-)
-- 2.4.10
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (2)
-
Martin Kletzander
-
Michal Privoznik