From nobody Sat May 4 06:10:45 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.zoho.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 1493272389341460.0671355430376; Wed, 26 Apr 2017 22:53:09 -0700 (PDT) Received: from localhost ([::1]:58867 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cMW-0005rB-4f for importer@patchew.org; Thu, 27 Apr 2017 01:53:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cHB-0001HB-7R for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3cH7-0003mH-AI for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:36 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60818 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 1d3cH7-0003m9-3t for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:33 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3R5hdbl068951 for ; Thu, 27 Apr 2017 01:47:32 -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 2a2q9ak4t9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Apr 2017 01:47:32 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 26 Apr 2017 23:47:31 -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; Wed, 26 Apr 2017 23:47:28 -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 v3R5lNWl10944932; Wed, 26 Apr 2017 22:47:23 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 949566E045; Wed, 26 Apr 2017 23:47:23 -0600 (MDT) Received: from localhost (unknown [9.80.102.60]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 52C1A6E03A; Wed, 26 Apr 2017 23:47:23 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 00:46:29 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17042705-0028-0000-0000-0000077AA830 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006981; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00853062; UDB=6.00421735; IPR=6.00631898; BA=6.00005313; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015201; XFM=3.00000013; UTC=2017-04-27 05:47:30 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042705-0029-0000-0000-0000356DC7D0 Message-Id: <1493271996-23607-2-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-27_05:, , 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-1703280000 definitions=main-1704270094 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 v2 1/8] qemu-ga: Make QGA VSS provider service run only when needed 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, 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: Sameeh Jubran Currently the service runs in background on boot even though it is not needed and once it is running it never stops. The service needs to be running only during freeze operation and it should be stopped after executing thaw. Signed-off-by: Sameeh Jubran Signed-off-by: Michael Roth --- qga/vss-win32/install.cpp | 28 ++++++++++++++++++++++++++-- qga/vss-win32/install.h | 20 ++++++++++++++++++++ qga/vss-win32/requester.cpp | 2 ++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 qga/vss-win32/install.h diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp index f4160a3..f41fcdf 100644 --- a/qga/vss-win32/install.cpp +++ b/qga/vss-win32/install.cpp @@ -14,7 +14,7 @@ =20 #include "vss-common.h" #include -#include +#include "install.h" #include #include #include @@ -276,7 +276,7 @@ STDAPI COMRegister(void) =20 chk(pCatalog->CreateServiceForApplication( _bstr_t(QGA_PROVIDER_LNAME), _bstr_t(QGA_PROVIDER_LNAME), - _bstr_t(L"SERVICE_AUTO_START"), _bstr_t(L"SERVICE_ERROR_NORMAL= "), + _bstr_t(L"SERVICE_DEMAND_START"), _bstr_t(L"SERVICE_ERROR_NORM= AL"), _bstr_t(L""), _bstr_t(L".\\localsystem"), _bstr_t(L""), FALSE)= ); chk(pCatalog->InstallComponent(_bstr_t(QGA_PROVIDER_LNAME), _bstr_t(dllPath), _bstr_t(tlbPath), @@ -461,3 +461,27 @@ namespace _com_util return bstr; } } + +/* Stop QGA VSS provider service from COM+ Application Admin Catalog */ + +STDAPI StopService(void) +{ + HRESULT hr; + COMInitializer initializer; + COMPointer pUnknown; + COMPointer pCatalog; + + int count =3D 0; + + chk(QGAProviderFind(QGAProviderCount, (void *)&count)); + if (count) { + chk(CoCreateInstance(CLSID_COMAdminCatalog, NULL, CLSCTX_INPROC_SE= RVER, + IID_IUnknown, (void **)pUnknown.replace())); + chk(pUnknown->QueryInterface(IID_ICOMAdminCatalog2, + (void **)pCatalog.replace())); + chk(pCatalog->ShutdownApplication(_bstr_t(QGA_PROVIDER_LNAME))); + } + +out: + return hr; +} diff --git a/qga/vss-win32/install.h b/qga/vss-win32/install.h new file mode 100644 index 0000000..35364af --- /dev/null +++ b/qga/vss-win32/install.h @@ -0,0 +1,20 @@ +/* + * QEMU Guest Agent VSS requester declarations + * + * Copyright Hitachi Data Systems Corp. 2013 + * + * Authors: + * Tomoki Sekiyama + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef INSTALL_H +#define INSTALL_H + +#include + +STDAPI StopService(void); + +#endif diff --git a/qga/vss-win32/requester.cpp b/qga/vss-win32/requester.cpp index 0cd2f0e..301762d 100644 --- a/qga/vss-win32/requester.cpp +++ b/qga/vss-win32/requester.cpp @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "vss-common.h" #include "requester.h" +#include "install.h" #include #include =20 @@ -501,4 +502,5 @@ void requester_thaw(int *num_vols, ErrorSet *errset) requester_cleanup(); =20 CoUninitialize(); + StopService(); } --=20 2.7.4 From nobody Sat May 4 06:10:45 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.zoho.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 1493272168210559.0052229050532; Wed, 26 Apr 2017 22:49:28 -0700 (PDT) Received: from localhost ([::1]:58852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cIw-0002Zp-Hm for importer@patchew.org; Thu, 27 Apr 2017 01:49:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cH7-0001Cd-87 for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3cH4-0003lI-4w for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:33 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33144 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 1d3cH3-0003l5-UI for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:30 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3R5hbxt146028 for ; Thu, 27 Apr 2017 01:47:28 -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 2a32a0rvqb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Apr 2017 01:47:28 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 26 Apr 2017 23:47:27 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 26 Apr 2017 23:47:25 -0600 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3R5lOPD14942592; Wed, 26 Apr 2017 22:47:24 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A3CBB13603A; Wed, 26 Apr 2017 23:47:24 -0600 (MDT) Received: from localhost (unknown [9.80.102.60]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id 6A37713603C; Wed, 26 Apr 2017 23:47:24 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 00:46:30 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17042705-0028-0000-0000-0000077AA82C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006981; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00853062; UDB=6.00421735; IPR=6.00631898; BA=6.00005313; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015201; XFM=3.00000013; UTC=2017-04-27 05:47:27 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042705-0029-0000-0000-0000356DC7CA Message-Id: <1493271996-23607-3-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-27_05:, , 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-1703280000 definitions=main-1704270094 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 v2 2/8] qga-win: Enable 'can-offline' field in 'guest-get-vcpus' reply 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, Sameeh Jubran , qemu-stable@nongnu.org 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: Sameeh Jubran The QGA schema states: @can-offline: Whether offlining the VCPU is possible. This member is always filled in by the guest agent when the structure is returned, and always ignored on input (hence it can be omitted then). Currently 'can-offline' is missing entirely from the reply. This causes errors in libvirt which is expecting the reply to be compliant with the schema docs. BZ#1438735: https://bugzilla.redhat.com/show_bug.cgi?id=3D1438735 Signed-off-by: Sameeh Jubran Reviewed-by: Eric Blake Cc: qemu-stable@nongnu.org Signed-off-by: Michael Roth --- qga/commands-win32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 04026ee..9fec1fb 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -1344,7 +1344,7 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error = **errp) vcpu =3D g_malloc0(sizeof *vcpu); vcpu->logical_id =3D current++; vcpu->online =3D true; - vcpu->has_can_offline =3D false; + vcpu->has_can_offline =3D true; =20 entry =3D g_malloc0(sizeof *entry); entry->value =3D vcpu; --=20 2.7.4 From nobody Sat May 4 06:10:45 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.zoho.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 1493272189515154.75567988217563; Wed, 26 Apr 2017 22:49:49 -0700 (PDT) Received: from localhost ([::1]:58854 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cJI-0002pD-6n for importer@patchew.org; Thu, 27 Apr 2017 01:49:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cH7-0001EJ-TN for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3cH4-0003lO-K2 for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:33 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34689 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 1d3cH4-0003lE-DI for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:30 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3R5ha0Y066115 for ; Thu, 27 Apr 2017 01:47:29 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 2a34vqu17t-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Apr 2017 01:47:29 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 26 Apr 2017 23:47:28 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 26 Apr 2017 23:47:26 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3R5lP6a16712106; Wed, 26 Apr 2017 22:47:25 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B8B76E03A; Wed, 26 Apr 2017 23:47:25 -0600 (MDT) Received: from localhost (unknown [9.80.102.60]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 644FA6E035; Wed, 26 Apr 2017 23:47:25 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 00:46:31 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17042705-0020-0000-0000-00000BD4A52A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006981; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00853062; UDB=6.00421735; IPR=6.00631898; BA=6.00005313; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015201; XFM=3.00000013; UTC=2017-04-27 05:47:27 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042705-0021-0000-0000-00005BFF2829 Message-Id: <1493271996-23607-4-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-27_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=4 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704270094 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 v2 3/8] qga-win: Fix a bug where qemu-ga service is stuck during stop operation 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, 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: Sameeh Jubran After triggering a freeze command without any following thaw command, qemu-ga will not respond to stop operation. This behaviour is wanted on Lin= ux as there is no time limit for a freeze command and we want to prevent quitting in the middle of freeze, on the other hand on Windows the time limit for freeze is 10 seconds, so we should wait for the timeout, thaw the file system and quit. Signed-off-by: Sameeh Jubran Signed-off-by: Michael Roth --- qga/main.c | 23 +++++++++++++++++++++++ qga/vss-win32.h | 1 + qga/vss-win32/vss-common.h | 11 +---------- qga/vss-win32/vss-handles.h | 14 ++++++++++++++ 4 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 qga/vss-win32/vss-handles.h diff --git a/qga/main.c b/qga/main.c index 07c2953..ad6f68f 100644 --- a/qga/main.c +++ b/qga/main.c @@ -131,9 +131,32 @@ static void quit_handler(int sig) * unless all log/pid files are on unfreezable filesystems. there's * also a very likely chance killing the agent before unfreezing * the filesystems is a mistake (or will be viewed as one later). + * On Windows the freeze interval is limited to 10 seconds, so + * we should quit, but first we should wait for the timeout, thaw + * the filesystem and quit. */ if (ga_is_frozen(ga_state)) { +#ifdef _WIN32 + int i =3D 0; + Error *err =3D NULL; + HANDLE hEventTimeout; + + g_debug("Thawing filesystems before exiting"); + + hEventTimeout =3D OpenEvent(EVENT_ALL_ACCESS, FALSE, EVENT_NAME_TI= MEOUT); + if (hEventTimeout) { + WaitForSingleObject(hEventTimeout, 0); + CloseHandle(hEventTimeout); + } + qga_vss_fsfreeze(&i, false, &err); + if (err) { + g_debug("Error unfreezing filesystems prior to exiting: %s", + error_get_pretty(err)); + error_free(err); + } +#else return; +#endif } g_debug("received signal num %d, quitting", sig); =20 diff --git a/qga/vss-win32.h b/qga/vss-win32.h index 51d303a..4f8e39a 100644 --- a/qga/vss-win32.h +++ b/qga/vss-win32.h @@ -13,6 +13,7 @@ #ifndef VSS_WIN32_H #define VSS_WIN32_H =20 +#include "qga/vss-win32/vss-handles.h" =20 bool vss_init(bool init_requester); void vss_deinit(bool deinit_requester); diff --git a/qga/vss-win32/vss-common.h b/qga/vss-win32/vss-common.h index c81a856..61c170b 100644 --- a/qga/vss-win32/vss-common.h +++ b/qga/vss-win32/vss-common.h @@ -51,21 +51,12 @@ * http://www.microsoft.com/en-us/download/details.aspx?id=3D23490 */ #include +#include "vss-handles.h" =20 /* Macros to convert char definitions to wchar */ #define _L(a) L##a #define L(a) _L(a) =20 -/* Constants for QGA VSS Provider */ - -#define QGA_PROVIDER_NAME "QEMU Guest Agent VSS Provider" -#define QGA_PROVIDER_LNAME L(QGA_PROVIDER_NAME) -#define QGA_PROVIDER_VERSION L(QEMU_VERSION) - -#define EVENT_NAME_FROZEN "Global\\QGAVSSEvent-frozen" -#define EVENT_NAME_THAW "Global\\QGAVSSEvent-thaw" -#define EVENT_NAME_TIMEOUT "Global\\QGAVSSEvent-timeout" - const GUID g_gProviderId =3D { 0x3629d4ed, 0xee09, 0x4e0e, {0x9a, 0x5c, 0x6d, 0x8b, 0xa2, 0x87, 0x2a, 0xef} }; const GUID g_gProviderVersion =3D { 0x11ef8b15, 0xcac6, 0x40d6, diff --git a/qga/vss-win32/vss-handles.h b/qga/vss-win32/vss-handles.h new file mode 100644 index 0000000..ff399dd --- /dev/null +++ b/qga/vss-win32/vss-handles.h @@ -0,0 +1,14 @@ +#ifndef VSS_HANDLES +#define VSS_HANDLES + +/* Constants for QGA VSS Provider */ + +#define QGA_PROVIDER_NAME "QEMU Guest Agent VSS Provider" +#define QGA_PROVIDER_LNAME L(QGA_PROVIDER_NAME) +#define QGA_PROVIDER_VERSION L(QEMU_VERSION) + +#define EVENT_NAME_FROZEN "Global\\QGAVSSEvent-frozen" +#define EVENT_NAME_THAW "Global\\QGAVSSEvent-thaw" +#define EVENT_NAME_TIMEOUT "Global\\QGAVSSEvent-timeout" + +#endif --=20 2.7.4 From nobody Sat May 4 06:10:45 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.zoho.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 1493272319598177.79317105747134; Wed, 26 Apr 2017 22:51:59 -0700 (PDT) Received: from localhost ([::1]:58865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cLO-0004ak-9B for importer@patchew.org; Thu, 27 Apr 2017 01:51:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cHB-0001HA-7L for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3cH6-0003lw-Ay for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:35 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44613) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3cH6-0003lf-2Z for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:32 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3R5hont038912 for ; Thu, 27 Apr 2017 01:47:31 -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 2a2xcmc0nt-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Apr 2017 01:47:30 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 26 Apr 2017 23:47:30 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 26 Apr 2017 23:47:27 -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 v3R5lQlJ12779998; Wed, 26 Apr 2017 22:47:26 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B3FB1136043; Wed, 26 Apr 2017 23:47:26 -0600 (MDT) Received: from localhost (unknown [9.80.102.60]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id 6B66713603A; Wed, 26 Apr 2017 23:47:26 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 00:46:32 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17042705-0016-0000-0000-000006A1B2F7 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006981; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00853062; UDB=6.00421735; IPR=6.00631898; BA=6.00005313; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015201; XFM=3.00000013; UTC=2017-04-27 05:47:28 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042705-0017-0000-0000-0000394FF331 Message-Id: <1493271996-23607-5-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-27_05:, , 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-1703280000 definitions=main-1704270094 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 v2 4/8] qga-win: Fix Event Viewer errors caused by 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, 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: Sameeh Jubran When the command "guest-fsfreeze-freeze" is executed it causes the VSS service to log the error below in the Event Viewer. This error is caused by an issue in the function "CommitSnapshots" in provider.cpp: * When VSS_TIMEOUT_MSEC expires the funtion returns E_ABORT. This causes the error #12293. |event id| error | * 12293 : Volume Shadow Copy Service error: Error calling a routine on a Shadow Copy Provider {00000000-0000-0000-0000-000000000000}. Routine details CommitSnapshots [hr =3D 0x80004004, Operation aborted. Signed-off-by: Sameeh Jubran Signed-off-by: Michael Roth --- qga/vss-win32/provider.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/qga/vss-win32/provider.cpp b/qga/vss-win32/provider.cpp index ef94669..72d8b0e 100644 --- a/qga/vss-win32/provider.cpp +++ b/qga/vss-win32/provider.cpp @@ -377,7 +377,6 @@ STDMETHODIMP CQGAVssProvider::CommitSnapshots(VSS_ID Sn= apshotSetId) if (WaitForSingleObject(hEventThaw, VSS_TIMEOUT_MSEC) !=3D WAIT_OBJECT= _0) { /* Send event to qemu-ga to notify the provider is timed out */ SetEvent(hEventTimeout); - hr =3D E_ABORT; } =20 CloseHandle(hEventThaw); --=20 2.7.4 From nobody Sat May 4 06:10:45 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.zoho.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 1493272305024121.20929316908905; Wed, 26 Apr 2017 22:51:45 -0700 (PDT) Received: from localhost ([::1]:58864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cL9-0004PI-OB for importer@patchew.org; Thu, 27 Apr 2017 01:51:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cHB-0001H8-7K for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3cH5-0003lk-OU for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:35 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33179 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 1d3cH5-0003lb-Ig for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:31 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3R5hbHT146027 for ; Thu, 27 Apr 2017 01:47:30 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0b-001b2d01.pphosted.com with ESMTP id 2a32a0rvrq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Apr 2017 01:47:30 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Apr 2017 01:47:30 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 27 Apr 2017 01:47:28 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3R5lSmU41091144; Thu, 27 Apr 2017 05:47:28 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 61ECD112051; Thu, 27 Apr 2017 01:47:26 -0400 (EDT) Received: from localhost (unknown [9.80.102.60]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 23B3211204B; Thu, 27 Apr 2017 01:47:26 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 00:46:33 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17042705-0048-0000-0000-0000016CEA48 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006981; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00853062; UDB=6.00421735; IPR=6.00631898; BA=6.00005313; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015201; XFM=3.00000013; UTC=2017-04-27 05:47:29 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042705-0049-0000-0000-000040D33150 Message-Id: <1493271996-23607-6-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-27_05:, , 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-1703280000 definitions=main-1704270094 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 v2 5/8] qga: Add 'guest-get-host-name' 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, Vinzenz Feenstra 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: Vinzenz Feenstra Retrieving the guest host name is a very useful feature for virtual managem= ent systems. This information can help to have more user friendly VM access details, instead of an IP there would be the host name. Also the host name reported can be used to have automated checks for valid SSL certificates. virsh # qemu-agent-command F25 '{ "execute": "guest-get-host-name" }' {"return":{"host-name":"F25.lab.evilissimo.net"}} Signed-off-by: Vinzenz Feenstra * minor whitespace fix-ups Signed-off-by: Michael Roth --- qga/commands.c | 11 +++++++++++ qga/qapi-schema.json | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/qga/commands.c b/qga/commands.c index 4d92946..57a31bb 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -499,3 +499,14 @@ int ga_parse_whence(GuestFileWhence *whence, Error **e= rrp) error_setg(errp, "invalid whence code %"PRId64, whence->u.value); return -1; } + +GuestHostName *qmp_guest_get_host_name(Error **err) +{ + GuestHostName *result =3D NULL; + gchar const *hostname =3D g_get_host_name(); + if (hostname !=3D NULL) { + result =3D g_new0(GuestHostName, 1); + result->host_name =3D g_strdup(hostname); + } + return result; +} diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index a02dbf2..6307ae2 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -1042,3 +1042,29 @@ 'data': { 'path': 'str', '*arg': ['str'], '*env': ['str'], '*input-data': 'str', '*capture-output': 'bool' }, 'returns': 'GuestExec' } + + +## +# @GuestHostName: +# @host-name: Fully qualified domain name of the guest OS +# +# Since: 2.10 +## +{ 'struct': 'GuestHostName', + 'data': { 'host-name': 'str' } } + +## +# @guest-get-host-name: +# +# Return a name for the machine. +# +# The returned name is not necessarily a fully-qualified domain name, or e= ven +# present in DNS or some other name service at all. It need not even be un= ique +# on your local network or site, but usually it is. +# +# Returns: the host name of the machine on success +# +# Since: 2.10 +## +{ 'command': 'guest-get-host-name', + 'returns': 'GuestHostName' } --=20 2.7.4 From nobody Sat May 4 06:10:45 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.zoho.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 1493272481000863.6433024095991; Wed, 26 Apr 2017 22:54:41 -0700 (PDT) Received: from localhost ([::1]:58874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cNz-0006jP-NM for importer@patchew.org; Thu, 27 Apr 2017 01:54:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cHB-0001HC-7R for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3cH7-0003ma-Gp for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:36 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39921) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3cH7-0003m6-8Q for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:33 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3R5ha9m018502 for ; Thu, 27 Apr 2017 01:47:32 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2a34vxk7ea-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Apr 2017 01:47:32 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 26 Apr 2017 23:47:31 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 26 Apr 2017 23:47:29 -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 v3R5lRkv10944964; Wed, 26 Apr 2017 22:47:28 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7FAE66A03D; Wed, 26 Apr 2017 23:47:28 -0600 (MDT) Received: from localhost (unknown [9.80.102.60]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 372456A03C; Wed, 26 Apr 2017 23:47:28 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 00:46:34 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17042705-0004-0000-0000-00001209A534 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006981; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00853062; UDB=6.00421735; IPR=6.00631898; BA=6.00005313; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015201; XFM=3.00000013; UTC=2017-04-27 05:47:30 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042705-0005-0000-0000-00007EF51B27 Message-Id: <1493271996-23607-7-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-27_05:, , 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-1703280000 definitions=main-1704270094 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id v3R5ha9m018502 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 v2 6/8] qga: improve fsfreeze documentations 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 Some users find the fsfreeze behaviour confusing. Add some notes about invalid mount points and Windows usage. Related to: https://bugzilla.redhat.com/show_bug.cgi?id=3D1436976 Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Vinzenz Feenstra Signed-off-by: Michael Roth --- qga/qapi-schema.json | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 6307ae2..0f4cba5 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -426,7 +426,13 @@ ## # @guest-fsfreeze-freeze: # -# Sync and freeze all freezable, local guest filesystems +# Sync and freeze all freezable, local guest filesystems. If this +# command succeeded, you may call @guest-fsfreeze-thaw later to +# unfreeze. +# +# Note: On Windows, the command is implemented with the help of a +# Volume Shadow-copy Service DLL helper. The frozen state is limited +# for up to 10 seconds by VSS. # # Returns: Number of file systems currently frozen. On error, all filesyst= ems # will be thawed. @@ -439,10 +445,12 @@ ## # @guest-fsfreeze-freeze-list: # -# Sync and freeze specified guest filesystems +# Sync and freeze specified guest filesystems. +# See also @guest-fsfreeze-freeze. # # @mountpoints: an array of mountpoints of filesystems to be frozen. # If omitted, every mounted filesystem is frozen. +# Invalid mount points are ignored. # # Returns: Number of file systems currently frozen. On error, all filesyst= ems # will be thawed. --=20 2.7.4 From nobody Sat May 4 06:10:45 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.zoho.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 1493272169815605.8643307108673; Wed, 26 Apr 2017 22:49:29 -0700 (PDT) Received: from localhost ([::1]:58853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cIy-0002bv-Dr for importer@patchew.org; Thu, 27 Apr 2017 01:49:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cHB-0001HD-7S for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3cH7-0003mh-N9 for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:37 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:51226 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 1d3cH7-0003mD-GK for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:33 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3R5hhbf187328 for ; Thu, 27 Apr 2017 01:47:32 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2a333hetvb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Apr 2017 01:47:32 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 26 Apr 2017 23:47:31 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 26 Apr 2017 23:47:30 -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 v3R5lTNS10813696; Wed, 26 Apr 2017 22:47:29 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C8D126A03B; Wed, 26 Apr 2017 23:47:29 -0600 (MDT) Received: from localhost (unknown [9.80.102.60]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 6145D6A03F; Wed, 26 Apr 2017 23:47:29 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 00:46:35 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17042705-0012-0000-0000-00001420A44B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006981; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00853062; UDB=6.00421735; IPR=6.00631898; BA=6.00005313; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015201; XFM=3.00000013; UTC=2017-04-27 05:47:31 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042705-0013-0000-0000-00004D54B156 Message-Id: <1493271996-23607-8-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-27_05:, , 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-1703280000 definitions=main-1704270094 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 v2 7/8] qga: Add 'guest-get-users' 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, Vinzenz Feenstra 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: Vinzenz Feenstra A command that will list all currently logged in users, and the time since when they are logged in. Examples: virsh # qemu-agent-command F25 '{ "execute": "guest-get-users" }' {"return":[{"login-time":1490622289.903835,"user":"root"}]} virsh # qemu-agent-command Win2k12r2 '{ "execute": "guest-get-users" }' {"return":[{"login-time":1490351044.670552,"domain":"LADIDA", "user":"Administrator"}]} Signed-off-by: Vinzenz Feenstra * make g_hash_table_contains compat func inline to avoid unused warnings Signed-off-by: Michael Roth --- configure | 2 +- include/glib-compat.h | 6 +++ qga/commands-posix.c | 60 +++++++++++++++++++++++++++++ qga/commands-win32.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ qga/qapi-schema.json | 25 ++++++++++++ 5 files changed, 195 insertions(+), 1 deletion(-) diff --git a/configure b/configure index c35acf1..80d17f3 100755 --- a/configure +++ b/configure @@ -743,7 +743,7 @@ if test "$mingw32" =3D "yes" ; then sysconfdir=3D"\${prefix}" local_statedir=3D confsuffix=3D"" - libs_qga=3D"-lws2_32 -lwinmm -lpowrprof -liphlpapi -lnetapi32 $libs_qga" + libs_qga=3D"-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -liphlpapi -lnetapi32= $libs_qga" fi =20 werror=3D"" diff --git a/include/glib-compat.h b/include/glib-compat.h index 863c8cf..fcffcd3 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -217,6 +217,12 @@ static inline void g_hash_table_add(GHashTable *hash_t= able, gpointer key) { g_hash_table_replace(hash_table, key, key); } + +static inline gboolean g_hash_table_contains(GHashTable *hash_table, + gpointer key) +{ + return g_hash_table_lookup_extended(hash_table, key, NULL, NULL); +} #endif =20 #ifndef g_assert_true diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 915df9e..ba06be4 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "qga/guest-agent-core.h" #include "qga-qmp-commands.h" #include "qapi/qmp/qerror.h" @@ -2517,3 +2518,62 @@ void ga_command_state_init(GAState *s, GACommandStat= e *cs) ga_command_state_add(cs, NULL, guest_fsfreeze_cleanup); #endif } + +#define QGA_MICRO_SECOND_TO_SECOND 1000000 + +static double ga_get_login_time(struct utmpx *user_info) +{ + double seconds =3D (double)user_info->ut_tv.tv_sec; + double useconds =3D (double)user_info->ut_tv.tv_usec; + useconds /=3D QGA_MICRO_SECOND_TO_SECOND; + return seconds + useconds; +} + +GuestUserList *qmp_guest_get_users(Error **err) +{ + GHashTable *cache =3D NULL; + GuestUserList *head =3D NULL, *cur_item =3D NULL; + struct utmpx *user_info =3D NULL; + gpointer value =3D NULL; + GuestUser *user =3D NULL; + GuestUserList *item =3D NULL; + double login_time =3D 0; + + cache =3D g_hash_table_new(g_str_hash, g_str_equal); + setutxent(); + + for (;;) { + user_info =3D getutxent(); + if (user_info =3D=3D NULL) { + break; + } else if (user_info->ut_type !=3D USER_PROCESS) { + continue; + } else if (g_hash_table_contains(cache, user_info->ut_user)) { + value =3D g_hash_table_lookup(cache, user_info->ut_user); + user =3D (GuestUser *)value; + login_time =3D ga_get_login_time(user_info); + /* We're ensuring the earliest login time to be sent */ + if (login_time < user->login_time) { + user->login_time =3D login_time; + } + continue; + } + + item =3D g_new0(GuestUserList, 1); + item->value =3D g_new0(GuestUser, 1); + item->value->user =3D g_strdup(user_info->ut_user); + item->value->login_time =3D ga_get_login_time(user_info); + + g_hash_table_insert(cache, item->value->user, item->value); + + if (!cur_item) { + head =3D cur_item =3D item; + } else { + cur_item->next =3D item; + cur_item =3D item; + } + } + endutxent(); + g_hash_table_destroy(cache); + return head; +} diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 9fec1fb..439d229 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -11,6 +11,9 @@ * See the COPYING file in the top-level directory. */ =20 +#ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0600 +#endif #include "qemu/osdep.h" #include #include @@ -25,6 +28,7 @@ #include #endif #include +#include =20 #include "qga/guest-agent-core.h" #include "qga/vss-win32.h" @@ -1536,3 +1540,102 @@ void ga_command_state_init(GAState *s, GACommandSta= te *cs) ga_command_state_add(cs, NULL, guest_fsfreeze_cleanup); } } + +/* MINGW is missing two fields: IncomingFrames & OutgoingFrames */ +typedef struct _GA_WTSINFOA { + WTS_CONNECTSTATE_CLASS State; + DWORD SessionId; + DWORD IncomingBytes; + DWORD OutgoingBytes; + DWORD IncomingFrames; + DWORD OutgoingFrames; + DWORD IncomingCompressedBytes; + DWORD OutgoingCompressedBy; + CHAR WinStationName[WINSTATIONNAME_LENGTH]; + CHAR Domain[DOMAIN_LENGTH]; + CHAR UserName[USERNAME_LENGTH + 1]; + LARGE_INTEGER ConnectTime; + LARGE_INTEGER DisconnectTime; + LARGE_INTEGER LastInputTime; + LARGE_INTEGER LogonTime; + LARGE_INTEGER CurrentTime; + +} GA_WTSINFOA; + +GuestUserList *qmp_guest_get_users(Error **err) +{ +#if (_WIN32_WINNT >=3D 0x0600) +#define QGA_NANOSECONDS 10000000 + + GHashTable *cache =3D NULL; + GuestUserList *head =3D NULL, *cur_item =3D NULL; + + DWORD buffer_size =3D 0, count =3D 0, i =3D 0; + GA_WTSINFOA *info =3D NULL; + WTS_SESSION_INFOA *entries =3D NULL; + GuestUserList *item =3D NULL; + GuestUser *user =3D NULL; + gpointer value =3D NULL; + INT64 login =3D 0; + double login_time =3D 0; + + cache =3D g_hash_table_new(g_str_hash, g_str_equal); + + if (WTSEnumerateSessionsA(NULL, 0, 1, &entries, &count)) { + for (i =3D 0; i < count; ++i) { + buffer_size =3D 0; + info =3D NULL; + if (WTSQuerySessionInformationA( + NULL, + entries[i].SessionId, + WTSSessionInfo, + (LPSTR *)&info, + &buffer_size + )) { + + if (strlen(info->UserName) =3D=3D 0) { + WTSFreeMemory(info); + continue; + } + + login =3D info->LogonTime.QuadPart; + login -=3D W32_FT_OFFSET; + login_time =3D ((double)login) / QGA_NANOSECONDS; + + if (g_hash_table_contains(cache, info->UserName)) { + value =3D g_hash_table_lookup(cache, info->UserName); + user =3D (GuestUser *)value; + if (user->login_time > login_time) { + user->login_time =3D login_time; + } + } else { + item =3D g_new0(GuestUserList, 1); + item->value =3D g_new0(GuestUser, 1); + + item->value->user =3D g_strdup(info->UserName); + item->value->domain =3D g_strdup(info->Domain); + item->value->has_domain =3D true; + + item->value->login_time =3D login_time; + + g_hash_table_add(cache, item->value->user); + + if (!cur_item) { + head =3D cur_item =3D item; + } else { + cur_item->next =3D item; + cur_item =3D item; + } + } + } + WTSFreeMemory(info); + } + WTSFreeMemory(entries); + } + g_hash_table_destroy(cache); + return head; +#else + error_setg(err, QERR_UNSUPPORTED); + return NULL; +#endif +} diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 0f4cba5..f25467a 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -1076,3 +1076,28 @@ ## { 'command': 'guest-get-host-name', 'returns': 'GuestHostName' } + + +## +# @GuestUser: +# @user: Username +# @domain: Logon domain (windows only) +# @login-time: Time of login of this user on the computer. If multiple +# instances of the user are logged in, the earliest login tim= e is +# reported. The value is in fractional seconds since epoch ti= me. +# +# Since: 2.10 +## +{ 'struct': 'GuestUser', + 'data': { 'user': 'str', 'login-time': 'number', '*domain': 'str' } } + +## +# @guest-get-users: +# Retrieves a list of currently active users on the VM. +# +# Returns: A unique list of users. +# +# Since: 2.10 +## +{ 'command': 'guest-get-users', + 'returns': ['GuestUser'] } --=20 2.7.4 From nobody Sat May 4 06:10:45 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.zoho.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 1493272301042917.5582100522353; Wed, 26 Apr 2017 22:51:41 -0700 (PDT) Received: from localhost ([::1]:58863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cL5-0004M9-S0 for importer@patchew.org; Thu, 27 Apr 2017 01:51:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3cHF-0001Uy-Go for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3cHB-0003nb-Kg for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60537) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3cHB-0003nC-C0 for qemu-devel@nongnu.org; Thu, 27 Apr 2017 01:47:37 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3R5hc6e090413 for ; Thu, 27 Apr 2017 01:47:36 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2a32j3r3jq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 27 Apr 2017 01:47:35 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 26 Apr 2017 23:47:34 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 26 Apr 2017 23:47:31 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3R5lVL015925520; Wed, 26 Apr 2017 22:47:31 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3351D78038; Wed, 26 Apr 2017 23:47:31 -0600 (MDT) Received: from localhost (unknown [9.80.102.60]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id D9B0678037; Wed, 26 Apr 2017 23:47:30 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 00:46:36 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1493271996-23607-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17042705-0012-0000-0000-00001420A44F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006981; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00853062; UDB=6.00421735; IPR=6.00631898; BA=6.00005313; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015201; XFM=3.00000013; UTC=2017-04-27 05:47:33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042705-0013-0000-0000-00004D54B15A Message-Id: <1493271996-23607-9-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-27_05:, , 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-1703280000 definitions=main-1704270094 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 v2 8/8] qga: Add `guest-get-timezone` 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, Vinzenz Feenstra 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: Vinzenz Feenstra Adds a new command `guest-get-timezone` reporting the currently configured timezone on the system. The information on what timezone is currently is configured is useful in case of Windows VMs where the offset of the hardware clock is required to have the same offset. This can be used for management systems like `oVirt` to detect the timezone difference and warn administrators of the misconfiguration. Signed-off-by: Vinzenz Feenstra Reviewed-by: Sameeh Jubran Tested-by: Sameeh Jubran * moved stub implementation to end of function for consistency * document that timezone names are for informational use only. Signed-off-by: Michael Roth --- qga/commands.c | 38 ++++++++++++++++++++++++++++++++++++++ qga/qapi-schema.json | 25 +++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/qga/commands.c b/qga/commands.c index 57a31bb..3333ed5 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -510,3 +510,41 @@ GuestHostName *qmp_guest_get_host_name(Error **err) } return result; } + +GuestTimezone *qmp_guest_get_timezone(Error **errp) +{ +#if GLIB_CHECK_VERSION(2, 28, 0) + GuestTimezone *info =3D NULL; + GTimeZone *tz =3D NULL; + gint64 now =3D 0; + gint32 intv =3D 0; + gchar const *name =3D NULL; + + info =3D g_new0(GuestTimezone, 1); + tz =3D g_time_zone_new_local(); + if (tz =3D=3D NULL) { + error_setg(errp, QERR_QGA_COMMAND_FAILED, + "Couldn't retrieve local timezone"); + goto error; + } + + now =3D g_get_real_time() / G_USEC_PER_SEC; + intv =3D g_time_zone_find_interval(tz, G_TIME_TYPE_UNIVERSAL, now); + info->offset =3D g_time_zone_get_offset(tz, intv); + name =3D g_time_zone_get_abbreviation(tz, intv); + if (name !=3D NULL) { + info->has_zone =3D true; + info->zone =3D g_strdup(name); + } + g_time_zone_unref(tz); + + return info; + +error: + g_free(info); + return NULL; +#else + error_setg(errp, QERR_UNSUPPORTED); + return NULL; +#endif +} diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index f25467a..03743ab 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -1101,3 +1101,28 @@ ## { 'command': 'guest-get-users', 'returns': ['GuestUser'] } + +## +# @GuestTimezone: +# +# @zone: Timezone name. These values may differ depending on guest/OS a= nd +# should only be used for informational purposes. +# @offset: Offset to UTC in seconds, negative numbers for time zones west= of +# GMT, positive numbers for east +# +# Since: 2.10 +## +{ 'struct': 'GuestTimezone', + 'data': { '*zone': 'str', 'offset': 'int' } } + +## +# @guest-get-timezone: +# +# Retrieves the timezone information from the guest. +# +# Returns: A GuestTimezone dictionary. +# +# Since: 2.10 +## +{ 'command': 'guest-get-timezone', + 'returns': 'GuestTimezone' } --=20 2.7.4