From e674605f9821a275e3ed87ce9accc835d565b753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= Date: Mon, 17 Jul 2017 15:58:33 +0200 Subject: qemu-ga: check if utmpx.h is available on the system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ý Signed-off-by: Michael Roth --- qga/commands-posix.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'qga') diff --git a/qga/commands-posix.c b/qga/commands-posix.c index d8e412275e..e7a047e4c2 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -15,7 +15,6 @@ #include #include #include -#include #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 +#endif + #ifndef CONFIG_HAS_ENVIRON #ifdef __APPLE__ #include @@ -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 -- cgit v1.2.1