mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
qga-win: Fix QGA VSS Provider service stop failure
On one hand "guest-fsfreeze-freeze" command, "COM+ System Application service" is stopped, on the other hand "guest-fsfreeze-thaw" stops QGA VSS Provider service from "COM+ Application Admin Catalog". Invoking a series of freeze and thaw commands may result in QGA failing to stop VSS Provider service as "COM+ System Application service" is stopped, which can cause some delay in qga response. In this commit StopService function was changed and VSS Provider service is now stopped using Winsvc library API. BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1549425 Signed-off-by: Basil Salman <bsalman@redhat.com> Signed-off-by: Basil Salman <basil@daynix.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
This commit is contained in:
parent
20c1df5476
commit
917ebcb170
1 changed files with 20 additions and 13 deletions
|
@ -19,6 +19,7 @@
|
||||||
#include <comdef.h>
|
#include <comdef.h>
|
||||||
#include <comutil.h>
|
#include <comutil.h>
|
||||||
#include <sddl.h>
|
#include <sddl.h>
|
||||||
|
#include <winsvc.h>
|
||||||
|
|
||||||
#define BUFFER_SIZE 1024
|
#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)
|
STDAPI StopService(void)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
COMInitializer initializer;
|
SC_HANDLE manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
||||||
COMPointer<IUnknown> pUnknown;
|
SC_HANDLE service = NULL;
|
||||||
COMPointer<ICOMAdminCatalog2> pCatalog;
|
|
||||||
|
|
||||||
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 (!service) {
|
||||||
if (count) {
|
errmsg(E_FAIL, "Failed to open service");
|
||||||
chk(CoCreateInstance(CLSID_COMAdminCatalog, NULL, CLSCTX_INPROC_SERVER,
|
hr = E_FAIL;
|
||||||
IID_IUnknown, (void **)pUnknown.replace()));
|
goto out;
|
||||||
chk(pUnknown->QueryInterface(IID_ICOMAdminCatalog2,
|
}
|
||||||
(void **)pCatalog.replace()));
|
if (!(ControlService(service, SERVICE_CONTROL_STOP, NULL))) {
|
||||||
chk(pCatalog->ShutdownApplication(_bstr_t(QGA_PROVIDER_LNAME)));
|
errmsg(E_FAIL, "Failed to stop service");
|
||||||
|
hr = E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
CloseServiceHandle(service);
|
||||||
|
CloseServiceHandle(manager);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue