qga-win: Handle VSS_E_PROVIDER_ALREADY_REGISTERED error

This patch handles the case where VSS Provider is already registered,
where in such case qga uninstalls the provider and registers it again.

Signed-off-by: Sameeh Jubran <sjubran@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:
Sameeh Jubran 2020-03-11 19:04:16 +02:00 committed by Michael Roth
parent bb1ce44b15
commit b2413df833

View File

@ -443,6 +443,17 @@ STDAPI DllRegisterServer(void)
VSS_PROV_SOFTWARE,
const_cast<WCHAR*>(QGA_PROVIDER_VERSION),
g_gProviderVersion);
if (hr == (long int) VSS_E_PROVIDER_ALREADY_REGISTERED) {
DllUnregisterServer();
hr = pVssAdmin->RegisterProvider(g_gProviderId, CLSID_QGAVSSProvider,
const_cast<WCHAR * >
(QGA_PROVIDER_LNAME),
VSS_PROV_SOFTWARE,
const_cast<WCHAR * >
(QGA_PROVIDER_VERSION),
g_gProviderVersion);
}
if (FAILED(hr)) {
errmsg_dialog(hr, "RegisterProvider failed");
}