]> Git Repo - qemu.git/blobdiff - qga/vss-win32.c
block: Introduce blk_set_allow_write_beyond_eof()
[qemu.git] / qga / vss-win32.c
index 89c0f3bd18a4fc5ba58e9bfabc999eb7175cffaa..9a0e46356ab7d12758c477ef38db81d099276e6b 100644 (file)
@@ -10,7 +10,7 @@
  * See the COPYING file in the top-level directory.
  */
 
-#include <stdio.h>
+#include "qemu/osdep.h"
 #include <windows.h>
 #include "qga/guest-agent-core.h"
 #include "qga/vss-win32.h"
@@ -119,20 +119,45 @@ bool vss_initialized(void)
     return !!provider_lib;
 }
 
+int ga_install_vss_provider(void)
+{
+    HRESULT hr;
+
+    if (!vss_init(false)) {
+        fprintf(stderr, "Installation of VSS provider is skipped. "
+                "fsfreeze will be disabled.\n");
+        return 0;
+    }
+    hr = call_vss_provider_func("COMRegister");
+    vss_deinit(false);
+
+    return SUCCEEDED(hr) ? 0 : EXIT_FAILURE;
+}
+
+void ga_uninstall_vss_provider(void)
+{
+    if (!vss_init(false)) {
+        fprintf(stderr, "Removal of VSS provider is skipped.\n");
+        return;
+    }
+    call_vss_provider_func("COMUnregister");
+    vss_deinit(false);
+}
+
 /* Call VSS requester and freeze/thaw filesystems and applications */
-void qga_vss_fsfreeze(int *nr_volume, Error **err, bool freeze)
+void qga_vss_fsfreeze(int *nr_volume, Error **errp, bool freeze)
 {
     const char *func_name = freeze ? "requester_freeze" : "requester_thaw";
     QGAVSSRequesterFunc func;
     ErrorSet errset = {
-        .error_set = (ErrorSetFunc)error_set_win32,
-        .errp = (void **)err,
-        .err_class = ERROR_CLASS_GENERIC_ERROR
+        .error_setg_win32_wrapper = error_setg_win32_internal,
+        .errp = errp,
     };
 
+    g_assert(errp);             /* requester.cpp requires it */
     func = (QGAVSSRequesterFunc)GetProcAddress(provider_lib, func_name);
     if (!func) {
-        error_setg_win32(err, GetLastError(), "failed to load %s from %s",
+        error_setg_win32(errp, GetLastError(), "failed to load %s from %s",
                          func_name, QGA_VSS_DLL);
         return;
     }
This page took 0.024133 seconds and 4 git commands to generate.