COMRegister and COMUnregister are invoked both from the MSI installer
(via DLLCOMRegister/rundll32) and from qemu-ga -s vss-install, where
stderr is typically not visible. Redirect stderr to
%SystemRoot%\Temp\qga-vss-install.log so that qga_debug output is
captured for post-install troubleshooting.

Suggested-by: Konstantin Kostiuk <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
---
 qga/vss-win32/install.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
index 9e8db79c122c..09d94edd4f53 100644
--- a/qga/vss-win32/install.cpp
+++ b/qga/vss-win32/install.cpp
@@ -241,10 +241,27 @@ out:
     return hr;
 }
 
+static void qga_vss_open_log(void)
+{
+    char path[MAX_PATH];
+    UINT n;
+
+    n = GetSystemWindowsDirectoryA(path, sizeof(path));
+    if (n == 0 || n >= sizeof(path)) {
+        return;
+    }
+    snprintf(path + n, sizeof(path) - n,
+             "\\Temp\\qga-vss-install.log");
+    if (freopen(path, "a", stderr)) {
+        setvbuf(stderr, NULL, _IONBF, 0);
+    }
+}
+
 /* Unregister this module from COM+ Applications Catalog */
 STDAPI COMUnregister(void);
 STDAPI COMUnregister(void)
 {
+    qga_vss_open_log();
     qga_debug_begin;
 
     HRESULT hr;
@@ -260,6 +277,7 @@ out:
 STDAPI COMRegister(void);
 STDAPI COMRegister(void)
 {
+    qga_vss_open_log();
     qga_debug_begin;
 
     HRESULT hr;

-- 
2.55.0.543.g5ebe2ebe4ea8


Reply via email to