[libvirt] [PATCH 0/2] build: Fix build on mingw

Fixes pushed under build-breaker rule. Martin Kletzander (2): Use stub for virNetDevGetName on mingw Build vircaps2xmltest and requirements only on Linux configure.ac | 7 ++++--- src/util/virnetdev.c | 10 ++++++++++ tests/Makefile.am | 17 ++++++++++------- tests/vircaps2xmltest.c | 16 ++-------------- 4 files changed, 26 insertions(+), 24 deletions(-) -- 2.12.2

If if_indextoname is not defined, the whole function using it should not be defined either. Add stub to fix build on mingw. Caused by 5dd607059d8a98e04024305ae4afbd038aadbdcd Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- configure.ac | 7 ++++--- src/util/virnetdev.c | 10 ++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index cf50422d5dab..08051d53aa0a 100644 --- a/configure.ac +++ b/configure.ac @@ -319,9 +319,10 @@ AC_CHECK_SIZEOF([long]) dnl Availability of various common functions (non-fatal if missing), dnl and various less common threadsafe functions AC_CHECK_FUNCS_ONCE([cfmakeraw fallocate geteuid getgid getgrnam_r \ - getmntent_r getpwuid_r getrlimit getuid kill mmap newlocale posix_fallocate \ - posix_memalign prlimit regexec sched_getaffinity setgroups setns \ - setrlimit symlink sysctlbyname getifaddrs sched_setscheduler unshare]) + getmntent_r getpwuid_r getrlimit getuid if_indextoname kill mmap \ + newlocale posix_fallocate posix_memalign prlimit regexec \ + sched_getaffinity setgroups setns setrlimit symlink sysctlbyname \ + getifaddrs sched_setscheduler unshare]) dnl Availability of various common headers (non-fatal if missing). AC_CHECK_HEADERS([pwd.h regex.h sys/un.h \ diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 47e2b20d56a1..170e34827f12 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -852,6 +852,7 @@ virNetDevGetRcvAllMulti(const char *ifname, return virNetDevGetIFFlag(ifname, VIR_IFF_ALLMULTI, receive); } +#if defined(HAVE_IF_INDEXTONAME) char *virNetDevGetName(int ifindex) { char name[IFNAMSIZ]; @@ -871,6 +872,15 @@ char *virNetDevGetName(int ifindex) cleanup: return ifname; } +#else +char *virNetDevGetName(int ifindex) +{ + virReportSystemError(ENOSYS, + _("Cannot get interface name for index '%i'"), + ifindex); + return NULL; +} +#endif /** * virNetDevGetIndex: -- 2.12.2

The mock, as well as the test, is only available on Linux. So skip building it everywhere else, especially when it fails on mingw. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- tests/Makefile.am | 17 ++++++++++------- tests/vircaps2xmltest.c | 16 ++-------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 076734feda70..67cf497b8b27 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -192,7 +192,6 @@ test_programs = virshtest sockettest \ domaincapstest \ domainconftest \ virhostdevtest \ - vircaps2xmltest \ virnetdevtest \ virtypedparamtest \ $(NULL) @@ -206,7 +205,6 @@ test_libraries = libshunload.la \ virnetdevmock.la \ virrandommock.la \ virhostcpumock.la \ - virnumamock.la \ domaincapsmock.la \ $(NULL) @@ -225,8 +223,10 @@ endif WITH_REMOTE if WITH_LINUX test_programs += fchosttest test_programs += scsihosttest +test_programs += vircaps2xmltest test_libraries += virusbmock.la \ virnetdevbandwidthmock.la \ + virnumamock.la \ virtestmock.la \ $(NULL) endif WITH_LINUX @@ -941,11 +941,6 @@ vircapstest_SOURCES += testutilsxen.c testutilsxen.h endif WITH_XEN vircapstest_LDADD = $(qemu_LDADDS) $(LDADDS) -vircaps2xmltest_SOURCES = \ - vircaps2xmltest.c testutils.h testutils.c -vircaps2xmltest_LDADD = $(LDADDS) - - domaincapsmock_la_SOURCES = domaincapsmock.c domaincapsmock_la_CFLAGS = $(AM_CFLAGS) domaincapsmock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS) @@ -1125,11 +1120,19 @@ virhostcpumock_la_CFLAGS = $(AM_CFLAGS) virhostcpumock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS) virhostcpumock_la_LIBADD = $(MOCKLIBS_LIBS) +if WITH_LINUX +vircaps2xmltest_SOURCES = \ + vircaps2xmltest.c testutils.h testutils.c +vircaps2xmltest_LDADD = $(LDADDS) + virnumamock_la_SOURCES = \ virnumamock.c virnumamock_la_CFLAGS = $(AM_CFLAGS) virnumamock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS) virnumamock_la_LIBADD = $(MOCKLIBS_LIBS) +else ! WITH_LINUX +EXTRA_DIST += vircaps2xmltest.c virnumamock.c +endif ! WITH_LINUX if WITH_NSS nsstest_SOURCES = \ diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c index 4dccd452cc82..ffbe9a783811 100644 --- a/tests/vircaps2xmltest.c +++ b/tests/vircaps2xmltest.c @@ -30,8 +30,6 @@ #define VIR_FROM_THIS VIR_FROM_NONE -#ifdef __linux__ - struct virCapabilitiesData { const char *filename; virArch arch; @@ -90,7 +88,7 @@ mymain(void) { int ret = 0; -# define DO_TEST_FULL(filename, arch, offlineMigrate, liveMigrate) \ +#define DO_TEST_FULL(filename, arch, offlineMigrate, liveMigrate) \ do { \ struct virCapabilitiesData data = {filename, arch, \ offlineMigrate, \ @@ -99,7 +97,7 @@ mymain(void) ret = -1; \ } while (0) -# define DO_TEST(filename, arch) DO_TEST_FULL(filename, arch, true, true) +#define DO_TEST(filename, arch) DO_TEST_FULL(filename, arch, true, true) DO_TEST_FULL("basic", VIR_ARCH_X86_64, false, false); DO_TEST_FULL("basic", VIR_ARCH_AARCH64, true, false); @@ -110,13 +108,3 @@ mymain(void) } VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/virnumamock.so") - -#else /* !__linux__ */ - -int -main(void) -{ - return EXIT_AM_SKIP; -} - -#endif /* !__linux__ */ -- 2.12.2
participants (1)
-
Martin Kletzander