Skip to content

Commit b39297a

Browse files
tsekiyamamdroth
authored andcommitted
qemu-ga: Add Windows VSS provider and requester as DLL
Adds VSS provider and requester as a qga-vss.dll, which is loaded by Windows VSS service as well as by qemu-ga. "provider.cpp" implements a basic stub of a software VSS provider. Currently, this module only relays a frozen event from VSS service to the agent, and thaw event from the agent to VSS service, to block VSS process to keep the system frozen while snapshots are taken at the host. To register the provider to the guest system as COM+ application, the type library (.tlb) for qga-vss.dll is required. To build it from COM IDL (.idl), VisualC++, MIDL and stdole2.tlb in Windows SDK are required. This patch also adds pre-compiled .tlb file in the repository in order to enable cross-compile qemu-ga.exe for Windows with VSS support. "requester.cpp" provides the VSS requester to kick the VSS snapshot process. Qemu-ga.exe works without the DLL, although fsfreeze features are disabled. These functions are only supported in Windows 2003 or later. In older systems, fsfreeze features are disabled. In several versions of Windows which don't support attribute VSS_VOLSNAP_ATTR_NO_AUTORECOVERY, DoSnapshotSet fails with error VSS_E_OBJECT_NOT_FOUND. In this patch, we just ignore this error. To solve this fundamentally, we need a framework to handle mount writable snapshot on guests, which is required by VSS auto-recovery feature (cleanup phase after a snapshot is taken). Signed-off-by: Tomoki Sekiyama <[email protected]> Signed-off-by: Michael Roth <[email protected]>
1 parent 20840d4 commit b39297a

13 files changed

+1724
-2
lines changed

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ clean:
235235
rm -f qemu-options.def
236236
find . -name '*.[oda]' -type f -exec rm -f {} +
237237
find . -name '*.l[oa]' -type f -exec rm -f {} +
238-
rm -f $(TOOLS) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
238+
rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
239239
rm -Rf .libs
240240
rm -f qemu-img-cmds.h
241241
@# May not be present in GENERATED_HEADERS

Diff for: Makefile.objs

+2
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ version-lobj-$(CONFIG_WIN32) += $(BUILD_DIR)/version.lo
109109
# FIXME: a few definitions from qapi-types.o/qapi-visit.o are needed
110110
# by libqemuutil.a. These should be moved to a separate .json schema.
111111
qga-obj-y = qga/ qapi-types.o qapi-visit.o
112+
qga-vss-dll-obj-y = qga/
112113

113114
vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
114115

@@ -120,6 +121,7 @@ nested-vars += \
120121
stub-obj-y \
121122
util-obj-y \
122123
qga-obj-y \
124+
qga-vss-dll-obj-y \
123125
block-obj-y \
124126
common-obj-y
125127
dummy := $(call unnest-vars)

Diff for: configure

+4-1
Original file line numberDiff line numberDiff line change
@@ -3568,8 +3568,11 @@ if test "$softmmu" = yes ; then
35683568
fi
35693569
fi
35703570
if [ "$guest_agent" != "no" ]; then
3571-
if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
3571+
if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
35723572
tools="qemu-ga\$(EXESUF) $tools"
3573+
if [ "$mingw32" = "yes" -a "$guest_agent_with_vss" = "yes" ]; then
3574+
tools="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb $tools"
3575+
fi
35733576
guest_agent=yes
35743577
elif [ "$guest_agent" != yes ]; then
35753578
guest_agent=no

Diff for: qga/Makefile.objs

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ qga-obj-$(CONFIG_POSIX) += commands-posix.o channel-posix.o
33
qga-obj-$(CONFIG_WIN32) += commands-win32.o channel-win32.o service-win32.o
44
qga-obj-y += qapi-generated/qga-qapi-types.o qapi-generated/qga-qapi-visit.o
55
qga-obj-y += qapi-generated/qga-qmp-marshal.o
6+
7+
qga-vss-dll-obj-$(CONFIG_QGA_VSS) += vss-win32/

Diff for: qga/vss-win32/Makefile.objs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# rules to build qga-vss.dll
2+
3+
qga-vss-dll-obj-y += requester.o provider.o install.o
4+
5+
obj-qga-vss-dll-obj-y = $(addprefix $(obj)/, $(qga-vss-dll-obj-y))
6+
$(obj-qga-vss-dll-obj-y): QEMU_CXXFLAGS = $(filter-out -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wredundant-decls -fstack-protector-all, $(QEMU_CFLAGS)) -Wno-unknown-pragmas -Wno-delete-non-virtual-dtor
7+
8+
$(obj)/qga-vss.dll: LDFLAGS = -shared -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32 -lshlwapi -luuid -static
9+
$(obj)/qga-vss.dll: $(obj-qga-vss-dll-obj-y) $(SRC_PATH)/$(obj)/qga-vss.def
10+
$(call quiet-command,$(CXX) -o $@ $(qga-vss-dll-obj-y) $(SRC_PATH)/qga/vss-win32/qga-vss.def $(CXXFLAGS) $(LDFLAGS)," LINK $(TARGET_DIR)$@")
11+
12+
13+
# rules to build qga-provider.tlb
14+
# Currently, only native build is supported because building .tlb
15+
# (TypeLibrary) from .idl requires WindowsSDK and MIDL (and cl.exe in VC++).
16+
MIDL=$(WIN_SDK)/Bin/midl
17+
18+
$(obj)/qga-vss.tlb: $(SRC_PATH)/$(obj)/qga-vss.idl
19+
ifeq ($(WIN_SDK),"")
20+
$(call quiet-command,cp $(dir $<)qga-vss.tlb $@, " COPY $(TARGET_DIR)$@")
21+
else
22+
$(call quiet-command,$(MIDL) -tlb $@ -I $(WIN_SDK)/Include $<," MIDL $(TARGET_DIR)$@")
23+
endif

0 commit comments

Comments
 (0)