[libvirt] [PATCH libvirt 1/3] build: do not build shunloadtest if pthread missing

Fixes build on Windows systems --- configure.ac | 2 ++ tests/Makefile.am | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 89fe818..347c48c 100644 --- a/configure.ac +++ b/configure.ac @@ -154,6 +154,8 @@ AC_CHECK_FUNC([clock_gettime],[ LIBS=$old_libs AC_SUBST(RT_LIBS) +AM_CONDITIONAL([HAVE_PTHREAD], [test x"$HAVE_PTHREAD_H" = x"1"]) + dnl Availability of various common headers (non-fatal if missing). AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/un.h \ sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \ diff --git a/tests/Makefile.am b/tests/Makefile.am index c4d550f..3d9235c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -98,7 +98,7 @@ test_programs = virshtest sockettest \ nodeinfotest virbuftest \ commandtest seclabeltest \ virhashtest virnetmessagetest virnetsockettest \ - utiltest virnettlscontexttest shunloadtest \ + utiltest virnettlscontexttest \ virtimetest viruritest virkeyfiletest \ virauthconfigtest @@ -106,6 +106,10 @@ test_programs = virshtest sockettest \ ssh_SOURCES = ssh.c ssh_LDADD = $(COVERAGE_LDFLAGS) +if HAVE_PTHREAD +test_programs += shunloadtest +endif + if WITH_XEN test_programs += xml2sexprtest sexpr2xmltest \ xmconfigtest xencapstest statstest reconnect @@ -527,10 +531,12 @@ libshunload_la_SOURCES = shunloadhelper.c libshunload_la_LIBADD = ../src/libvirt.la libshunload_la_LDFLAGS = -module -avoid-version -rpath /evil/libtool/hack/to/force/shared/lib/creation +if HAVE_PTHREAD shunloadtest_SOURCES = \ shunloadtest.c shunloadtest_LDADD = -lpthread shunloadtest_DEPENDENCIES = libshunload.la +endif if WITH_CIL CILOPTFLAGS = -- 1.7.10

Fix a few more places where pid_t is printed with wrong type --- src/conf/domain_audit.c | 4 ++-- src/conf/domain_conf.c | 4 ++-- src/util/command.c | 2 +- src/util/virpidfile.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index b885906..653657b 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -562,8 +562,8 @@ virDomainAuditLifecycle(virDomainObjPtr vm, const char *op, } VIR_AUDIT(VIR_AUDIT_RECORD_MACHINE_CONTROL, success, - "virt=%s op=%s reason=%s %s uuid=%s vm-pid=%d", - virt, op, reason, vmname, uuidstr, vm->pid); + "virt=%s op=%s reason=%s %s uuid=%s vm-pid=%lld", + virt, op, reason, vmname, uuidstr, (long long)vm->pid); VIR_FREE(vmname); } diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ac877f9..15a097a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12787,10 +12787,10 @@ static char *virDomainObjFormat(virCapsPtr caps, int i; state = virDomainObjGetState(obj, &reason); - virBufferAsprintf(&buf, "<domstatus state='%s' reason='%s' pid='%d'>\n", + virBufferAsprintf(&buf, "<domstatus state='%s' reason='%s' pid='%lld'>\n", virDomainStateTypeToString(state), virDomainStateReasonToString(state, reason), - obj->pid); + (long long)obj->pid); for (i = 0 ; i < VIR_DOMAIN_TAINT_LAST ; i++) { if (obj->taint & (1 << i)) diff --git a/src/util/command.c b/src/util/command.c index 2837450..800ec8f 100644 --- a/src/util/command.c +++ b/src/util/command.c @@ -2399,7 +2399,7 @@ void virPidAbort(pid_t pid) { /* Not yet ported to mingw. Any volunteers? */ - VIR_DEBUG("failed to reap child %d, abandoning it", pid); + VIR_DEBUG("failed to reap child %lldd, abandoning it", (long long)pid); } void diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index 1934341..59d0c94 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -222,7 +222,7 @@ int virPidFileReadPathIfAlive(const char *path, #endif if (binpath) { - if (virAsprintf(&procpath, "/proc/%d/exe", *pid) < 0) { + if (virAsprintf(&procpath, "/proc/%lld/exe", (long long)*pid) < 0) { *pid = -1; return -1; } -- 1.7.10

On 04/20/2012 07:13 AM, Marc-André Lureau wrote:
Fix a few more places where pid_t is printed with wrong type --- src/conf/domain_audit.c | 4 ++-- src/conf/domain_conf.c | 4 ++-- src/util/command.c | 2 +- src/util/virpidfile.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
+++ b/src/util/command.c @@ -2399,7 +2399,7 @@ void virPidAbort(pid_t pid) { /* Not yet ported to mingw. Any volunteers? */ - VIR_DEBUG("failed to reap child %d, abandoning it", pid); + VIR_DEBUG("failed to reap child %lldd, abandoning it", (long long)pid);
Typo (extra 'd'). ACK with that fixed, and pushed. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

The code uses long long for pid_t now. It fails on mingw64 without this change. --- src/util/virpidfile.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index 59d0c94..27811e1 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -316,8 +316,7 @@ cleanup: return rc; } - -verify(sizeof(pid_t) <= sizeof(unsigned int)); +verify(sizeof(pid_t) <= sizeof(long long)); int virPidFileAcquirePath(const char *path, pid_t pid) -- 1.7.10

On 04/20/2012 07:13 AM, Marc-André Lureau wrote:
The code uses long long for pid_t now. It fails on mingw64 without this change. --- src/util/virpidfile.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index 59d0c94..27811e1 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -316,8 +316,7 @@ cleanup: return rc; }
- -verify(sizeof(pid_t) <= sizeof(unsigned int)); +verify(sizeof(pid_t) <= sizeof(long long));
All integers are smaller than 'long long' (well, I know that there is work to add 128-bit integers, but you'd be crazy to make pid_t that big). I'd rather just delete the assertion altogether. ACK with that change, and pushed. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

ping On Fri, Apr 20, 2012 at 3:13 PM, Marc-André Lureau <marcandre.lureau@gmail.com> wrote:
Fixes build on Windows systems --- configure.ac | 2 ++ tests/Makefile.am | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac index 89fe818..347c48c 100644 --- a/configure.ac +++ b/configure.ac @@ -154,6 +154,8 @@ AC_CHECK_FUNC([clock_gettime],[ LIBS=$old_libs AC_SUBST(RT_LIBS)
+AM_CONDITIONAL([HAVE_PTHREAD], [test x"$HAVE_PTHREAD_H" = x"1"]) + dnl Availability of various common headers (non-fatal if missing). AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/un.h \ sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \ diff --git a/tests/Makefile.am b/tests/Makefile.am index c4d550f..3d9235c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -98,7 +98,7 @@ test_programs = virshtest sockettest \ nodeinfotest virbuftest \ commandtest seclabeltest \ virhashtest virnetmessagetest virnetsockettest \ - utiltest virnettlscontexttest shunloadtest \ + utiltest virnettlscontexttest \ virtimetest viruritest virkeyfiletest \ virauthconfigtest
@@ -106,6 +106,10 @@ test_programs = virshtest sockettest \ ssh_SOURCES = ssh.c ssh_LDADD = $(COVERAGE_LDFLAGS)
+if HAVE_PTHREAD +test_programs += shunloadtest +endif + if WITH_XEN test_programs += xml2sexprtest sexpr2xmltest \ xmconfigtest xencapstest statstest reconnect @@ -527,10 +531,12 @@ libshunload_la_SOURCES = shunloadhelper.c libshunload_la_LIBADD = ../src/libvirt.la libshunload_la_LDFLAGS = -module -avoid-version -rpath /evil/libtool/hack/to/force/shared/lib/creation
+if HAVE_PTHREAD shunloadtest_SOURCES = \ shunloadtest.c shunloadtest_LDADD = -lpthread shunloadtest_DEPENDENCIES = libshunload.la +endif
if WITH_CIL CILOPTFLAGS = -- 1.7.10
-- Marc-André Lureau

On Wed, May 02, 2012 at 04:57:41PM +0200, Marc-André Lureau wrote:
ping
On Fri, Apr 20, 2012 at 3:13 PM, Marc-André Lureau <marcandre.lureau@gmail.com> wrote:
Fixes build on Windows systems --- configure.ac | 2 ++ tests/Makefile.am | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac index 89fe818..347c48c 100644 --- a/configure.ac +++ b/configure.ac @@ -154,6 +154,8 @@ AC_CHECK_FUNC([clock_gettime],[ LIBS=$old_libs AC_SUBST(RT_LIBS)
+AM_CONDITIONAL([HAVE_PTHREAD], [test x"$HAVE_PTHREAD_H" = x"1"]) + dnl Availability of various common headers (non-fatal if missing). AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/un.h \ sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \ diff --git a/tests/Makefile.am b/tests/Makefile.am index c4d550f..3d9235c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -98,7 +98,7 @@ test_programs = virshtest sockettest \ nodeinfotest virbuftest \ commandtest seclabeltest \ virhashtest virnetmessagetest virnetsockettest \ - utiltest virnettlscontexttest shunloadtest \ + utiltest virnettlscontexttest \ virtimetest viruritest virkeyfiletest \ virauthconfigtest
@@ -106,6 +106,10 @@ test_programs = virshtest sockettest \ ssh_SOURCES = ssh.c ssh_LDADD = $(COVERAGE_LDFLAGS)
+if HAVE_PTHREAD +test_programs += shunloadtest +endif + if WITH_XEN test_programs += xml2sexprtest sexpr2xmltest \ xmconfigtest xencapstest statstest reconnect @@ -527,10 +531,12 @@ libshunload_la_SOURCES = shunloadhelper.c libshunload_la_LIBADD = ../src/libvirt.la libshunload_la_LDFLAGS = -module -avoid-version -rpath /evil/libtool/hack/to/force/shared/lib/creation
+if HAVE_PTHREAD shunloadtest_SOURCES = \ shunloadtest.c shunloadtest_LDADD = -lpthread shunloadtest_DEPENDENCIES = libshunload.la +endif
if WITH_CIL CILOPTFLAGS =
ACK, even though it is possible to have pthreads on Windows, libvirt is designed to use native windows threading instead. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 05/02/2012 09:16 AM, Daniel P. Berrange wrote:
On Wed, May 02, 2012 at 04:57:41PM +0200, Marc-André Lureau wrote:
ping
ACK, even though it is possible to have pthreads on Windows, libvirt is designed to use native windows threading instead.
Pushed, and I will review the others in the series as well. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 05/02/2012 12:38 PM, Eric Blake wrote:
On 05/02/2012 09:16 AM, Daniel P. Berrange wrote:
On Wed, May 02, 2012 at 04:57:41PM +0200, Marc-André Lureau wrote:
ping
ACK, even though it is possible to have pthreads on Windows, libvirt is designed to use native windows threading instead.
Pushed, and I will review the others in the series as well.
Scratch that, it fails 'make syntax-check': prohibit_always_true_header_tests configure.ac:157:AM_CONDITIONAL([HAVE_PTHREAD], [test x"$HAVE_PTHREAD_H" = x"1"]) maint.mk: do not test the above HAVE_<header>_H symbol(s); with the corresponding gnulib module, they are always true make: *** [sc_prohibit_always_true_header_tests] Error 1 Rather, we should be using the same conditional as threads.h; namely #ifdef WIN32. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 04/20/2012 07:13 AM, Marc-André Lureau wrote:
Fixes build on Windows systems --- configure.ac | 2 ++ tests/Makefile.am | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac index 89fe818..347c48c 100644 --- a/configure.ac +++ b/configure.ac @@ -154,6 +154,8 @@ AC_CHECK_FUNC([clock_gettime],[ LIBS=$old_libs AC_SUBST(RT_LIBS)
+AM_CONDITIONAL([HAVE_PTHREAD], [test x"$HAVE_PTHREAD_H" = x"1"])
NACK. If I understand things, the only reason you are adding this conditional is so that:
+if HAVE_PTHREAD shunloadtest_SOURCES = \ shunloadtest.c shunloadtest_LDADD = -lpthread
this line won't trigger a link failure if -lpthread does not exist. But we've already conditionalized -pthread; so does this (shorter) patch work to fix the problem instead? diff --git i/tests/Makefile.am w/tests/Makefile.am index c4d550f..b30d79c 100644 --- i/tests/Makefile.am +++ w/tests/Makefile.am @@ -529,7 +529,7 @@ libshunload_la_LDFLAGS = -module -avoid-version -rpath /evil/libtool/hack/to/for shunloadtest_SOURCES = \ shunloadtest.c -shunloadtest_LDADD = -lpthread +shunloadtest_LDADD = $(LIB_PTHREAD) shunloadtest_DEPENDENCIES = libshunload.la if WITH_CIL -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

ping On 05/02/2012 12:45 PM, Eric Blake wrote:
On 04/20/2012 07:13 AM, Marc-André Lureau wrote:
Fixes build on Windows systems
we've already conditionalized -pthread; so does this (shorter) patch work to fix the problem instead?
diff --git i/tests/Makefile.am w/tests/Makefile.am index c4d550f..b30d79c 100644 --- i/tests/Makefile.am +++ w/tests/Makefile.am @@ -529,7 +529,7 @@ libshunload_la_LDFLAGS = -module -avoid-version -rpath /evil/libtool/hack/to/for
shunloadtest_SOURCES = \ shunloadtest.c -shunloadtest_LDADD = -lpthread +shunloadtest_LDADD = $(LIB_PTHREAD) shunloadtest_DEPENDENCIES = libshunload.la
if WITH_CIL
-- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Mon, May 07, 2012 at 04:13:32PM -0600, Eric Blake wrote:
ping
On 05/02/2012 12:45 PM, Eric Blake wrote:
On 04/20/2012 07:13 AM, Marc-André Lureau wrote:
Fixes build on Windows systems
we've already conditionalized -pthread; so does this (shorter) patch work to fix the problem instead?
diff --git i/tests/Makefile.am w/tests/Makefile.am index c4d550f..b30d79c 100644 --- i/tests/Makefile.am +++ w/tests/Makefile.am @@ -529,7 +529,7 @@ libshunload_la_LDFLAGS = -module -avoid-version -rpath /evil/libtool/hack/to/for
shunloadtest_SOURCES = \ shunloadtest.c -shunloadtest_LDADD = -lpthread +shunloadtest_LDADD = $(LIB_PTHREAD) shunloadtest_DEPENDENCIES = libshunload.la
if WITH_CIL
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 05/08/2012 04:16 AM, Daniel P. Berrange wrote:
On Mon, May 07, 2012 at 04:13:32PM -0600, Eric Blake wrote:
ping
On 05/02/2012 12:45 PM, Eric Blake wrote:
On 04/20/2012 07:13 AM, Marc-André Lureau wrote:
Fixes build on Windows systems
we've already conditionalized -pthread; so does this (shorter) patch work to fix the problem instead?
diff --git i/tests/Makefile.am w/tests/Makefile.am index c4d550f..b30d79c 100644 --- i/tests/Makefile.am +++ w/tests/Makefile.am @@ -529,7 +529,7 @@ libshunload_la_LDFLAGS = -module -avoid-version -rpath /evil/libtool/hack/to/for
shunloadtest_SOURCES = \ shunloadtest.c -shunloadtest_LDADD = -lpthread +shunloadtest_LDADD = $(LIB_PTHREAD) shunloadtest_DEPENDENCIES = libshunload.la
if WITH_CIL
ACK
Thanks; pushed. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Marc-André Lureau