From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, "Tomáš Golembiovský" <tgolembi@redhat.com>
Subject: [Qemu-devel] [PULL v2 3/8] qemu-ga: check if utmpx.h is available on the system
Date: Tue, 18 Jul 2017 06:01:39 -0500 [thread overview]
Message-ID: <1500375704-28002-4-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1500375704-28002-1-git-send-email-mdroth@linux.vnet.ibm.com>
From: Tomáš Golembiovský <tgolembi@redhat.com>
Commit 161a56a9065 added command guest-get-users and requires the
utmpx.h (defined by POSIX) to work. It is however not always available
(e.g. on OpenBSD) therefor a check for its existence is necessary.
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
configure | 19 +++++++++++++++++++
qga/commands-posix.c | 17 ++++++++++++++++-
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index a3f0522..e8798ce 100755
--- a/configure
+++ b/configure
@@ -4915,6 +4915,21 @@ if compile_prog "" "" ; then
fi
##########################################
+# check for utmpx.h, it is missing e.g. on OpenBSD
+
+have_utmpx=no
+cat > $TMPC << EOF
+#include <utmpx.h>
+struct utmpx user_info;
+int main(void) {
+ return 0;
+}
+EOF
+if compile_prog "" "" ; then
+ have_utmpx=yes
+fi
+
+##########################################
# End of CC checks
# After here, no more $cc or $ld runs
@@ -5959,6 +5974,10 @@ if test "$have_static_assert" = "yes" ; then
echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
fi
+if test "$have_utmpx" = "yes" ; then
+ echo "HAVE_UTMPX=y" >> $config_host_mak
+fi
+
# Hold two types of flag:
# CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
# a thread we have a handle to
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index d8e4122..e7a047e 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -15,7 +15,6 @@
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <dirent.h>
-#include <utmpx.h>
#include "qga/guest-agent-core.h"
#include "qga-qmp-commands.h"
#include "qapi/qmp/qerror.h"
@@ -25,6 +24,10 @@
#include "qemu/base64.h"
#include "qemu/cutils.h"
+#ifdef HAVE_UTMPX
+#include <utmpx.h>
+#endif
+
#ifndef CONFIG_HAS_ENVIRON
#ifdef __APPLE__
#include <crt_externs.h>
@@ -2519,6 +2522,8 @@ void ga_command_state_init(GAState *s, GACommandState *cs)
#endif
}
+#ifdef HAVE_UTMPX
+
#define QGA_MICRO_SECOND_TO_SECOND 1000000
static double ga_get_login_time(struct utmpx *user_info)
@@ -2577,3 +2582,13 @@ GuestUserList *qmp_guest_get_users(Error **err)
g_hash_table_destroy(cache);
return head;
}
+
+#else
+
+GuestUserList *qmp_guest_get_users(Error **errp)
+{
+ error_setg(errp, QERR_UNSUPPORTED);
+ return NULL;
+}
+
+#endif
--
2.7.4
next prev parent reply other threads:[~2017-07-18 11:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-18 11:01 [Qemu-devel] [PULL v2 0/8] qemu-ga patch queue Michael Roth
2017-07-18 11:01 ` [Qemu-devel] [PULL v2 1/8] qga-win: fix installation on localized windows Michael Roth
2017-07-18 11:01 ` [Qemu-devel] [PULL v2 2/8] qemu-ga: add missing libpcre to MSI build Michael Roth
2017-07-18 11:01 ` Michael Roth [this message]
2017-07-18 11:01 ` [Qemu-devel] [PULL v2 4/8] qga-win32: remove a redundancy code Michael Roth
2017-07-18 11:01 ` [Qemu-devel] [PULL v2 5/8] qga: report error on keyfile dump error Michael Roth
2017-07-18 11:01 ` [Qemu-devel] [PULL v2 6/8] qemu-ga: add guest-get-osinfo command Michael Roth
2017-07-18 11:01 ` [Qemu-devel] [PULL v2 7/8] test-qga: pass environemnt to qemu-ga Michael Roth
2017-07-18 11:01 ` [Qemu-devel] [PULL v2 8/8] test-qga: add test for guest-get-osinfo Michael Roth
2017-07-18 14:22 ` [Qemu-devel] [PULL v2 0/8] qemu-ga patch queue Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1500375704-28002-4-git-send-email-mdroth@linux.vnet.ibm.com \
--to=mdroth@linux.vnet.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=tgolembi@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).