From nobody Thu May 2 00:10:04 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; dkim=fail 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 1490286495001594.6294963196724; Thu, 23 Mar 2017 09:28:15 -0700 (PDT) Received: from localhost ([::1]:57400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr5av-0002as-KS for importer@patchew.org; Thu, 23 Mar 2017 12:28:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr5Zn-0001pk-2W for qemu-devel@nongnu.org; Thu, 23 Mar 2017 12:27:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cr5Zl-0000kr-5F for qemu-devel@nongnu.org; Thu, 23 Mar 2017 12:27:03 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:33892) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cr5Zk-0000kK-V9 for qemu-devel@nongnu.org; Thu, 23 Mar 2017 12:27:01 -0400 Received: by mail-wr0-x243.google.com with SMTP id y90so8128998wrb.1 for ; Thu, 23 Mar 2017 09:27:00 -0700 (PDT) Received: from bark.daynix ([141.226.163.173]) by smtp.gmail.com with ESMTPSA id j34sm6409170wre.7.2017.03.23.09.26.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Mar 2017 09:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IsiYtktB6zraHrIdc+BZKfleTsXYResUervuPsc1EGQ=; b=jlyRK+ceQPlsm3+hxam5CqFNt3TGKK3BTBJHRtGKGWIJGdhGaRP8eSokl4gA6UOy6y N5HTMZbcqouwv2aCIxtcixTehUm2EyR5gvn4g0LL5GRaHvnfi3ff/WhQmCpHYBoaJyoL spsQYyu9lNg6DfAzrI2B1DyKarkLJNrSQ2h/4vlT3UoPiuY4h3DUYUn3Tuf0ZhjBPCPF DLehrlPHqaJus5SVFauJ4mdtLlwdnEarMlVgd0ccFdxGgcV9Yclpl7I5eavQtXkSfcCE 6OjhwFZVDseBagTC3bUnEVD6mtLoAHakYjJq3B+mdErdi5Gx4QhXmwBES2OtG/haORxf 7m2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IsiYtktB6zraHrIdc+BZKfleTsXYResUervuPsc1EGQ=; b=q1Gov9ax5SdbWeb2sdTCSTkYFmb+sv54XZg0emyP44G1nHA2XoGDsBjZCcyjQB5yVN 2Lb0mp5+myUWCwi0J7GT979WjY07t+lGQkGtxWeDBkiQeqV2BBMKLwBybEm/ydCr5Eqv CwPapWzKum6ijzlU41mS8I6clERI1Tiv90ifqYxzPAcct0Lg6XbE/Lr+3MYmXoeXJs95 Z7H0zx41fVx22dF7OnLdAkI495PGX06QX0dlWnY69deXiDaeBpwA99FGKT1l451fokzp XbPnaBoOrNmW4C8TlqSa9jARdH89rg6MxJrW3HNkK/mtTnVXwzWQmCXcTSQ47zdpeHNC ds7w== X-Gm-Message-State: AFeK/H2oYtPjLk6p568LhgyrCQ6iNgHbRPL7BJxeJBjbHw+mgRHZexpeivZpZiCmU31TQQ== X-Received: by 10.223.134.229 with SMTP id 34mr3368822wry.104.1490286419908; Thu, 23 Mar 2017 09:26:59 -0700 (PDT) From: Sameeh Jubran To: qemu-devel@nongnu.org, Michael Roth Date: Thu, 23 Mar 2017 18:26:50 +0200 Message-Id: <20170323162650.16973-2-sameeh@daynix.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170323162650.16973-1-sameeh@daynix.com> References: <20170323162650.16973-1-sameeh@daynix.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PATCH qemu-ga v2] 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: Yan Vugenfirer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 272e71b..27308ad 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.9.3