From 8ab1bf120d7fcf84f199679ad0d25acbc354c69c Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Wed, 23 May 2012 15:48:04 -0300 Subject: [PATCH 1/2] configure: check if environ is declared Some systems may declare environ automatically, others don't. Check for it. Signed-off-by: Luiz Capitulino Signed-off-by: Michael Roth --- configure | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/configure b/configure index b55a792de..1f338f8dc 100755 --- a/configure +++ b/configure @@ -2831,6 +2831,21 @@ if compile_prog "" "" ; then linux_magic_h=yes fi +######################################## +# check if environ is declared + +has_environ=no +cat > $TMPC << EOF +#include +int main(void) { + environ = environ; + return 0; +} +EOF +if compile_prog "" "" ; then + has_environ=yes +fi + ########################################## # End of CC checks # After here, no more $cc or $ld runs @@ -3342,6 +3357,10 @@ if test "$linux_magic_h" = "yes" ; then echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak fi +if test "$has_environ" = "yes" ; then + echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak +fi + # USB host support case "$usb" in linux) From 2c02cbf6e929c20545b46feb5ecde9c86877198a Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Wed, 23 May 2012 15:48:05 -0300 Subject: [PATCH 2/2] qemu-ga: Fix missing environ declaration Commit 3674838cd05268954bb6473239cd7f700a79bf0f uses the environ global variable, but is relying on environ to be declared somewhere else. This worked for me because on F16 environ is declared in , but that doesn't happen in OpenBSD for example, causing a build failure. This commit fixes the build error by declaring environ if it hasn't being declared yet. Also fixes a build warning due to a missing include. Signed-off-by: Luiz Capitulino Signed-off-by: Michael Roth --- qga/commands-posix.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 7664be10a..dab3bf9c9 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -14,12 +14,17 @@ #include #include #include +#include #include "qga/guest-agent-core.h" #include "qga-qmp-commands.h" #include "qerror.h" #include "qemu-queue.h" #include "host-utils.h" +#ifndef CONFIG_HAS_ENVIRON +extern char **environ; +#endif + #if defined(__linux__) #include #include @@ -27,7 +32,6 @@ #include #include #include -#include #if defined(__linux__) && defined(FIFREEZE) #define CONFIG_FSFREEZE