qemu-ga: check if utmpx.h is available on the system
Commit 161a56a906
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>
This commit is contained in:
parent
f2dce827f5
commit
e674605f98
19
configure
vendored
19
configure
vendored
@ -4914,6 +4914,21 @@ if compile_prog "" "" ; then
|
|||||||
have_static_assert=yes
|
have_static_assert=yes
|
||||||
fi
|
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
|
# End of CC checks
|
||||||
# After here, no more $cc or $ld runs
|
# 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
|
echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "$have_utmpx" = "yes" ; then
|
||||||
|
echo "HAVE_UTMPX=y" >> $config_host_mak
|
||||||
|
fi
|
||||||
|
|
||||||
# Hold two types of flag:
|
# Hold two types of flag:
|
||||||
# CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
|
# CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
|
||||||
# a thread we have a handle to
|
# a thread we have a handle to
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <utmpx.h>
|
|
||||||
#include "qga/guest-agent-core.h"
|
#include "qga/guest-agent-core.h"
|
||||||
#include "qga-qmp-commands.h"
|
#include "qga-qmp-commands.h"
|
||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
@ -25,6 +24,10 @@
|
|||||||
#include "qemu/base64.h"
|
#include "qemu/base64.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_UTMPX
|
||||||
|
#include <utmpx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_HAS_ENVIRON
|
#ifndef CONFIG_HAS_ENVIRON
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <crt_externs.h>
|
#include <crt_externs.h>
|
||||||
@ -2519,6 +2522,8 @@ void ga_command_state_init(GAState *s, GACommandState *cs)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_UTMPX
|
||||||
|
|
||||||
#define QGA_MICRO_SECOND_TO_SECOND 1000000
|
#define QGA_MICRO_SECOND_TO_SECOND 1000000
|
||||||
|
|
||||||
static double ga_get_login_time(struct utmpx *user_info)
|
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);
|
g_hash_table_destroy(cache);
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
GuestUserList *qmp_guest_get_users(Error **errp)
|
||||||
|
{
|
||||||
|
error_setg(errp, QERR_UNSUPPORTED);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user