qemu-ga: fsfreeze on Windows using VSS
v3 cover qemu-ga: fsfreeze on Windows using VSS
Hi,
This patch series adds fsfreeze support for Windows qemu-guest-agent.
changes from v2:
- [06/11] Fix errors in Windows 7, reported by Li Baiqing (see below for details).
changes from v1:
- Fix out-tree build by stop using recursive Makefile
- Added script to extract VSS SDK headers on POSIX systems using msitools (thanks Paolo)
- Remove some unnecessary header files
v2: http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg02518.html
* Description
In Windows, VSS (Volume Shadow Copy Service) provides a facility to quiesce filesystems and applications before disk snapshots are taken. This patch series implements "fsfreeze" command of qemu-ga using VSS.
* How to build & run qemu-ga with VSS support
- Download Microsoft VSS SDK from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490
- Setup the SDK
scripts/extract-vsssdk-headers setup.exe (on POSIX-systems)
- Specify installed SDK directory to configure option as:
./configure -with-vss-sdk="path/to/VSS SDK" --cross-prefix=i686-w64-mingw32-
- make qemu-ga.exe
- Install qemu-ga.exe, qga/vss-win32-provider/qga-provider.{dll,tlb}, and the other required mingw libraries into the same directory in guests
- Run qemu-ga.exe -s install' and net start qemu-ga' in the guests
* About errors in Windows 7 with patch v2
VSS requires to write to snapshot volumes just before making them read-only
at final commit phase. This feature is called `auto-recovery'
(See http://msdn.microsoft.com/en-us/library/windows/desktop/aa384651(v=vs.85).aspx#base.vssgloss_auto_recoved_shadow_copy for details).
Since qemu and libvirt don't have feature to handle writable snapshots, this patchset just disables auto-recovery by specifying VSS_VOLSNAP_ATTR_NO_AUTORECOVERY flag to SetContext. Unfortunately, this flag seems unsupported in Windows 7 or earlier. It tries to look up the snapshot volumes to write and fails in VSS_E_OBJECT_NOT_FOUND.
For fundamental resolution we need a framework for guests to query snapshots and to mount them as writable snapshots, but we just ignore the error in this patchset.
Any feedback are appliciated.
---
Tomoki Sekiyama (11):
configure: Support configuring c++ compiler
Fix errors and warnings while compiling with c++ compilier
Add a script to extract VSS SDK headers on POSIX system
qemu-ga: Add an configure option to specify path to Windows VSS SDK
qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze
qemu-ga: Add Windows VSS requester to quisce applications and filesystems
qemu-ga: call Windows VSS requester in fsfreeze command handler
qemu-ga: install Windows VSS provider on `qemu-ga -s install'
qemu-ga: Add VSS provider .tlb file in the repository QMP/qemu-ga-client: make timeout longer for guest-fsfreeze-freeze command QMP/qmp.py: set locale for exceptions to display non-ascii messages correctly
.gitignore | 1 Makefile | 3 Makefile.objs | 2 QMP/qemu-ga-client | 4 QMP/qmp.py | 4 configure | 59 ++++ hmp.c | 2 hw/pci/pci.c | 2 qga/Makefile.objs | 7 qga/commands-win32.c | 74 ++++- qga/main.c | 41 +++ qga/vss-win32-provider.h | 26 ++ qga/vss-win32-provider/Makefile.objs | 25 ++ qga/vss-win32-provider/install.cpp | 494 +++++++++++++++++++++++++++++++ qga/vss-win32-provider/provider.cpp | 474 ++++++++++++++++++++++++++++++ qga/vss-win32-provider/qga-provider.def | 10 + qga/vss-win32-provider/qga-provider.idl | 20 + qga/vss-win32-provider/qga-provider.tlb | Bin qga/vss-win32-requester.cpp | 404 +++++++++++++++++++++++++ qga/vss-win32-requester.h | 31 ++ qga/vss-win32.h | 85 +++++ rules.mak | 9 + scripts/extract-vsssdk-headers | 25 ++ scripts/qapi.py | 9 + 24 files changed, 1796 insertions(+), 15 deletions(-) create mode 100644 qga/vss-win32-provider.h create mode 100644 qga/vss-win32-provider/Makefile.objs create mode 100644 qga/vss-win32-provider/install.cpp create mode 100644 qga/vss-win32-provider/provider.cpp create mode 100644 qga/vss-win32-provider/qga-provider.def create mode 100644 qga/vss-win32-provider/qga-provider.idl create mode 100644 qga/vss-win32-provider/qga-provider.tlb create mode 100644 qga/vss-win32-requester.cpp create mode 100644 qga/vss-win32-requester.h create mode 100644 qga/vss-win32.h create mode 100755 scripts/extract-vsssdk-headers
RFC PATCH v3 1/11 configure: Support configuring c++ compiler
Add configuration for c++ compiler (${corss_prefix}g++ as default) in configure and Makefiles.
Currently, usage of c++ language is only for access to Windows VSS using COM+ services in qemu-guest-agent for Windows.
--- configure | 6 ++++++ rules.mak | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
configure +6 -0
@@ -280,6 +280,7 @@ else cc="${CC-${cross_prefix}gcc}" fi +cxx="${CXX-${cross_prefix}g++}" ar="${AR-${cross_prefix}ar}" as="${AS-${cross_prefix}as}" cpp="${CPP-$cc -E}"
@@ -614,6 +615,8 @@ for opt do ;; --host-cc=*) host_cc="$optarg" ;; + --cxx=*) cxx="$optarg" + ;; --objcc=*) objcc="$optarg" ;; --make=*) make="$optarg"
@@ -1069,6 +1072,7 @@ echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]" echo " --cc=CC use C compiler CC [$cc]" echo " --host-cc=CC use C compiler CC [$host_cc] for code run at" echo " build time" +echo " --cxx=CXX use C++ compiler CXX [$cxx]" echo " --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]" echo " --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS" echo " --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS"
@@ -3496,6 +3500,7 @@ fi echo "Source path $source_path" echo "C compiler $cc" echo "Host C compiler $host_cc" +echo "C++ compiler $cxx" echo "Objective-C compiler $objcc" echo "CFLAGS $CFLAGS" echo "QEMU_CFLAGS $QEMU_CFLAGS"
@@ -4069,6 +4074,7 @@ echo "PYTHON=$python" >> $config_host_mak echo "CC=$cc" >> $config_host_mak echo "CC_I386=$cc_i386" >> $config_host_mak echo "HOST_CC=$host_cc" >> $config_host_mak +echo "CXX=$cxx" >> $config_host_mak echo "OBJCC=$objcc" >> $config_host_mak echo "AR=$ar" >> $config_host_mak echo "AS=$as" >> $config_host_mak
rules.mak +8 -1
@@ -8,9 +8,13 @@ MAKEFLAGS += -rR %.d: %.h: %.c: +%.cpp: %.m: %.mak: +# Flags for C++ compilation +QEMU_CXXFLAGS = -D__STDC_LIMIT_MACROS $(filter-out -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wredundant-decls, $(QEMU_CFLAGS)) + # Flags for dependency generation QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
@@ -50,6 +54,9 @@ endif %.o: %.asm $(call quiet-command,$(AS) $(ASFLAGS) -o $@ $<," AS $(TARGET_DIR)$@") +%.o: %.cpp + $(call quiet-command,$(CXX) $(QEMU_INCLUDES) $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," CXX $(TARGET_DIR)$@") + %.o: %.m $(call quiet-command,$(OBJCC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," OBJC $(TARGET_DIR)$@")
@@ -70,7 +77,7 @@ quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \ >/dev/null 2>&1 && echo OK), $2, $3) -VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi %.sh %.rc +VPATH_SUFFIXES = %.c %.h %.S %.cpp %.m %.mak %.texi %.sh %.rc set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) # find-in-path
Re: [Qemu-devel] [RFC PATCH v3 01/11] configure: Support configuring c++ compiler
Quoted 1 line · Tomoki Sekiyama
Add configuration for c++ compiler (${corss_prefix}g++ as default) in
s/corss/cross/
Quoted 5 lines
configure and Makefiles.
Currently, usage of c++ language is only for access to Windows VSS using COM+ services in qemu-guest-agent for Windows.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [RFC PATCH v3 01/11] configure: Support configuring c++ compiler
Hi Eric,
Thank you for the review.
Quoted 4 lines · Eric Blake
Quoted 1 line · Tomoki Sekiyama
Add configuration for c++ compiler (${corss_prefix}g++ as default) in
s/corss/cross/
Oops, I'll fix this in next version...
(with a fix for logic to configure c++ compiler, pointed out on Peter's mail)
Quoted 4 lines
Quoted 4 lines
configure and Makefiles.
Currently, usage of c++ language is only for access to Windows VSS using COM+ services in qemu-guest-agent for Windows.
Thanks,
Signature · 1 line
Tomoki Sekiyama
Re: [Qemu-devel] [RFC PATCH v3 01/11] configure: Support configuring c++ compiler
In reply to Tomoki SekiyamaQuoted 2 lines · Tomoki Sekiyama
Add configuration for c++ compiler (${corss_prefix}g++ as default) in configure and Makefiles.
I think you should follow the same logic we use for picking the C compiler, so that we use 'c++' rather than 'g++' if cross_prefix isn't specified. Otherwise we'll end up on MacOSX with the odd effect of using clang for C and some ancient compiler for C++...
Quoted 2 lines
Currently, usage of c++ language is only for access to Windows VSS using COM+ services in qemu-guest-agent for Windows.
...which isn't important for this use, but I'm sure once configure has support for C++ it'll spread to other uses later.
thanks
-- PMM
Re: [Qemu-devel] [RFC PATCH v3 01/11] configure: Support configuring c++ compiler
Hi Peter,
Quoted 10 lines · Peter Maydell
Quoted 2 lines · Tomoki Sekiyama
Add configuration for c++ compiler (${corss_prefix}g++ as default) in configure and Makefiles.
I think you should follow the same logic we use for picking the C compiler, so that we use 'c++' rather than 'g++' if
cross_prefixisn't specified. Otherwise we'll end up on MacOSX with the odd effect of using clang for C and some ancient compiler for C++...
Quoted 8 lines
Quoted 2 lines
Currently, usage of c++ language is only for access to Windows VSS using COM+ services in qemu-guest-agent for Windows.
...which isn't important for this use, but I'm sure once configure has support for C++ it'll spread to other uses later.
thanks
-- PMM
OK, I will follow the logic for C compiler in the next version.
Thanks,
Signature · 1 line
Tomoki Sekiyama
RFC PATCH v3 2/11 Fix errors and warnings while compiling with c++ compilier
In reply to Tomoki SekiyamaAdd C++ keywords to avoid errors in compiling with c++ compiler. This also renames class member of PciDeviceInfo to q_class.
--- hmp.c | 2 +- hw/pci/pci.c | 2 +- scripts/qapi.py | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-)
hmp.c +1 -1
@@ -484,7 +484,7 @@ static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev)if (dev->class_info.has_desc) {monitor_printf (mon,"%s" , dev->class_info.desc); }else { -monitor_printf (mon,"Class %04" PRId64, dev->class_info.class); +monitor_printf (mon,"Class %04" PRId64, dev->class_info.q_class); } monitor_printf(mon, ": PCI device %04" PRIx64 ":%04" PRIx64 "\n",
hw/pci/pci.c +1 -1
@@ -1460,7 +1460,7 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus, info->function =PCI_FUNC (dev->devfn); class =pci_get_word (dev->config +PCI_CLASS_DEVICE ); - info->class_info.class = class; + info->class_info.q_class = class; desc =get_class_desc (class);if (desc->desc) { info->class_info.has_desc = true;
scripts/qapi.py +8 -1
@@ -156,9 +156,16 @@ def c_var(name, protect=True): # GCC http://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/C-Extensions.html # excluding _.* gcc_words = set(['asm', 'typeof']) + # C++ ISO/IEC 14882:2003 2.11 + cpp_words = set(['bool', 'catch', 'class', 'const_cast', 'delete', + 'dynamic_cast', 'explicit', 'false', 'friend', 'mutable', + 'namespace', 'new', 'operator', 'private', 'protected', + 'public', 'reinterpret_cast', 'static_cast', 'template', + 'this', 'throw', 'true', 'try', 'typeid', 'typename', + 'using', 'virtual', 'wchar_t']) # namespace pollution: polluted_words = set(['unix']) - if protect and (name in c89_words | c99_words | c11_words | gcc_words | polluted_words): + if protect and (name in c89_words | c99_words | c11_words | gcc_words | cpp_words | polluted_words): return "q_" + name return name.replace('-', '_').lstrip("*")
Re: [Qemu-devel] [RFC PATCH v3 02/11] Fix errors and warnings while compiling with c++ compilier
Quoted 9 lines · Tomoki Sekiyama
Add C++ keywords to avoid errors in compiling with c++ compiler. This also renames class member of PciDeviceInfo to
q_class.Signed-off-by Tomoki Sekiyama <[email protected]>--- hmp.c | 2 +- hw/pci/pci.c | 2 +- scripts/qapi.py | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-)
Please also extend scripts/checkpatch.pl. Otherwise it is very likely that C++ keywords will be introduced again in the future. Most people will not build the VSS code and therefore checkpatch.pl needs to ensure that patches with C++ keywords will not be accepted.
Stefan
Re: [Qemu-devel] [RFC PATCH v3 02/11] Fix errors and warnings while compiling with c++ compilier
Quoted 11 lines · Stefan Hajnoczi
Quoted 9 lines · Tomoki Sekiyama
Add C++ keywords to avoid errors in compiling with c++ compiler. This also renames class member of PciDeviceInfo to
q_class.Signed-off-by Tomoki Sekiyama <[email protected]>--- hmp.c | 2 +- hw/pci/pci.c | 2 +- scripts/qapi.py | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-)
Quoted 6 lines
Please also extend
scripts/checkpatch.pl. Otherwise it is very likely that C++ keywords will be introduced again in the future. Most people will not build the VSS code and therefore checkpatch.pl needs to ensure that patches with C++ keywords will not be accepted.Stefan
I think it would be difficult to identify problematic C++ keywords usage from patches because headers can legally contain C++ keywords and checkpatch.pl doesn't know where it should be used.
Do you have any good ideas?
And, at least for QAPI, scripts/qapi.py automatically detects the keywords to add q_ prefix for them (like `q_class' in this patch).
Thanks,
Tomoki Sekiyama
Re: [Qemu-devel] [RFC PATCH v3 02/11] Fix errors and warnings while compiling with c++ compilier
Quoted 18 lines · Tomoki Sekiyama
Quoted 16 lines · Stefan Hajnoczi
Quoted 9 lines · Tomoki Sekiyama
Add C++ keywords to avoid errors in compiling with c++ compiler. This also renames class member of PciDeviceInfo to
q_class.Signed-off-by Tomoki Sekiyama <[email protected]>--- hmp.c | 2 +- hw/pci/pci.c | 2 +- scripts/qapi.py | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-)Please also extend
scripts/checkpatch.pl. Otherwise it is very likely that C++ keywords will be introduced again in the future. Most people will not build the VSS code and therefore checkpatch.pl needs to ensure that patches with C++ keywords will not be accepted.
Quoted 6 lines
Quoted 1 line
Stefan
I think it would be difficult to identify problematic C++ keywords usage from patches because headers can legally contain C++ keywords and checkpatch.pl doesn't know where it should be used.
Do you have any good ideas?
We can ignore false warnings for 0.1% of patches (the ones that touch VSS C++ code). But for the remaining 99.9% of patches it's worth guarding against VSS bitrot.
Remember not many people will compile it and therefore they won't notice when they break it. I really think it's worth putting some effort in now so VSS doesn't periodically break.
checkpatch.pl is a hacky sort of C parser. It already checks for a bunch of similar things and it knows about comments, macros, and strings. It does not perform #include expansion, so there is no risk of including system headers that have C++ code.
Stefan
Re: [Qemu-devel] [RFC PATCH v3 02/11] Fix errors and warnings while compiling with c++ compilier
Quoted 34 lines · Stefan Hajnoczi
Quoted 18 lines · Tomoki Sekiyama
Quoted 16 lines · Stefan Hajnoczi
Quoted 9 lines · Tomoki Sekiyama
Add C++ keywords to avoid errors in compiling with c++ compiler. This also renames class member of PciDeviceInfo to
q_class.Signed-off-by Tomoki Sekiyama <[email protected]>--- hmp.c | 2 +- hw/pci/pci.c | 2 +- scripts/qapi.py | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-)Please also extend
scripts/checkpatch.pl. Otherwise it is very likely that C++ keywords will be introduced again in the future. Most people will not build the VSS code and therefore checkpatch.pl needs to ensure that patches with C++ keywords will not be accepted.Quoted 6 lines
Quoted 1 line
Stefan
I think it would be difficult to identify problematic C++ keywords usage from patches because headers can legally contain C++ keywords and checkpatch.pl doesn't know where it should be used.
Do you have any good ideas?We can ignore false warnings for 0.1% of patches (the ones that touch VSS C++ code). But for the remaining 99.9% of patches it's worth guarding against VSS bitrot.
Remember not many people will compile it and therefore they won't notice when they break it. I really think it's worth putting some effort in now so VSS doesn't periodically break.
Quoted 6 lines
checkpatch.pl is a hacky sort of C parser. It already checks for a bunch of similar things and it knows about comments, macros, and strings. It does not perform #include expansion, so there is no risk of including system headers that have C++ code.
Stefan
Thanks for your comment.
I'm still wondering because it actually causes a lot false positives (not just 0.1%...) even for the patches not touching VSS.
For example, keyword 'class' is used in qdev-monitor.c, qom/object.c, and a lot of files in hw/*/*.c and include/{hw,qom}/*.h, but they have nothing to do with qemu-ga. Qemu-ga is just a part of whole qemu source code, so I don't want to warn around the other parts.
Thanks,
Tomoki Sekiyama
Re: [Qemu-devel] [RFC PATCH v3 02/11] Fix errors and warnings while compiling with c++ compilier
Quoted 45 lines · Tomoki Sekiyama
Quoted 34 lines · Stefan Hajnoczi
Quoted 18 lines · Tomoki Sekiyama
Quoted 16 lines · Stefan Hajnoczi
Quoted 9 lines · Tomoki Sekiyama
Add C++ keywords to avoid errors in compiling with c++ compiler. This also renames class member of PciDeviceInfo to
q_class.Signed-off-by Tomoki Sekiyama <[email protected]>--- hmp.c | 2 +- hw/pci/pci.c | 2 +- scripts/qapi.py | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-)Please also extend
scripts/checkpatch.pl. Otherwise it is very likely that C++ keywords will be introduced again in the future. Most people will not build the VSS code and therefore checkpatch.pl needs to ensure that patches with C++ keywords will not be accepted.Quoted 6 lines
Quoted 1 line
Stefan
I think it would be difficult to identify problematic C++ keywords usage from patches because headers can legally contain C++ keywords and checkpatch.pl doesn't know where it should be used.
Do you have any good ideas?We can ignore false warnings for 0.1% of patches (the ones that touch VSS C++ code). But for the remaining 99.9% of patches it's worth guarding against VSS bitrot.
Remember not many people will compile it and therefore they won't notice when they break it. I really think it's worth putting some effort in now so VSS doesn't periodically break.
Quoted 6 lines
checkpatch.pl is a hacky sort of C parser. It already checks for a bunch of similar things and it knows about comments, macros, and strings. It does not perform #include expansion, so there is no risk of including system headers that have C++ code.
Stefan
Thanks for your comment.
Quoted 7 lines
I'm still wondering because it actually causes a lot false positives (not just 0.1%...) even for the patches not touching VSS.
For example, keyword 'class' is used in
qdev-monitor.c,qom/object.c, and a lot of files in hw/*/*.c andinclude/{hw,qom}/*.h, but they have nothing to do with qemu-ga. Qemu-ga is just a part of whole qemu source code, so I don't want to warn around the other parts.
And I appreciate that. Purging some other language's keywords feels like pointless churn to me.
Re: [Qemu-devel] [RFC PATCH v3 02/11] Fix errors and warnings while compiling with c++ compilier
Quoted 50 lines · Markus Armbruster
Quoted 48 lines · Tomoki Sekiyama
Quoted 34 lines · Stefan Hajnoczi
Quoted 18 lines · Tomoki Sekiyama
Quoted 16 lines · Stefan Hajnoczi
Quoted 9 lines · Tomoki Sekiyama
Add C++ keywords to avoid errors in compiling with c++ compiler. This also renames class member of PciDeviceInfo to
q_class.Signed-off-by Tomoki Sekiyama <[email protected]>--- hmp.c | 2 +- hw/pci/pci.c | 2 +- scripts/qapi.py | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-)Please also extend
scripts/checkpatch.pl. Otherwise it is very likely that C++ keywords will be introduced again in the future. Most people will not build the VSS code and therefore checkpatch.pl needs to ensure that patches with C++ keywords will not be accepted.Quoted 6 lines
Quoted 1 line
Stefan
I think it would be difficult to identify problematic C++ keywords usage from patches because headers can legally contain C++ keywords and checkpatch.pl doesn't know where it should be used.
Do you have any good ideas?We can ignore false warnings for 0.1% of patches (the ones that touch VSS C++ code). But for the remaining 99.9% of patches it's worth guarding against VSS bitrot.
Remember not many people will compile it and therefore they won't notice when they break it. I really think it's worth putting some effort in now so VSS doesn't periodically break.
Quoted 6 lines
checkpatch.pl is a hacky sort of C parser. It already checks for a bunch of similar things and it knows about comments, macros, and strings. It does not perform #include expansion, so there is no risk of including system headers that have C++ code.
Stefan
Thanks for your comment.
I'm still wondering because it actually causes a lot false positives (not just 0.1%...) even for the patches not touching VSS.
Quoted 7 lines
Quoted 4 lines
For example, keyword 'class' is used in
qdev-monitor.c,qom/object.c, and a lot of files in hw/*/*.c andinclude/{hw,qom}/*.h, but they have nothing to do with qemu-ga. Qemu-ga is just a part of whole qemu source code, so I don't want to warn around the other parts.And I appreciate that. Purging some other language's keywords feels like pointless churn to me.
I see what you guys are saying now. You want to protect only qemu-ga. I was proposing protecting the entire codebase so we never get into a situation where changing a header breaks qemu-ga.
It's not that hard to use "klass" instead of "class", but if it's unpopular then we'll just have to live with VSS breakage.
Stefan
Re: [Qemu-devel] [RFC PATCH v3 02/11] Fix errors and warnings while compiling with c++ compilier
In reply to Tomoki SekiyamaQuoted 11 lines · Tomoki Sekiyama
scripts/qapi.py +3
-0@@ -156,9 +156,16 @@ def c_var(name, protect=True): # GCC http://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/C-Extensions.html # excluding _.* gcc_words = set(['asm', 'typeof']) + # C++ ISO/IEC 14882:2003 2.11 + cpp_words = set(['bool', 'catch', 'class', 'const_cast', 'delete', + 'dynamic_cast', 'explicit', 'false', 'friend', 'mutable',
scripts/qapi.py def c_var(name, protect=True): · line 170
Quoted 10 lines
scripts/qapi.py +5
-1+ 'namespace', 'new', 'operator', 'private', 'protected', + 'public', 'reinterpret_cast', 'static_cast', 'template', + 'this', 'throw', 'true', 'try', 'typeid', 'typename', + 'using', 'virtual', 'wchar_t']) # namespace pollution: polluted_words = set(['unix']) - if protect and (name in c89_words | c99_words | c11_words | gcc_words | polluted_words): + if protect and (name in c89_words | c99_words | c11_words | gcc_words | cpp_words | polluted_words): return "q_" + name return name.replace('-', '_').lstrip("*")
Since you're respinning anyway, perhaps consider adding these lovely "alternative representations" from just one paragraph below (they are reserved and "shall not be used otherwise" than the operators they stand for):
and bitand compl not_eq or_eq xor_eqand_eq bitor not or xor
although probably noone would use these as identifiers or otherwise... So just mentioning it for completeness.
Laszlo
Re: [Qemu-devel] [RFC PATCH v3 02/11] Fix errors and warnings while compiling with c++ compilier
Quoted 35 lines · Laszlo Ersek
Quoted 22 lines · Tomoki Sekiyama
scripts/qapi.py +7
-1@@ -156,9 +156,16 @@ def c_var(name, protect=True): # GCC http://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/C-Extensions.html # excluding _.* gcc_words = set(['asm', 'typeof']) + # C++ ISO/IEC 14882:2003 2.11 + cpp_words = set(['bool', 'catch', 'class', 'const_cast', 'delete', + 'dynamic_cast', 'explicit', 'false', 'friend', 'mutable', + 'namespace', 'new', 'operator', 'private', 'protected', + 'public', 'reinterpret_cast', 'static_cast', 'template', + 'this', 'throw', 'true', 'try', 'typeid', 'typename', + 'using', 'virtual', 'wchar_t']) # namespace pollution: polluted_words = set(['unix']) - if protect and (name in c89_words | c99_words | c11_words |Quoted 5 lines
gcc_words|polluted_words):
+ if protect and (name inc89_words|c99_words|c11_words|gcc_words|cpp_words|polluted_words):
return "q_" + name
returnname.replace('-', '_').lstrip("*")Since you're respinning anyway, perhaps consider adding these lovely "alternative representations" from just one paragraph below (they are reserved and "shall not be used otherwise" than the operators they stand for):
Quoted 7 lines
and bitand compl
not_eqor_eqxor_eqand_eqbitor not or xoralthough probably noone would use these as identifiers or otherwise... So just mentioning it for completeness.
Laszlo
OK, I will try adding these keywords in next submit.
Thanks,
Tomoki Sekiyama
RFC PATCH v3 3/11 Add a script to extract VSS SDK headers on POSIX system
In reply to Tomoki SekiyamaVSS SDK(*) setup.exe is only runnable on Windows. This adds a script to extract VSS SDK headers on POSIX-systems using msitools.
* http://www.microsoft.com/en-us/download/details.aspx?id=23490
From: Paolo Bonzini <[email protected]>
--- scripts/extract-vsssdk-headers | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 scripts/extract-vsssdk-headers
scripts/extract-vsssdk-headers new file +25 -0
@@ -0,0 +1,25 @@ +#! /bin/bash + +# extract-vsssdk-headers +# Author: Paolo Bonzini <[email protected]> + +set -e +if test $# = 0 || ! test -f "$1"; then + echo 'Usage: extract-vsssdk-headers /path/to/setup.exe' + exit 1 +fi + +# Extract .MSI file in the .exe, looking for the OLE compound +# document signature. Extra data at the end does not matter. +export LC_ALL=C +MAGIC=$'\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1' +offset=`grep -abom1 "$MAGIC" "$1" | sed -n 's/:/\n/; P' ` +(dd of=/dev/null skip=$offset bs=1 count=0; cat) < "$1" > vsssdk.msi + +# Now extract the files. +tmpdir=tmp$$ +mkdir $tmpdir +msiextract -C $tmpdir vsssdk.msi +mv "$tmpdir/Program Files/Microsoft/VSSSDK72/inc" inc +rm -rf $tmpdir vsssdk.msi +exit 0
Re: [Qemu-devel] [RFC PATCH v3 03/11] Add a script to extract VSS SDK headers on POSIX system
Quoted 6 lines · Tomoki Sekiyama
VSS
SDK(*)setup.exe is only runnable on Windows. This adds a script to extract VSS SDK headers on POSIX-systems using msitools.* http://www.microsoft.com/en-us/download/details.aspx?id=23490
From: Paolo Bonzini <[email protected]>
Quoted 8 lines
Signed-off-by Tomoki Sekiyama <[email protected]>--- scripts/extract-vsssdk-headers | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 scripts/extract-vsssdk-headers+#!
/bin/bash
Since you are using bash...
scripts/extract-vsssdk-headers line 7
Quoted 6 lines
scripts/extract-vsssdk-headers new file +6
-0+ +# extract-vsssdk-headers +# Author: Paolo Bonzini <[email protected]> + +set -e +if test $# = 0 || ! test -f "$1"; then
Why reject 0 arguments but not 2? Shouldn't the first check be test $# != 1?
scripts/extract-vsssdk-headers line 16
Quoted 9 lines
scripts/extract-vsssdk-headers new file +9
-0+ echo 'Usage: extract-vsssdk-headers /path/to/setup.exe' + exit 1 +fi + +# Extract .MSI file in the .exe, looking for the OLE compound +# document signature. Extra data at the end does not matter. +export LC_ALL=C +MAGIC=$'\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1' +offset=`grep -abom1 "$MAGIC" "$1" | sed -n 's/:/\n/; P' `
...I'd prefer $() over ``.
scripts/extract-vsssdk-headers line 21
Quoted 5 lines
scripts/extract-vsssdk-headers new file +5
-0+(dd of=/dev/null skip=$offset bs=1 count=0; cat) < "$1" > vsssdk.msi + +# Now extract the files. +tmpdir=tmp$$ +mkdir $tmpdir
...also, this name is rather predictable; adding a $RANDOM might help improve its quality.
scripts/extract-vsssdk-headers line 24
Quoted 3 lines
scripts/extract-vsssdk-headers new file +3
-0+msiextract -C $tmpdir vsssdk.msi +mv "$tmpdir/Program Files/Microsoft/VSSSDK72/inc" inc +rm -rf $tmpdir vsssdk.msi
What, no trap, to guarantee clean up of the temp directory even if you Ctrl-C the script in the middle of a potentially long-running msiextract?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [RFC PATCH v3 03/11] Add a script to extract VSS SDK headers on POSIX system
Quoted 18 lines · Eric Blake
Quoted 6 lines · Tomoki Sekiyama
VSS
SDK(*)setup.exe is only runnable on Windows. This adds a script to extract VSS SDK headers on POSIX-systems using msitools.* http://www.microsoft.com/en-us/download/details.aspx?id=23490
From: Paolo Bonzini <[email protected]>
Quoted 8 lines
Signed-off-by Tomoki Sekiyama <[email protected]>--- scripts/extract-vsssdk-headers | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 scripts/extract-vsssdk-headers+#!
/bin/bashSince you are using bash...
Quoted 9 lines
scripts/extract-vsssdk-headers line 7
Quoted 6 lines
scripts/extract-vsssdk-headers new file +6
-0+ +# extract-vsssdk-headers +# Author: Paolo Bonzini <[email protected]> + +set -e +if test $# = 0 || ! test -f "$1"; thenWhy reject 0 arguments but not 2? Shouldn't the first check be test $# != 1?
I agree, will fix this.
Quoted 11 lines
scripts/extract-vsssdk-headers line 16
Quoted 9 lines
scripts/extract-vsssdk-headers new file +9
-0+ echo 'Usage: extract-vsssdk-headers /path/to/setup.exe' + exit 1 +fi + +# Extract .MSI file in the .exe, looking for the OLE compound +# document signature. Extra data at the end does not matter. +export LC_ALL=C +MAGIC=$'\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1' +offset=`grep -abom1 "$MAGIC" "$1" | sed -n 's/:/\n/; P' `...I'd prefer $() over ``.
OK.
Quoted 8 lines
scripts/extract-vsssdk-headers line 21
Quoted 5 lines
scripts/extract-vsssdk-headers new file +5
-0+(dd of=/dev/null skip=$offset bs=1 count=0; cat) < "$1" > vsssdk.msi + +# Now extract the files. +tmpdir=tmp$$ +mkdir $tmpdir...also, this name is rather predictable; adding a $RANDOM might help improve its quality.
I will add $RANDOM here.
Quoted 6 lines
scripts/extract-vsssdk-headers line 24
Quoted 3 lines
scripts/extract-vsssdk-headers new file +3
-0+msiextract -C $tmpdir vsssdk.msi +mv "$tmpdir/Program Files/Microsoft/VSSSDK72/inc" inc +rm -rf $tmpdir vsssdk.msiWhat, no trap, to guarantee clean up of the temp directory even if you Ctrl-C the script in the middle of a potentially long-running msiextract?
OK, I will add some trap here.
Maybe it also should have an additional check and a message to install Msitools for the case msiextract isn't exectable.
Thanks,
Signature · 1 line
Tomoki Sekiyama
Re: [Qemu-devel] [RFC PATCH v3 03/11] Add a script to extract VSS SDK headers on POSIX system
Quoted 2 lines · Tomoki Sekiyama
Maybe it also should have an additional check and a message to install Msitools for the case msiextract isn't exectable.
Right. One POSIX-y way would be
command -v msiextract >/dev/null
and checking the exit status.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
Alternatively, just go ahead calling it, and if the exit status is 126 or 127, assume it is not (correctly) installed and emit an extra hint afterwards:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01_01
Laszlo
Re: [Qemu-devel] [RFC PATCH v3 03/11] Add a script to extract VSS SDK headers on POSIX system
In reply to Tomoki SekiyamaQuoted 18 lines · Tomoki Sekiyama
VSS
SDK(*)setup.exe is only runnable on Windows. This adds a script to extract VSS SDK headers on POSIX-systems using msitools.* http://www.microsoft.com/en-us/download/details.aspx?id=23490
From: Paolo Bonzini <[email protected]>
Signed-off-by Tomoki Sekiyama <[email protected]>--- scripts/extract-vsssdk-headers | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 scripts/extract-vsssdk-headersscripts/extract-vsssdk-headers new file +0
-0
scripts/extract-vsssdk-headers line 10
Quoted 10 lines
scripts/extract-vsssdk-headers new file +10
-0@@ -0,0 +1,25 @@ +#! /bin/bash + +# extract-vsssdk-headers +# Author: Paolo Bonzini <[email protected]> + +set -e +if test $# = 0 || ! test -f "$1"; then + echo 'Usage: extract-vsssdk-headers /path/to/setup.exe' + exit 1 +fi
Error message to >&2 ?
(Would not be worth a repost but you're already doing one...)
scripts/extract-vsssdk-headers line 15
Quoted 5 lines
scripts/extract-vsssdk-headers new file +5
-0+ +# Extract .MSI file in the .exe, looking for the OLE compound +# document signature. Extra data at the end does not matter. +export LC_ALL=C +MAGIC=$'\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1'
Can't help mentioning the following portable (alas, octal) equivalent :)
MAGIC=$(printf '%b' '\0320\0317\0021\0340\0241\0261\0032\0341')
<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html#tag_20_94>
scripts/extract-vsssdk-headers line 16
Quoted 1 line
scripts/extract-vsssdk-headers new file +1
-0+offset=`grep -abom1 "$MAGIC" "$1" | sed -n 's/:/\n/; P' `
Of these grep options, none are portable, hence I'm supposing dependency on GNU grep. In that case, see (*).
scripts/extract-vsssdk-headers line 17
Quoted 1 line
scripts/extract-vsssdk-headers new file +1
-0+(dd of=/dev/null skip=$offset bs=1 count=0; cat) < "$1" > vsssdk.msi
In place of dd for seeking + cat, suggest
tail -c +$((offset+1)) -- "$1"
<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/tail.html>
scripts/extract-vsssdk-headers line 25
Quoted 8 lines
scripts/extract-vsssdk-headers new file +8
-0+ +# Now extract the files. +tmpdir=tmp$$ +mkdir $tmpdir +msiextract -C $tmpdir vsssdk.msi +mv "$tmpdir/Program Files/Microsoft/VSSSDK72/inc" inc +rm -rf $tmpdir vsssdk.msi +exit 0
(*) Since we rely on GNU utilities anyway, I propose the mktemp utility ("Written by Jim Meyering and Eric Blake", heh) from GNU coreutils:
tmpdir=$(mktemp -d)
Feel free to ignore any of the above, of course :)
Thanks,
Laszlo
Re: [Qemu-devel] [RFC PATCH v3 03/11] Add a script to extract VSS SDK headers on POSIX system
Quoted 10 lines · Laszlo Ersek
scripts/extract-vsssdk-headers line 15
Quoted 6 lines
+++ b/scripts/extract-vsssdk-headers
scripts/extract-vsssdk-headers new file +3
-0@@ -0,0 +1,25 @@ +#! /bin/bash + +MAGIC=$'\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1'Can't help mentioning the following portable (alas, octal) equivalent :)
MAGIC=$(printf '%b' '\0320\0317\0021\0340\0241\0261\0032\0341')
Yeah, but as long as the she-bang is (correctly) requiring bash, we might as well use the full power of bash. Also, Issue 8 of POSIX will be mandating $'' handling (but it could be several years before Issue 8 becomes a standard, compared to Issue 7 [aka POSIX 2008] just barely released its first technical corrigendum [aka POSIX 2013]).
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [RFC PATCH v3 03/11] Add a script to extract VSS SDK headers on POSIX system
Quoted 7 lines · Eric Blake
Quoted 4 lines · Laszlo Ersek
Quoted 4 lines
+++ b/scripts/extract-vsssdk-headers
(quoted diff) +2
-0@@ -0,0 +1,25 @@ +#! /bin/bash +
Quoted 7 lines
Quoted 5 lines
scripts/extract-vsssdk-headers line 15
Quoted 1 line
scripts/extract-vsssdk-headers new file +1
-0+MAGIC=$'\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1'Can't help mentioning the following portable (alas, octal) equivalent :)
MAGIC=$(printf '%b' '\0320\0317\0021\0340\0241\0261\0032\0341')
Yeah, but as long as the she-bang is (correctly) requiring bash,
Yes, that's why I edited my original "please consider using" to "can't help mentioning" :) I recalled that you had mentioned dash in one of your reviews (*), I checked your reply to this v3 03/11 and saw that it wasn't it -- here you'd written "Since you are using bash" so I edited the above paragraph. Clearly insufficiently :)
(*) ... Apparently you mentioned dash in a MALLOC_PERTURB_ thread.
L.
RFC PATCH v3 4/11 qemu-ga: Add an configure option to specify path to Windows VSS SDK
In reply to Tomoki SekiyamaTo enable VSS support in qemu-ga for Windows, header files included in VSS SDK is required.
The VSS support is enabled when the option like below:
./configure --with-vss-sdk="/pass/to/VSS SDK"
VSS SDK is available from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490
To cross-compilie using mingw32 for Linux, you need to setup the SDK on Windows environments to extract headers. You can also extract the SDK headers using scripts/extract-vss-headers, written by Paolo Bonzini.
--- .gitignore | 1 + Makefile | 1 + configure | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+)
.gitignore +1 -0
@@ -79,6 +79,7 @@ fsdev/virtfs-proxy-helper.pod *.la *.pc .libs +.sdk *.swp *.orig .pc
Makefile +1 -0
@@ -272,6 +272,7 @@ distclean: clean for d in $(TARGET_DIRS); do \ rm -rf $$d || exit 1 ; \ done + rm -Rf .sdk if test -f pixman/config.log; then make -C pixman distclean; fi if test -f dtc/version_gen.h; then make $(DTC_MAKE_ARGS) clean; fi
configure +48 -0
84 lines not on this page · raw message
Re: [Qemu-devel] [RFC PATCH v3 04/11] qemu-ga: Add an configure option to specify path to Windows VSS SDK
Quoted 9 lines · Tomoki Sekiyama
To enable VSS support in qemu-ga for Windows, header files included in VSS SDK is required.
The VSS support is enabled when the option like below:
./configure --with-vss-sdk="/pass/to/VSS SDK"VSS SDK is available from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490To cross-compilie using mingw32 for Linux, you need to setup the SDK on
s/compilie/compile/
There are two mingw projects: mingw (older, 32-bit only) and mingw64 (newer, both 32- and 64-bit support). The name 'mingw32' is misleading, as neither project uses it. Fedora uses mingw64.
Quoted 2 lines
Windows environments to extract headers. You can also extract the SDK headers using
scripts/extract-vss-headers, written by Paolo Bonzini.
I haven't downloaded the sdk to check for myself; are we breaking any licensing restrictions by compiling against those files?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [RFC PATCH v3 04/11] qemu-ga: Add an configure option to specify path to Windows VSS SDK
Quoted 9 lines · Eric Blake
Quoted 8 lines · Tomoki Sekiyama
To enable VSS support in qemu-ga for Windows, header files included in VSS SDK is required.
The VSS support is enabled when the option like below:
./configure --with-vss-sdk="/pass/to/VSS SDK"VSS SDK is available from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490
Quoted 7 lines
Quoted 1 line
To cross-compilie using mingw32 for Linux, you need to setup the SDK on
s/compilie/compile/
There are two mingw projects: mingw (older, 32-bit only) and mingw64 (newer, both 32- and 64-bit support). The name 'mingw32' is misleading, as neither project uses it. Fedora uses mingw64.
Ah, I should say just mingw here.
Quoted 5 lines
Quoted 2 lines
Windows environments to extract headers. You can also extract the SDK headers using
scripts/extract-vss-headers, written by Paolo Bonzini.I haven't downloaded the sdk to check for myself; are we breaking any licensing restrictions by compiling against those files?
I believe it is ok while the SDK is used for development of software running on Windows, and while the SDK is not redistributed.
Re: [Qemu-devel] [RFC PATCH v3 04/11] qemu-ga: Add an configure option to specify path to Windows VSS SDK
In reply to Eric BlakeQuoted 9 lines · Eric Blake
Quoted 8 lines · Tomoki Sekiyama
To enable VSS support in qemu-ga for Windows, header files included in VSS SDK is required.
The VSS support is enabled when the option like below:
./configure --with-vss-sdk="/pass/to/VSS SDK"VSS SDK is available from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490
Quoted 7 lines
Quoted 1 line
To cross-compilie using mingw32 for Linux, you need to setup the SDK on
s/compilie/compile/
There are two mingw projects: mingw (older, 32-bit only) and mingw64 (newer, both 32- and 64-bit support). The name 'mingw32' is misleading, as neither project uses it. Fedora uses mingw64.
RHEL-6 has packages named mingw32-* (from "rhel-6-workstation-optional-rpms" -- on my laptop anyway).
I believe saying just "mingw" should be fine, as proposed.
Laszlo
Re: [Qemu-devel] [RFC PATCH v3 04/11] qemu-ga: Add an configure option to specify path to Windows VSS SDK
In reply to Tomoki Sekiyamaconfigure if test "$usb_redir" != "no" ; then · line 3139
Quoted 8 lines · Tomoki Sekiyama
configure +8
-0+ if test "$vss_win32_sdk" != "" ; then + echo "ERROR: Please download and install Microsoft VSS SDK:" + echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490" + echo "ERROR: On POSIX-systems, you can extract the SDK headers by:" + echo "ERROR: scripts/extract-vsssdk-headers setup.exe" + echo "ERROR: The headers are extracted in the directory \`inc'." + feature_not_found "VSS support" + fi
Please consider adding >&2 after the "fi".
(... although even feature_not_found() --> error_exit() misses that redirection (and the behavior would change with my suggestion), so maybe it's more consistent the way you submitted it.)
Laszlo
RFC PATCH v3 5/11 qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze
In reply to Tomoki SekiyamaImplements a basic stub of software VSS provider. Currently, this modules only provides a relay function of events between qemu-guest-agent and Windows VSS when VSS finished filesystem freeze and when qemu snapshot is done.
In the future, this module could be extended to support the other VSS functions, such as query for snapshot volumes and recovery.
--- Makefile.objs | 2 configure | 5 qga/Makefile.objs | 6 qga/vss-win32-provider.h | 26 ++ qga/vss-win32-provider/Makefile.objs | 21 + qga/vss-win32-provider/install.cpp | 494 +++++++++++++++++++++++++++++++ qga/vss-win32-provider/provider.cpp | 474 ++++++++++++++++++++++++++++++ qga/vss-win32-provider/qga-provider.def | 10 + qga/vss-win32-provider/qga-provider.idl | 20 + qga/vss-win32.h | 85 +++++ 10 files changed, 1142 insertions(+), 1 deletion(-) create mode 100644 qga/vss-win32-provider.h create mode 100644 qga/vss-win32-provider/Makefile.objs create mode 100644 qga/vss-win32-provider/install.cpp create mode 100644 qga/vss-win32-provider/provider.cpp create mode 100644 qga/vss-win32-provider/qga-provider.def create mode 100644 qga/vss-win32-provider/qga-provider.idl create mode 100644 qga/vss-win32.h
Makefile.objs +2 -0
@@ -102,6 +102,7 @@ common-obj-y += disas/ # 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-prv-obj-y = qga/ vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
@@ -113,6 +114,7 @@ nested-vars += \ stub-obj-y \ util-obj-y \ qga-obj-y \ + qga-prv-obj-y \ block-obj-y \ common-obj-y dummy := $(call unnest-vars)
configure +4 -1
@@ -3503,9 +3503,12 @@ if test "$softmmu" = yes ; then virtfs=no fi fi - if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then + if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then if [ "$guest_agent" = "yes" ]; then tools="qemu-ga\$(EXESUF) $tools" + if [ "$mingw32" = "yes" ]; then + tools="qga/vss-win32-provider/qga-provider.dll qga/vss-win32-provider/qga-provider.tlb $tools" + fi fi fi fi
qga/Makefile.objs +6 -0
@@ -3,3 +3,9 @@ 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 + +ifeq ($(CONFIG_QGA_VSS),y) +QEMU_CFLAGS += -DHAS_VSS_SDK +qga-obj-y += vss-win32-provider/ +qga-prv-obj-y += vss-win32-provider/ +endif
qga/vss-win32-provider.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* QEMU Guest Agent win32 VSS provider declarations +* +* Copyright Hitachi Data Systems Corp. 2013 +* +* Authors: +* Tomoki Sekiyama <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef VSS_WIN32_PROVIDER_H +#define VSS_WIN32_PROVIDER_H + +#include <windows.h> + +STDAPI VSSCheckOSVersion (void ); + +STDAPI COMRegister (void ); +STDAPI COMUnregister (void ); + +STDAPI DllRegisterServer (void ); +STDAPI DllUnregisterServer (void ); + +#endif
qga/vss-win32-provider/Makefile.objs new file +21 -0
@@ -0,0 +1,21 @@ +# rules to build qga-provider.dll + +qga-obj-y += qga-provider.dll +qga-prv-obj-y += provider.o install.o + +obj-qga-prv-obj-y = $(addprefix $(obj)/, $(qga-prv-obj-y)) +$(obj-qga-prv-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-provider.dll: LDFLAGS = -shared -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32 -lshlwapi -luuid -static +$(obj)/qga-provider.dll: $(obj-qga-prv-obj-y) $(SRC_PATH)/$(obj)/qga-provider.def $(obj)/qga-provider.tlb + $(call quiet-command,$(CXX) -o $@ $(qga-prv-obj-y) $(SRC_PATH)/qga/vss-win32-provider/qga-provider.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 (included in VC++). +MIDL=midl +WINSDK="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Include" + +$(obj)/qga-provider.tlb: $(SRC_PATH)/$(obj)/qga-provider.idl + $(call quiet-command,$(MIDL) -m64 -o $@ -I $(WINSDK) $<," MIDL $(TARGET_DIR)$@")
qga/vss-win32-provider/install.cpp new file +494 -0
494 lines not on this page · raw message
qga/vss-win32-provider/provider.cpp new file +474 -0
474 lines not on this page · raw message
qga/vss-win32-provider/qga-provider.def new file +10 -0
@@ -0,0 +1,10 @@ +LIBRARY "QGA-PROVIDER.DLL" + +EXPORTS + VSSCheckOSVersion PRIVATE + COMRegister PRIVATE + COMUnregister PRIVATE + DllCanUnloadNow PRIVATE + DllGetClassObject PRIVATE + DllRegisterServer PRIVATE + DllUnregisterServer PRIVATE
qga/vss-win32-provider/qga-provider.idl new file +20 -0
@@ -0,0 +1,20 @@ +import "oaidl.idl"; +import "ocidl.idl"; + +[ + uuid(103B8142-6CE5-48A7-BDE1-794D3192FCF1), + version(1.0), + helpstring("QGAVSSProvider Type Library") +] +library QGAVSSHWProviderLib +{ + importlib("stdole2.tlb"); + [ + uuid(6E6A3492-8D4D-440C-9619-5E5D0CC31CA8), + helpstring("QGAVSSProvider Class") + ] + coclass QGAVSSHWProvider + { + [default] interface IUnknown; + }; +};
qga/vss-win32.h new file +85 -0
85 lines not on this page · raw message
Re: [Qemu-devel] [RFC PATCH v3 05/11] qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze
Quoted 20 lines · Tomoki Sekiyama
Implements a basic stub of software VSS provider. Currently, this modules only provides a relay function of events between qemu-guest-agent and Windows VSS when VSS finished filesystem freeze and when qemu snapshot is done.
In the future, this module could be extended to support the other VSS functions, such as query for snapshot volumes and recovery.
Signed-off-by Tomoki Sekiyama <[email protected]>--- Makefile.objs | 2 configure | 5 qga/Makefile.objs | 6 qga/vss-win32-provider.h | 26 ++ qga/vss-win32-provider/Makefile.objs | 21 + qga/vss-win32-provider/install.cpp | 494 +++++++++++++++++++++++++++++++ qga/vss-win32-provider/provider.cpp | 474 ++++++++++++++++++++++++++++++ qga/vss-win32-provider/qga-provider.def | 10 + qga/vss-win32-provider/qga-provider.idl | 20 + qga/vss-win32.h | 85 +++++
Quoted 8 lines
10 files changed, 1142 insertions(+), 1 deletion(-) create mode 100644 qga/vss-win32-provider.h create mode 100644 qga/vss-win32-provider/Makefile.objs create mode 100644 qga/vss-win32-provider/install.cpp create mode 100644 qga/vss-win32-provider/provider.cpp create mode 100644 qga/vss-win32-provider/qga-provider.def create mode 100644 qga/vss-win32-provider/qga-provider.idl create mode 100644 qga/vss-win32.h
Please run scripts/checkpatch.pl and use QEMU coding style (see ./CODING_STYLE and ./HACKING).
Quoted 14 lines
qga/vss-win32-provider/Makefile.objs new file +8
-0@@ -0,0 +1,21 @@ +# rules to build qga-provider.dll + +qga-obj-y += qga-provider.dll +qga-prv-obj-y += provider.o install.o + +obj-qga-prv-obj-y = $(addprefix $(obj)/, $(qga-prv-obj-y)) +$(obj-qga-prv-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 +
qga/vss-win32-provider/Makefile.objs line 18
Quoted 10 lines
qga/vss-win32-provider/Makefile.objs new file +10
-0+$(obj)/qga-provider.dll: LDFLAGS = -shared -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32 -lshlwapi -luuid -static +$(obj)/qga-provider.dll: $(obj-qga-prv-obj-y) $(SRC_PATH)/$(obj)/qga-provider.def $(obj)/qga-provider.tlb + $(call quiet-command,$(CXX) -o $@ $(qga-prv-obj-y) $(SRC_PATH)/qga/vss-win32-provider/qga-provider.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 (included in VC++). +MIDL=midl +WINSDK="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Include"
This needs to be a ./configure option.
Quoted 29 lines
qga/vss-win32.h new file +23
-0@@ -0,0 +1,85 @@ +/* +* QEMU Guest Agent win32 VSS common declarations +* +* Copyright Hitachi Data Systems Corp. 2013 +* +* Authors: +* Tomoki Sekiyama <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef VSS_WIN32_H +#define VSS_WIN32_H + +#define __MIDL_user_allocate_free_DEFINED__ +#include "config-host.h" +#include <windows.h> +#include <shlwapi.h> + +/* Reduce warnings to include vss.h */ +#define __in IN +#define __out OUT
qga/vss-win32.h line 33
Quoted 10 lines
qga/vss-win32.h new file +10
-0+#define __RPC_unique_pointer +#define __RPC_string +#define __RPC__deref_inout_opt +#define __RPC__out +#ifndef __RPC__out_ecount_part +#define __RPC__out_ecount_part (x, y) +#endif +#define _declspec (x) +#undef uuid +#define uuid (x)
This looks hacky. Why are you stubbing out macros that vss.h uses?
Re: [Qemu-devel] [RFC PATCH v3 05/11] qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze
Quoted 33 lines · Stefan Hajnoczi
Quoted 23 lines · Tomoki Sekiyama
Implements a basic stub of software VSS provider. Currently, this modules
only provides a relay function of events between qemu-guest-agent and Windows VSS when VSS finished filesystem freeze and when qemu snapshot is done.In the future, this module could be extended to support the other VSS functions, such as query for snapshot volumes and recovery.
Signed-off-by Tomoki Sekiyama <[email protected]>--- Makefile.objs | 2 configure | 5 qga/Makefile.objs | 6 qga/vss-win32-provider.h | 26 ++ qga/vss-win32-provider/Makefile.objs | 21 + qga/vss-win32-provider/install.cpp | 494 +++++++++++++++++++++++++++++++ qga/vss-win32-provider/provider.cpp | 474 ++++++++++++++++++++++++++++++ qga/vss-win32-provider/qga-provider.def | 10 + qga/vss-win32-provider/qga-provider.idl | 20 + qga/vss-win32.h | 85 +++++Quoted 8 lines
10 files changed, 1142 insertions(+), 1 deletion(-) create mode 100644 qga/vss-win32-provider.h create mode 100644 qga/vss-win32-provider/Makefile.objs create mode 100644 qga/vss-win32-provider/install.cpp create mode 100644 qga/vss-win32-provider/provider.cpp create mode 100644 qga/vss-win32-provider/qga-provider.def create mode 100644 qga/vss-win32-provider/qga-provider.idl create mode 100644 qga/vss-win32.h
Quoted 2 lines
Please run
scripts/checkpatch.pland use QEMU coding style (see ./CODING_STYLE and ./HACKING).
Ah, actually this passes checkpatch.pl, but I notice that checkpatch.pl skips some checks for .cpp files ... I will enable them for .cpp files and fix some style errors.
Quoted 28 lines
Quoted 28 lines
qga/vss-win32-provider/Makefile.objs new file +7
-2@@ -0,0 +1,21 @@ +# rules to build qga-provider.dll + +qga-obj-y += qga-provider.dll +qga-prv-obj-y += provider.o install.o + +obj-qga-prv-obj-y = $(addprefix $(obj)/, $(qga-prv-obj-y)) +$(obj-qga-prv-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
qga/vss-win32-provider/Makefile.objs new file +3
-2+ +$(obj)/qga-provider.dll: LDFLAGS = -shared -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32 -lshlwapi -luuid -static +$(obj)/qga-provider.dll: $(obj-qga-prv-obj-y)$(SRC_PATH)/$(obj)/qga-provider.def $(obj)/qga-provider.tlb
qga/vss-win32-provider/Makefile.objs new file +1
-0+ $(call quiet-command,$(CXX) -o $@ $(qga-prv-obj-y)$(SRC_PATH)/qga/vss-win32-provider/qga-provider.def $(CXXFLAGS) $(LDFLAGS)," LINK $(TARGET_DIR)$@")
qga/vss-win32-provider/Makefile.objs new file +2
-0+ +
Quoted 8 lines
qga/vss-win32-provider/Makefile.objs line 18
Quoted 6 lines
qga/vss-win32-provider/Makefile.objs new file +3
-0+# rules to build qga-provider.tlb +# Currently, only native build is supported because building .tlb +# (TypeLibrary) from .idl requires WindowsSDK and MIDL (included inVC++).
qga/vss-win32-provider/Makefile.objs new file +2
-0+MIDL=midl +WINSDK="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Include"This needs to be a ./configure option.
OK. I will add something like --with-winsdk="\\path\to\windows\sdk" to configure this.
Quoted 34 lines
Quoted 34 lines
qga/vss-win32.h new file +9
-0@@ -0,0 +1,85 @@ +/* +* QEMU Guest Agent win32 VSS common declarations +* +* Copyright Hitachi Data Systems Corp. 2013 +* +* Authors: +* Tomoki Sekiyama <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */qga/vss-win32.h new file +16
-0+ +#ifndef VSS_WIN32_H +#define VSS_WIN32_H + +#define __MIDL_user_allocate_free_DEFINED__ +#include "config-host.h" +#include <windows.h> +#include <shlwapi.h> + +/* Reduce warnings to include vss.h */ +#define __in IN +#define __out OUT +#define __RPC_unique_pointer +#define __RPC_string +#define __RPC__deref_inout_opt +#define __RPC__out
Quoted 8 lines
qga/vss-win32.h line 33
Quoted 6 lines
qga/vss-win32.h new file +6
-0+#ifndef __RPC__out_ecount_part +#define __RPC__out_ecount_part (x, y) +#endif +#define _declspec (x) +#undef uuid +#define uuid (x)This looks hacky. Why are you stubbing out macros that
vss.huses?
Because these macros are internally defined/used by windows SDK's headers and not fully covered by mingw (some of them is only meaningful with Microsoft IDE), so it don't compile without these define's.
This could be better if mingw supports these VSS headers, but I have no idea how to achieve that...
Thanks,
Tomoki Sekiyama
Re: [Qemu-devel] [RFC PATCH v3 05/11] qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze
Quoted 46 lines · Tomoki Sekiyama
Quoted 35 lines · Stefan Hajnoczi
Quoted 34 lines · Tomoki Sekiyama
qga/vss-win32.h new file +9
-0@@ -0,0 +1,85 @@ +/* +* QEMU Guest Agent win32 VSS common declarations +* +* Copyright Hitachi Data Systems Corp. 2013 +* +* Authors: +* Tomoki Sekiyama <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */qga/vss-win32.h new file +16
-0+ +#ifndef VSS_WIN32_H +#define VSS_WIN32_H + +#define __MIDL_user_allocate_free_DEFINED__ +#include "config-host.h" +#include <windows.h> +#include <shlwapi.h> + +/* Reduce warnings to include vss.h */ +#define __in IN +#define __out OUT +#define __RPC_unique_pointer +#define __RPC_string +#define __RPC__deref_inout_opt +#define __RPC__outQuoted 8 lines
qga/vss-win32.h line 33
Quoted 6 lines
qga/vss-win32.h new file +6
-0+#ifndef __RPC__out_ecount_part +#define __RPC__out_ecount_part (x, y) +#endif +#define _declspec (x) +#undef uuid +#define uuid (x)This looks hacky. Why are you stubbing out macros that
vss.huses?
Quoted 7 lines
Because these macros are internally defined/used by windows SDK's headers and not fully covered by mingw (some of them is only meaningful with Microsoft IDE), so it don't compile without these define's.
This could be better if mingw supports these VSS headers, but I have no idea how to achieve that...
Please add a comment explaining this.
BTW, did you look at the macro definitions to see if they define anything important? In other words, is there a difference when compiled using Visual C++ where the macros actually have meaning?
Stefan
Re: [Qemu-devel] [RFC PATCH v3 05/11] qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze
Quoted 53 lines · Stefan Hajnoczi
Quoted 52 lines · Tomoki Sekiyama
Quoted 16 lines · Stefan Hajnoczi
Quoted 6 lines · Tomoki Sekiyama
qga/vss-win32.h new file +0
-0qga/vss-win32.h line 9
Quoted 9 lines
qga/vss-win32.h new file +9
-0@@ -0,0 +1,85 @@ +/* +* QEMU Guest Agent win32 VSS common declarations +* +* Copyright Hitachi Data Systems Corp. 2013 +* +* Authors: +* Tomoki Sekiyama <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or
Quoted 19 lines
Quoted 19 lines
later.
+ * See the COPYING file in the top-level directory.
+ */qga/vss-win32.h new file +16
-0+ +#ifndef VSS_WIN32_H +#define VSS_WIN32_H + +#define __MIDL_user_allocate_free_DEFINED__ +#include "config-host.h" +#include <windows.h> +#include <shlwapi.h> + +/* Reduce warnings to include vss.h */ +#define __in IN +#define __out OUT +#define __RPC_unique_pointer +#define __RPC_string +#define __RPC__deref_inout_opt +#define __RPC__outQuoted 8 lines
qga/vss-win32.h line 33
Quoted 6 lines
qga/vss-win32.h new file +6
-0+#ifndef __RPC__out_ecount_part +#define __RPC__out_ecount_part (x, y) +#endif +#define _declspec (x) +#undef uuid +#define uuid (x)This looks hacky. Why are you stubbing out macros that
vss.huses?Because these macros are internally defined/used by windows SDK's headers and not fully covered by mingw (some of them is only meaningful with Microsoft IDE), so it don't compile without these define's.
Quoted 4 lines
Quoted 2 lines
This could be better if mingw supports these VSS headers, but I have no idea how to achieve that...
Please add a comment explaining this.
OK.
Quoted 5 lines
BTW, did you look at the macro definitions to see if they define anything important? In other words, is there a difference when compiled using Visual C++ where the macros actually have meaning?
Stefan
They are just annotating for compiler to warn things like "this shouldn't be NULL', or to give a hint to code generators.
I believe they don't affect compiled executable binaries.
Thanks,
Tomoki Sekiyama
Re: [Qemu-devel] [RFC PATCH v3 05/11] qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze
In reply to Tomoki SekiyamaQuoted 79 lines · Tomoki Sekiyama
Quoted 33 lines · Stefan Hajnoczi
Quoted 23 lines · Tomoki Sekiyama
Implements a basic stub of software VSS provider. Currently, this modules
only provides a relay function of events between qemu-guest-agent and Windows VSS when VSS finished filesystem freeze and when qemu snapshot is done.In the future, this module could be extended to support the other VSS functions, such as query for snapshot volumes and recovery.
Signed-off-by Tomoki Sekiyama <[email protected]>--- Makefile.objs | 2 configure | 5 qga/Makefile.objs | 6 qga/vss-win32-provider.h | 26 ++ qga/vss-win32-provider/Makefile.objs | 21 + qga/vss-win32-provider/install.cpp | 494 +++++++++++++++++++++++++++++++ qga/vss-win32-provider/provider.cpp | 474 ++++++++++++++++++++++++++++++ qga/vss-win32-provider/qga-provider.def | 10 + qga/vss-win32-provider/qga-provider.idl | 20 + qga/vss-win32.h | 85 +++++Quoted 8 lines
10 files changed, 1142 insertions(+), 1 deletion(-) create mode 100644 qga/vss-win32-provider.h create mode 100644 qga/vss-win32-provider/Makefile.objs create mode 100644 qga/vss-win32-provider/install.cpp create mode 100644 qga/vss-win32-provider/provider.cpp create mode 100644 qga/vss-win32-provider/qga-provider.def create mode 100644 qga/vss-win32-provider/qga-provider.idl create mode 100644 qga/vss-win32.hQuoted 2 lines
Please run
scripts/checkpatch.pland use QEMU coding style (see ./CODING_STYLE and ./HACKING).Ah, actually this passes checkpatch.pl, but I notice that checkpatch.pl skips some checks for .cpp files ... I will enable them for .cpp files and fix some style errors.
Quoted 28 lines
Quoted 28 lines
qga/vss-win32-provider/Makefile.objs new file +7
-2@@ -0,0 +1,21 @@ +# rules to build qga-provider.dll + +qga-obj-y += qga-provider.dll +qga-prv-obj-y += provider.o install.o + +obj-qga-prv-obj-y = $(addprefix $(obj)/, $(qga-prv-obj-y)) +$(obj-qga-prv-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
qga/vss-win32-provider/Makefile.objs new file +3
-2+ +$(obj)/qga-provider.dll: LDFLAGS = -shared -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32 -lshlwapi -luuid -static +$(obj)/qga-provider.dll: $(obj-qga-prv-obj-y)$(SRC_PATH)/$(obj)/qga-provider.def $(obj)/qga-provider.tlb
qga/vss-win32-provider/Makefile.objs new file +1
-0+ $(call quiet-command,$(CXX) -o $@ $(qga-prv-obj-y)$(SRC_PATH)/qga/vss-win32-provider/qga-provider.def $(CXXFLAGS) $(LDFLAGS)," LINK $(TARGET_DIR)$@")
qga/vss-win32-provider/Makefile.objs new file +2
-0+ +Quoted 8 lines
qga/vss-win32-provider/Makefile.objs line 18
Quoted 6 lines
qga/vss-win32-provider/Makefile.objs new file +3
-0+# rules to build qga-provider.tlb +# Currently, only native build is supported because building .tlb +# (TypeLibrary) from .idl requires WindowsSDK and MIDL (included inVC++).
qga/vss-win32-provider/Makefile.objs new file +2
-0+MIDL=midl +WINSDK="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Include"This needs to be a ./configure option.
Quoted 3 lines
OK. I will add something like --with-winsdk="\\path\to\windows\sdk" to configure this.
Patch 9/11 adds a binary tlb in, so that midl is not required. I would like to see patch 09/11 just be squashed into this patch, so the build will always work without requiring midl. Otherwise, from this patch up through patch 9, qemu-ga.exe will fail to build unless you have the Windows SDK installed.
And if that is done, I don't know if this needs a ./configure option or not, because you will only build the .tlb if you explicitly purge the existing binary. Stefan, would you still like to see it in ./configure option, in that case?
Quoted 55 lines
Quoted 34 lines
Quoted 34 lines
qga/vss-win32.h new file +9
-0@@ -0,0 +1,85 @@ +/* +* QEMU Guest Agent win32 VSS common declarations +* +* Copyright Hitachi Data Systems Corp. 2013 +* +* Authors: +* Tomoki Sekiyama <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */qga/vss-win32.h new file +16
-0+ +#ifndef VSS_WIN32_H +#define VSS_WIN32_H + +#define __MIDL_user_allocate_free_DEFINED__ +#include "config-host.h" +#include <windows.h> +#include <shlwapi.h> + +/* Reduce warnings to include vss.h */ +#define __in IN +#define __out OUT +#define __RPC_unique_pointer +#define __RPC_string +#define __RPC__deref_inout_opt +#define __RPC__outQuoted 8 lines
qga/vss-win32.h line 33
Quoted 6 lines
qga/vss-win32.h new file +6
-0+#ifndef __RPC__out_ecount_part +#define __RPC__out_ecount_part (x, y) +#endif +#define _declspec (x) +#undef uuid +#define uuid (x)This looks hacky. Why are you stubbing out macros that
vss.huses?Because these macros are internally defined/used by windows SDK's headers and not fully covered by mingw (some of them is only meaningful with Microsoft IDE), so it don't compile without these define's.
This could be better if mingw supports these VSS headers, but I have no idea how to achieve that...
Thanks,
Tomoki Sekiyama
Re: [Qemu-devel] [RFC PATCH v3 05/11] qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze
Quoted 45 lines · Jeff Cody
Quoted 40 lines · Tomoki Sekiyama
Quoted 29 lines · Stefan Hajnoczi
Quoted 28 lines · Tomoki Sekiyama
qga/vss-win32-provider/Makefile.objs new file +7
-2@@ -0,0 +1,21 @@ +# rules to build qga-provider.dll + +qga-obj-y += qga-provider.dll +qga-prv-obj-y += provider.o install.o + +obj-qga-prv-obj-y = $(addprefix $(obj)/, $(qga-prv-obj-y)) +$(obj-qga-prv-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
qga/vss-win32-provider/Makefile.objs new file +3
-2+ +$(obj)/qga-provider.dll: LDFLAGS = -shared -Wl,--add-stdcall-alias,--enable-stdcall-fixup -lole32 -loleaut32 -lshlwapi -luuid -static +$(obj)/qga-provider.dll: $(obj-qga-prv-obj-y)$(SRC_PATH)/$(obj)/qga-provider.def $(obj)/qga-provider.tlb
qga/vss-win32-provider/Makefile.objs new file +1
-0+ $(call quiet-command,$(CXX) -o $@ $(qga-prv-obj-y)$(SRC_PATH)/qga/vss-win32-provider/qga-provider.def $(CXXFLAGS) $(LDFLAGS)," LINK $(TARGET_DIR)$@")
qga/vss-win32-provider/Makefile.objs new file +2
-0+ +Quoted 8 lines
qga/vss-win32-provider/Makefile.objs line 18
Quoted 6 lines
qga/vss-win32-provider/Makefile.objs new file +3
-0+# rules to build qga-provider.tlb +# Currently, only native build is supported because building .tlb +# (TypeLibrary) from .idl requires WindowsSDK and MIDL (included inVC++).
qga/vss-win32-provider/Makefile.objs new file +2
-0+MIDL=midl +WINSDK="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Include"This needs to be a ./configure option.
Quoted 3 lines
OK. I will add something like --with-winsdk="\\path\to\windows\sdk" to configure this.
Quoted 5 lines
Patch 9/11 adds a binary tlb in, so that midl is not required. I would like to see patch 09/11 just be squashed into this patch, so the build will always work without requiring midl. Otherwise, from this patch up through patch 9, qemu-ga.exe will fail to build unless you have the Windows SDK installed.
Good idea.
Quoted 4 lines
And if that is done, I don't know if this needs a ./configure option or not, because you will only build the .tlb if you explicitly purge the existing binary. Stefan, would you still like to see it in ./configure option, in that case?
It still feels weird to hardcode an install path to a specific version of the Windows SDK. Please make it a configure option - that way it can be automated in a clean way by anyone who builds the tlb from source (downstream).
Stefan
Re: [Qemu-devel] [RFC PATCH v3 05/11] qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze
Quoted 4 lines · Jeff Cody
Quoted 3 lines · Tomoki Sekiyama
Quoted 2 lines · Stefan Hajnoczi
Quoted 1 line · Tomoki Sekiyama
<snip>
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
qga/vss-win32-provider/Makefile.objs line 18
Quoted 6 lines
qga/vss-win32-provider/Makefile.objs new file +3
-0+# rules to build qga-provider.tlb +# Currently, only native build is supported because building .tlb +# (TypeLibrary) from .idl requires WindowsSDK and MIDL (included inVC++).
qga/vss-win32-provider/Makefile.objs new file +2
-0+MIDL=midl +WINSDK="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Include"This needs to be a ./configure option.
OK. I will add something like --with-winsdk="\\path\to\windows\sdk" to configure this.
Quoted 7 lines
Quoted 5 lines
Patch 9/11 adds a binary tlb in, so that midl is not required. I would like to see patch 09/11 just be squashed into this patch, so the build will always work without requiring midl. Otherwise, from this patch up through patch 9, qemu-ga.exe will fail to build unless you have the Windows SDK installed.
Good idea.
That's true. I will squash 09/11 into 05/11.
Quoted 9 lines
Quoted 4 lines
And if that is done, I don't know if this needs a ./configure option or not, because you will only build the .tlb if you explicitly purge the existing binary. Stefan, would you still like to see it in ./configure option, in that case?
It still feels weird to hardcode an install path to a specific version of the Windows SDK. Please make it a configure option - that way it can be automated in a clean way by anyone who builds the tlb from source (downstream).
I understood your concern, I'll move this into configure, and make it search the newest version of SDK installed (only if it is in the default path (%PROGRAMFILES%\Microsoft SDKs\Windows\v*)).
Thanks,
Tomoki Sekiyama
RFC PATCH v3 6/11 qemu-ga: Add Windows VSS requester to quisce applications and filesystems
In reply to Tomoki SekiyamaAdd VSS requester functions for to qemu-ga.
This provides facility to request VSS service in Windows guest to quisce applications and filesystems. This function is only supported in Windows 2003 or later. In older guests, this function does nothing.
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 (a cleanup phase after snapshot is taken).
--- qga/Makefile.objs | 3 qga/vss-win32-requester.cpp | 404 +++++++++++++++++++++++++++++++++++++++++++ qga/vss-win32-requester.h | 31 +++ 3 files changed, 437 insertions(+), 1 deletion(-) create mode 100644 qga/vss-win32-requester.cpp create mode 100644 qga/vss-win32-requester.h
qga/Makefile.objs +2 -1
@@ -6,6 +6,7 @@ qga-obj-y += qapi-generated/qga-qmp-marshal.o ifeq ($(CONFIG_QGA_VSS),y) QEMU_CFLAGS += -DHAS_VSS_SDK -qga-obj-y += vss-win32-provider/ +qga-obj-y += vss-win32-provider/ vss-win32-requester.o qga-prv-obj-y += vss-win32-provider/ +$(obj)/vss-win32-requester.o: QEMU_CXXFLAGS += -Wno-unknown-pragmas endif
qga/vss-win32-requester.cpp new file +404 -0
404 lines not on this page · raw message
qga/vss-win32-requester.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* QEMU Guest Agent VSS Requester declarations +* +* Copyright Hitachi Data Systems Corp. 2013 +* +* Authors: +* Tomoki Sekiyama <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef VSS_WIN32_REQUESTER_H +#define VSS_WIN32_REQUESTER_H + +#ifdef __cplusplus +extern "C" { +#endif + +HRESULT vss_init (void ); +void vss_deinit (void ); +int vss_initialized (void ); + +void qga_vss_fsfreeze_freeze (int *nr_volume,struct Error **err); +void qga_vss_fsfreeze_thaw (int *nr_volume,struct Error **err); + +#ifdef __cplusplus +} +#endif + +#endif
Re: [Qemu-devel] [RFC PATCH v3 06/11] qemu-ga: Add Windows VSS requester to quisce applications and filesystems
Quoted 2 lines · Tomoki Sekiyama
Add VSS requester functions for to qemu-ga.
This provides facility to request VSS service in Windows guest to quisce
s/quisce/quiesce/
Quoted 9 lines
applications and filesystems. This function is only supported in Windows 2003 or later. In older guests, this function does nothing.
In several versions of Windows which don't support attribute
VSS_VOLSNAP_ATTR_NO_AUTORECOVERY, DoSnapshotSet fails with errorVSS_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 (a cleanup phase after snapshot is taken).
I take it that such a framework may involve additional guest-agent commands and management work (such as libvirt having to be aware of the added framework). How important is this functionality? How frequently does VSS even get us into that state? That is, are Windows guests going to frequently hit our current first-round implementation limits that fail to let them do auto-recovery?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [RFC PATCH v3 06/11] qemu-ga: Add Windows VSS requester to quisce applications and filesystems
Quoted 5 lines · Eric Blake
Quoted 2 lines · Tomoki Sekiyama
Add VSS requester functions for to qemu-ga.
This provides facility to request VSS service in Windows guest to quisces/quisce/quiesce/
Oops, thanks again.
Quoted 11 lines
Quoted 10 lines
applications and filesystems. This function is only supported in Windows 2003 or later. In older guests, this function does nothing.
In several versions of Windows which don't support attribute
VSS_VOLSNAP_ATTR_NO_AUTORECOVERY, DoSnapshotSet fails with errorVSS_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 (a cleanup phase after snapshot is taken).
Quoted 6 lines
I take it that such a framework may involve additional guest-agent commands and management work (such as libvirt having to be aware of the added framework). How important is this functionality? How frequently does VSS even get us into that state? That is, are Windows guests going to frequently hit our current first-round implementation limits that fail to let them do auto-recovery?
"Auto-recovery" is invoked every time after snapshots are taken by VSS (the name is misleading, but it is normal path...) to make the snapshot completely consistent state by rolling back incomplete transactions. VSS requesters can explicitly disable this, but this may remain some incomplete data in the snapshot when some applications which relying on this feature are running. However, I believe they can usually be recovered *after the snapshot is rolled back*.
Full-support of VSS including auto-recovery may require the other channel between libvirt and guest-agent to conduct snapshot operation from guests. I think such interface can also enable various VSS feature such as partial- recovery from snapshots. It would be nice to have in the future version, but is overkill just to enable fsfreeze command so far....
Thanks,
Tomoki Sekiyama
Re: [Qemu-devel] [RFC PATCH v3 06/11] qemu-ga: Add Windows VSS requester to quisce applications and filesystems
In reply to Tomoki SekiyamaQuoted 404 lines · Tomoki Sekiyama
Add VSS requester functions for to qemu-ga.
This provides facility to request VSS service in Windows guest to quisce applications and filesystems. This function is only supported in Windows 2003 or later. In older guests, this function does nothing.In several versions of Windows which don't support attribute
VSS_VOLSNAP_ATTR_NO_AUTORECOVERY, DoSnapshotSet fails with errorVSS_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 (a cleanup phase after snapshot is taken).Signed-off-by Tomoki Sekiyama <[email protected]>--- qga/Makefile.objs | 3 qga/vss-win32-requester.cpp | 404 +++++++++++++++++++++++++++++++++++++++++++ qga/vss-win32-requester.h | 31 +++ 3 files changed, 437 insertions(+), 1 deletion(-) create mode 100644 qga/vss-win32-requester.cpp create mode 100644 qga/vss-win32-requester.hqga/Makefile.objs +2
-1@@ -6,6 +6,7 @@ qga-obj-y += qapi-generated/qga-qmp-marshal.o ifeq ($(CONFIG_QGA_VSS),y) QEMU_CFLAGS += -DHAS_VSS_SDK -qga-obj-y += vss-win32-provider/ +qga-obj-y += vss-win32-provider/ vss-win32-requester.o qga-prv-obj-y += vss-win32-provider/ +$(obj)/vss-win32-requester.o: QEMU_CXXFLAGS += -Wno-unknown-pragmas endifqga/vss-win32-requester.cpp new file +364
-0@@ -0,0 +1,404 @@ +/* + * QEMU Guest Agent win32 VSS Requester implementations + * + * Copyright Hitachi Data Systems Corp. 2013 + * + * Authors: + * Tomoki Sekiyama <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include <stdio.h> +#include <assert.h> +extern "C" { +#include "guest-agent-core.h" +} +#include "vss-win32-requester.h" +#include "vss-win32-provider.h" +#include "vss-win32.h" +#include "inc/win2003/vswriter.h" +#include "inc/win2003/vsbackup.h" + +/* Functions in VSSAPI.DLL */ +typedef HRESULT (STDAPICALLTYPE* t_CreateVssBackupComponents)(OUT IVssBackupComponents **); +typedef void (APIENTRY* t_VssFreeSnapshotProperties)(IN VSS_SNAPSHOT_PROP*); + +static t_CreateVssBackupComponents _CreateVssBackupComponents = NULL; +static t_VssFreeSnapshotProperties _VssFreeSnapshotProperties = NULL; +static IVssBackupComponents *pVssbc = NULL; +static IVssAsync *pAsyncSnapshot = NULL; +static HMODULE hLib = NULL; +static HANDLE hEvent = INVALID_HANDLE_VALUE, hEvent2 = INVALID_HANDLE_VALUE; +static int cFrozenVols = 0; + +GCC_FMT_ATTR(1, 2) +static void errmsg(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + char *msg = g_strdup_vprintf(fmt, ap); + va_end(ap); + MessageBox(NULL, msg, "Error in QEMU guest agent", MB_OK | MB_ICONWARNING); + g_free(msg); +} + +static void error_set_win32(Error **errp, DWORD err, + ErrorClass eclass, const char *text) +{ + char *msg = NULL, *nul = strchr(text, '('); + int len = nul ? nul - text : -1; + + /* print error message in native encoding */ + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (char *)&msg, 0, NULL); + printf("%.*s. (Error: %lx) %s\n", len, text, err, msg); + LocalFree(msg); + + /* set error message in UTF-8 encoding */ + msg = g_win32_error_message(err); + error_set(errp, eclass, "%.*s. (Error: %lx) %s", len, text, err, msg); + g_free(msg); +} +#define error_setg_win32(errp, err, text) \ + error_set_win32(errp, err, ERROR_CLASS_GENERIC_ERROR, text) + +#define _chk(status, text, errp, err_label) \ + do { \ + HRESULT __hr = (status); \ + if (FAILED(__hr)) { \ + error_setg_win32(errp, __hr, text); \ + goto err_label; \ + } \ + } while(0) + +#define chk(status) _chk(status, "Failed to " #status, err, out) + + +HRESULT WaitForAsync(IVssAsync *pAsync) +{ + HRESULT ret, hr; + + do { + hr = pAsync->Wait(); + if (FAILED(hr)) { + ret = hr; + break; + } + hr = pAsync->QueryStatus(&ret, NULL); + if (FAILED(hr)) { + ret = hr; + break; + } + } while (ret == VSS_S_ASYNC_PENDING); + + return ret; +} + +HRESULT vss_init(void) +{ + HRESULT hr; + + hr = VSSCheckOSVersion(); + if (hr == S_FALSE) { + return hr; + } + + hr = CoInitialize(NULL); + if (FAILED(hr)) { + errmsg("CoInitialize failed [%lx]", hr); + goto out; + }; + hr = CoInitializeSecurity( + NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, + RPC_C_IMP_LEVEL_IDENTIFY, NULL, EOAC_NONE, NULL); + if (FAILED(hr)) { + errmsg("CoInitializeSecurity failed [%lx]", hr); + goto out; + } + + hLib = LoadLibraryA("VSSAPI.DLL"); + if (!hLib) { + errmsg("LoadLibrary VSSAPI.DLL failed"); + hr = E_FAIL; + goto out; + } + + _CreateVssBackupComponents = (t_CreateVssBackupComponents) + GetProcAddress(hLib, +#ifdef _WIN64 /* 64bit environment */ + "?CreateVssBackupComponents@@YAJPEAPEAVIVssBackupComponents@@@Z" +#else /* 32bit environment */ + "?CreateVssBackupComponents@@YGJPAPAVIVssBackupComponents@@@Z" +#endif + ); + _VssFreeSnapshotProperties = (t_VssFreeSnapshotProperties) + GetProcAddress(hLib, "VssFreeSnapshotProperties"); + if (!_CreateVssBackupComponents || !_VssFreeSnapshotProperties) { + errmsg("GetProcAddress failed"); + hr = E_FAIL; + goto out; + } + + return S_OK; +out: + vss_deinit(); + return hr; +} + +static void vss_cleanup(void) +{ + if (hEvent != INVALID_HANDLE_VALUE) { + CloseHandle(hEvent); + hEvent = INVALID_HANDLE_VALUE; + } + if (hEvent2 != INVALID_HANDLE_VALUE) { + CloseHandle(hEvent2); + hEvent2 = INVALID_HANDLE_VALUE; + } + if (pVssbc) { + pVssbc->Release(); + pVssbc = NULL; + } +} + +void vss_deinit(void) +{ + if (VSSCheckOSVersion() == S_FALSE) { + return; + } + + vss_cleanup(); + + CoUninitialize(); + + _CreateVssBackupComponents = NULL; + _VssFreeSnapshotProperties = NULL; + if (hLib) { + FreeLibrary(hLib); + hLib = NULL; + } +} + +int vss_initialized(void) +{ + return hLib != NULL; +} + +static void vss_add_components(Error **err) +{ + unsigned int cWriters, i; + VSS_ID id, idInstance, idWriter; + BSTR bstrWriterName; + VSS_USAGE_TYPE usage; + VSS_SOURCE_TYPE source; + unsigned int cComponents, c1, c2, j; + IVssExamineWriterMetadata *pMetadata; + IVssWMComponent *pComponent; + PVSSCOMPONENTINFO pInfo = NULL; + + chk( pVssbc->GetWriterMetadataCount(&cWriters) ); + + for (i = 0; i < cWriters; i++) { + chk( pVssbc->GetWriterMetadata(i, &id, &pMetadata) ); + chk( pMetadata->GetIdentity(&idInstance, &idWriter, + &bstrWriterName, &usage, &source) ); + chk( pMetadata->GetFileCounts(&c1, &c2, &cComponents) ); + + for (j = 0; j < cComponents; j++) { + chk( pMetadata->GetComponent(j, &pComponent) ); + chk( pComponent->GetComponentInfo(&pInfo) ); + if (pInfo->bSelectable) { + chk( pVssbc->AddComponent(idInstance, idWriter, pInfo->type, + pInfo->bstrLogicalPath, + pInfo->bstrComponentName) ); + } + pComponent->FreeComponentInfo(pInfo); + pInfo = NULL; + pComponent->Release(); + pComponent = NULL; + } + + pMetadata->Release(); + pMetadata = NULL; + } +out: + if (pComponent) { + if (pInfo) { + pComponent->FreeComponentInfo(pInfo); + } + pComponent->Release(); + } + if (pMetadata) { + pMetadata->Release(); + } +} + +void qga_vss_fsfreeze_freeze(int *num_vols, Error **err) +{ + IVssAsync *pAsync; + HANDLE h; + GUID guidSnapshotSet = GUID_NULL; + SECURITY_DESCRIPTOR sd; + SECURITY_ATTRIBUTES sa; + WCHAR buf[64], *b = buf; + int n = 0; + + if (pVssbc) { /* already frozen */ + *num_vols = 0; + return; + } + + assert(_CreateVssBackupComponents != NULL); + chk( _CreateVssBackupComponents(&pVssbc) ); + chk( pVssbc->InitializeForBackup() ); + chk( pVssbc->SetBackupState(true, true, VSS_BT_FULL, false) ); + /* + * Currently writable snapshots are not supported. + * To prevent the final commit (which requires to write to snapshots), + * VSS_VOLSNAP_ATTR_NO_AUTORECOVERY are specified here. + */ + chk( pVssbc->SetContext(VSS_CTX_APP_ROLLBACK | + VSS_VOLSNAP_ATTR_NO_AUTORECOVERY | + VSS_VOLSNAP_ATTR_TXF_RECOVERY) ); + + chk( pVssbc->GatherWriterMetadata(&pAsync) ); + _chk( WaitForAsync(pAsync), "GatherWriterMetadata", err, out ); + pAsync->Release(); + + vss_add_components(err); + if (error_is_set(err)) { + goto out; + } + + chk( pVssbc->StartSnapshotSet(&guidSnapshotSet) ); + + h = FindFirstVolumeW(buf, sizeof(buf)); + while (h != INVALID_HANDLE_VALUE) { + if (GetDriveTypeW(buf) == DRIVE_FIXED) { + VSS_ID pid; + HRESULT hr = pVssbc->AddToSnapshotSet(buf, g_gProviderId, &pid); + if (FAILED(hr)) { + WCHAR name[PATH_MAX]; + char msg[PATH_MAX+32]; + if (GetVolumePathNamesForVolumeNameW( + buf, name, sizeof(name), NULL) && *name) { + b = name; + } + snprintf(msg, sizeof(msg), "add %S to snapshot set", b); + error_setg_win32(err, hr, msg); + goto out; + } + n++; + } + if (!FindNextVolumeW(h, buf, sizeof(buf))) { + FindVolumeClose(h); + break; + } + } + + chk( pVssbc->PrepareForBackup(&pAsync) ); + _chk( WaitForAsync(pAsync), "PrepareForBackup", err, out ); + pAsync->Release(); + + chk( pVssbc->GatherWriterStatus(&pAsync) ); + _chk( WaitForAsync(pAsync), "GatherWriterStatus", err, out ); + pAsync->Release(); + + /* Allow unrestricted access to events */ + InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION); + SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE); + sa.nLength = sizeof(sa); + sa.lpSecurityDescriptor = &sd; + sa.bInheritHandle = FALSE; + + hEvent = CreateEvent(&sa, TRUE, FALSE, EVENT_NAME_FROZEN); + if (hEvent == INVALID_HANDLE_VALUE) { + error_setg_win32(err, GetLastError(), "CreateEvenet"); + goto out; + } + hEvent2 = CreateEvent(&sa, TRUE, FALSE, EVENT_NAME_THAW); + if (hEvent2 == INVALID_HANDLE_VALUE) { + error_setg_win32(err, GetLastError(), "CreateEvenet"); + goto out; + } + + chk( pVssbc->DoSnapshotSet(&pAsyncSnapshot) ); + + /* Need to call QueryStatus several times to make VSS provider progress */ + for (int i = 0; i < 1000; i++) { + HRESULT hr = S_OK; + chk( pAsyncSnapshot->QueryStatus(&hr, NULL) ); + if (hr != VSS_S_ASYNC_PENDING) { + error_setg(err, "DoSnapshotSet exited without freeze event"); + goto out; + } + DWORD ret = WaitForSingleObject(hEvent, 10); + if (ret == WAIT_OBJECT_0) { + break; + } + } + + *num_vols = cFrozenVols = n; + return; + +out: + if (pVssbc) { + pVssbc->AbortBackup(); + } + vss_cleanup(); +} + + +void qga_vss_fsfreeze_thaw(int *num_vols, Error **err) +{ + IVssAsync *pAsync; + + if (hEvent2 == INVALID_HANDLE_VALUE) { + /* + * In this case, DoSnapshotSet is aborted or not started, + * and no volumes must be frozen. We return without an error. + */
qga/vss-win32-requester.cpp line 374
Quoted 10 lines
qga/vss-win32-requester.cpp new file +10
-0+ *num_vols = 0; + return; + } + SetEvent(hEvent2); + + assert(pVssbc); + assert(pAsyncSnapshot); + + HRESULT hr = WaitForAsync(pAsyncSnapshot); + if (hr == VSS_E_OBJECT_NOT_FOUND) {
When I tried compiling, I received a warning that this is a signed / unsigned comparison. I think, from the VSS_E_OBJECT_NOT_FOUND definition found in inc/win2003/vss.h, that it is intended to be negative (it is a 32-bit int that leads with 0x800). However, it is interpreted as unsigned and throws the warning.
Does that sound correct?
Quoted 69 lines
qga/vss-win32-requester.cpp new file +30
-0+ /* + * On Windows earlier than 2008 SP2 which does not support + * VSS_VOLSNAP_ATTR_NO_AUTORECOVERY context, the final commit is not + * skipped and VSS is aborted by VSS_E_OBJECT_NOT_FOUND. Still, as the + * applications and file systems are frozen, we just ignore the error. + */ + pAsyncSnapshot->Release(); + pAsyncSnapshot = NULL; + goto final; + } + _chk( hr, "DoSnapshotSet", err, out ); + pAsyncSnapshot->Release(); + pAsyncSnapshot = NULL; + + chk( pVssbc->BackupComplete(&pAsync) ); + _chk( WaitForAsync(pAsync), "BackupComplete", err, out ); + pAsync->Release(); + +final: + *num_vols = cFrozenVols; + cFrozenVols = 0; + goto done; + +out: + if (pVssbc) { + pVssbc->AbortBackup(); + } +done: + vss_cleanup(); +}qga/vss-win32-requester.h new file +31
-0@@ -0,0 +1,31 @@ +/* +* QEMU Guest Agent VSS Requester declarations +* +* Copyright Hitachi Data Systems Corp. 2013 +* +* Authors: +* Tomoki Sekiyama <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef VSS_WIN32_REQUESTER_H +#define VSS_WIN32_REQUESTER_H + +#ifdef __cplusplus +extern "C" { +#endif + +HRESULT vss_init (void ); +void vss_deinit (void ); +int vss_initialized (void ); + +void qga_vss_fsfreeze_freeze (int *nr_volume,struct Error **err); +void qga_vss_fsfreeze_thaw (int *nr_volume,struct Error **err); + +#ifdef __cplusplus +} +#endif + +#endif
Re: [Qemu-devel] [RFC PATCH v3 06/11] qemu-ga: Add Windows VSS requester to quisce applications and filesystems
Quoted 11 lines · Jeff Cody
qga/vss-win32-requester.cpp line 374
Quoted 2 lines · Tomoki Sekiyama
qga/vss-win32-requester.cpp new file +2
-0+ HRESULT hr = WaitForAsync(pAsyncSnapshot); + if (hr == VSS_E_OBJECT_NOT_FOUND) {When I tried compiling, I received a warning that this is a signed / unsigned comparison. I think, from the
VSS_E_OBJECT_NOT_FOUNDdefinition found ininc/win2003/vss.h, that it is intended to be negative (it is a 32-bit int that leads with0x800). However, it is interpreted as unsigned and throws the warning.
Does that sound correct?
0x80042308 or 0x80042308L looks interpreted as unsigned 32-bit int in mingw gcc. And in mingw headers, these errors are defined like:
#define VSS_E_OBJECT_NOT_FOUND _HRESULT_TYPEDEF_(0x80042308)
where _HRESULT_TYPEDEF_ is a cast to HRESULT (signed 32-bit int).
Maybe I should add casts like (HRESULT)VSS_E_... to avoid the warning....
Tomoki Sekiyama
RFC PATCH v3 7/11 qemu-ga: call Windows VSS requester in fsfreeze command handler
In reply to Tomoki SekiyamaSupport 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.
--- qga/commands-win32.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++---- qga/main.c | 33 ++++++++++++++++++++++ 2 files changed, 100 insertions(+), 7 deletions(-)
qga/commands-win32.c +68 -6
@@ -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"
@@ -151,34 +152,95 @@ void qmp_guest_file_flush(int64_t handle, Error **err)error_set (err,QERR_UNSUPPORTED ); } +#ifdef HAS_VSS_SDK +/* * Return status of freeze/thaw */ 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; + +slog ("guest-fsfreeze called" ); + +if (!vss_initialized ()) { +error_set (err,QERR_UNSUPPORTED ); +return 0 ; + } + +/* 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 (NULL );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) { +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; +} + +#else + +GuestFsfreezeStatus qmp_guest_fsfreeze_status (Error **err) +{ +error_set (err,QERR_UNSUPPORTED ); +return 0 ; +} + +int64_t qmp_guest_fsfreeze_freeze (Error **err) +{ +error_set (err,QERR_UNSUPPORTED ); +return 0 ; +} + +int64_t qmp_guest_fsfreeze_thaw (Error **err) +{error_set (err,QERR_UNSUPPORTED );return 0 ; } +#endif +/* * Walk list of mounted file systems in the guest, and discard unused * areas.
qga/main.c +32 -1
@@ -34,6 +34,10 @@#include "qemu/bswap.h" #ifdef _WIN32#include "qga/service-win32.h" +#ifdef HAS_VSS_SDK +#include "qga/vss-win32-provider.h" +#include "qga/vss-win32-requester.h" +#endif #include <windows.h> #endif #ifdef __linux__
@@ -685,6 +689,25 @@ static gboolean channel_init(GAState *s, const gchar *method, const gchar *path) }#ifdef _WIN32 + +static gboolean vss_win32_init (void ) +{ +#ifdef HAS_VSS_SDK +if (FAILED (vss_init ())) { +g_critical ("failed to initialize VSS" ); +return false; + } +#endif +return true; +} + +static void vss_win32_deinit (void ) +{ +#ifdef HAS_VSS_SDK +vss_deinit (); +#endif +} + DWORD WINAPI service_ctrl_handler(DWORD ctrl, DWORD type, LPVOID data,LPVOID ctx) {
@@ -727,8 +750,12 @@ VOID WINAPI service_main(DWORD argc, TCHAR *argv[]) service->status.dwWaitHint =0 ;SetServiceStatus (service->status_handle, &service->status); +if (!vss_win32_init ()) { + goto out_bad; + }g_main_loop_run (ga_state->main_loop); - +vss_win32_deinit (); +out_bad: service->status.dwCurrentState =SERVICE_STOPPED ;SetServiceStatus (service->status_handle, &service->status); }
@@ -1132,7 +1159,11 @@ int main(int argc, char **argv) { (char *)QGA_SERVICE_NAME, service_main }, { NULL, NULL } };StartServiceCtrlDispatcher (service_table); } else { +if (!vss_win32_init ()) { + goto out_bad; + }g_main_loop_run (ga_state->main_loop); +vss_win32_deinit (); }#endif
RFC PATCH v3 8/11 qemu-ga: install Windows VSS provider on `qemu-ga -s install'
In reply to Tomoki SekiyamaRegister QGA VSS provider library into Windows when qemu-ga is installed as Windows service ('-s install' option). It is deregistered when the service is uninstalled ('-s uninstall' option).
--- qga/main.c | 8 ++++++++ 1 file changed, 8 insertions(+)
qga/main.c +8 -0
@@ -1029,8 +1029,16 @@ int main(int argc, char **argv)case 's' : service = optarg;if (strcmp (service,"install" ) ==0 ) { +#ifdef HAS_VSS_SDK +if (FAILED (COMRegister ())) { +return EXIT_FAILURE ; + } +#endif return ga_install_service (path, log_filepath); }else if (strcmp (service,"uninstall" ) ==0 ) { +#ifdef HAS_VSS_SDK +COMUnregister (); +#endif return ga_uninstall_service (); }else {printf ("Unknown service command.\n" );
RFC PATCH v3 9/11 qemu-ga: Add VSS provider .tlb file in the repository
In reply to Tomoki SekiyamaTo build type library (.tlb) for qga-provider.dll from COM IDL (.idl), MIDL in VisualC++ and stdole2.tlb in Windows SDK are required.
This patch adds pre-compiled .tlb file in the repository in order to enable cross-compile qemu-ga.exe for Windows with VSS support.
--- Makefile | 2 +- qga/vss-win32-provider/Makefile.objs | 4 ++++ qga/vss-win32-provider/qga-provider.tlb | Bin 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 qga/vss-win32-provider/qga-provider.tlb
Makefile +1 -1
@@ -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
qga/vss-win32-provider/Makefile.objs +4 -0
@@ -18,4 +18,8 @@ MIDL=midl WINSDK="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Include" $(obj)/qga-provider.tlb: $(SRC_PATH)/$(obj)/qga-provider.idl +ifeq ($(wildcard $(SRC_PATH)/$(obj)/qga-provider.tlb),) $(call quiet-command,$(MIDL) -m64 -o $@ -I $(WINSDK) $<," MIDL $(TARGET_DIR)$@") +else + $(call quiet-command,cp $(dir $<)qga-provider.tlb $@, " COPY $(TARGET_DIR)$@") +endif
qga/vss-win32-provider/qga-provider.tlb new file binary +0 -0
Re: [Qemu-devel] [RFC PATCH v3 09/11] qemu-ga: Add VSS provider .tlb file in the repository
qga/vss-win32-provider/qga-provider.tlb
Quoted 61 lines · Tomoki Sekiyama
To build type library (.tlb) for qga-provider.dll from COM IDL (.idl), MIDL in VisualC++ and stdole2.tlb in Windows SDK are required.
This patch adds pre-compiled .tlb file in the repository in order to enable cross-compile qemu-ga.exe for Windows with VSS support.
Signed-off-by Tomoki Sekiyama <[email protected]>--- Makefile | 2 +- qga/vss-win32-provider/Makefile.objs | 4 ++++ qga/vss-win32-provider/qga-provider.tlb | Bin 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 qga/vss-win32-provider/qga-provider.tlbMakefile +1
-1@@ -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_HEADERSqga/vss-win32-provider/Makefile.objs +4
-0@@ -18,4 +18,8 @@ MIDL=midl WINSDK="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Include" $(obj)/qga-provider.tlb: $(SRC_PATH)/$(obj)/qga-provider.idl +ifeq ($(wildcard $(SRC_PATH)/$(obj)/qga-provider.tlb),) $(call quiet-command,$(MIDL) -m64 -o $@ -I $(WINSDK) $<," MIDL $(TARGET_DIR)$@") +else + $(call quiet-command,cp $(dir $<)qga-provider.tlb $@, " COPY $(TARGET_DIR)$@") +endifqga/vss-win32-provider/qga-provider.tlb new file binary +0
-0
It would be nice for this to be squashed into 05/11. (I mentioned this in reply to patch 5, but I figured I would do it here as well for completeness).
Thanks,
Jeff
RFC PATCH v3 10/11 QMP/qemu-ga-client: make timeout longer for guest-fsfreeze-freeze command
In reply to Tomoki Sekiyamaguest-fsfreeze-freeze command can take longer than 3 seconds when heavy disk I/O is running. To avoid unexpected timeout, this changes the timeout to 30 seconds.
--- QMP/qemu-ga-client | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
QMP/qemu-ga-client +3 -1
@@ -267,7 +267,9 @@ def main(address, cmd, args): print('Hint: qemu is not running?') sys.exit(1) - if cmd != 'ping': + if cmd == 'fsfreeze' and args[0] == 'freeze': + client.sync(30) + elif cmd != 'ping': client.sync() globals()['_cmd_' + cmd](client, args)
RFC PATCH v3 11/11 QMP/qmp.py: set locale for exceptions to display non-ascii messages correctly
In reply to Tomoki Sekiyamaqemu-ga in Windows may return error message with multibyte characters when the guest OS language is set to other than English. To display such messages correctly, this encodes the message based on the locale settings.
--- QMP/qmp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
QMP/qmp.py +3 -1
@@ -11,6 +11,7 @@ import json import errno import socket +import locale class QMPError(Exception): pass
@@ -133,7 +134,8 @@ class QEMUMonitorProtocol: def command(self, cmd, **kwds): ret = self.cmd(cmd, kwds) if ret.has_key('error'): - raise Exception(ret['error']['desc']) + enc = locale.getpreferredencoding() + raise Exception(ret['error']['desc'].encode(enc)) return ret['return'] def pull_event(self, wait=False):
Re: [Qemu-devel] [RFC PATCH v3 11/11] QMP/qmp.py: set locale for exceptions to display non-ascii messages correctly
Quoted 22 lines · Tomoki Sekiyama
qemu-ga in Windows may return error message with multibyte characters when the guest OS language is set to other than English. To display such messages correctly, this encodes the message based on the locale settings.
Signed-off-by Tomoki Sekiyama <[email protected]>--- QMP/qmp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)QMP/qmp.py +1
-0@@ -11,6 +11,7 @@ import json import errno import socket +import locale class QMPError(Exception): pass
QMP/qmp.py class QEMUMonitorProtocol: · line 138
Quoted 6 lines
QMP/qmp.py +2
-1@@ -133,7 +134,8 @@ class QEMUMonitorProtocol: def command(self, cmd, **kwds): ret = self.cmd(cmd, kwds) if ret.has_key('error'): - raise Exception(ret['error']['desc']) + enc = locale.getpreferredencoding() + raise Exception(ret['error']['desc'].encode(enc))
You should not need to explicitly encode the error descriptor. The error description should be UTF-8 on the wire and a Unicode Python string in this script.
I think the real problem is:
1. Guest qga is writing strings in local encoding onto the wire.
or
2. qmp.py isn't UTF-8-decoding strings received over the wire.
Either or both bugs could be present. Once they are fixed you shouldn't see encoding problems.
Stefan
Re: [Qemu-devel] [RFC PATCH v3 11/11] QMP/qmp.py: set locale for exceptions to display non-ascii messages correctly
Quoted 35 lines · Stefan Hajnoczi
Quoted 23 lines · Tomoki Sekiyama
qemu-ga in Windows may return error message with multibyte characters when the guest OS language is set to other than English. To display such messages correctly, this encodes the message based on the locale settings.
Signed-off-by Tomoki Sekiyama <[email protected]>--- QMP/qmp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)QMP/qmp.py +1
-0@@ -11,6 +11,7 @@ import json import errno import socket +import locale class QMPError(Exception): passQMP/qmp.py class QEMUMonitorProtocol: · line 138
Quoted 6 lines
QMP/qmp.py +2
-1@@ -133,7 +134,8 @@ class QEMUMonitorProtocol: def command(self, cmd, **kwds): ret = self.cmd(cmd, kwds) if ret.has_key('error'): - raise Exception(ret['error']['desc']) + enc = locale.getpreferredencoding() + raise Exception(ret['error']['desc'].encode(enc))You should not need to explicitly encode the error descriptor. The error description should be UTF-8 on the wire and a Unicode Python string in this script.
Quoted 3 lines
I think the real problem is:
1. Guest qga is writing strings in local encoding onto the wire.
The error description Guest qga writes is encoded like:
{"error": {"class": "GenericError", "desc": "\u64CD\u4F5C\u306F..."}}
I feel this is correct (\u64CD is a correct representation of single character in Unicode).
Quoted 3 lines
or
2.
qmp.pyisn't UTF-8-decoding strings received over the wire.
And qmp.py can decode this correctly, and ret['error']['desc'] is Unicode Python string.
The problem looks like in python Exception, that cannot print out the message at all if it contains non-ascii Unicode string:
% python
Quoted 1 line
QMP/qmp.py class QEMUMonitorProtocol: · line 139
Quoted 1 line
QMP/qmp.py +0
-0> raise Exception(u"abc")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Exception: abc
Quoted 1 line
QMP/qmp.py class QEMUMonitorProtocol: · line 140
Quoted 1 line
QMP/qmp.py +0
-0> raise Exception(u"abcü")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Exception
while the "print" doesn't have this issue:
Quoted 1 line
QMP/qmp.py class QEMUMonitorProtocol: · line 141
Quoted 1 line
QMP/qmp.py +0
-0> print(u"abcü")
abcü
Quoted 4 lines
Either or both bugs could be present. Once they are fixed you shouldn't see encoding problems.
Stefan
Anyway, as I understood this patch for qmp.py is not correct way to fix this issue, I'm going to drop it from the series.
Thanks,
Tomoki Sekiyama
Re: [Qemu-devel] [RFC PATCH v3 11/11] QMP/qmp.py: set locale for exceptions to display non-ascii messages correctly
Quoted 8 lines · Tomoki Sekiyama
Quoted 4 lines · Stefan Hajnoczi
Either or both bugs could be present. Once they are fixed you shouldn't see encoding problems.
Stefan
Anyway, as I understood this patch for
qmp.pyis not correct way to fix this issue, I'm going to drop it from the series.
Interesting, thanks for showing that that QEMU and qmp.py are behaving correctly.
For reference, the Python unicode exception bug is here and doesn't seem to be fixable in Python 2.x:
http://bugs.python.org/issue2517
Stefan
Sekiyama-san,
Quoted 12 lines · Tomoki Sekiyama
* About errors in Windows 7 with patch v2
VSS requires to write to snapshot volumes just before making them read-only
at final commit phase. This feature is called `auto-recovery'
(See http://msdn.microsoft.com/en-us/library/windows/desktop/aa384651(v=vs.85).aspx#base.vssgloss_auto_recoved_shadow_copy for details).Since qemu and libvirt don't have feature to handle writable snapshots, this patchset just disables auto-recovery by specifying
VSS_VOLSNAP_ATTR_NO_AUTORECOVERYflag to SetContext. Unfortunately, this flag seems unsupported in Windows 7 or earlier. It tries to look up the snapshot volumes to write and fails inVSS_E_OBJECT_NOT_FOUND.
Quoted 3 lines
For fundamental resolution we need a framework for guests to query snapshots and to mount them as writable snapshots, but we just ignore the error in this patchset.
I've been trying to understand VSS as documented in
<http://technet.microsoft.com/en-us/library/ee923636%28v=ws.10%29.aspx>
I'll be referring to the steps detailed there as "VSS steps".
Currently I'm under the impression that the "guest-fsfreeze-freeze" and "guest-fsfreeze-thaw" commands do not match VSS from a "who has control when" perspective.
VSS steps 1 to 5 correspond to "guest-fsfreeze-freeze". In the POSIX flavor of qemu-ga, including fsfreeze hook scripts, at this point qemu-ga gets back and returns control to the management stack, and backup can be done.
VSS step 6 corresponds to the management stack preparing the snapshot(s) or other means of backup.
VSS steps 7 to 8 correspond to "guest-fsfreeze-thaw". The POSIX flavor of qemu-ga thaws filesystems and reactivates applications / enables them to dirty their own data stores. This action is initiated by the management stack which has full control over its timing and conditions etc.
I believe to discover the following (orthogonal) mismatches between VSS and our current freeze/thaw APIs:
(i) Once VSS starts running at step 1, it doesn't relinquish control after step 5, and it doesn't allow an external controller to relaunch it from step 7. In other words, VSS step 6 is a callout / callback initiated by Windows logic that doesn't match our current control ownership.
In theory VSS step 6 should issue a QMP event (?) that allows libvirt to make the snapshot, and until libvirt is done with that, VSS step 6 should block.
(ii) Somewhat similar is the control over backup storage:
An fsfreeze hook script causes the corresponding application to clean up its live data store. The application doesn't encounter the notion of a separate / detached copy, and no additional storage is visible (needs to be visible) in the guest. The management stack exploits this guarantee when it (basically blindly) snapshots the disk image.
Under VSS, in-guest components (VSS providers, basically drivers) are responsible for incremental backup (copy-on-write etc.) features. I'm not sure how this can be combined with qcow2 features managed by libvirt. The VSS provider could target a separate disk, update it incrementally to mirror the current live data, and libvirt could keep snapshots of this backup disk.
(iii) VSS step 10 exists because in fact I cheated in (i) and VSS steps 1 to 5 do not correspond to guest-fsfreeze-freeze; the VSS design has aspects that are completely absent from guest-fsfreeze-freeze.
guest-fsfreeze-freeze, including the hook scripts, gives as much time to applications to quiesce as they need. When the main hook script returns control to qemu-qa, and when qemu-ga returns control to libvirt, the layer taking back control is assured that the lower layer has completed all of its freezing responsibilities.
This is not so with VSS steps 1-5, and the root cause is performance / avoidance of live service interruption. VSS puts a 60 second limit on application data store quiescing, and a 10 second limit on actual snapshotting / backup (VSS step 6). Live service should resume in no more than 70 seconds apparently.
VSS realizes that many applications won't be able to satisfy this requirement. Therefore the application level quiescing is split in a synchronous handler and an asynchronous "bottom half" (which is VSS step 10).
- Up to and including VSS step 5, an application prepares but a separate dirty context (in 60 seconds).
- In VSS step 6, this context ("shadow copy") is detached (move to other storage, probably).
- In VSS steps 7 and 8, the application resumes live service. Also,
- VSS step 10, the "bottom half" of the application (a subprocess or a dedicated thread, maybe), cleans up the now detached dirty context, *in parallel* to the live service of the application.
If we disable VSS step 10 (VSS_VOLSNAP_ATTR_NO_AUTORECOVERY), I'm still confused / unsure about:
- the control ownership problem in (i) and the storage problem in (ii) -- I believe your series must already solve this; can you please describe it in a few words?
- the time limits for VSS steps 5 and 6 probably remain in place, but without a bottom half (VSS step 10) applications may not be able to satisfy them. Does VSS_VOLSNAP_ATTR_NO_AUTORECOVERY make applications exempt from the time limits?
Interestingly, like at least
<http://wiki.iaso.com/index.php/Manual:MSSQL_VSS_Auto_Recovery> suggests for MSSQL, VSS step 10 seems to depend on both the VSS requestor and the application:
!VSS_VOLSNAP_ATTR_NO_AUTORECOVERY && MSSQL.AllowVssAutoRecover
If this condition is not satisfied, then (I believe from the linked article) MSSQL will not choose
"breach time limits but create pristine backup",
instead it will opt for
"prepare dirty backup and delay recovery until restore time".
This is probably not optimal and VSS step 10 could be a requirement if quick restore is important.
Please point out any mistakes in the above reasoning (although I'm sure it's easier to point out the few places where I'm *not* mistaken) -- I need to understand clearly the VSS procedure and its mapping (steps 1 to
9) to our APIs for any half-useful review (I know nothing about Windows). Apologies if this has been discussed before, can you please provide pointers in that case?
Thank you,
Laszlo
Hi Laszlo,
Thank you for reviewing.
Quoted 59 lines · Laszlo Ersek
Sekiyama-san,
Quoted 16 lines · Tomoki Sekiyama
* About errors in Windows 7 with patch v2
VSS requires to write to snapshot volumes just before making them
read-only
at final commit phase. This feature is called `auto-recovery' (See
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384651(v=vs.85)
.aspx#base.vssgloss_auto_recoved_shadow_copy for details).Since qemu and libvirt don't have feature to handle writable
snapshots,
this patchset just disables auto-recovery by specifyingVSS_VOLSNAP_ATTR_NO_AUTORECOVERYflag to SetContext. Unfortunately, this flag seems unsupported in Windows 7 or earlier. It tries to look up the snapshot volumes to write and fails inVSS_E_OBJECT_NOT_FOUND.Quoted 5 lines
For fundamental resolution we need a framework for guests to query
snapshots
and to mount them as writable snapshots, but we just ignore the error
in
this patchset.I've been trying to understand VSS as documented in
<http://technet.microsoft.com/en-us/library/ee923636%28v=ws.10%29.aspx>
I'll be referring to the steps detailed there as "VSS steps".
Currently I'm under the impression that the "guest-fsfreeze-freeze" and "guest-fsfreeze-thaw" commands do not match VSS from a "who has control when" perspective.
VSS steps 1 to 5 correspond to "guest-fsfreeze-freeze". In the POSIX flavor of qemu-ga, including fsfreeze hook scripts, at this point qemu-ga gets back and returns control to the management stack, and backup can be done.
VSS step 6 corresponds to the management stack preparing the snapshot(s) or other means of backup.
VSS steps 7 to 8 correspond to "guest-fsfreeze-thaw". The POSIX flavor of qemu-ga thaws filesystems and reactivates applications / enables them to dirty their own data stores. This action is initiated by the management stack which has full control over its timing and conditions etc.
I believe to discover the following (orthogonal) mismatches between VSS and our current freeze/thaw APIs:
(i) Once VSS starts running at step 1, it doesn't relinquish control after step 5, and it doesn't allow an external controller to relaunch it from step 7. In other words, VSS step 6 is a callout / callback initiated by Windows logic that doesn't match our current control ownership.
Quoted 3 lines
In theory VSS step 6 should issue a QMP event (?) that allows libvirt to make the snapshot, and until libvirt is done with that, VSS step 6 should block.
The patchset gives two components to qemu-ga; VSS requester and VSS provider.
Actually, the purpose of qemu-ga provider is to issue the QMP event you say.
- When qemu-ga receives guest-fsfreeze-freeze, the requester initiate the VSS process (step 1).
-- It designate qemu-ga provider (which just send an event to qemu-ga
requester) so that qemu-ga gets the control again at the step 6.
- At step 6, qemu-ga responds to libvirt to notify guest-fsfreeze-freeze is finished.
- libvirt make the snapshot.
- After it is done, libvirt sends guest-fsfreeze-thaw to qemu-ga
- Qemu-ga VSS provider tells VSS that snapshotting is finished, to resume the remaining steps.
Quoted 8 lines
(ii) Somewhat similar is the control over backup storage:
An fsfreeze hook script causes the corresponding application to clean up its live data store. The application doesn't encounter the notion of a separate / detached copy, and no additional storage is visible (needs to be visible) in the guest. The management stack exploits this guarantee when it (basically blindly) snapshots the disk image.
Quoted 4 lines
Under VSS, in-guest components (VSS providers, basically drivers) are responsible for incremental backup (copy-on-write etc.) features. I'm not sure how this can be combined with qcow2 features managed by libvirt.
I agree there is some mismatch of ownership design of snapshots. Currently qcow2 feature is not directly exposed to guests. Instead, the provider is used just to kick the snapshot in the libvirt. When VSS query the snapshot volume, the provider always say "not found", so the VSS-oriented restore is not possible. (That is, we need to resume the disk on libvirt side).
This makes it difficult to execute step 10 (auto-recovery; modification phase of the snapshot volume before make it read-only), because the
volume is invisible to the guest. A possible way of achieve step 10 may be create another external qcow2 image based on the snapshot taken at step 6, mount it (as a writable disk) to the guest.
Quoted 33 lines
The VSS provider could target a separate disk, update it incrementally to mirror the current live data, and libvirt could keep snapshots of this backup disk.
(iii) VSS step 10 exists because in fact I cheated in (i) and VSS steps 1 to 5 do not correspond to guest-fsfreeze-freeze; the VSS design has aspects that are completely absent from guest-fsfreeze-freeze.
guest-fsfreeze-freeze, including the hook scripts, gives as much time to applications to quiesce as they need. When the main hook script returns control to qemu-qa, and when qemu-ga returns control to libvirt, the layer taking back control is assured that the lower layer has completed all of its freezing responsibilities.
This is not so with VSS steps 1-5, and the root cause is performance / avoidance of live service interruption. VSS puts a 60 second limit on application data store quiescing, and a 10 second limit on actual snapshotting / backup (VSS step 6). Live service should resume in no more than 70 seconds apparently.
VSS realizes that many applications won't be able to satisfy this Requirement. Therefore the application level quiescing is split in a synchronous handler and an asynchronous "bottom half" (which is VSS step 10).
- Up to and including VSS step 5, an application prepares but a separate dirty context (in 60 seconds).
- In VSS step 6, this context ("shadow copy") is detached (move to other storage, probably).
- In VSS steps 7 and 8, the application resumes live service. Also,
- VSS step 10, the "bottom half" of the application (a subprocess or a dedicated thread, maybe), cleans up the now detached dirty context, *in parallel* to the live service of the application.
Quoted 6 lines
If we disable VSS step 10 (
VSS_VOLSNAP_ATTR_NO_AUTORECOVERY), I'm still confused / unsure about:- the control ownership problem in (i) and the storage problem in (ii) -- I believe your series must already solve this; can you please describe it in a few words?
I hope the explanation above is answering (i) and (ii),
Quoted 4 lines
- the time limits for VSS steps 5 and 6 probably remain in place, but without a bottom half (VSS step 10) applications may not be able to satisfy them. Does
VSS_VOLSNAP_ATTR_NO_AUTORECOVERYmake applications exempt from the time limits?
In my patch, VSS_VOLSNAP_ATTR_NO_AUTORECOVERY is mainly used to avoid
the writes to snapshots(taken at step 6), because it is already invisible from guests.
I think time limits issues is an orthogonal with this problemm; Exceeding time limits could happen even because the guest is in heavy I/O, regardless auto-recovery is enabled or not.
What we can do then might be retrying after some minutes...
Quoted 27 lines
Interestingly, like at least
<http://wiki.iaso.com/index.php/Manual:MSSQL_VSS_Auto_Recovery> suggests for MSSQL, VSS step 10 seems to depend on both the VSS requestor and the application:!VSS_VOLSNAP_ATTR_NO_AUTORECOVERY && MSSQL.AllowVssAutoRecover
If this condition is not satisfied, then (I believe from the linked article) MSSQL will not choose
"breach time limits but create pristine backup",
instead it will opt for
"prepare dirty backup and delay recovery until restore time".
This is probably not optimal and VSS step 10 could be a requirement if quick restore is important.
Please point out any mistakes in the above reasoning (although I'm sure it's easier to point out the few places where I'm *not* mistaken) -- I need to understand clearly the VSS procedure and its mapping (steps 1 to
9) to our APIs for any half-useful review (I know nothing about Windows). Apologies if this has been discussed before, can you please provide pointers in that case?
Quoted 2 lines
Thank you,
Laszlo
Thanks,
Tomoki Sekiyama
Quoted 10 lines · Tomoki Sekiyama
* How to build & run qemu-ga with VSS support
- Download Microsoft VSS SDK from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490- Setup the SDK
scripts/extract-vsssdk-headerssetup.exe (on POSIX-systems)- Specify installed SDK directory to configure option as:
./configure -with-vss-sdk="path/to/VSS SDK" --cross-prefix=i686-w64-mingw32-
Are there any plans to make this more developer-friendly? In the Linux world it's unusual to download third-party SDKs; development headers are available as packages from the distro.
I haven't looked at the SDK license but hopefully the VSS headers can be added to the mingw cross-build toolchain?
Stefan
Il 23/05/2013 14:15, Stefan Hajnoczi ha scritto:
Quoted 12 lines · Tomoki Sekiyama
Quoted 10 lines
* How to build & run qemu-ga with VSS support
- Download Microsoft VSS SDK from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490- Setup the SDK
scripts/extract-vsssdk-headerssetup.exe (on POSIX-systems)- Specify installed SDK directory to configure option as:
./configure -with-vss-sdk="path/to/VSS SDK" --cross-prefix=i686-w64-mingw32-
Quoted 6 lines
Are there any plans to make this more developer-friendly? In the Linux world it's unusual to download third-party SDKs; development headers are available as packages from the distro.
I haven't looked at the SDK license but hopefully the VSS headers can be added to the mingw cross-build toolchain?
No, the mingw headers are (re)written by hand, or something like that. The VSS license does not permit redistribution. :/
Paolo
Quoted 17 lines · Paolo Bonzini
Il 23/05/2013 14:15, Stefan Hajnoczi ha scritto:
Quoted 16 lines · Tomoki Sekiyama
Quoted 10 lines
* How to build & run qemu-ga with VSS support
- Download Microsoft VSS SDK from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490- Setup the SDK
scripts/extract-vsssdk-headerssetup.exe (on POSIX-systems)- Specify installed SDK directory to configure option as:
./configure -with-vss-sdk="path/to/VSS SDK" --cross-prefix=i686-w64-mingw32-Are there any plans to make this more developer-friendly? In the Linux world it's unusual to download third-party SDKs; development headers are available as packages from the distro.
Quoted 5 lines
Quoted 2 lines
I haven't looked at the SDK license but hopefully the VSS headers can be added to the mingw cross-build toolchain?
No, the mingw headers are (re)written by hand, or something like that. The VSS license does not permit redistribution. :/
Can we follow the same process for VSS as for the other mingw headers?
TBH I don't see how one can write them by hand without deriving it from the SDK, which seems dubious. But if it worked for the rest of mingw (which comes with Windows and DirectX headers, for example) then maybe it can work here too.
Stefan
Il 23/05/2013 15:28, Stefan Hajnoczi ha scritto:
Quoted 18 lines · Paolo Bonzini
Quoted 17 lines
Il 23/05/2013 14:15, Stefan Hajnoczi ha scritto:
Quoted 16 lines · Tomoki Sekiyama
Quoted 10 lines
* How to build & run qemu-ga with VSS support
- Download Microsoft VSS SDK from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490- Setup the SDK
scripts/extract-vsssdk-headerssetup.exe (on POSIX-systems)- Specify installed SDK directory to configure option as:
./configure -with-vss-sdk="path/to/VSS SDK" --cross-prefix=i686-w64-mingw32-Are there any plans to make this more developer-friendly? In the Linux world it's unusual to download third-party SDKs; development headers are available as packages from the distro.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I haven't looked at the SDK license but hopefully the VSS headers can be added to the mingw cross-build toolchain?
No, the mingw headers are (re)written by hand, or something like that. The VSS license does not permit redistribution. :/
Can we follow the same process for VSS as for the other mingw headers?
I have no idea. Many of them are automatically generated, but some of the others have content seemed non-trivial.
Quoted 4 lines
TBH I don't see how one can write them by hand without deriving it from the SDK, which seems dubious. But if it worked for the rest of mingw (which comes with Windows and DirectX headers, for example) then maybe it can work here too.
I'd rather avoid muddy legal waters...
Paolo
Quoted 30 lines · Paolo Bonzini
Il 23/05/2013 15:28, Stefan Hajnoczi ha scritto:
Quoted 18 lines · Paolo Bonzini
Quoted 17 lines
Il 23/05/2013 14:15, Stefan Hajnoczi ha scritto:
Quoted 16 lines · Tomoki Sekiyama
Quoted 10 lines
* How to build & run qemu-ga with VSS support
- Download Microsoft VSS SDK from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490- Setup the SDK
scripts/extract-vsssdk-headerssetup.exe (on POSIX-systems)- Specify installed SDK directory to configure option as:
./configure -with-vss-sdk="path/to/VSS SDK" --cross-prefix=i686-w64-mingw32-Are there any plans to make this more developer-friendly? In the Linux world it's unusual to download third-party SDKs; development headers are available as packages from the distro.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I haven't looked at the SDK license but hopefully the VSS headers can be added to the mingw cross-build toolchain?
No, the mingw headers are (re)written by hand, or something like that. The VSS license does not permit redistribution. :/
Can we follow the same process for VSS as for the other mingw headers?
I have no idea. Many of them are automatically generated, but some of the others have content seemed non-trivial.
Quoted 6 lines
Quoted 4 lines
TBH I don't see how one can write them by hand without deriving it from the SDK, which seems dubious. But if it worked for the rest of mingw (which comes with Windows and DirectX headers, for example) then maybe it can work here too.
I'd rather avoid muddy legal waters...
I'll try to figure out mingw's process. If mingw has a process that is clean, then let's use it for VSS headers too.
What gives me hope is that mingw headers are shipped by Fedora and Debian so the legal situation must be somewhat reasonable.
Stefan
Il 24/05/2013 10:59, Stefan Hajnoczi ha scritto:
Quoted 36 lines · Paolo Bonzini
Quoted 35 lines
Il 23/05/2013 15:28, Stefan Hajnoczi ha scritto:
Quoted 18 lines · Paolo Bonzini
Quoted 17 lines
Il 23/05/2013 14:15, Stefan Hajnoczi ha scritto:
Quoted 16 lines · Tomoki Sekiyama
Quoted 10 lines
* How to build & run qemu-ga with VSS support
- Download Microsoft VSS SDK from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490- Setup the SDK
scripts/extract-vsssdk-headerssetup.exe (on POSIX-systems)- Specify installed SDK directory to configure option as:
./configure -with-vss-sdk="path/to/VSS SDK" --cross-prefix=i686-w64-mingw32-Are there any plans to make this more developer-friendly? In the Linux world it's unusual to download third-party SDKs; development headers are available as packages from the distro.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I haven't looked at the SDK license but hopefully the VSS headers can be added to the mingw cross-build toolchain?
No, the mingw headers are (re)written by hand, or something like that. The VSS license does not permit redistribution. :/
Can we follow the same process for VSS as for the other mingw headers?
I have no idea. Many of them are automatically generated, but some of the others have content seemed non-trivial.
Quoted 4 lines
TBH I don't see how one can write them by hand without deriving it from the SDK, which seems dubious. But if it worked for the rest of mingw (which comes with Windows and DirectX headers, for example) then maybe it can work here too.
Quoted 7 lines
Quoted 1 line
I'd rather avoid muddy legal waters...
I'll try to figure out mingw's process. If mingw has a process that is clean, then let's use it for VSS headers too.
What gives me hope is that mingw headers are shipped by Fedora and Debian so the legal situation must be somewhat reasonable.
Yes, but they are done by experienced people. I'm not sure it would be the same if done by us.
Paolo
Quoted 22 lines · Paolo Bonzini
Il 23/05/2013 15:28, Stefan Hajnoczi ha scritto:
Quoted 21 lines · Paolo Bonzini
Quoted 20 lines
Il 23/05/2013 14:15, Stefan Hajnoczi ha scritto:
Quoted 18 lines · Tomoki Sekiyama
Quoted 10 lines
* How to build & run qemu-ga with VSS support
- Download Microsoft VSS SDK from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490- Setup the SDK
scripts/extract-vsssdk-headerssetup.exe (on POSIX-systems)- Specify installed SDK directory to configure option as:
./configure -with-vss-sdk="path/to/VSS SDK" --cross-prefix=i686-w64-mingw32-Are there any plans to make this more developer-friendly? In the Linux world it's unusual to download third-party SDKs; development headers are available as packages from the distro.
I haven't looked at the SDK license but hopefully the VSS headers can be added to the mingw cross-build toolchain?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
No, the mingw headers are (re)written by hand, or something like that. The VSS license does not permit redistribution. :/
Can we follow the same process for VSS as for the other mingw headers?
I have no idea. Many of them are automatically generated, but some of the others have content seemed non-trivial.
Here we go:
"For missing declarations or import functions in the mingw runtime or w32api it is essential to specify the source of the documentation on which you based your patch, or to otherwise provide proof that you have developed your solution through your own experimental effort. Never resolve an issue by looking at someone else's work (unless it is public domain). We only accept patches based on publicly available documentation, (MSDN is an acceptable source, as is any BSD or similarly licensed source; no GPL or LPGL licensed source is acceptable, unless your patch relates to a MinGW package which is already distributed under one of these licences), or on individual experimental effort, and never based on others' work, (particularly where that work may be proprietary). Note, in particular, that we adopt a much stricter standpoint on extracting information from Microsoft's SDK headers, than that taken by some other projects, such as Wine or ReactOS; consequently we will always reject, unconditionally, patches based on information extracted from files published by such projects."
http://www.mingw.org/wiki/SubmitPatches
So basically they reimplement headers by studying MSDN and maybe experimenting in Visual C++ without peeking at the official SDK.
This would take extra effort. It would be a nice thing to have in mingw but is out of scope here.
Stefan
Hi,
I tried the patch v3,with the following config.
Guest os : win7 32bit professional
Host os : fedora 17
Command:
qemu-kvm -enable-kvm -name win7 -M pc-0.15 -m 1024 -smp 2 -boot c -device virtio-serial -drive file=/home/libaiqing/vss/win7.img,if=virtio,index=0,format=qcow2 - -monitor stdio -vga qxl -vnc :1 -chardev socket,id=charchannel0,path=/var/lib/libvirt/qemu/wahaha1_requester,server,nowait -device virtserialport,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0
Output:
[root@fedora121 ~]# socat stdio,ignoreeof unix-connect:/var/lib/libvirt/qemu/wahaha1_requester
{"execute":"guest-fsfreeze-freeze"}
{"return": 2}
{"execute":"guest-fsfreeze-status"}
{"return": "frozen"}
{"execute":"guest-fsfreeze-thaw"}
{"error": {"class": "GenericError", "desc": "DoSnapshotSet. (Error: 8004230f) "}}
{"execute":"guest-fsfreeze-status"}
{"return": "thawed"}
{"execute":"guest-fsfreeze-freeze"}
{"return": 2}
{"execute":"guest-fsfreeze-status"}
{"return": "frozen"}
{"execute":"guest-fsfreeze-thaw"}
{"error": {"class": "GenericError", "desc": "DoSnapshotSet. (Error: 80042314) "}}
{"execute":"guest-fsfreeze-status"}
{"return": "thawed"} Issue:
1 Extcuting the command "guest-fsfreeze-thaw" failed,but the fs status is changed to thawed.Is this ok? 2 Extcuting the command "guest-fsfreeze-thaw" twice,the desc is different each time.
Could you give me some advise to debug this problem ? I can provide more information if need.
Regards,
baiqing
Quoted 134 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Tomoki Sekiyama
Sent: Tuesday, May 21, 2013 11:34 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Qemu-devel] [RFC PATCH v3 00/11] qemu-ga: fsfreeze on Windows using VSSHi,
This patch series adds fsfreeze support for Windows qemu-guest-agent.
changes from v2:
- [06/11] Fix errors in Windows 7, reported by Li Baiqing (see below for details).changes from v1:
- Fix out-tree build by stop using recursiveMakefile
- Added script to extract VSS SDK headers on POSIX systems using msitools (thanks Paolo)
- Remove some unnecessary header filesv2: http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg02518.html
* Description
In Windows, VSS (Volume Shadow Copy Service) provides a facility to quiesce filesystems and applications before disk snapshots are taken. This patch series implements "fsfreeze" command of qemu-ga using VSS.* How to build & run qemu-ga with VSS support
- Download Microsoft VSS SDK from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490- Setup the SDK
scripts/extract-vsssdk-headerssetup.exe (on POSIX-systems)- Specify installed SDK directory to configure option as:
./configure -with-vss-sdk="path/to/VSS SDK"
--cross-prefix=i686-w64-mingw32-- make qemu-ga.exe
- Install qemu-ga.exe, qga/vss-win32-provider/qga-provider.{dll,tlb}, and the other required mingw libraries into the same directory in guests
- Run
qemu-ga.exe -s install' andnet start qemu-ga' in the guests* About errors in Windows 7 with patch v2
VSS requires to write to snapshot volumes just before making them read-only at final commit phase. This feature is called `auto-recovery' (See
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384651(v=vs.85)
.aspx#base.vssgloss_auto_recoved_shadow_copy for details).Since qemu and libvirt don't have feature to handle writable snapshots, this patchset just disables auto-recovery by specifying
VSS_VOLSNAP_ATTR_NO_AUTORECOVERYflag to SetContext. Unfortunately, this flag seems unsupported in Windows 7 or earlier. It tries to look up the snapshot volumes to write and fails inVSS_E_OBJECT_NOT_FOUND.For fundamental resolution we need a framework for guests to query
snapshots
and to mount them as writable snapshots, but we just ignore the error in this patchset.Any feedback are appliciated.
---
Tomoki Sekiyama (11):
configure: Support configuring c++ compiler
Fix errors and warnings while compiling with c++ compilier Add a script to extract VSS SDK headers on POSIX system
qemu-ga: Add an configure option to specify path to Windows VSS SDK
qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze
qemu-ga: Add Windows VSS requester to quisce applications and
filesystems
qemu-ga: call Windows VSS requester in fsfreeze command handler
qemu-ga: install Windows VSS provider on `qemu-ga -s install'
qemu-ga: Add VSS provider .tlb file in the repository QMP/qemu-ga-client: make timeout longer for guest-fsfreeze-freeze
command
QMP/qmp.py: set locale for exceptions to display non-ascii messages
correctly.gitignore | 1 Makefile | 3 Makefile.objs | 2 QMP/qemu-ga-client | 4 QMP/qmp.py | 4 configure | 59 ++++ hmp.c | 2 hw/pci/pci.c | 2 qga/Makefile.objs | 7 qga/commands-win32.c | 74 ++++- qga/main.c | 41 +++ qga/vss-win32-provider.h | 26 ++ qga/vss-win32-provider/Makefile.objs | 25 ++ qga/vss-win32-provider/install.cpp | 494 +++++++++++++++++++++++++++++++ qga/vss-win32-provider/provider.cpp | 474 ++++++++++++++++++++++++++++++ qga/vss-win32-provider/qga-provider.def | 10 + qga/vss-win32-provider/qga-provider.idl | 20 + qga/vss-win32-provider/qga-provider.tlb | Bin qga/vss-win32-requester.cpp | 404 +++++++++++++++++++++++++ qga/vss-win32-requester.h | 31 ++ qga/vss-win32.h | 85 +++++ rules.mak | 9 + scripts/extract-vsssdk-headers | 25 ++ scripts/qapi.py | 9 + 24 files changed, 1796 insertions(+), 15 deletions(-) create mode 100644 qga/vss-win32-provider.h create mode 100644 qga/vss-win32-provider/Makefile.objs create mode 100644 qga/vss-win32-provider/install.cpp create mode 100644 qga/vss-win32-provider/provider.cpp create mode 100644 qga/vss-win32-provider/qga-provider.def create mode 100644 qga/vss-win32-provider/qga-provider.idl create mode 100644 qga/vss-win32-provider/qga-provider.tlb create mode 100644 qga/vss-win32-requester.cpp create mode 100644 qga/vss-win32-requester.h create mode 100644 qga/vss-win32.h create mode 100755 scripts/extract-vsssdk-headers
Hi,
Thank you for testing the patch.
Quoted 1 line
{"error": {"class": "GenericError", "desc": "DoSnapshotSet. (Error: 8004230f) "}}This is VSS_E_UNEXPECTED_PROVIDER_ERROR. I can't say what happens from this, but Detailed error log would be logged in Event Viewer.
Could you send me the log in Event Viewer corresponding to this code for further investigation please?
Quoted 1 line
{"error": {"class": "GenericError", "desc": "DoSnapshotSet. (Error: 80042314) "}}This is time out error. Windows can only hold writes for snapshot only for 10 seconds. In other words, you need to issue guest-fsfeeze-thaw in 10 seconds after guest-fsfreeze-freeze, otherwise it fails to keep the consistency. (If you need more time, you could pause the guest.)
Also in this case, Event Viewer must have more detailed reason.
(I should add more kind error messages for this case....)
Quoted 2 lines
Issue:
1 Extcuting the command "guest-fsfreeze-thaw" failed,but the fs status is changed to thawed.Is this ok?
It is actually thawed in this case. Since Windows cannot hold I/O more than 10 seconds, it is automatically thawed after that time.
Quoted 1 line
2 Extcuting the command "guest-fsfreeze-thaw" twice,the desc is different each time.
As I mentioned above, it could be because of duration of fsfreeze.
Thanks,
Tomoki Sekiyama
________________________________________
From: Libaiqing [[email protected]]
Sent: Monday, May 27, 2013 12:13 AM
To: Tomoki Sekiyama; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Seiji Aguchi; [email protected]; Haofeng
Subject: RE: [Qemu-devel] [RFC PATCH v3 00/11] qemu-ga: fsfreeze on Windows using VSS
Hi,
I tried the patch v3,with the following config.
Guest os : win7 32bit professional
Host os : fedora 17
Command:
qemu-kvm -enable-kvm -name win7 -M pc-0.15 -m 1024 -smp 2 -boot c -device virtio-serial -drive file=/home/libaiqing/vss/win7.img,if=virtio,index=0,format=qcow2 - -monitor stdio -vga qxl -vnc :1 -chardev socket,id=charchannel0,path=/var/lib/libvirt/qemu/wahaha1_requester,server,nowait -device virtserialport,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0
Output:
[root@fedora121 ~]# socat stdio,ignoreeof unix-connect:/var/lib/libvirt/qemu/wahaha1_requester
{"execute":"guest-fsfreeze-freeze"}
{"return": 2}
{"execute":"guest-fsfreeze-status"}
{"return": "frozen"}
{"execute":"guest-fsfreeze-thaw"}
{"error": {"class": "GenericError", "desc": "DoSnapshotSet. (Error: 8004230f) "}}
{"execute":"guest-fsfreeze-status"}
{"return": "thawed"}
{"execute":"guest-fsfreeze-freeze"}
{"return": 2}
{"execute":"guest-fsfreeze-status"}
{"return": "frozen"}
{"execute":"guest-fsfreeze-thaw"}
{"error": {"class": "GenericError", "desc": "DoSnapshotSet. (Error: 80042314) "}}
{"execute":"guest-fsfreeze-status"}
{"return": "thawed"} Issue:
1 Extcuting the command "guest-fsfreeze-thaw" failed,but the fs status is changed to thawed.Is this ok? 2 Extcuting the command "guest-fsfreeze-thaw" twice,the desc is different each time.
Could you give me some advise to debug this problem ? I can provide more information if need.
Regards,
baiqing
Quoted 134 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Tomoki Sekiyama
Sent: Tuesday, May 21, 2013 11:34 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Qemu-devel] [RFC PATCH v3 00/11] qemu-ga: fsfreeze on Windows using VSSHi,
This patch series adds fsfreeze support for Windows qemu-guest-agent.
changes from v2:
- [06/11] Fix errors in Windows 7, reported by Li Baiqing (see below for details).changes from v1:
- Fix out-tree build by stop using recursiveMakefile
- Added script to extract VSS SDK headers on POSIX systems using msitools (thanks Paolo)
- Remove some unnecessary header filesv2: http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg02518.html
* Description
In Windows, VSS (Volume Shadow Copy Service) provides a facility to quiesce filesystems and applications before disk snapshots are taken. This patch series implements "fsfreeze" command of qemu-ga using VSS.* How to build & run qemu-ga with VSS support
- Download Microsoft VSS SDK from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490- Setup the SDK
scripts/extract-vsssdk-headerssetup.exe (on POSIX-systems)- Specify installed SDK directory to configure option as:
./configure -with-vss-sdk="path/to/VSS SDK"
--cross-prefix=i686-w64-mingw32-- make qemu-ga.exe
- Install qemu-ga.exe, qga/vss-win32-provider/qga-provider.{dll,tlb}, and the other required mingw libraries into the same directory in guests
- Run
qemu-ga.exe -s install' andnet start qemu-ga' in the guests* About errors in Windows 7 with patch v2
VSS requires to write to snapshot volumes just before making them read-only at final commit phase. This feature is called `auto-recovery' (See
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384651(v=vs.85)
.aspx#base.vssgloss_auto_recoved_shadow_copy for details).Since qemu and libvirt don't have feature to handle writable snapshots, this patchset just disables auto-recovery by specifying
VSS_VOLSNAP_ATTR_NO_AUTORECOVERYflag to SetContext. Unfortunately, this flag seems unsupported in Windows 7 or earlier. It tries to look up the snapshot volumes to write and fails inVSS_E_OBJECT_NOT_FOUND.For fundamental resolution we need a framework for guests to query
snapshots
and to mount them as writable snapshots, but we just ignore the error in this patchset.Any feedback are appliciated.
---
Tomoki Sekiyama (11):
configure: Support configuring c++ compiler
Fix errors and warnings while compiling with c++ compilier Add a script to extract VSS SDK headers on POSIX system
qemu-ga: Add an configure option to specify path to Windows VSS SDK
qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze
qemu-ga: Add Windows VSS requester to quisce applications and
filesystems
qemu-ga: call Windows VSS requester in fsfreeze command handler
qemu-ga: install Windows VSS provider on `qemu-ga -s install'
qemu-ga: Add VSS provider .tlb file in the repository QMP/qemu-ga-client: make timeout longer for guest-fsfreeze-freeze
command
QMP/qmp.py: set locale for exceptions to display non-ascii messages
correctly.gitignore | 1 Makefile | 3 Makefile.objs | 2 QMP/qemu-ga-client | 4 QMP/qmp.py | 4 configure | 59 ++++ hmp.c | 2 hw/pci/pci.c | 2 qga/Makefile.objs | 7 qga/commands-win32.c | 74 ++++- qga/main.c | 41 +++ qga/vss-win32-provider.h | 26 ++ qga/vss-win32-provider/Makefile.objs | 25 ++ qga/vss-win32-provider/install.cpp | 494 +++++++++++++++++++++++++++++++ qga/vss-win32-provider/provider.cpp | 474 ++++++++++++++++++++++++++++++ qga/vss-win32-provider/qga-provider.def | 10 + qga/vss-win32-provider/qga-provider.idl | 20 + qga/vss-win32-provider/qga-provider.tlb | Bin qga/vss-win32-requester.cpp | 404 +++++++++++++++++++++++++ qga/vss-win32-requester.h | 31 ++ qga/vss-win32.h | 85 +++++ rules.mak | 9 + scripts/extract-vsssdk-headers | 25 ++ scripts/qapi.py | 9 + 24 files changed, 1796 insertions(+), 15 deletions(-) create mode 100644 qga/vss-win32-provider.h create mode 100644 qga/vss-win32-provider/Makefile.objs create mode 100644 qga/vss-win32-provider/install.cpp create mode 100644 qga/vss-win32-provider/provider.cpp create mode 100644 qga/vss-win32-provider/qga-provider.def create mode 100644 qga/vss-win32-provider/qga-provider.idl create mode 100644 qga/vss-win32-provider/qga-provider.tlb create mode 100644 qga/vss-win32-requester.cpp create mode 100644 qga/vss-win32-requester.h create mode 100644 qga/vss-win32.h create mode 100755 scripts/extract-vsssdk-headers
Hi,
Thank you for your advice.
When executing the command " guest-fsfreeze-thaw " within 10s,it works well. Output:
[root@fedora121 ~]# socat stdio,ignoreeof unix-connect:/var/lib/libvirt/qemu/wahaha1_requester {"execute":"guest-fsfreeze-freeze"}
{"return": 2}
{"execute":"guest-fsfreeze-status"}
{"return": "frozen"}
{"execute":"guest-fsfreeze-thaw"}
{"return": 2}
When freezing timeout,the log of eventviewer is applied as attachment.
In vss spec,vss is thawed automatically when time is out.Is error desc necessary?
Regards,
baiqing
Quoted 250 lines
-----Original Message-----
From: Tomoki Sekiyama [mailto:[email protected]]
Sent: Monday, May 27, 2013 3:02 PM
To: Libaiqing; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Seiji Aguchi; [email protected]; Haofeng
Subject: RE: [Qemu-devel] [RFC PATCH v3 00/11] qemu-ga: fsfreeze on Windows using VSSHi,
Thank you for testing the patch.
Quoted 1 line
{"error": {"class": "GenericError", "desc": "DoSnapshotSet. (Error:
8004230f) "}}This is
VSS_E_UNEXPECTED_PROVIDER_ERROR. I can't say what happens from this, but
Detailed error log would be logged in Event Viewer.Could you send me the log in Event Viewer corresponding to this code for further investigation please?
Quoted 1 line
{"error": {"class": "GenericError", "desc": "DoSnapshotSet. (Error:80042314) "}}
This is time out error. Windows can only hold writes for snapshot only for 10 seconds.
In other words, you need to issue guest-fsfeeze-thaw in 10 seconds after guest-fsfreeze-freeze,
otherwise it fails to keep the consistency. (If you need more time, you could pause the guest.)Also in this case, Event Viewer must have more detailed reason.
(I should add more kind error messages for this case....)
Quoted 2 lines
Issue:
1 Extcuting the command "guest-fsfreeze-thaw" failed,but the fs statusis changed to thawed.Is this ok?
It is actually thawed in this case. Since Windows cannot hold I/O more than 10 seconds, it is
automatically thawed after that time.Quoted 1 line
2 Extcuting the command "guest-fsfreeze-thaw" twice,the desc is
different each time.
As I mentioned above, it could be because of duration of fsfreeze.
Thanks,
Tomoki Sekiyama
________________________________________
From: Libaiqing [[email protected]]
Sent: Monday, May 27, 2013 12:13 AM
To: Tomoki Sekiyama; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Seiji Aguchi; [email protected]; Haofeng
Subject: RE: [Qemu-devel] [RFC PATCH v3 00/11] qemu-ga: fsfreeze on Windows using VSSHi,
I tried the patch v3,with the following config.Guest os : win7 32bit professional
Host os : fedora 17
Command:qemu-kvm -enable-kvm -name win7 -M pc-0.15 -m 1024 -smp 2 -boot c-device virtio-serial -drive file=/home/libaiqing/vss/win7.img,if=virtio,index=0,format=qcow2 - -monitor stdio -vga qxl -vnc :1 -chardev
socket,id=charchannel0,path=/var/lib/libvirt/qemu/wahaha1_requester,server, nowait -device virtserialport,chardev=charchannel0,id=channel0,name=org.qemu.guest_agen t.0
Output:
[root@fedora121 ~]# socat stdio,ignoreeof
unix-connect:/var/lib/libvirt/qemu/wahaha1_requester{"execute":"guest-fsfreeze-freeze"} {"return": 2} {"execute":"guest-fsfreeze-status"} {"return": "frozen"} {"execute":"guest-fsfreeze-thaw"} {"error": {"class": "GenericError", "desc": "DoSnapshotSet. (Error: 8004230f) "}} {"execute":"guest-fsfreeze-status"} {"return": "thawed"} {"execute":"guest-fsfreeze-freeze"} {"return": 2} {"execute":"guest-fsfreeze-status"} {"return": "frozen"} {"execute":"guest-fsfreeze-thaw"} {"error": {"class": "GenericError", "desc": "DoSnapshotSet. (Error: 80042314) "}} {"execute":"guest-fsfreeze-status"} {"return": "thawed"}Issue:
1 Extcuting the command "guest-fsfreeze-thaw" failed,but the fs status is
changed to thawed.Is this ok?
2 Extcuting the command "guest-fsfreeze-thaw" twice,the desc is
different each time.Could you give me some advise to debug this problem ? I can provide more
information if need.Regards,
baiqingQuoted 3 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On BehalfOf
Quoted 46 lines
Tomoki Sekiyama
Sent: Tuesday, May 21, 2013 11:34 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Qemu-devel] [RFC PATCH v3 00/11] qemu-ga: fsfreeze on Windows using VSSHi,
This patch series adds fsfreeze support for Windows qemu-guest-agent.
changes from v2:
- [06/11] Fix errors in Windows 7, reported by Li Baiqing (see below for details).changes from v1:
- Fix out-tree build by stop using recursiveMakefile
- Added script to extract VSS SDK headers on POSIX systems using msitools (thanks Paolo)
- Remove some unnecessary header filesv2: http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg02518.html
* Description
In Windows, VSS (Volume Shadow Copy Service) provides a facility to quiesce filesystems and applications before disk snapshots are taken. This patch series implements "fsfreeze" command of qemu-ga using VSS.* How to build & run qemu-ga with VSS support
- Download Microsoft VSS SDK from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490- Setup the SDK
scripts/extract-vsssdk-headerssetup.exe (on POSIX-systems)- Specify installed SDK directory to configure option as:
./configure -with-vss-sdk="path/to/VSS SDK"
--cross-prefix=i686-w64-mingw32-- make qemu-ga.exe
Quoted 8 lines
- Install qemu-ga.exe, qga/vss-win32-provider/qga-provider.{dll,tlb}, and the other required mingw libraries into the same directory in guests
- Run
qemu-ga.exe -s install' andnet start qemu-ga' in the guests* About errors in Windows 7 with patch v2
VSS requires to write to snapshot volumes just before making themread-only
Quoted 3 lines
at final commit phase. This feature is called `auto-recovery' (See
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384651(v=vs.85)
Quoted 14 lines
.aspx#base.vssgloss_auto_recoved_shadow_copy for details).
Since qemu and libvirt don't have feature to handle writable snapshots, this patchset just disables auto-recovery by specifying
VSS_VOLSNAP_ATTR_NO_AUTORECOVERYflag to SetContext. Unfortunately, this flag seems unsupported in Windows 7 or earlier. It tries to look up the snapshot volumes to write and fails inVSS_E_OBJECT_NOT_FOUND.For fundamental resolution we need a framework for guests to query
snapshots
and to mount them as writable snapshots, but we just ignore the error in this patchset.Quoted 8 lines
Any feedback are appliciated.
---
Tomoki Sekiyama (11):
configure: Support configuring c++ compiler
Fix errors and warnings while compiling with c++ compilier Add a script to extract VSS SDK headers on POSIX system
qemu-ga: Add an configure option to specify path to Windows VSSSDK
Quoted 1 line
qemu-ga: Add Windows VSS provider to quiesce applications on
fsfreeze
Quoted 51 lines
qemu-ga: Add Windows VSS requester to quisce applications and
filesystems
qemu-ga: call Windows VSS requester in fsfreeze command handler
qemu-ga: install Windows VSS provider on `qemu-ga -s install'
qemu-ga: Add VSS provider .tlb file in the repository QMP/qemu-ga-client: make timeout longer for guest-fsfreeze-freeze
command
QMP/qmp.py: set locale for exceptions to display non-ascii messages
correctly.gitignore | 1 Makefile | 3 Makefile.objs | 2 QMP/qemu-ga-client | 4 QMP/qmp.py | 4 configure | 59 ++++ hmp.c | 2 hw/pci/pci.c | 2 qga/Makefile.objs | 7 qga/commands-win32.c | 74 ++++- qga/main.c | 41 +++ qga/vss-win32-provider.h | 26 ++ qga/vss-win32-provider/Makefile.objs | 25 ++ qga/vss-win32-provider/install.cpp | 494 +++++++++++++++++++++++++++++++ qga/vss-win32-provider/provider.cpp | 474 ++++++++++++++++++++++++++++++ qga/vss-win32-provider/qga-provider.def | 10 + qga/vss-win32-provider/qga-provider.idl | 20 + qga/vss-win32-provider/qga-provider.tlb | Bin qga/vss-win32-requester.cpp | 404 +++++++++++++++++++++++++ qga/vss-win32-requester.h | 31 ++ qga/vss-win32.h | 85 +++++ rules.mak | 9 + scripts/extract-vsssdk-headers | 25 ++ scripts/qapi.py | 9 + 24 files changed, 1796 insertions(+), 15 deletions(-) create mode 100644 qga/vss-win32-provider.h create mode 100644 qga/vss-win32-provider/Makefile.objs create mode 100644 qga/vss-win32-provider/install.cpp create mode 100644 qga/vss-win32-provider/provider.cpp create mode 100644 qga/vss-win32-provider/qga-provider.def create mode 100644 qga/vss-win32-provider/qga-provider.idl create mode 100644 qga/vss-win32-provider/qga-provider.tlb create mode 100644 qga/vss-win32-requester.cpp create mode 100644 qga/vss-win32-requester.h create mode 100644 qga/vss-win32.h create mode 100755 scripts/extract-vsssdk-headers
Hi,
When installing the guest-agent on windows2008R2, an error occurs.
Executing command "qemu-ga.exe -s install",
the app popups a dialog box with the message: "CoCreateInstance(VSSCoordinator)failed.(Error:80010154)" the commandline output is"Failed to pCatalog->InstallComponent.(Error:80110401) ......"
Provider.dll is built with --cross-prefix=i686-w64-mingw32-, does it support 64-bit system? I also found some info from ms webstie: http://msdn.microsoft.com/en-us/library/aa384627(v=vs.85).aspx
Could you give me some advise to debug this problem ? I can provide more information if need.
Regards,
baiqing
Quoted 134 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Tomoki Sekiyama
Sent: Tuesday, May 21, 2013 11:34 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Qemu-devel] [RFC PATCH v3 00/11] qemu-ga: fsfreeze on Windows using VSSHi,
This patch series adds fsfreeze support for Windows qemu-guest-agent.
changes from v2:
- [06/11] Fix errors in Windows 7, reported by Li Baiqing (see below for details).changes from v1:
- Fix out-tree build by stop using recursiveMakefile
- Added script to extract VSS SDK headers on POSIX systems using msitools (thanks Paolo)
- Remove some unnecessary header filesv2: http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg02518.html
* Description
In Windows, VSS (Volume Shadow Copy Service) provides a facility to quiesce filesystems and applications before disk snapshots are taken. This patch series implements "fsfreeze" command of qemu-ga using VSS.* How to build & run qemu-ga with VSS support
- Download Microsoft VSS SDK from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490- Setup the SDK
scripts/extract-vsssdk-headerssetup.exe (on POSIX-systems)- Specify installed SDK directory to configure option as:
./configure -with-vss-sdk="path/to/VSS SDK"
--cross-prefix=i686-w64-mingw32-- make qemu-ga.exe
- Install qemu-ga.exe, qga/vss-win32-provider/qga-provider.{dll,tlb}, and the other required mingw libraries into the same directory in guests
- Run
qemu-ga.exe -s install' andnet start qemu-ga' in the guests* About errors in Windows 7 with patch v2
VSS requires to write to snapshot volumes just before making them read-only at final commit phase. This feature is called `auto-recovery' (See
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384651(v=vs.85)
.aspx#base.vssgloss_auto_recoved_shadow_copy for details).Since qemu and libvirt don't have feature to handle writable snapshots, this patchset just disables auto-recovery by specifying
VSS_VOLSNAP_ATTR_NO_AUTORECOVERYflag to SetContext. Unfortunately, this flag seems unsupported in Windows 7 or earlier. It tries to look up the snapshot volumes to write and fails inVSS_E_OBJECT_NOT_FOUND.For fundamental resolution we need a framework for guests to query
snapshots
and to mount them as writable snapshots, but we just ignore the error in this patchset.Any feedback are appliciated.
---
Tomoki Sekiyama (11):
configure: Support configuring c++ compiler
Fix errors and warnings while compiling with c++ compilier Add a script to extract VSS SDK headers on POSIX system
qemu-ga: Add an configure option to specify path to Windows VSS SDK
qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze
qemu-ga: Add Windows VSS requester to quisce applications and
filesystems
qemu-ga: call Windows VSS requester in fsfreeze command handler
qemu-ga: install Windows VSS provider on `qemu-ga -s install'
qemu-ga: Add VSS provider .tlb file in the repository QMP/qemu-ga-client: make timeout longer for guest-fsfreeze-freeze
command
QMP/qmp.py: set locale for exceptions to display non-ascii messages
correctly.gitignore | 1 Makefile | 3 Makefile.objs | 2 QMP/qemu-ga-client | 4 QMP/qmp.py | 4 configure | 59 ++++ hmp.c | 2 hw/pci/pci.c | 2 qga/Makefile.objs | 7 qga/commands-win32.c | 74 ++++- qga/main.c | 41 +++ qga/vss-win32-provider.h | 26 ++ qga/vss-win32-provider/Makefile.objs | 25 ++ qga/vss-win32-provider/install.cpp | 494 +++++++++++++++++++++++++++++++ qga/vss-win32-provider/provider.cpp | 474 ++++++++++++++++++++++++++++++ qga/vss-win32-provider/qga-provider.def | 10 + qga/vss-win32-provider/qga-provider.idl | 20 + qga/vss-win32-provider/qga-provider.tlb | Bin qga/vss-win32-requester.cpp | 404 +++++++++++++++++++++++++ qga/vss-win32-requester.h | 31 ++ qga/vss-win32.h | 85 +++++ rules.mak | 9 + scripts/extract-vsssdk-headers | 25 ++ scripts/qapi.py | 9 + 24 files changed, 1796 insertions(+), 15 deletions(-) create mode 100644 qga/vss-win32-provider.h create mode 100644 qga/vss-win32-provider/Makefile.objs create mode 100644 qga/vss-win32-provider/install.cpp create mode 100644 qga/vss-win32-provider/provider.cpp create mode 100644 qga/vss-win32-provider/qga-provider.def create mode 100644 qga/vss-win32-provider/qga-provider.idl create mode 100644 qga/vss-win32-provider/qga-provider.tlb create mode 100644 qga/vss-win32-requester.cpp create mode 100644 qga/vss-win32-requester.h create mode 100644 qga/vss-win32.h create mode 100755 scripts/extract-vsssdk-headers
Hi Baiqing,
Quoted 1 line
Provider.dll is built with --cross-prefix=i686-w64-mingw32-, does it support 64-bit system?
No. The DLL is dynamic-linked to the VSS system component, so it must be built for the same architecture (32-bit (i686) or 64-bit (x86_64)) as the operating system you run.
Thanks,
Tomoki Sekiyama
________________________________________
From: Libaiqing [[email protected]]
Sent: Thursday, May 30, 2013 9:30 PM
To: Tomoki Sekiyama; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Seiji Aguchi; [email protected]; Haofeng
Subject: RE: [Qemu-devel] [RFC PATCH v3 00/11] qemu-ga: fsfreeze on Windows using VSS
Hi,
When installing the guest-agent on windows2008R2, an error occurs.
Executing command "qemu-ga.exe -s install",
the app popups a dialog box with the message: "CoCreateInstance(VSSCoordinator)failed.(Error:80010154)" the commandline output is"Failed to pCatalog->InstallComponent.(Error:80110401) ......"
Provider.dll is built with --cross-prefix=i686-w64-mingw32-, does it support 64-bit system? I also found some info from ms webstie: http://msdn.microsoft.com/en-us/library/aa384627(v=vs.85).aspx
Could you give me some advise to debug this problem ? I can provide more information if need.
Regards,
baiqing
Quoted 134 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Tomoki Sekiyama
Sent: Tuesday, May 21, 2013 11:34 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Qemu-devel] [RFC PATCH v3 00/11] qemu-ga: fsfreeze on Windows using VSSHi,
This patch series adds fsfreeze support for Windows qemu-guest-agent.
changes from v2:
- [06/11] Fix errors in Windows 7, reported by Li Baiqing (see below for details).changes from v1:
- Fix out-tree build by stop using recursiveMakefile
- Added script to extract VSS SDK headers on POSIX systems using msitools (thanks Paolo)
- Remove some unnecessary header filesv2: http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg02518.html
* Description
In Windows, VSS (Volume Shadow Copy Service) provides a facility to quiesce filesystems and applications before disk snapshots are taken. This patch series implements "fsfreeze" command of qemu-ga using VSS.* How to build & run qemu-ga with VSS support
- Download Microsoft VSS SDK from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490- Setup the SDK
scripts/extract-vsssdk-headerssetup.exe (on POSIX-systems)- Specify installed SDK directory to configure option as:
./configure -with-vss-sdk="path/to/VSS SDK"
--cross-prefix=i686-w64-mingw32-- make qemu-ga.exe
- Install qemu-ga.exe, qga/vss-win32-provider/qga-provider.{dll,tlb}, and the other required mingw libraries into the same directory in guests
- Run
qemu-ga.exe -s install' andnet start qemu-ga' in the guests* About errors in Windows 7 with patch v2
VSS requires to write to snapshot volumes just before making them read-only at final commit phase. This feature is called `auto-recovery' (See
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384651(v=vs.85)
.aspx#base.vssgloss_auto_recoved_shadow_copy for details).Since qemu and libvirt don't have feature to handle writable snapshots, this patchset just disables auto-recovery by specifying
VSS_VOLSNAP_ATTR_NO_AUTORECOVERYflag to SetContext. Unfortunately, this flag seems unsupported in Windows 7 or earlier. It tries to look up the snapshot volumes to write and fails inVSS_E_OBJECT_NOT_FOUND.For fundamental resolution we need a framework for guests to query
snapshots
and to mount them as writable snapshots, but we just ignore the error in this patchset.Any feedback are appliciated.
---
Tomoki Sekiyama (11):
configure: Support configuring c++ compiler
Fix errors and warnings while compiling with c++ compilier Add a script to extract VSS SDK headers on POSIX system
qemu-ga: Add an configure option to specify path to Windows VSS SDK
qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze
qemu-ga: Add Windows VSS requester to quisce applications and
filesystems
qemu-ga: call Windows VSS requester in fsfreeze command handler
qemu-ga: install Windows VSS provider on `qemu-ga -s install'
qemu-ga: Add VSS provider .tlb file in the repository QMP/qemu-ga-client: make timeout longer for guest-fsfreeze-freeze
command
QMP/qmp.py: set locale for exceptions to display non-ascii messages
correctly.gitignore | 1 Makefile | 3 Makefile.objs | 2 QMP/qemu-ga-client | 4 QMP/qmp.py | 4 configure | 59 ++++ hmp.c | 2 hw/pci/pci.c | 2 qga/Makefile.objs | 7 qga/commands-win32.c | 74 ++++- qga/main.c | 41 +++ qga/vss-win32-provider.h | 26 ++ qga/vss-win32-provider/Makefile.objs | 25 ++ qga/vss-win32-provider/install.cpp | 494 +++++++++++++++++++++++++++++++ qga/vss-win32-provider/provider.cpp | 474 ++++++++++++++++++++++++++++++ qga/vss-win32-provider/qga-provider.def | 10 + qga/vss-win32-provider/qga-provider.idl | 20 + qga/vss-win32-provider/qga-provider.tlb | Bin qga/vss-win32-requester.cpp | 404 +++++++++++++++++++++++++ qga/vss-win32-requester.h | 31 ++ qga/vss-win32.h | 85 +++++ rules.mak | 9 + scripts/extract-vsssdk-headers | 25 ++ scripts/qapi.py | 9 + 24 files changed, 1796 insertions(+), 15 deletions(-) create mode 100644 qga/vss-win32-provider.h create mode 100644 qga/vss-win32-provider/Makefile.objs create mode 100644 qga/vss-win32-provider/install.cpp create mode 100644 qga/vss-win32-provider/provider.cpp create mode 100644 qga/vss-win32-provider/qga-provider.def create mode 100644 qga/vss-win32-provider/qga-provider.idl create mode 100644 qga/vss-win32-provider/qga-provider.tlb create mode 100644 qga/vss-win32-requester.cpp create mode 100644 qga/vss-win32-requester.h create mode 100644 qga/vss-win32.h create mode 100755 scripts/extract-vsssdk-headers
Hi,
Thanks for your advice,it works well when using prefix=x86_64-w64-mingw32-. The dlls may download from here: http://qemu.weilnetz.de/w64/dll/.
One more question:
Qemu-ga.exe can't run successfully under normal account which belongs to Administration group. Qemu-ga service can start successfully under this account after Administrator installed.
The output is:
1370307591.689600:critical:error opening path
1370307591.705200:critical:error opening channel
1370307591.720800:critical:failed to create guest agent channel
1370307591.736400:critical:failed to initialize guest agent channelCould you give me some advise to debug this problem ? I can provide more information if need.
Regards,
baiqing
Quoted 189 lines
-----Original Message-----
From: Tomoki Sekiyama [mailto:[email protected]]
Sent: Friday, May 31, 2013 10:20 AM
To: Libaiqing; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Seiji Aguchi; [email protected]; Haofeng
Subject: RE: [Qemu-devel] [RFC PATCH v3 00/11] qemu-ga: fsfreeze on Windows using VSSHi Baiqing,
Quoted 1 line
Provider.dll is built with --cross-prefix=i686-w64-mingw32-, does it support
64-bit system?
No. The DLL is dynamic-linked to the VSS system component, so it must be built for the same architecture (32-bit (i686) or 64-bit (
x86_64)) as the operating system you run.Thanks,
Tomoki Sekiyama________________________________________
From: Libaiqing [[email protected]]
Sent: Thursday, May 30, 2013 9:30 PM
To: Tomoki Sekiyama; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Seiji Aguchi; [email protected]; Haofeng
Subject: RE: [Qemu-devel] [RFC PATCH v3 00/11] qemu-ga: fsfreeze on Windows using VSSHi,
When installing the guest-agent on windows2008R2, an error occurs. Executing command "qemu-ga.exe -s install",
the app popups a dialog box with the message:
"CoCreateInstance(VSSCoordinator)failed.(Error:80010154)"
the commandline output is"Failed to
pCatalog->InstallComponent.(Error:80110401) ......"Provider.dll is built with --cross-prefix=i686-w64-mingw32-, does it support
64-bit system?
I also found some info from ms webstie:
http://msdn.microsoft.com/en-us/library/aa384627(v=vs.85).aspxCould you give me some advise to debug this problem ? I can provide more
information if need.Regards,
baiqingQuoted 3 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On BehalfOf
Quoted 46 lines
Tomoki Sekiyama
Sent: Tuesday, May 21, 2013 11:34 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Qemu-devel] [RFC PATCH v3 00/11] qemu-ga: fsfreeze on Windows using VSSHi,
This patch series adds fsfreeze support for Windows qemu-guest-agent.
changes from v2:
- [06/11] Fix errors in Windows 7, reported by Li Baiqing (see below for details).changes from v1:
- Fix out-tree build by stop using recursiveMakefile
- Added script to extract VSS SDK headers on POSIX systems using msitools (thanks Paolo)
- Remove some unnecessary header filesv2: http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg02518.html
* Description
In Windows, VSS (Volume Shadow Copy Service) provides a facility to quiesce filesystems and applications before disk snapshots are taken. This patch series implements "fsfreeze" command of qemu-ga using VSS.* How to build & run qemu-ga with VSS support
- Download Microsoft VSS SDK from:
http://www.microsoft.com/en-us/download/details.aspx?id=23490- Setup the SDK
scripts/extract-vsssdk-headerssetup.exe (on POSIX-systems)- Specify installed SDK directory to configure option as:
./configure -with-vss-sdk="path/to/VSS SDK"
--cross-prefix=i686-w64-mingw32-- make qemu-ga.exe
Quoted 8 lines
- Install qemu-ga.exe, qga/vss-win32-provider/qga-provider.{dll,tlb}, and the other required mingw libraries into the same directory in guests
- Run
qemu-ga.exe -s install' andnet start qemu-ga' in the guests* About errors in Windows 7 with patch v2
VSS requires to write to snapshot volumes just before making themread-only
Quoted 3 lines
at final commit phase. This feature is called `auto-recovery' (See
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384651(v=vs.85)
Quoted 14 lines
.aspx#base.vssgloss_auto_recoved_shadow_copy for details).
Since qemu and libvirt don't have feature to handle writable snapshots, this patchset just disables auto-recovery by specifying
VSS_VOLSNAP_ATTR_NO_AUTORECOVERYflag to SetContext. Unfortunately, this flag seems unsupported in Windows 7 or earlier. It tries to look up the snapshot volumes to write and fails inVSS_E_OBJECT_NOT_FOUND.For fundamental resolution we need a framework for guests to query
snapshots
and to mount them as writable snapshots, but we just ignore the error in this patchset.Quoted 8 lines
Any feedback are appliciated.
---
Tomoki Sekiyama (11):
configure: Support configuring c++ compiler
Fix errors and warnings while compiling with c++ compilier Add a script to extract VSS SDK headers on POSIX system
qemu-ga: Add an configure option to specify path to Windows VSSSDK
Quoted 1 line
qemu-ga: Add Windows VSS provider to quiesce applications on
fsfreeze
Quoted 51 lines
qemu-ga: Add Windows VSS requester to quisce applications and
filesystems
qemu-ga: call Windows VSS requester in fsfreeze command handler
qemu-ga: install Windows VSS provider on `qemu-ga -s install'
qemu-ga: Add VSS provider .tlb file in the repository QMP/qemu-ga-client: make timeout longer for guest-fsfreeze-freeze
command
QMP/qmp.py: set locale for exceptions to display non-ascii messages
correctly.gitignore | 1 Makefile | 3 Makefile.objs | 2 QMP/qemu-ga-client | 4 QMP/qmp.py | 4 configure | 59 ++++ hmp.c | 2 hw/pci/pci.c | 2 qga/Makefile.objs | 7 qga/commands-win32.c | 74 ++++- qga/main.c | 41 +++ qga/vss-win32-provider.h | 26 ++ qga/vss-win32-provider/Makefile.objs | 25 ++ qga/vss-win32-provider/install.cpp | 494 +++++++++++++++++++++++++++++++ qga/vss-win32-provider/provider.cpp | 474 ++++++++++++++++++++++++++++++ qga/vss-win32-provider/qga-provider.def | 10 + qga/vss-win32-provider/qga-provider.idl | 20 + qga/vss-win32-provider/qga-provider.tlb | Bin qga/vss-win32-requester.cpp | 404 +++++++++++++++++++++++++ qga/vss-win32-requester.h | 31 ++ qga/vss-win32.h | 85 +++++ rules.mak | 9 + scripts/extract-vsssdk-headers | 25 ++ scripts/qapi.py | 9 + 24 files changed, 1796 insertions(+), 15 deletions(-) create mode 100644 qga/vss-win32-provider.h create mode 100644 qga/vss-win32-provider/Makefile.objs create mode 100644 qga/vss-win32-provider/install.cpp create mode 100644 qga/vss-win32-provider/provider.cpp create mode 100644 qga/vss-win32-provider/qga-provider.def create mode 100644 qga/vss-win32-provider/qga-provider.idl create mode 100644 qga/vss-win32-provider/qga-provider.tlb create mode 100644 qga/vss-win32-requester.cpp create mode 100644 qga/vss-win32-requester.h create mode 100644 qga/vss-win32.h create mode 100755 scripts/extract-vsssdk-headers
Quoted 8 lines · On Mon, 3 Jun 2013 09:12:55 +0000 Libaiqing <[email protected]> wrote:
Hi,
Thanks for your advice,it works well when using prefix=x86_64-w64-mingw32-. The dlls may download from here: http://qemu.weilnetz.de/w64/dll/.One more question:
Qemu-ga.exe can't run successfully under normal account which belongs to Administration group. Qemu-ga service can start successfully under this account after Administrator installed.
Quoted 7 lines
The output is:
1370307591.689600:critical:error opening path 1370307591.705200:critical:error opening channel 1370307591.720800:critical:failed to create guest agent channel 1370307591.736400:critical:failed to initialize guest agent channelCould you give me some advise to debug this problem ? I can provide more information if need.
Maybe it's because it needs admin permissions to open the virtio device.