aboutsummaryrefslogtreecommitdiff
path: root/qga/vss-win32/install.cpp
diff options
context:
space:
mode:
authorSameeh Jubran <sameeh@daynix.com>2017-03-23 18:26:50 +0200
committerMichael Roth <mdroth@linux.vnet.ibm.com>2017-04-26 23:56:46 -0500
commitf342cc93ec918d684e8a6f6e646551a9c7fbc019 (patch)
tree716d871a6745b5a2d1daa450350a15b5d1c74949 /qga/vss-win32/install.cpp
parent81b2d5ceb0cfb4cdc2163492e3169ed714b0cda9 (diff)
qemu-ga: Make QGA VSS provider service run only when needed
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 <sameeh@daynix.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'qga/vss-win32/install.cpp')
-rw-r--r--qga/vss-win32/install.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
index f4160a3a86..f41fcdfdda 100644
--- a/qga/vss-win32/install.cpp
+++ b/qga/vss-win32/install.cpp
@@ -14,7 +14,7 @@
#include "vss-common.h"
#include <inc/win2003/vscoordint.h>
-#include <comadmin.h>
+#include "install.h"
#include <wbemidl.h>
#include <comdef.h>
#include <comutil.h>
@@ -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<IUnknown> pUnknown;
+ COMPointer<ICOMAdminCatalog2> 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;
+}