From patchwork Thu Mar 23 16:26:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameeh Jubran X-Patchwork-Id: 9641553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 763C2601E9 for ; Thu, 23 Mar 2017 16:27:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67AFE26E16 for ; Thu, 23 Mar 2017 16:27:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C79B2841D; Thu, 23 Mar 2017 16:27:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9FC9327F90 for ; Thu, 23 Mar 2017 16:27:51 +0000 (UTC) Received: from localhost ([::1]:57397 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cr5aY-0001rg-MT for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Mar 2017 12:27:50 -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) 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) 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) 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 @@ #include "vss-common.h" #include -#include +#include "install.h" #include #include #include @@ -276,7 +276,7 @@ STDAPI COMRegister(void) 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_NORMAL"), _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 = 0; + + chk(QGAProviderFind(QGAProviderCount, (void *)&count)); + if (count) { + chk(CoCreateInstance(CLSID_COMAdminCatalog, NULL, CLSCTX_INPROC_SERVER, + 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 later. + * 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 @@ -501,4 +502,5 @@ void requester_thaw(int *num_vols, ErrorSet *errset) requester_cleanup(); CoUninitialize(); + StopService(); }