From nobody Tue Apr 30 12:31:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500300024882960.6645702986202; Mon, 17 Jul 2017 07:00:24 -0700 (PDT) Received: from localhost ([::1]:50602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX6ZS-0002R8-IH for importer@patchew.org; Mon, 17 Jul 2017 10:00:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX6Xp-0000w9-IZ for qemu-devel@nongnu.org; Mon, 17 Jul 2017 09:58:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX6Xl-0005MU-KW for qemu-devel@nongnu.org; Mon, 17 Jul 2017 09:58:41 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:35712) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dX6Xl-0005Lm-DS for qemu-devel@nongnu.org; Mon, 17 Jul 2017 09:58:37 -0400 Received: by mail-wm0-f51.google.com with SMTP id w126so76929676wme.0 for ; Mon, 17 Jul 2017 06:58:36 -0700 (PDT) Received: from fiorina.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id c131sm14274468wmh.2.2017.07.17.06.58.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:58:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/fn7LMYUneb0y3ERW8dVWqvlBi4zQ2Gvhc1eNPM/zCs=; b=ilBKveBA19x8USHOBEfVlqX2HQxXGaS3HXGeuxqQKw3yp0k1ercwHEmITHtfPHKwrQ qQxkdAA7lT2F89eOXZcR4Y0rJ/FUD5l+P/qe4LSyMk15D+tDPp8VSAhL+K6Q1cgf+zNW 2BmTXS1bvq5Vg134SohtaBT5EnpVJ9ZZitEMyoQ45xtCOH33/GPPGNSrMV2hDyIe3sB0 yCOW9MTqsZx8DxCNqHa16BzRCevUTBpROFFAyKZd2Cegb8r/PDolLUxjOaOALCju06Gd CY08KwaD5Apxn/JpqxAu8tefK02HZ3vFzkUJbDeHtMCuvQiZRqXREZThLl7quk2mRfnW jr2A== X-Gm-Message-State: AIVw110xEWFFZQXdcT147MGaYpSRGMLcUBTdB0KonCPiwc4HxBpQnaG3 Kq81tis/arHPAjyt X-Received: by 10.28.105.91 with SMTP id e88mr4263793wmc.52.1500299915267; Mon, 17 Jul 2017 06:58:35 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: Peter Maydell , Michael Roth Date: Mon, 17 Jul 2017 15:58:33 +0200 Message-Id: <8c99564250c916aa0bd3484071bbb0f1ad4d8cf3.1500299896.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.13.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.51 Subject: [Qemu-devel] [PATCH] qemu-ga: check if utmpx.h is available on the system X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 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=C3=A1=C5=A1 Golembiovsk=C3=BD --- configure | 19 +++++++++++++++++++ qga/commands-posix.c | 17 ++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/configure b/configure index a3f0522e8f..e8798cec79 100755 --- a/configure +++ b/configure @@ -4915,6 +4915,21 @@ if compile_prog "" "" ; then fi =20 ########################################## +# check for utmpx.h, it is missing e.g. on OpenBSD + +have_utmpx=3Dno +cat > $TMPC << EOF +#include +struct utmpx user_info; +int main(void) { + return 0; +} +EOF +if compile_prog "" "" ; then + have_utmpx=3Dyes +fi + +########################################## # End of CC checks # After here, no more $cc or $ld runs =20 @@ -5959,6 +5974,10 @@ if test "$have_static_assert" =3D "yes" ; then echo "CONFIG_STATIC_ASSERT=3Dy" >> $config_host_mak fi =20 +if test "$have_utmpx" =3D "yes" ; then + echo "HAVE_UTMPX=3Dy" >> $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 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" =20 +#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 } =20 +#ifdef HAVE_UTMPX + #define QGA_MICRO_SECOND_TO_SECOND 1000000 =20 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 --=20 2.13.1