Make QGA VSS provider service run only when needed
PATCH v2 1/1 Make QGA VSS provider service run only when needed
Difference from v1:
Added missing install.h file
Sameeh Jubran (1):
qemu-ga: Make QGA VSS provider service run only when needed
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
Signature · 1 line
2.9.3
PATCH v2 1/1 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.
--- 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
qga/vss-win32/install.cpp +26 -2
@@ -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; +}
qga/vss-win32/install.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* QEMU Guest Agent VSS requester declarations +* +* Copyright Hitachi Data Systems Corp. 2013 +* +* Authors: +* Tomoki Sekiyama <[email protected]> +* +* 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 <comadmin.h> + +STDAPI StopService (void ); + +#endif
qga/vss-win32/requester.cpp +2 -0
@@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "vss-common.h" #include "requester.h" +#include "install.h" #include <inc/win2003/vswriter.h> #include <inc/win2003/vsbackup.h>
@@ -501,4 +502,5 @@ void requester_thaw(int *num_vols, ErrorSet *errset) requester_cleanup(); CoUninitialize(); + StopService(); }
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH qemu-ga v2] qemu-ga: Make QGA VSS provider service run only when needed
Ping.
Quoted 116 lines · 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 <[email protected]>--- 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.hqga/vss-win32/install.cpp +2
-2@@ -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),qga/vss-win32/install.cpp +15
-0@@ -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,qga/vss-win32/install.cpp +9
-0+ IID_IUnknown, (void **)pUnknown.replace())); + chk(pUnknown->QueryInterface(IID_ICOMAdminCatalog2, + (void **)pCatalog.replace())); + chk(pCatalog->ShutdownApplication(_bstr_t(QGA_PROVIDER_LNAME))); + } + +out: + return hr; +}qga/vss-win32/install.h new file +9
-0@@ -0,0 +1,20 @@ +/* +* QEMU Guest Agent VSS requester declarations +* +* Copyright Hitachi Data Systems Corp. 2013 +* +* Authors: +* Tomoki Sekiyama <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */qga/vss-win32/install.h new file +9
-0+ +#ifndef INSTALL_H +#define INSTALL_H + +#include <comadmin.h> + +STDAPI StopService (void ); + +#endif qga/vss-win32/requester.cpp +2
-1@@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "vss-common.h" #include "requester.h" +#include "install.h" #include <inc/win2003/vswriter.h> #include <inc/win2003/vsbackup.h>@@ -501,4 +502,5 @@ void requester_thaw(int *num_vols, ErrorSet *errset) requester_cleanup(); CoUninitialize(); + StopService(); } --2.9.3
Signature · 4 lines
Respectfully, *Sameeh Jubran* *Linkedin <https://il.linkedin.com/pub/sameeh-jubran/87/747/a8a>* *Software Engineer @ Daynix <http://www.daynix.com>.*
Michael Roth
AppliedRe: [Qemu-devel] [PATCH qemu-ga v2] qemu-ga: Make QGA VSS provider service run only when needed
In reply to Sameeh JubranQuoting Sameeh Jubran (2017-03-23 11:26:50)
Quoted 6 lines
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 <[email protected]>
Thanks, applied to qga tree:
https://github.com/mdroth/qemu/commits/qga
Quoted 104 lines
--- 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.hqga/vss-win32/install.cpp +26
-2@@ -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; +}qga/vss-win32/install.h new file +20
-0@@ -0,0 +1,20 @@ +/* +* QEMU Guest Agent VSS requester declarations +* +* Copyright Hitachi Data Systems Corp. 2013 +* +* Authors: +* Tomoki Sekiyama <[email protected]> +* +* 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 <comadmin.h> + +STDAPI StopService (void ); + +#endif qga/vss-win32/requester.cpp +2
-0@@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "vss-common.h" #include "requester.h" +#include "install.h" #include <inc/win2003/vswriter.h> #include <inc/win2003/vsbackup.h>@@ -501,4 +502,5 @@ void requester_thaw(int *num_vols, ErrorSet *errset) requester_cleanup(); CoUninitialize(); + StopService(); }Signature · 1 line
2.9.3