Commit b39297ae authored by Tomoki Sekiyama's avatar Tomoki Sekiyama Committed by Michael Roth
Browse files

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: default avatarTomoki Sekiyama <tomoki.sekiyama@hds.com>
Signed-off-by: default avatarMichael Roth <mdroth@linux.vnet.ibm.com>
parent 20840d4c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -235,7 +235,7 @@ clean:
	rm -f qemu-options.def
	find . -name '*.[oda]' -type f -exec rm -f {} +
	find . -name '*.l[oa]' -type f -exec rm -f {} +
	rm -f $(TOOLS) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
	rm -Rf .libs
	rm -f qemu-img-cmds.h
	@# May not be present in GENERATED_HEADERS
+2 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ version-lobj-$(CONFIG_WIN32) += $(BUILD_DIR)/version.lo
# FIXME: a few definitions from qapi-types.o/qapi-visit.o are needed
# by libqemuutil.a.  These should be moved to a separate .json schema.
qga-obj-y = qga/ qapi-types.o qapi-visit.o
qga-vss-dll-obj-y = qga/

vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)

@@ -120,6 +121,7 @@ nested-vars += \
	stub-obj-y \
	util-obj-y \
	qga-obj-y \
	qga-vss-dll-obj-y \
	block-obj-y \
	common-obj-y
dummy := $(call unnest-vars)
+4 −1
Original line number Diff line number Diff line
@@ -3568,8 +3568,11 @@ if test "$softmmu" = yes ; then
  fi
fi
if [ "$guest_agent" != "no" ]; then
  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
      tools="qemu-ga\$(EXESUF) $tools"
      if [ "$mingw32" = "yes" -a "$guest_agent_with_vss" = "yes" ]; then
        tools="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb $tools"
      fi
      guest_agent=yes
  elif [ "$guest_agent" != yes ]; then
      guest_agent=no
+2 −0
Original line number Diff line number Diff line
@@ -3,3 +3,5 @@ qga-obj-$(CONFIG_POSIX) += commands-posix.o channel-posix.o
qga-obj-$(CONFIG_WIN32) += commands-win32.o channel-win32.o service-win32.o
qga-obj-y += qapi-generated/qga-qapi-types.o qapi-generated/qga-qapi-visit.o
qga-obj-y += qapi-generated/qga-qmp-marshal.o

qga-vss-dll-obj-$(CONFIG_QGA_VSS) += vss-win32/
+23 −0
Original line number Diff line number Diff line
# rules to build qga-vss.dll

qga-vss-dll-obj-y += requester.o provider.o install.o

obj-qga-vss-dll-obj-y = $(addprefix $(obj)/, $(qga-vss-dll-obj-y))
$(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

$(obj)/qga-vss.dll: LDFLAGS = -shared -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32 -lshlwapi -luuid -static
$(obj)/qga-vss.dll: $(obj-qga-vss-dll-obj-y) $(SRC_PATH)/$(obj)/qga-vss.def
	$(call quiet-command,$(CXX) -o $@ $(qga-vss-dll-obj-y) $(SRC_PATH)/qga/vss-win32/qga-vss.def $(CXXFLAGS) $(LDFLAGS),"  LINK  $(TARGET_DIR)$@")


# rules to build qga-provider.tlb
# Currently, only native build is supported because building .tlb
# (TypeLibrary) from .idl requires WindowsSDK and MIDL (and cl.exe in VC++).
MIDL=$(WIN_SDK)/Bin/midl

$(obj)/qga-vss.tlb: $(SRC_PATH)/$(obj)/qga-vss.idl
ifeq ($(WIN_SDK),"")
	$(call quiet-command,cp $(dir $<)qga-vss.tlb $@, "  COPY  $(TARGET_DIR)$@")
else
	$(call quiet-command,$(MIDL) -tlb $@ -I $(WIN_SDK)/Include $<,"  MIDL  $(TARGET_DIR)$@")
endif
Loading