From: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
To: qemu-devel@nongnu.org
Cc: libaiqing@huawei.com, ghammer@redhat.com, stefanha@gmail.com,
mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com,
vrozenfe@redhat.com, pbonzini@redhat.com, seiji.aguchi@hds.com,
lersek@redhat.com, areis@redhat.com
Subject: [Qemu-devel] [PATCH v5 09/11] qemu-ga: Call Windows VSS requester in fsfreeze command handler
Date: Wed, 03 Jul 2013 11:49:49 -0400 [thread overview]
Message-ID: <20130703154949.20767.93528.stgit@hds.com> (raw)
In-Reply-To: <20130703154903.20767.27940.stgit@hds.com>
Support guest-fsfreeze-freeze and guest-fsfreeze-thaw commands for Windows
guests. When fsfreeze command is issued, it calls the VSS requester to
freeze filesystems and applications. On thaw command, it again tells the VSS
requester to thaw them.
This also adds calling of initialize functions for the VSS requester.
Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
---
qga/commands-win32.c | 84 +++++++++++++++++++++++++++++++++++++++++++++-----
qga/main.c | 13 +++++++-
2 files changed, 88 insertions(+), 9 deletions(-)
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 24e4ad0..c72f821 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -15,6 +15,7 @@
#include <wtypes.h>
#include <powrprof.h>
#include "qga/guest-agent-core.h"
+#include "qga/vss-win32-requester.h"
#include "qga-qmp-commands.h"
#include "qapi/qmp/qerror.h"
@@ -156,29 +157,93 @@ void qmp_guest_file_flush(int64_t handle, Error **err)
*/
GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
{
- error_set(err, QERR_UNSUPPORTED);
- return 0;
+ if (!vss_initialized()) {
+ error_set(err, QERR_UNSUPPORTED);
+ return 0;
+ }
+
+ if (ga_is_frozen(ga_state)) {
+ return GUEST_FSFREEZE_STATUS_FROZEN;
+ }
+
+ return GUEST_FSFREEZE_STATUS_THAWED;
}
/*
- * Walk list of mounted file systems in the guest, and freeze the ones which
- * are real local file systems.
+ * Freeze local file systems using Volume Shadow-copy Service.
+ * The frozen state is limited for up to 10 seconds by VSS.
*/
int64_t qmp_guest_fsfreeze_freeze(Error **err)
{
- error_set(err, QERR_UNSUPPORTED);
+ int i;
+ Error *local_err = NULL;
+
+ if (!vss_initialized()) {
+ error_set(err, QERR_UNSUPPORTED);
+ return 0;
+ }
+
+ slog("guest-fsfreeze called");
+
+ /* cannot risk guest agent blocking itself on a write in this state */
+ ga_set_frozen(ga_state);
+
+ qga_vss_fsfreeze_freeze(&i, err);
+ if (error_is_set(err)) {
+ goto error;
+ }
+
+ return i;
+
+error:
+ qmp_guest_fsfreeze_thaw(&local_err);
+ if (error_is_set(&local_err)) {
+ g_debug("cleanup thaw: %s", error_get_pretty(local_err));
+ error_free(local_err);
+ }
return 0;
}
/*
- * Walk list of frozen file systems in the guest, and thaw them.
+ * Thaw local file systems using Volume Shadow-copy Service.
*/
int64_t qmp_guest_fsfreeze_thaw(Error **err)
{
- error_set(err, QERR_UNSUPPORTED);
- return 0;
+ int i;
+
+ if (!vss_initialized()) {
+ error_set(err, QERR_UNSUPPORTED);
+ return 0;
+ }
+
+ qga_vss_fsfreeze_thaw(&i, err);
+
+ ga_unset_frozen(ga_state);
+ return i;
+}
+
+#ifdef CONFIG_QGA_VSS
+
+static void guest_fsfreeze_cleanup(void)
+{
+ Error *err = NULL;
+
+ if (!vss_initialized()) {
+ return;
+ }
+
+ if (ga_is_frozen(ga_state) == GUEST_FSFREEZE_STATUS_FROZEN) {
+ qmp_guest_fsfreeze_thaw(&err);
+ if (err) {
+ slog("failed to clean up frozen filesystems: %s",
+ error_get_pretty(err));
+ error_free(err);
+ }
+ }
}
+#endif
+
/*
* Walk list of mounted file systems in the guest, and discard unused
* areas.
@@ -354,4 +419,7 @@ int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
/* register init/cleanup routines for stateful command groups */
void ga_command_state_init(GAState *s, GACommandState *cs)
{
+#ifdef CONFIG_QGA_VSS
+ ga_command_state_add(cs, NULL, guest_fsfreeze_cleanup);
+#endif
}
diff --git a/qga/main.c b/qga/main.c
index 0e04e73..160ff28 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -34,6 +34,7 @@
#include "qemu/bswap.h"
#ifdef _WIN32
#include "qga/service-win32.h"
+#include "qga/vss-win32-requester.h"
#include <windows.h>
#endif
#ifdef __linux__
@@ -701,6 +702,7 @@ static gboolean channel_init(GAState *s, const gchar *method, const gchar *path)
}
#ifdef _WIN32
+
DWORD WINAPI service_ctrl_handler(DWORD ctrl, DWORD type, LPVOID data,
LPVOID ctx)
{
@@ -743,8 +745,12 @@ VOID WINAPI service_main(DWORD argc, TCHAR *argv[])
service->status.dwWaitHint = 0;
SetServiceStatus(service->status_handle, &service->status);
+ if (!vss_init()) {
+ goto out_bad;
+ }
g_main_loop_run(ga_state->main_loop);
-
+out_bad:
+ vss_deinit();
service->status.dwCurrentState = SERVICE_STOPPED;
SetServiceStatus(service->status_handle, &service->status);
}
@@ -1175,7 +1181,12 @@ int main(int argc, char **argv)
{ (char *)QGA_SERVICE_NAME, service_main }, { NULL, NULL } };
StartServiceCtrlDispatcher(service_table);
} else {
+ if (!vss_init()) {
+ vss_deinit();
+ goto out_bad;
+ }
g_main_loop_run(ga_state->main_loop);
+ vss_deinit();
}
#endif
next prev parent reply other threads:[~2013-07-03 15:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 15:49 [Qemu-devel] [PATCH v5 00/11] qemu-ga: fsfreeze on Windows using VSS Tomoki Sekiyama
2013-07-03 15:49 ` [Qemu-devel] [PATCH v5 01/11] configure: Support configuring C++ compiler Tomoki Sekiyama
2013-07-03 15:49 ` [Qemu-devel] [PATCH v5 02/11] Add c++ keywords to QAPI helper script Tomoki Sekiyama
2013-07-03 15:49 ` [Qemu-devel] [PATCH v5 03/11] checkpatch.pl: Check .cpp files Tomoki Sekiyama
2013-07-03 15:49 ` [Qemu-devel] [PATCH v5 04/11] Add a script to extract VSS SDK headers on POSIX system Tomoki Sekiyama
2013-07-03 15:49 ` [Qemu-devel] [PATCH v5 05/11] qemu-ga: Add configure options to specify path to Windows/VSS SDK Tomoki Sekiyama
2013-07-03 15:49 ` [Qemu-devel] [PATCH v5 06/11] qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze Tomoki Sekiyama
2013-07-03 15:49 ` [Qemu-devel] [PATCH v5 07/11] error: Add error_set_win32 and error_setg_win32 Tomoki Sekiyama
2013-07-03 15:49 ` [Qemu-devel] [PATCH v5 08/11] qemu-ga: Add Windows VSS requester to quiesce applications and filesystems Tomoki Sekiyama
2013-07-03 15:49 ` Tomoki Sekiyama [this message]
2013-07-03 15:49 ` [Qemu-devel] [PATCH v5 10/11] qemu-ga: Install Windows VSS provider on `qemu-ga -s install' Tomoki Sekiyama
2013-07-03 15:58 ` Paolo Bonzini
2013-07-03 16:19 ` Tomoki Sekiyama
2013-07-04 12:54 ` Paolo Bonzini
2013-07-05 17:06 ` Tomoki Sekiyama
2013-07-08 13:58 ` Laszlo Ersek
2013-07-08 14:16 ` Tomoki Sekiyama
2013-07-08 14:44 ` Laszlo Ersek
2013-07-03 15:49 ` [Qemu-devel] [PATCH v5 11/11] QMP/qemu-ga-client: Make timeout longer for guest-fsfreeze-freeze command Tomoki Sekiyama
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130703154949.20767.93528.stgit@hds.com \
--to=tomoki.sekiyama@hds.com \
--cc=areis@redhat.com \
--cc=ghammer@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=lersek@redhat.com \
--cc=libaiqing@huawei.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=seiji.aguchi@hds.com \
--cc=stefanha@gmail.com \
--cc=vrozenfe@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).