diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2020-07-14 21:21:58 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2020-07-14 21:21:58 +0100 |
| commit | c920fdba39480989cb5f1af3cc63acccef021b54 (patch) | |
| tree | a19a5c8002b47dfc1320b46e83aea052bd4c21d5 /qga/vss-win32/install.cpp | |
| parent | 8bfa25a46ff1082f75e7052875b5d435119dcf49 (diff) | |
| parent | 0d3a8f32b1e0eca279da1b0cc793efc7250c3daf (diff) | |
| download | focaccia-qemu-c920fdba39480989cb5f1af3cc63acccef021b54.tar.gz focaccia-qemu-c920fdba39480989cb5f1af3cc63acccef021b54.zip | |
Merge remote-tracking branch 'remotes/mdroth/tags/qga-pull-2020-07-13-tag' into staging
qemu-ga patch queue for hard-freeze * fix erroneously reporting stale hostname in guest-get-host-name * fix regression where guest-shutdown asserts when called * fix race condition with guest-fs-freeze/thaw on w32 # gpg: Signature made Tue 14 Jul 2020 05:47:11 BST # gpg: using RSA key CEACC9E15534EBABB82D3FA03353C9CEF108B584 # gpg: issuer "mdroth@linux.vnet.ibm.com" # gpg: Good signature from "Michael Roth <flukshun@gmail.com>" [full] # gpg: aka "Michael Roth <mdroth@utexas.edu>" [full] # gpg: aka "Michael Roth <mdroth@linux.vnet.ibm.com>" [full] # Primary key fingerprint: CEAC C9E1 5534 EBAB B82D 3FA0 3353 C9CE F108 B584 * remotes/mdroth/tags/qga-pull-2020-07-13-tag: qga: Use qemu_get_host_name() instead of g_get_host_name() util: Introduce qemu_get_host_name() qga: fix assert regression on guest-shutdown qga-win: Fix QGA VSS Provider service stop failure Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qga/vss-win32/install.cpp')
| -rw-r--r-- | qga/vss-win32/install.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp index a456841360..40de133774 100644 --- a/qga/vss-win32/install.cpp +++ b/qga/vss-win32/install.cpp @@ -19,6 +19,7 @@ #include <comdef.h> #include <comutil.h> #include <sddl.h> +#include <winsvc.h> #define BUFFER_SIZE 1024 @@ -509,26 +510,32 @@ namespace _com_util } } -/* Stop QGA VSS provider service from COM+ Application Admin Catalog */ - +/* Stop QGA VSS provider service using Winsvc API */ STDAPI StopService(void) { HRESULT hr; - COMInitializer initializer; - COMPointer<IUnknown> pUnknown; - COMPointer<ICOMAdminCatalog2> pCatalog; + SC_HANDLE manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + SC_HANDLE service = NULL; - int count = 0; + if (!manager) { + errmsg(E_FAIL, "Failed to open service manager"); + hr = E_FAIL; + goto out; + } + service = OpenService(manager, QGA_PROVIDER_NAME, SC_MANAGER_ALL_ACCESS); - 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))); + if (!service) { + errmsg(E_FAIL, "Failed to open service"); + hr = E_FAIL; + goto out; + } + if (!(ControlService(service, SERVICE_CONTROL_STOP, NULL))) { + errmsg(E_FAIL, "Failed to stop service"); + hr = E_FAIL; } out: + CloseServiceHandle(service); + CloseServiceHandle(manager); return hr; } |