From nobody Fri May 3 21:58:47 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 1500355541310523.3759689654355; Mon, 17 Jul 2017 22:25:41 -0700 (PDT) Received: from localhost ([::1]:54080 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXL0s-0004qJ-8i for importer@patchew.org; Tue, 18 Jul 2017 01:25:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXKwI-0000TB-Vb for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXKwF-0005Yv-PR for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:54 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54327 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXKwF-0005YL-JI for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:51 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6I5JLMG089320 for ; Tue, 18 Jul 2017 01:20:50 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bsbm2970t-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Jul 2017 01:20:50 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Jul 2017 23:20:49 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 17 Jul 2017 23:20:47 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6I5KkvA64422068; Mon, 17 Jul 2017 22:20:46 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C0116E044; Mon, 17 Jul 2017 23:20:46 -0600 (MDT) Received: from localhost (unknown [9.80.83.16]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 5C9046E035; Mon, 17 Jul 2017 23:20:46 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 00:20:09 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071805-0020-0000-0000-00000C6483D8 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007380; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00889179; UDB=6.00444123; IPR=6.00669352; BA=6.00005478; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016257; XFM=3.00000015; UTC=2017-07-18 05:20:48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071805-0021-0000-0000-00005D4D0A18 Message-Id: <1500355216-23603-2-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-18_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707180089 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL 1/8] qga-win: fix installation on localized windows 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: Daniel Rempel , peter.maydell@linaro.org, Sameeh Jubran Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Daniel Rempel Bug: https://bugzilla.redhat.com/show_bug.cgi?id=3D1357789 Replace hardcoded user and group names ("Administrators", "SYSTEM") with th= e ones acquired from system. Windows uses localized strings for these names= and it may cause the installation to fail. Windows has Well-known SIDs for "Administrators" group and "SYSTEM" user so= they were used to identify required users and groups. Well-known SIDs: https://support.microsoft.com/en-us/help/243330/well-known= -security-identifiers-in-windows-operating-systems Signed-off-by: Daniel Rempel Signed-off-by: Sameeh Jubran Reviewed-by: Sameeh Jubran Signed-off-by: Michael Roth --- qga/vss-win32/install.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp index f41fcdf..ba7c94e 100644 --- a/qga/vss-win32/install.cpp +++ b/qga/vss-win32/install.cpp @@ -18,6 +18,9 @@ #include #include #include +#include + +#define BUFFER_SIZE 1024 =20 extern HINSTANCE g_hinstDll; =20 @@ -135,6 +138,27 @@ out: return hr; } =20 +/* Acquire group or user name by SID */ +static HRESULT getNameByStringSID( + const wchar_t *sid, LPWSTR buffer, LPDWORD bufferLen) +{ + HRESULT hr =3D S_OK; + PSID psid =3D NULL; + SID_NAME_USE groupType; + DWORD domainNameLen =3D BUFFER_SIZE; + wchar_t domainName[BUFFER_SIZE]; + + chk(ConvertStringSidToSidW(sid, &psid)); + LookupAccountSidW(NULL, psid, buffer, bufferLen, + domainName, &domainNameLen, &groupType); + hr =3D HRESULT_FROM_WIN32(GetLastError()); + + LocalFree(psid); + +out: + return hr; +} + /* Find and iterate QGA VSS provider in COM+ Application Catalog */ static HRESULT QGAProviderFind( HRESULT (*found)(ICatalogCollection *, int, void *), void *arg) @@ -216,6 +240,10 @@ STDAPI COMRegister(void) CHAR dllPath[MAX_PATH], tlbPath[MAX_PATH]; bool unregisterOnFailure =3D false; int count =3D 0; + DWORD bufferLen =3D BUFFER_SIZE; + wchar_t buffer[BUFFER_SIZE]; + const wchar_t *administratorsGroupSID =3D L"S-1-5-32-544"; + const wchar_t *systemUserSID =3D L"S-1-5-18"; =20 if (!g_hinstDll) { errmsg(E_FAIL, "Failed to initialize DLL"); @@ -284,11 +312,12 @@ STDAPI COMRegister(void) =20 /* Setup roles of the applicaion */ =20 + chk(getNameByStringSID(administratorsGroupSID, buffer, &bufferLen)); chk(pApps->GetCollection(_bstr_t(L"Roles"), key, (IDispatch **)pRoles.replace())); chk(pRoles->Populate()); chk(pRoles->Add((IDispatch **)pObj.replace())); - chk(put_Value(pObj, L"Name", L"Administrators")); + chk(put_Value(pObj, L"Name", buffer)); chk(put_Value(pObj, L"Description", L"Administrators group")); chk(pRoles->SaveChanges(&n)); chk(pObj->get_Key(&key)); @@ -303,8 +332,10 @@ STDAPI COMRegister(void) chk(GetAdminName(&name)); chk(put_Value(pObj, L"User", _bstr_t(".\\") + name)); =20 + bufferLen =3D BUFFER_SIZE; + chk(getNameByStringSID(systemUserSID, buffer, &bufferLen)); chk(pUsersInRole->Add((IDispatch **)pObj.replace())); - chk(put_Value(pObj, L"User", L"SYSTEM")); + chk(put_Value(pObj, L"User", buffer)); chk(pUsersInRole->SaveChanges(&n)); =20 out: --=20 2.7.4 From nobody Fri May 3 21:58:47 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 1500355368273298.02378449420314; Mon, 17 Jul 2017 22:22:48 -0700 (PDT) Received: from localhost ([::1]:54065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXKy6-0001pY-R6 for importer@patchew.org; Tue, 18 Jul 2017 01:22:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXKwK-0000Tk-0d for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXKwG-0005ZT-Qw for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:55 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59311 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXKwG-0005ZF-LC for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:52 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6I5JMSw040840 for ; Tue, 18 Jul 2017 01:20:52 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0b-001b2d01.pphosted.com with ESMTP id 2bs4ja04j7-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Jul 2017 01:20:52 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Jul 2017 23:20:51 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 17 Jul 2017 23:20:48 -0600 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6I5Klqm24117308; Mon, 17 Jul 2017 22:20:47 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D7389136044; Mon, 17 Jul 2017 23:20:47 -0600 (MDT) Received: from localhost (unknown [9.80.83.16]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id 97C6213603A; Mon, 17 Jul 2017 23:20:47 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 00:20:10 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17071805-0028-0000-0000-0000080A81DE X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007380; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00889179; UDB=6.00444123; IPR=6.00669352; BA=6.00005478; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016257; XFM=3.00000015; UTC=2017-07-18 05:20:50 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071805-0029-0000-0000-000036BA9534 Message-Id: <1500355216-23603-3-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-18_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707180089 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0b-001b2d01.pphosted.com id v6I5JMSw040840 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL 2/8] qemu-ga: add missing libpcre to MSI build 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: peter.maydell@linaro.org, Thomas Lamprecht , Stefan Weil Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Thomas Lamprecht glib depends on libpcre which was not shipped with the MSI, thus starting of the qemu-ga.exe failed with the respective error message. Tell WIXL to ship this library with the MSI to avoid this problem. Signed-off-by: Thomas Lamprecht CC: Stefan Weil CC: Michael Roth Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Michael Roth --- qga/installer/qemu-ga.wxs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qga/installer/qemu-ga.wxs b/qga/installer/qemu-ga.wxs index fa2260c..5af1162 100644 --- a/qga/installer/qemu-ga.wxs +++ b/qga/installer/qemu-ga.wxs @@ -125,6 +125,9 @@ + + + @@ -173,6 +176,7 @@ + =20 --=20 2.7.4 From nobody Fri May 3 21:58:47 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 1500355632400350.60935245132714; Mon, 17 Jul 2017 22:27:12 -0700 (PDT) Received: from localhost ([::1]:54084 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXL2N-00063X-8R for importer@patchew.org; Tue, 18 Jul 2017 01:27:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXKwK-0000VX-T0 for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXKwH-0005Zx-N0 for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:56 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44444) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXKwH-0005ZM-Cn for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:53 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6I5JMBt003400 for ; Tue, 18 Jul 2017 01:20:52 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bs9y7cm6a-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Jul 2017 01:20:52 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Jul 2017 23:20:51 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 17 Jul 2017 23:20:49 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6I5KmAR63308004; Mon, 17 Jul 2017 22:20:48 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1AC976A03C; Mon, 17 Jul 2017 23:20:49 -0600 (MDT) Received: from localhost (unknown [9.80.83.16]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id DB5016A03B; Mon, 17 Jul 2017 23:20:48 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 00:20:11 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17071805-0028-0000-0000-0000080A81DF X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007380; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00889179; UDB=6.00444123; IPR=6.00669352; BA=6.00005478; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016257; XFM=3.00000015; UTC=2017-07-18 05:20:50 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071805-0029-0000-0000-000036BA9535 Message-Id: <1500355216-23603-4-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-18_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707180089 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id v6I5JMBt003400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 3/8] 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: peter.maydell@linaro.org, =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD 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 Signed-off-by: Michael Roth --- 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 =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 d8e4122..e7a047e 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.7.4 From nobody Fri May 3 21:58:47 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 150035550219552.478380557313926; Mon, 17 Jul 2017 22:25:02 -0700 (PDT) Received: from localhost ([::1]:54073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXL0H-0004GU-20 for importer@patchew.org; Tue, 18 Jul 2017 01:25:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48657) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXKwM-0000Ws-Vt for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:21:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXKwJ-0005b6-LF for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:58 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34618) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXKwJ-0005aK-Af for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:55 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6I5JLfW021972 for ; Tue, 18 Jul 2017 01:20:54 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bsaghbn32-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Jul 2017 01:20:54 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Jul 2017 23:20:53 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 17 Jul 2017 23:20:50 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6I5KnYL65536092; Mon, 17 Jul 2017 22:20:49 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BCF0F78041; Mon, 17 Jul 2017 23:20:49 -0600 (MDT) Received: from localhost (unknown [9.80.83.16]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 7E2D67804D; Mon, 17 Jul 2017 23:20:49 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 00:20:12 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071805-8235-0000-0000-00000BF38A0A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007380; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00889179; UDB=6.00444123; IPR=6.00669352; BA=6.00005478; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016257; XFM=3.00000015; UTC=2017-07-18 05:20:51 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071805-8236-0000-0000-00003CCD8AD0 Message-Id: <1500355216-23603-5-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-18_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707180089 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 4/8] qga-win32: remove a redundancy code 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: peter.maydell@linaro.org, Peng Hao Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peng Hao In the first line of run_agent,it has set ga_state =3D s,don't need set ga_state =3D s again behind. Signed-off-by: Peng Hao Signed-off-by: Michael Roth --- qga/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qga/main.c b/qga/main.c index 405c129..dcd6104 100644 --- a/qga/main.c +++ b/qga/main.c @@ -1314,7 +1314,7 @@ static int run_agent(GAState *s, GAConfig *config, in= t socket_activation) ga_command_state_init(s, s->command_state); ga_command_state_init_all(s->command_state); json_message_parser_init(&s->parser, process_event); - ga_state =3D s; + #ifndef _WIN32 if (!register_signal_handlers()) { g_critical("failed to register signal handlers"); --=20 2.7.4 From nobody Fri May 3 21:58:47 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 1500355372955532.5573461694818; Mon, 17 Jul 2017 22:22:52 -0700 (PDT) Received: from localhost ([::1]:54066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXKyB-0001tC-HQ for importer@patchew.org; Tue, 18 Jul 2017 01:22:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXKwM-0000Wm-Re for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:21:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXKwJ-0005b1-LR for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:58 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:41239) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXKwJ-0005aO-BG for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:55 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6I5JSFt089329 for ; Tue, 18 Jul 2017 01:20:54 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bsbx40cwr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Jul 2017 01:20:54 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Jul 2017 23:20:52 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 17 Jul 2017 23:20:51 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6I5KoZZ2884042; Mon, 17 Jul 2017 22:20:50 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A45D0BE044; Mon, 17 Jul 2017 23:20:50 -0600 (MDT) Received: from localhost (unknown [9.80.83.16]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id 70D0EBE039; Mon, 17 Jul 2017 23:20:50 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 00:20:13 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17071805-0016-0000-0000-000007328688 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007380; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00889179; UDB=6.00444123; IPR=6.00669351; BA=6.00005478; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016257; XFM=3.00000015; UTC=2017-07-18 05:20:52 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071805-0017-0000-0000-00003AA20A1F Message-Id: <1500355216-23603-6-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-18_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707180089 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id v6I5JSFt089329 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 5/8] qga: report error on keyfile dump error 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: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Cc:qemu-trivial@nongnu.org Signed-off-by: Michael Roth --- qga/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qga/main.c b/qga/main.c index dcd6104..1b381d0 100644 --- a/qga/main.c +++ b/qga/main.c @@ -1074,7 +1074,12 @@ static void config_dump(GAConfig *config) g_free(tmp); =20 tmp =3D g_key_file_to_data(keyfile, NULL, &error); - printf("%s", tmp); + if (error) { + g_critical("Failed to dump keyfile: %s", error->message); + g_clear_error(&error); + } else { + printf("%s", tmp); + } =20 g_free(tmp); g_key_file_free(keyfile); --=20 2.7.4 From nobody Fri May 3 21:58:47 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 1500355698013332.41057007870734; Mon, 17 Jul 2017 22:28:18 -0700 (PDT) Received: from localhost ([::1]:54086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXL3Q-0006cz-LY for importer@patchew.org; Tue, 18 Jul 2017 01:28:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXKwN-0000Wt-EW for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:21:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXKwK-0005bV-4k for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56971) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXKwJ-0005af-Qh for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:56 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6I5JMfu090328 for ; Tue, 18 Jul 2017 01:20:54 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bs1svyr5y-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Jul 2017 01:20:54 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Jul 2017 23:20:53 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 17 Jul 2017 23:20:52 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6I5KpPa57147638; Mon, 17 Jul 2017 22:20:51 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9A4C3C6043; Mon, 17 Jul 2017 23:20:51 -0600 (MDT) Received: from localhost (unknown [9.80.83.16]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 57254C603E; Mon, 17 Jul 2017 23:20:51 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 00:20:14 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17071805-0008-0000-0000-000008409133 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007380; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00889179; UDB=6.00444123; IPR=6.00669351; BA=6.00005478; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016257; XFM=3.00000015; UTC=2017-07-18 05:20:53 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071805-0009-0000-0000-00004322F848 Message-Id: <1500355216-23603-7-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-18_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707180089 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id v6I5JMfu090328 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 6/8] qemu-ga: add guest-get-osinfo command 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: peter.maydell@linaro.org, =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Vinzenz Feenstra Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD Add a new 'guest-get-osinfo' command for reporting basic information of the guest operating system. This includes machine architecture, version and release of the kernel and several fields from os-release file if it is present (as defined in [1]). [1] https://www.freedesktop.org/software/systemd/man/os-release.html Signed-off-by: Vinzenz Feenstra Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD Signed-off-by: Michael Roth --- qga/commands-posix.c | 134 ++++++++++++++++++++++++++++++++++++ qga/commands-win32.c | 188 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ qga/qapi-schema.json | 65 ++++++++++++++++++ 3 files changed, 387 insertions(+) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index e7a047e..672bf29 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -13,6 +13,7 @@ =20 #include "qemu/osdep.h" #include +#include #include #include #include "qga/guest-agent-core.h" @@ -2592,3 +2593,136 @@ GuestUserList *qmp_guest_get_users(Error **errp) } =20 #endif + +/* Replace escaped special characters with theire real values. The replace= ment + * is done in place -- returned value is in the original string. + */ +static void ga_osrelease_replace_special(gchar *value) +{ + gchar *p, *p2, quote; + + /* Trim the string at first space or semicolon if it is not enclosed in + * single or double quotes. */ + if ((value[0] !=3D '"') || (value[0] =3D=3D '\'')) { + p =3D strchr(value, ' '); + if (p !=3D NULL) { + *p =3D 0; + } + p =3D strchr(value, ';'); + if (p !=3D NULL) { + *p =3D 0; + } + return; + } + + quote =3D value[0]; + p2 =3D value; + p =3D value + 1; + while (*p !=3D 0) { + if (*p =3D=3D '\\') { + p++; + switch (*p) { + case '$': + case '\'': + case '"': + case '\\': + case '`': + break; + default: + /* Keep literal backslash followed by whatever is there */ + p--; + break; + } + } else if (*p =3D=3D quote) { + *p2 =3D 0; + break; + } + *(p2++) =3D *(p++); + } +} + +static GKeyFile *ga_parse_osrelease(const char *fname) +{ + gchar *content =3D NULL; + gchar *content2 =3D NULL; + GError *err =3D NULL; + GKeyFile *keys =3D g_key_file_new(); + const char *group =3D "[os-release]\n"; + + if (!g_file_get_contents(fname, &content, NULL, &err)) { + slog("failed to read '%s', error: %s", fname, err->message); + goto fail; + } + + if (!g_utf8_validate(content, -1, NULL)) { + slog("file is not utf-8 encoded: %s", fname); + goto fail; + } + content2 =3D g_strdup_printf("%s%s", group, content); + + if (!g_key_file_load_from_data(keys, content2, -1, G_KEY_FILE_NONE, + &err)) { + slog("failed to parse file '%s', error: %s", fname, err->message); + goto fail; + } + + g_free(content); + g_free(content2); + return keys; + +fail: + g_error_free(err); + g_free(content); + g_free(content2); + g_key_file_free(keys); + return NULL; +} + +GuestOSInfo *qmp_guest_get_osinfo(Error **errp) +{ + GuestOSInfo *info =3D NULL; + struct utsname kinfo =3D {0}; + + info =3D g_new0(GuestOSInfo, 1); + + if (uname(&kinfo) !=3D 0) { + error_setg_errno(errp, errno, "uname failed"); + } else { + info->has_kernel_version =3D true; + info->kernel_version =3D g_strdup(kinfo.version); + info->has_kernel_release =3D true; + info->kernel_release =3D g_strdup(kinfo.release); + info->has_machine =3D true; + info->machine =3D g_strdup(kinfo.machine); + } + + GKeyFile *osrelease =3D ga_parse_osrelease("/etc/os-release"); + if (osrelease =3D=3D NULL) { + osrelease =3D ga_parse_osrelease("/usr/lib/os-release"); + } + + if (osrelease !=3D NULL) { + char *value; + +#define GET_FIELD(field, osfield) do { \ + value =3D g_key_file_get_value(osrelease, "os-release", osfield, NULL)= ; \ + if (value !=3D NULL) { \ + ga_osrelease_replace_special(value); \ + info->has_ ## field =3D true; \ + info->field =3D value; \ + } \ +} while (0) + GET_FIELD(id, "ID"); + GET_FIELD(name, "NAME"); + GET_FIELD(pretty_name, "PRETTY_NAME"); + GET_FIELD(version, "VERSION"); + GET_FIELD(version_id, "VERSION_ID"); + GET_FIELD(variant, "VARIANT"); + GET_FIELD(variant_id, "VARIANT_ID"); +#undef GET_FIELD + + g_key_file_free(osrelease); + } + + return info; +} diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 6f16457..524c71b 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -1642,3 +1642,191 @@ GuestUserList *qmp_guest_get_users(Error **err) return NULL; #endif } + +typedef struct _ga_matrix_lookup_t { + int major; + int minor; + char const *version; + char const *version_id; +} ga_matrix_lookup_t; + +static ga_matrix_lookup_t const WIN_VERSION_MATRIX[2][8] =3D { + { + /* Desktop editions */ + { 5, 0, "Microsoft Windows 2000", "2000"}, + { 5, 1, "Microsoft Windows XP", "xp"}, + { 6, 0, "Microsoft Windows Vista", "vista"}, + { 6, 1, "Microsoft Windows 7" "7"}, + { 6, 2, "Microsoft Windows 8", "8"}, + { 6, 3, "Microsoft Windows 8.1", "8.1"}, + {10, 0, "Microsoft Windows 10", "10"}, + { 0, 0, 0} + },{ + /* Server editions */ + { 5, 2, "Microsoft Windows Server 2003", "2003"}, + { 6, 0, "Microsoft Windows Server 2008", "2008"}, + { 6, 1, "Microsoft Windows Server 2008 R2", "2008r2"}, + { 6, 2, "Microsoft Windows Server 2012", "2012"}, + { 6, 3, "Microsoft Windows Server 2012 R2", "2012r2"}, + {10, 0, "Microsoft Windows Server 2016", "2016"}, + { 0, 0, 0}, + { 0, 0, 0} + } +}; + +static void ga_get_win_version(RTL_OSVERSIONINFOEXW *info, Error **errp) +{ + typedef NTSTATUS(WINAPI * rtl_get_version_t)( + RTL_OSVERSIONINFOEXW *os_version_info_ex); + + info->dwOSVersionInfoSize =3D sizeof(RTL_OSVERSIONINFOEXW); + + HMODULE module =3D GetModuleHandle("ntdll"); + PVOID fun =3D GetProcAddress(module, "RtlGetVersion"); + if (fun =3D=3D NULL) { + error_setg(errp, QERR_QGA_COMMAND_FAILED, + "Failed to get address of RtlGetVersion"); + return; + } + + rtl_get_version_t rtl_get_version =3D (rtl_get_version_t)fun; + rtl_get_version(info); + return; +} + +static char *ga_get_win_name(OSVERSIONINFOEXW const *os_version, bool id) +{ + DWORD major =3D os_version->dwMajorVersion; + DWORD minor =3D os_version->dwMinorVersion; + int tbl_idx =3D (os_version->wProductType !=3D VER_NT_WORKSTATION); + ga_matrix_lookup_t const *table =3D WIN_VERSION_MATRIX[tbl_idx]; + while (table->version !=3D NULL) { + if (major =3D=3D table->major && minor =3D=3D table->minor) { + if (id) { + return g_strdup(table->version_id); + } else { + return g_strdup(table->version); + } + } + ++table; + } + slog("failed to lookup Windows version: major=3D%lu, minor=3D%lu", + major, minor); + return g_strdup("N/A"); +} + +static char *ga_get_win_product_name(Error **errp) +{ + HKEY key =3D NULL; + DWORD size =3D 128; + char *result =3D g_malloc0(size); + LONG err =3D ERROR_SUCCESS; + + err =3D RegOpenKeyA(HKEY_LOCAL_MACHINE, + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", + &key); + if (err !=3D ERROR_SUCCESS) { + error_setg_win32(errp, err, "failed to open registry key"); + goto fail; + } + + err =3D RegQueryValueExA(key, "ProductName", NULL, NULL, + (LPBYTE)result, &size); + if (err =3D=3D ERROR_MORE_DATA) { + slog("ProductName longer than expected (%lu bytes), retrying", + size); + g_free(result); + result =3D NULL; + if (size > 0) { + result =3D g_malloc0(size); + err =3D RegQueryValueExA(key, "ProductName", NULL, NULL, + (LPBYTE)result, &size); + } + } + if (err !=3D ERROR_SUCCESS) { + error_setg_win32(errp, err, "failed to retrive ProductName"); + goto fail; + } + + return result; + +fail: + g_free(result); + return NULL; +} + +static char *ga_get_current_arch(void) +{ + SYSTEM_INFO info; + GetNativeSystemInfo(&info); + char *result =3D NULL; + switch (info.wProcessorArchitecture) { + case PROCESSOR_ARCHITECTURE_AMD64: + result =3D g_strdup("x86_64"); + break; + case PROCESSOR_ARCHITECTURE_ARM: + result =3D g_strdup("arm"); + break; + case PROCESSOR_ARCHITECTURE_IA64: + result =3D g_strdup("ia64"); + break; + case PROCESSOR_ARCHITECTURE_INTEL: + result =3D g_strdup("x86"); + break; + case PROCESSOR_ARCHITECTURE_UNKNOWN: + default: + slog("unknown processor architecture 0x%0x", + info.wProcessorArchitecture); + result =3D g_strdup("unknown"); + break; + } + return result; +} + +GuestOSInfo *qmp_guest_get_osinfo(Error **errp) +{ + Error *local_err =3D NULL; + OSVERSIONINFOEXW os_version =3D {0}; + + ga_get_win_version(&os_version, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return NULL; + } + + bool server =3D os_version.wProductType !=3D VER_NT_WORKSTATION; + char *product_name =3D ga_get_win_product_name(&local_err); + if (product_name =3D=3D NULL) { + error_propagate(errp, local_err); + return NULL; + } + + GuestOSInfo *info =3D g_new0(GuestOSInfo, 1); + + info->has_kernel_version =3D true; + info->kernel_version =3D g_strdup_printf("%lu.%lu", + os_version.dwMajorVersion, + os_version.dwMinorVersion); + info->has_kernel_release =3D true; + info->kernel_release =3D g_strdup_printf("%lu", + os_version.dwBuildNumber); + info->has_machine =3D true; + info->machine =3D ga_get_current_arch(); + + info->has_id =3D true; + info->id =3D g_strdup("mswindows"); + info->has_name =3D true; + info->name =3D g_strdup("Microsoft Windows"); + info->has_pretty_name =3D true; + info->pretty_name =3D product_name; + info->has_version =3D true; + info->version =3D ga_get_win_name(&os_version, false); + info->has_version_id =3D true; + info->version_id =3D ga_get_win_name(&os_version, true); + info->has_variant =3D true; + info->variant =3D g_strdup(server ? "server" : "client"); + info->has_variant_id =3D true; + info->variant_id =3D g_strdup(server ? "server" : "client"); + + return info; +} diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 03743ab..90a0c86 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -1126,3 +1126,68 @@ ## { 'command': 'guest-get-timezone', 'returns': 'GuestTimezone' } + +## +# @GuestOSInfo: +# +# @kernel-release: +# * POSIX: release field returned by uname(2) +# * Windows: version number of the OS +# @kernel-version: +# * POSIX: version field returned by uname(2) +# * Windows: build number of the OS +# @machine: +# * POSIX: machine field returned by uname(2) +# * Windows: one of x86, x86_64, arm, ia64 +# @id: +# * POSIX: as defined by os-release(5) +# * Windows: contains string "mswindows" +# @name: +# * POSIX: as defined by os-release(5) +# * Windows: contains string "Microsoft Windows" +# @pretty-name: +# * POSIX: as defined by os-release(5) +# * Windows: product name, e.g. "Microsoft Windows 10 Enterprise" +# @version: +# * POSIX: as defined by os-release(5) +# * Windows: long version string, e.g. "Microsoft Windows Server 2008" +# @version-id: +# * POSIX: as defined by os-release(5) +# * Windows: short version identifier, e.g. "7" or "20012r2" +# @variant: +# * POSIX: as defined by os-release(5) +# * Windows: contains string "server" or "client" +# @variant-id: +# * POSIX: as defined by os-release(5) +# * Windows: contains string "server" or "client" +# +# Notes: +# +# On POSIX systems the fields @id, @name, @pretty-name, @version, @version= -id, +# @variant and @variant-id follow the definition specified in os-release(5= ). +# Refer to the manual page for exact description of the fields. Their valu= es +# are taken from the os-release file. If the file is not present in the sy= stem, +# or the values are not present in the file, the fields are not included. +# +# On Windows the values are filled from information gathered from the syst= em. +# +# Since: 2.10 +## +{ 'struct': 'GuestOSInfo', + 'data': { + '*kernel-release': 'str', '*kernel-version': 'str', + '*machine': 'str', '*id': 'str', '*name': 'str', + '*pretty-name': 'str', '*version': 'str', '*version-id': 'str', + '*variant': 'str', '*variant-id': 'str' } } + +## +# @guest-get-osinfo: +# +# Retrieve guest operating system information +# +# Returns: @GuestOSInfo +# +# Since: 2.10 +## +{ 'command': 'guest-get-osinfo', + 'returns': 'GuestOSInfo' } --=20 2.7.4 From nobody Fri May 3 21:58:47 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 1500355505379552.0251850021076; Mon, 17 Jul 2017 22:25:05 -0700 (PDT) Received: from localhost ([::1]:54074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXL0K-0004JK-3C for importer@patchew.org; Tue, 18 Jul 2017 01:25:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXKwO-0000XP-IH for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:21:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXKwL-0005dW-DS for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:21:00 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:41338) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXKwL-0005bk-3D for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:57 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6I5JSFv089329 for ; Tue, 18 Jul 2017 01:20:56 -0400 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bsbx40cxg-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Jul 2017 01:20:55 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 18 Jul 2017 01:20:54 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 18 Jul 2017 01:20:53 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6I5Kqx625886836; Tue, 18 Jul 2017 05:20:52 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 352452804C; Tue, 18 Jul 2017 01:20:46 -0400 (EDT) Received: from localhost (unknown [9.80.83.16]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id 03EA32803F; Tue, 18 Jul 2017 01:20:45 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 00:20:15 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17071805-0044-0000-0000-0000036F9E0E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007380; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00889179; UDB=6.00444123; IPR=6.00669351; BA=6.00005478; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016257; XFM=3.00000015; UTC=2017-07-18 05:20:54 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071805-0045-0000-0000-0000079DA3A0 Message-Id: <1500355216-23603-8-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-18_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707180089 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id v6I5JSFv089329 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 7/8] test-qga: pass environemnt to qemu-ga 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: peter.maydell@linaro.org, =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD Modify fixture_setup() to pass environemnt variables to spawned qemu-ga instance. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Michael Roth --- tests/test-qga.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test-qga.c b/tests/test-qga.c index c77f241..631b986 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -46,7 +46,7 @@ static void qga_watch(GPid pid, gint status, gpointer use= r_data) } =20 static void -fixture_setup(TestFixture *fixture, gconstpointer data) +fixture_setup(TestFixture *fixture, gconstpointer data, gchar **envp) { const gchar *extra_arg =3D data; GError *error =3D NULL; @@ -67,7 +67,7 @@ fixture_setup(TestFixture *fixture, gconstpointer data) g_shell_parse_argv(cmd, NULL, &argv, &error); g_assert_no_error(error); =20 - g_spawn_async(fixture->test_dir, argv, NULL, + g_spawn_async(fixture->test_dir, argv, envp, G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &fixture->pid, &error); g_assert_no_error(error); @@ -707,7 +707,7 @@ static void test_qga_blacklist(gconstpointer data) QDict *ret, *error; const gchar *class, *desc; =20 - fixture_setup(&fix, "-b guest-ping,guest-get-time"); + fixture_setup(&fix, "-b guest-ping,guest-get-time", NULL); =20 /* check blacklist */ ret =3D qmp_fd(fix.fd, "{'execute': 'guest-ping'}"); @@ -943,7 +943,7 @@ int main(int argc, char **argv) =20 setlocale (LC_ALL, ""); g_test_init(&argc, &argv, NULL); - fixture_setup(&fix, NULL); + fixture_setup(&fix, NULL, NULL); =20 g_test_add_data_func("/qga/sync-delimited", &fix, test_qga_sync_delimi= ted); g_test_add_data_func("/qga/sync", &fix, test_qga_sync); --=20 2.7.4 From nobody Fri May 3 21:58:47 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 1500355376172372.05786609762947; Mon, 17 Jul 2017 22:22:56 -0700 (PDT) Received: from localhost ([::1]:54067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXKyE-0001xH-Pw for importer@patchew.org; Tue, 18 Jul 2017 01:22:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXKwP-0000YT-LB for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:21:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXKwM-0005e2-E7 for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:21:01 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:41385) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXKwM-0005dT-3l for qemu-devel@nongnu.org; Tue, 18 Jul 2017 01:20:58 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6I5Jkft090334 for ; Tue, 18 Jul 2017 01:20:57 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bsbx40cy2-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Jul 2017 01:20:56 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 18 Jul 2017 01:20:55 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 18 Jul 2017 01:20:53 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6I5KrsO22020158; Tue, 18 Jul 2017 05:20:53 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E51F124037; Tue, 18 Jul 2017 01:18:20 -0400 (EDT) Received: from localhost (unknown [9.80.83.16]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id E962012403F; Tue, 18 Jul 2017 01:18:19 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 00:20:16 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1500355216-23603-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17071805-0024-0000-0000-000002B1D613 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007380; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00889179; UDB=6.00444123; IPR=6.00669352; BA=6.00005478; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016257; XFM=3.00000015; UTC=2017-07-18 05:20:55 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071805-0025-0000-0000-000044CA7593 Message-Id: <1500355216-23603-9-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-18_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707180089 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id v6I5Jkft090334 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 8/8] test-qga: add test for guest-get-osinfo 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: peter.maydell@linaro.org, =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD Add test for guest-get-osinfo command. Qemu-ga was modified to accept QGA_OS_RELEASE environment variable. If the variable is defined it is interpreted as path to the os-release file and it is parsed instead of the default paths. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Michael Roth --- qga/commands-posix.c | 13 +++++++--- tests/data/test-qga-os-release | 7 ++++++ tests/test-qga.c | 56 ++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 tests/data/test-qga-os-release diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 672bf29..86c20e9 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -2682,6 +2682,8 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp) { GuestOSInfo *info =3D NULL; struct utsname kinfo =3D {0}; + GKeyFile *osrelease =3D NULL; + =20 info =3D g_new0(GuestOSInfo, 1); =20 @@ -2696,9 +2698,14 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp) info->machine =3D g_strdup(kinfo.machine); } =20 - GKeyFile *osrelease =3D ga_parse_osrelease("/etc/os-release"); - if (osrelease =3D=3D NULL) { - osrelease =3D ga_parse_osrelease("/usr/lib/os-release"); + const char *qga_os_release =3D g_getenv("QGA_OS_RELEASE"); + if (qga_os_release !=3D NULL) { + osrelease =3D ga_parse_osrelease(qga_os_release); + } else { + osrelease =3D ga_parse_osrelease("/etc/os-release"); + if (osrelease =3D=3D NULL) { + osrelease =3D ga_parse_osrelease("/usr/lib/os-release"); + } } =20 if (osrelease !=3D NULL) { diff --git a/tests/data/test-qga-os-release b/tests/data/test-qga-os-release new file mode 100644 index 0000000..70664eb --- /dev/null +++ b/tests/data/test-qga-os-release @@ -0,0 +1,7 @@ +ID=3Dqemu-ga-test +NAME=3DQEMU-GA +PRETTY_NAME=3D"QEMU Guest Agent test" +VERSION=3D"Test 1" +VERSION_ID=3D1 +VARIANT=3D"Unit test \"\'\$\`\\ and \\\\ etc." +VARIANT_ID=3Dunit-test diff --git a/tests/test-qga.c b/tests/test-qga.c index 631b986..06783e7 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -936,6 +936,60 @@ static void test_qga_guest_exec_invalid(gconstpointer = fix) QDECREF(ret); } =20 +static void test_qga_guest_get_osinfo(gconstpointer data) +{ + TestFixture fixture; + const gchar *str; + gchar *cwd, *env[2]; + QDict *ret, *val; + + cwd =3D g_get_current_dir(); + env[0] =3D g_strdup_printf( + "QGA_OS_RELEASE=3D%s%ctests%cdata%ctest-qga-os-release", + cwd, G_DIR_SEPARATOR, G_DIR_SEPARATOR, G_DIR_SEPARATOR); + env[1] =3D NULL; + g_free(cwd); + fixture_setup(&fixture, NULL, env); + + ret =3D qmp_fd(fixture.fd, "{'execute': 'guest-get-osinfo'}"); + g_assert_nonnull(ret); + qmp_assert_no_error(ret); + + val =3D qdict_get_qdict(ret, "return"); + + str =3D qdict_get_try_str(val, "id"); + g_assert_nonnull(str); + g_assert_cmpstr(str, =3D=3D, "qemu-ga-test"); + + str =3D qdict_get_try_str(val, "name"); + g_assert_nonnull(str); + g_assert_cmpstr(str, =3D=3D, "QEMU-GA"); + + str =3D qdict_get_try_str(val, "pretty-name"); + g_assert_nonnull(str); + g_assert_cmpstr(str, =3D=3D, "QEMU Guest Agent test"); + + str =3D qdict_get_try_str(val, "version"); + g_assert_nonnull(str); + g_assert_cmpstr(str, =3D=3D, "Test 1"); + + str =3D qdict_get_try_str(val, "version-id"); + g_assert_nonnull(str); + g_assert_cmpstr(str, =3D=3D, "1"); + + str =3D qdict_get_try_str(val, "variant"); + g_assert_nonnull(str); + g_assert_cmpstr(str, =3D=3D, "Unit test \"'$`\\ and \\\\ etc."); + + str =3D qdict_get_try_str(val, "variant-id"); + g_assert_nonnull(str); + g_assert_cmpstr(str, =3D=3D, "unit-test"); + + QDECREF(ret); + g_free(env[0]); + fixture_tear_down(&fixture, NULL); +} + int main(int argc, char **argv) { TestFixture fix; @@ -972,6 +1026,8 @@ int main(int argc, char **argv) g_test_add_data_func("/qga/guest-exec", &fix, test_qga_guest_exec); g_test_add_data_func("/qga/guest-exec-invalid", &fix, test_qga_guest_exec_invalid); + g_test_add_data_func("/qga/guest-get-osinfo", &fix, + test_qga_guest_get_osinfo); =20 if (g_getenv("QGA_TEST_SIDE_EFFECTING")) { g_test_add_data_func("/qga/fsfreeze-and-thaw", &fix, --=20 2.7.4