@@ -100,6 +100,8 @@ HRESULT put_Value(ICatalogObject *pObj, LPCWSTR name, T val)
/* Lookup Administrators group name from winmgmt */
static HRESULT GetAdminName(_bstr_t *name)
{
+ PRINT_DEBUG_BEGIN;
+
HRESULT hr;
COMPointer<IWbemLocator> pLoc;
COMPointer<IWbemServices> pSvc;
@@ -142,6 +144,7 @@ static HRESULT GetAdminName(_bstr_t *name)
}
out:
+ PRINT_DEBUG_END;
return hr;
}
@@ -149,6 +152,8 @@ out:
static HRESULT getNameByStringSID(
const wchar_t *sid, LPWSTR buffer, LPDWORD bufferLen)
{
+ PRINT_DEBUG_BEGIN;
+
HRESULT hr = S_OK;
PSID psid = NULL;
SID_NAME_USE groupType;
@@ -168,6 +173,7 @@ static HRESULT getNameByStringSID(
LocalFree(psid);
out:
+ PRINT_DEBUG_END;
return hr;
}
@@ -175,6 +181,8 @@ out:
static HRESULT QGAProviderFind(
HRESULT (*found)(ICatalogCollection *, int, void *), void *arg)
{
+ PRINT_DEBUG_BEGIN;
+
HRESULT hr;
COMInitializer initializer;
COMPointer<IUnknown> pUnknown;
@@ -205,12 +213,15 @@ static HRESULT QGAProviderFind(
chk(pColl->SaveChanges(&n));
out:
+ PRINT_DEBUG_END;
return hr;
}
/* Count QGA VSS provider in COM+ Application Catalog */
static HRESULT QGAProviderCount(ICatalogCollection *coll, int i, void *arg)
{
+ PRINT_DEBUG_BEGIN;
+
(*(int *)arg)++;
return S_OK;
}
@@ -218,28 +229,35 @@ static HRESULT QGAProviderCount(ICatalogCollection *coll, int i, void *arg)
/* Remove QGA VSS provider from COM+ Application Catalog Collection */
static HRESULT QGAProviderRemove(ICatalogCollection *coll, int i, void *arg)
{
+ PRINT_DEBUG_BEGIN;
HRESULT hr;
PRINT_DEBUG("Removing COM+ Application: %s", QGA_PROVIDER_NAME);
chk(coll->Remove(i));
out:
+ PRINT_DEBUG_END;
return hr;
}
/* Unregister this module from COM+ Applications Catalog */
STDAPI COMUnregister(void)
{
+ PRINT_DEBUG_BEGIN;
+
HRESULT hr;
DllUnregisterServer();
chk(QGAProviderFind(QGAProviderRemove, NULL));
out:
+ PRINT_DEBUG_END;
return hr;
}
/* Register this module to COM+ Applications Catalog */
STDAPI COMRegister(void)
{
+ PRINT_DEBUG_BEGIN;
+
HRESULT hr;
COMInitializer initializer;
COMPointer<IUnknown> pUnknown;
@@ -259,12 +277,14 @@ STDAPI COMRegister(void)
if (!g_hinstDll) {
errmsg(E_FAIL, "Failed to initialize DLL");
+ PRINT_DEBUG_END;
return E_FAIL;
}
chk(QGAProviderFind(QGAProviderCount, (void *)&count));
if (count) {
errmsg(E_ABORT, "QGA VSS Provider is already installed");
+ PRINT_DEBUG_END;
return E_ABORT;
}
@@ -355,6 +375,7 @@ out:
COMUnregister();
}
+ PRINT_DEBUG_END;
return hr;
}
@@ -370,6 +391,8 @@ STDAPI_(void) CALLBACK DLLCOMUnregister(HWND, HINSTANCE, LPSTR, int)
static BOOL CreateRegistryKey(LPCTSTR key, LPCTSTR value, LPCTSTR data)
{
+ PRINT_DEBUG_BEGIN;
+
HKEY hKey;
LONG ret;
DWORD size;
@@ -390,6 +413,7 @@ static BOOL CreateRegistryKey(LPCTSTR key, LPCTSTR value, LPCTSTR data)
RegCloseKey(hKey);
out:
+ PRINT_DEBUG_END;
if (ret != ERROR_SUCCESS) {
/* As we cannot printf within DllRegisterServer(), show a dialog. */
errmsg_dialog(ret, "Cannot add registry", key);
@@ -401,6 +425,8 @@ out:
/* Register this dll as a VSS provider */
STDAPI DllRegisterServer(void)
{
+ PRINT_DEBUG_BEGIN;
+
COMInitializer initializer;
COMPointer<IVssAdmin> pVssAdmin;
HRESULT hr = E_FAIL;
@@ -479,12 +505,15 @@ out:
DllUnregisterServer();
}
+ PRINT_DEBUG_END;
return hr;
}
/* Unregister this VSS hardware provider from the system */
STDAPI DllUnregisterServer(void)
{
+ PRINT_DEBUG_BEGIN;
+
TCHAR key[256];
COMInitializer initializer;
COMPointer<IVssAdmin> pVssAdmin;
@@ -502,6 +531,7 @@ STDAPI DllUnregisterServer(void)
SHDeleteKey(HKEY_CLASSES_ROOT, key);
SHDeleteKey(HKEY_CLASSES_ROOT, g_szProgid);
+ PRINT_DEBUG_END;
return S_OK; /* Uninstall should never fail */
}
@@ -528,6 +558,8 @@ namespace _com_util
/* Stop QGA VSS provider service using Winsvc API */
STDAPI StopService(void)
{
+ PRINT_DEBUG_BEGIN;
+
HRESULT hr = S_OK;
SC_HANDLE manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
SC_HANDLE service = NULL;
@@ -552,5 +584,6 @@ STDAPI StopService(void)
out:
CloseServiceHandle(service);
CloseServiceHandle(manager);
+ PRINT_DEBUG_END;
return hr;
}
@@ -12,6 +12,7 @@
#include "qemu/osdep.h"
#include "vss-common.h"
+#include "vss-debug.h"
#ifdef HAVE_VSS_SDK
#include <vscoordint.h>
#else
@@ -529,9 +530,11 @@ STDAPI DllCanUnloadNow()
EXTERN_C
BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD dwReason, LPVOID lpReserved)
{
+ PRINT_DEBUG("begin, reason = %lu", dwReason);
if (dwReason == DLL_PROCESS_ATTACH) {
g_hinstDll = hinstDll;
DisableThreadLibraryCalls(hinstDll);
}
+ PRINT_DEBUG_END;
return TRUE;
}
@@ -57,6 +57,8 @@ static struct QGAVSSContext {
STDAPI requester_init(void)
{
+ PRINT_DEBUG_BEGIN;
+
COMInitializer initializer; /* to call CoInitializeSecurity */
HRESULT hr = CoInitializeSecurity(
NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
@@ -92,11 +94,14 @@ STDAPI requester_init(void)
return HRESULT_FROM_WIN32(GetLastError());
}
+ PRINT_DEBUG_END;
return S_OK;
}
static void requester_cleanup(void)
{
+ PRINT_DEBUG_BEGIN;
+
if (vss_ctx.hEventFrozen) {
CloseHandle(vss_ctx.hEventFrozen);
vss_ctx.hEventFrozen = NULL;
@@ -118,10 +123,13 @@ static void requester_cleanup(void)
vss_ctx.pVssbc = NULL;
}
vss_ctx.cFrozenVols = 0;
+ PRINT_DEBUG_END;
}
STDAPI requester_deinit(void)
{
+ PRINT_DEBUG_BEGIN;
+
requester_cleanup();
pCreateVssBackupComponents = NULL;
@@ -131,11 +139,14 @@ STDAPI requester_deinit(void)
hLib = NULL;
}
+ PRINT_DEBUG_END;
return S_OK;
}
static HRESULT WaitForAsync(IVssAsync *pAsync)
{
+ PRINT_DEBUG_BEGIN;
+
HRESULT ret, hr;
do {
@@ -151,11 +162,14 @@ static HRESULT WaitForAsync(IVssAsync *pAsync)
}
} while (ret == VSS_S_ASYNC_PENDING);
+ PRINT_DEBUG_END;
return ret;
}
static void AddComponents(ErrorSet *errset)
{
+ PRINT_DEBUG_BEGIN;
+
unsigned int cWriters, i;
VSS_ID id, idInstance, idWriter;
BSTR bstrWriterName = NULL;
@@ -237,17 +251,21 @@ out:
if (pComponent && info) {
pComponent->FreeComponentInfo(info);
}
+ PRINT_DEBUG_END;
}
DWORD get_reg_dword_value(HKEY baseKey, LPCSTR subKey, LPCSTR valueName,
DWORD defaultData)
{
+ PRINT_DEBUG_BEGIN;
+
DWORD regGetValueError;
DWORD dwordData;
DWORD dataSize = sizeof(DWORD);
regGetValueError = RegGetValue(baseKey, subKey, valueName, RRF_RT_DWORD,
NULL, &dwordData, &dataSize);
+ PRINT_DEBUG_END;
if (regGetValueError != ERROR_SUCCESS) {
return defaultData;
}
@@ -262,6 +280,8 @@ bool is_valid_vss_backup_type(VSS_BACKUP_TYPE vssBT)
VSS_BACKUP_TYPE get_vss_backup_type(
VSS_BACKUP_TYPE defaultVssBT = DEFAULT_VSS_BACKUP_TYPE)
{
+ PRINT_DEBUG_BEGIN;
+
VSS_BACKUP_TYPE vssBackupType;
vssBackupType = static_cast<VSS_BACKUP_TYPE>(
@@ -269,6 +289,7 @@ VSS_BACKUP_TYPE get_vss_backup_type(
QGA_PROVIDER_REGISTRY_ADDRESS,
"VssOption",
defaultVssBT));
+ PRINT_DEBUG_END;
if (!is_valid_vss_backup_type(vssBackupType)) {
return defaultVssBT;
}
@@ -277,6 +298,8 @@ VSS_BACKUP_TYPE get_vss_backup_type(
void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset)
{
+ PRINT_DEBUG_BEGIN;
+
COMPointer<IVssAsync> pAsync;
HANDLE volume;
HRESULT hr;
@@ -292,6 +315,7 @@ void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset)
if (vss_ctx.pVssbc) { /* already frozen */
*num_vols = 0;
+ PRINT_DEBUG("finished, already frozen");
return;
}
@@ -449,6 +473,7 @@ void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset)
}
}
+ PRINT_DEBUG("preparing for backup");
hr = vss_ctx.pVssbc->PrepareForBackup(pAsync.replace());
if (SUCCEEDED(hr)) {
hr = WaitForAsync(pAsync);
@@ -472,6 +497,7 @@ void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset)
* CQGAVssProvider::CommitSnapshots will kick vss_ctx.hEventFrozen
* after the applications and filesystems are frozen.
*/
+ PRINT_DEBUG("do snapshot set");
hr = vss_ctx.pVssbc->DoSnapshotSet(&vss_ctx.pAsyncSnapshot);
if (FAILED(hr)) {
err_set(errset, hr, "failed to do snapshot set");
@@ -518,6 +544,7 @@ void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset)
*num_vols = vss_ctx.cFrozenVols = num_fixed_drives;
}
+ PRINT_DEBUG("end successful");
return;
out:
@@ -528,11 +555,14 @@ out:
out1:
requester_cleanup();
CoUninitialize();
+
+ PRINT_DEBUG_END;
}
void requester_thaw(int *num_vols, void *mountpints, ErrorSet *errset)
{
+ PRINT_DEBUG_BEGIN;
COMPointer<IVssAsync> pAsync;
if (!vss_ctx.hEventThaw) {
@@ -541,6 +571,8 @@ void requester_thaw(int *num_vols, void *mountpints, ErrorSet *errset)
* and no volumes must be frozen. We return without an error.
*/
*num_vols = 0;
+ PRINT_DEBUG("finished, no volumes were frozen");
+
return;
}
@@ -597,4 +629,6 @@ void requester_thaw(int *num_vols, void *mountpints, ErrorSet *errset)
CoUninitialize();
StopService();
+
+ PRINT_DEBUG_END;
}
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com> --- qga/vss-win32/install.cpp | 33 +++++++++++++++++++++++++++++++++ qga/vss-win32/provider.cpp | 3 +++ qga/vss-win32/requester.cpp | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+)