Patchwork [RFC,03/10] qemu-ga: Add an configure option to specify path to Windows VSS SDK

login
register
mail settings
Submitter Tomoki Sekiyama
Date Feb. 14, 2013, 6:10 a.m.
Message ID <20130214061039.15062.65827.stgit@melchior2.sdl.hitachi.co.jp>
Download mbox | patch
Permalink /patch/220376/
State New
Headers show

Comments

Tomoki Sekiyama - Feb. 14, 2013, 6:10 a.m.
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

To cross-compilie using mingw32 for Linux, you need to setup the SDK on
Windows environments to extract headers. You can also use wine to run the
setup of SDK on Linux etc.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama.qu@hitachi.com>
---
 .gitignore |    1 +
 Makefile   |    1 +
 configure  |   41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+)
Paolo Bonzini - Feb. 14, 2013, 2:36 p.m.
Il 14/02/2013 07:10, Tomoki Sekiyama ha scritto:
> 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
> 
> To cross-compilie using mingw32 for Linux, you need to setup the SDK on
> Windows environments to extract headers. You can also use wine to run the
> setup of SDK on Linux etc.

You can also use msitools (https://live.gnome.org/msitools; right now
they are not packaged for any distro, but will be in Fedora soon):

-----
#! /bin/bash

# extract-vsssdk-headers
# Author: Paolo Bonzini <pbonzini@redhat.com>

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" setup.exe | 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
-----

Can you add this in scripts/extract-vsssdk-headers please?


>  ##########################################
> +# check if we have VSS SDK headers for win
> +
> +if test "$mingw32" = "yes" -a "$guest_agent" = "yes" ; then
> +  case "$vss_win32_sdk" in
> +    "")   vss_win32_include="" ;;
> +    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
> +          # handle path with spaces. So we copy the headers into ".sdk/sdk".
> +          vss_win32_include="-I$source_path/.sdk/vss"
> +          symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
> +	  ;;
> +    *)    vss_win32_include="-I$vss_win32_sdk"
> +  esac

Please also add support for these:

--with-vss-sdk=no and --without-vss-sdk to disable VSS

--with-vss-sdk (with no path) is the same as "--with-vss-sdk=", but
should fail if the program does not compile.

The default should be what you have now, i.e. test and proceed according
to the result.

> +  cat > $TMPC << EOF
> +#define __MIDL_user_allocate_free_DEFINED__
> +#include <inc/win2003/vss.h>
> +int main(void) { return VSS_CTX_BACKUP; }
> +EOF
> +  if compile_prog "$vss_win32_include" "" ; then
> +    guest_agent_with_vss="yes"
> +    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
> +    libs_qga="-lole32 -loleaut32 -lshlwapi -luuid -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
> +  else
> +    if test "$vss_win32_sdk" != "" ; then
> +      echo "ERROR: Please download and install Microsoft VSS SDK from"
> +      echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"

Please add a note here detailing how to extract the headers on POSIX
systems.

Paolo

> +      feature_not_found "VSS support"
> +    fi
> +    guest_agent_with_vss="no"
> +  fi
> +fi
> +
> +##########################################
>  
>  ##########################################
>  # check if we have fdatasync
> @@ -3343,6 +3380,7 @@ echo "usb net redir     $usb_redir"
>  echo "OpenGL support    $opengl"
>  echo "libiscsi support  $libiscsi"
>  echo "build guest agent $guest_agent"
> +echo "QGA VSS support   $guest_agent_with_vss"
>  echo "seccomp support   $seccomp"
>  echo "coroutine backend $coroutine_backend"
>  echo "GlusterFS support $glusterfs"
> @@ -3404,6 +3442,9 @@ if test "$mingw32" = "yes" ; then
>    version_micro=0
>    echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
>    echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
> +  if test "$guest_agent_with_vss" = "yes" ; then
> +    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
> +  fi
>  else
>    echo "CONFIG_POSIX=y" >> $config_host_mak
>  fi
> 
> 
>
Michael Roth - Feb. 15, 2013, 12:47 a.m.
On Thu, Feb 14, 2013 at 03:10:39PM +0900, Tomoki Sekiyama wrote:
> 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
> 
> To cross-compilie using mingw32 for Linux, you need to setup the SDK on
> Windows environments to extract headers. You can also use wine to run the
> setup of SDK on Linux etc.
> 
> Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama.qu@hitachi.com>
> ---
>  .gitignore |    1 +
>  Makefile   |    1 +
>  configure  |   41 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 43 insertions(+)
> 
> diff --git a/.gitignore b/.gitignore
> index 53fe9c3..3f450e8 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -77,6 +77,7 @@ fsdev/virtfs-proxy-helper.pod
>  *.la
>  *.pc
>  .libs
> +.sdk
>  *.swp
>  *.orig
>  .pc
> diff --git a/Makefile b/Makefile
> index 0d9099a..fab664f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -252,6 +252,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
> 
>  KEYMAPS=da     en-gb  et  fr     fr-ch  is  lt  modifiers  no  pt-br  sv \
> diff --git a/configure b/configure
> index e279263..da49c52 100755
> --- a/configure
> +++ b/configure
> @@ -220,6 +220,8 @@ usb_redir=""
>  opengl=""
>  zlib="yes"
>  guest_agent="yes"
> +guest_agent_with_vss="no"
> +vss_win32_sdk=""
>  want_tools="yes"
>  libiscsi=""
>  coroutine=""
> @@ -884,6 +886,8 @@ for opt do
>    ;;
>    --disable-guest-agent) guest_agent="no"
>    ;;
> +  --with-vss-sdk=*) vss_win32_sdk="$optarg"
> +  ;;
>    --enable-tools) want_tools="yes"
>    ;;
>    --disable-tools) want_tools="no"
> @@ -1142,6 +1146,7 @@ echo "  --disable-usb-redir      disable usb network redirection support"
>  echo "  --enable-usb-redir       enable usb network redirection support"
>  echo "  --disable-guest-agent    disable building of the QEMU Guest Agent"
>  echo "  --enable-guest-agent     enable building of the QEMU Guest Agent"
> +echo "  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent"
>  echo "  --disable-seccomp        disable seccomp support"
>  echo "  --enable-seccomp         enables seccomp support"
>  echo "  --with-coroutine=BACKEND coroutine backend. Supported options:"
> @@ -2897,6 +2902,38 @@ if test "$usb_redir" != "no" ; then
>  fi
> 
>  ##########################################
> +# check if we have VSS SDK headers for win
> +
> +if test "$mingw32" = "yes" -a "$guest_agent" = "yes" ; then
> +  case "$vss_win32_sdk" in
> +    "")   vss_win32_include="" ;;
> +    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
> +          # handle path with spaces. So we copy the headers into ".sdk/sdk".
> +          vss_win32_include="-I$source_path/.sdk/vss"
> +          symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
> +	  ;;
> +    *)    vss_win32_include="-I$vss_win32_sdk"
> +  esac
> +  cat > $TMPC << EOF
> +#define __MIDL_user_allocate_free_DEFINED__
> +#include <inc/win2003/vss.h>
> +int main(void) { return VSS_CTX_BACKUP; }
> +EOF

Hi Tomoki,

Did you happen to run into this issue compiling the test program?

[mdroth@vm qemu-build]$ ls ~/w/vsssdk/inc/win2003/
vdslun.h    vsbackup.h    vscoordint.idl  vsmgmt.idl  vsprov.idl
vss.idl    vsswprv.idl
vdslun.idl  vscoordint.h  vsmgmt.h        vsprov.h    vss.h
vsswprv.h  vswriter.h
[mdroth@vm qemu-build]$ cat test.c 
#define __MIDL_user_allocate_free_DEFINED__
#include <inc/win2003/vss.h>
int main(void) { return VSS_CTX_BACKUP; }
[mdroth@vm qemu-build]$ gcc -I ~/w/vsssdk/ -o test test.c
In file included from test.c:2:0:
/home/mdroth/w/vsssdk/inc/win2003/vss.h:25:17: fatal error: rpc.h: No
such file or directory
compilation terminated.

I can't seem to locate any mingw or microsoft package that provides that.
It's also not present anywhere on the Wine filesystem I installed the
VSS SDK to.

> +  if compile_prog "$vss_win32_include" "" ; then
> +    guest_agent_with_vss="yes"
> +    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
> +    libs_qga="-lole32 -loleaut32 -lshlwapi -luuid -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
> +  else
> +    if test "$vss_win32_sdk" != "" ; then
> +      echo "ERROR: Please download and install Microsoft VSS SDK from"
> +      echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
> +      feature_not_found "VSS support"
> +    fi
> +    guest_agent_with_vss="no"
> +  fi
> +fi
> +
> +##########################################
> 
>  ##########################################
>  # check if we have fdatasync
> @@ -3343,6 +3380,7 @@ echo "usb net redir     $usb_redir"
>  echo "OpenGL support    $opengl"
>  echo "libiscsi support  $libiscsi"
>  echo "build guest agent $guest_agent"
> +echo "QGA VSS support   $guest_agent_with_vss"
>  echo "seccomp support   $seccomp"
>  echo "coroutine backend $coroutine_backend"
>  echo "GlusterFS support $glusterfs"
> @@ -3404,6 +3442,9 @@ if test "$mingw32" = "yes" ; then
>    version_micro=0
>    echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
>    echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
> +  if test "$guest_agent_with_vss" = "yes" ; then
> +    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
> +  fi
>  else
>    echo "CONFIG_POSIX=y" >> $config_host_mak
>  fi
>
Tomoki Sekiyama - Feb. 15, 2013, 3:55 a.m.
On 2013/02/15 9:47, mdroth wrote:
[...]
>
> Hi Tomoki,

Hi,

> Did you happen to run into this issue compiling the test program?
>
> [mdroth@vm qemu-build]$ ls ~/w/vsssdk/inc/win2003/
> vdslun.h    vsbackup.h    vscoordint.idl  vsmgmt.idl  vsprov.idl
> vss.idl    vsswprv.idl
> vdslun.idl  vscoordint.h  vsmgmt.h        vsprov.h    vss.h
> vsswprv.h  vswriter.h
> [mdroth@vm qemu-build]$ cat test.c
> #define __MIDL_user_allocate_free_DEFINED__
> #include <inc/win2003/vss.h>
> int main(void) { return VSS_CTX_BACKUP; }
> [mdroth@vm qemu-build]$ gcc -I ~/w/vsssdk/ -o test test.c
> In file included from test.c:2:0:
> /home/mdroth/w/vsssdk/inc/win2003/vss.h:25:17: fatal error: rpc.h: No
> such file or directory
> compilation terminated.
>
> I can't seem to locate any mingw or microsoft package that provides that.
> It's also not present anywhere on the Wine filesystem I installed the
> VSS SDK to.
>

Hmm, I haven't seen this yet.
I am testing this on Fedora 18 x86_64 host, and it provides package
"mingw32-headers.noarch" or "mingw64-headers.noarch" which contains
the rpc.h
(filepath is /usr/x86_64-w64-mingw32/sys-root/mingw/include/rpc.h )
Tomoki Sekiyama - Feb. 15, 2013, 3:56 a.m.
Hi Paolo,

On 2013/02/14 23:36, Paolo Bonzini wrote:
> Il 14/02/2013 07:10, Tomoki Sekiyama ha scritto:
>> 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
>>
>> To cross-compilie using mingw32 for Linux, you need to setup the SDK on
>> Windows environments to extract headers. You can also use wine to run the
>> setup of SDK on Linux etc.
> 
> You can also use msitools (https://live.gnome.org/msitools; right now
> they are not packaged for any distro, but will be in Fedora soon):
> 
> -----
> #! /bin/bash
> 
> # extract-vsssdk-headers
> # Author: Paolo Bonzini <pbonzini@redhat.com>
> 
> 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" setup.exe | 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
> -----
> 
> Can you add this in scripts/extract-vsssdk-headers please?

Thank you for the code (tricky!), I will add this.

>>  ##########################################
>> +# check if we have VSS SDK headers for win
>> +
>> +if test "$mingw32" = "yes" -a "$guest_agent" = "yes" ; then
>> +  case "$vss_win32_sdk" in
>> +    "")   vss_win32_include="" ;;
>> +    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
>> +          # handle path with spaces. So we copy the headers into ".sdk/sdk".
>> +          vss_win32_include="-I$source_path/.sdk/vss"
>> +          symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
>> +	  ;;
>> +    *)    vss_win32_include="-I$vss_win32_sdk"
>> +  esac
> 
> Please also add support for these:
> 
> --with-vss-sdk=no and --without-vss-sdk to disable VSS
> 
> --with-vss-sdk (with no path) is the same as "--with-vss-sdk=", but
> should fail if the program does not compile.
> 
> The default should be what you have now, i.e. test and proceed according
> to the result.

I see.

>> +  cat > $TMPC << EOF
>> +#define __MIDL_user_allocate_free_DEFINED__
>> +#include <inc/win2003/vss.h>
>> +int main(void) { return VSS_CTX_BACKUP; }
>> +EOF
>> +  if compile_prog "$vss_win32_include" "" ; then
>> +    guest_agent_with_vss="yes"
>> +    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
>> +    libs_qga="-lole32 -loleaut32 -lshlwapi -luuid -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
>> +  else
>> +    if test "$vss_win32_sdk" != "" ; then
>> +      echo "ERROR: Please download and install Microsoft VSS SDK from"
>> +      echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
> 
> Please add a note here detailing how to extract the headers on POSIX
> systems.

OK, thanks again.

> Paolo
> 
>> +      feature_not_found "VSS support"
>> +    fi
>> +    guest_agent_with_vss="no"
>> +  fi
>> +fi
>> +
>> +##########################################
>>  
>>  ##########################################
>>  # check if we have fdatasync
>> @@ -3343,6 +3380,7 @@ echo "usb net redir     $usb_redir"
>>  echo "OpenGL support    $opengl"
>>  echo "libiscsi support  $libiscsi"
>>  echo "build guest agent $guest_agent"
>> +echo "QGA VSS support   $guest_agent_with_vss"
>>  echo "seccomp support   $seccomp"
>>  echo "coroutine backend $coroutine_backend"
>>  echo "GlusterFS support $glusterfs"
>> @@ -3404,6 +3442,9 @@ if test "$mingw32" = "yes" ; then
>>    version_micro=0
>>    echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
>>    echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
>> +  if test "$guest_agent_with_vss" = "yes" ; then
>> +    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
>> +  fi
>>  else
>>    echo "CONFIG_POSIX=y" >> $config_host_mak
>>  fi
>>
>>
>>
Michael Roth - Feb. 19, 2013, 12:15 a.m.
On Fri, Feb 15, 2013 at 12:55:49PM +0900, Tomoki Sekiyama wrote:
> On 2013/02/15 9:47, mdroth wrote:
> [...]
> >
> > Hi Tomoki,
> 
> Hi,
> 
> > Did you happen to run into this issue compiling the test program?
> >
> > [mdroth@vm qemu-build]$ ls ~/w/vsssdk/inc/win2003/
> > vdslun.h    vsbackup.h    vscoordint.idl  vsmgmt.idl  vsprov.idl
> > vss.idl    vsswprv.idl
> > vdslun.idl  vscoordint.h  vsmgmt.h        vsprov.h    vss.h
> > vsswprv.h  vswriter.h
> > [mdroth@vm qemu-build]$ cat test.c
> > #define __MIDL_user_allocate_free_DEFINED__
> > #include <inc/win2003/vss.h>
> > int main(void) { return VSS_CTX_BACKUP; }
> > [mdroth@vm qemu-build]$ gcc -I ~/w/vsssdk/ -o test test.c
> > In file included from test.c:2:0:
> > /home/mdroth/w/vsssdk/inc/win2003/vss.h:25:17: fatal error: rpc.h: No
> > such file or directory
> > compilation terminated.
> >
> > I can't seem to locate any mingw or microsoft package that provides that.
> > It's also not present anywhere on the Wine filesystem I installed the
> > VSS SDK to.
> >
> 
> Hmm, I haven't seen this yet.
> I am testing this on Fedora 18 x86_64 host, and it provides package
> "mingw32-headers.noarch" or "mingw64-headers.noarch" which contains
> the rpc.h
> (filepath is /usr/x86_64-w64-mingw32/sys-root/mingw/include/rpc.h )

Thanks. I actually did have that header, but I was doing something silly
(forgot to use cross-compiler for the test program). The configure issue
I was hitting was also an error on my part (options with "~" weren't
resolving to my home dir). I did end up missing ntverp.h however in
vss-win32.h using Fedora 15. I made some progress trying the build
without it however. Can you confirm all the headers in vss-win32.h are
needed? I went ahead and put together an FC18 environment, but would be
nice if we can get this building for older environments (if possible).

> 
> -- 
> Tomoki Sekiyama <tomoki.sekiyama.qu@hitachi.com>
> Linux Technology Center
> Hitachi, Ltd., Yokohama Research Laboratory
>
Tomoki Sekiyama - Feb. 20, 2013, 8:16 a.m.
On 2013/02/19 9:15, mdroth wrote:
> On Fri, Feb 15, 2013 at 12:55:49PM +0900, Tomoki Sekiyama wrote:
>> On 2013/02/15 9:47, mdroth wrote:
>> [...]
>>>
>>> Hi Tomoki,
>>
>> Hi,
>>
>>> Did you happen to run into this issue compiling the test program?
>>>
>>> [mdroth@vm qemu-build]$ ls ~/w/vsssdk/inc/win2003/
>>> vdslun.h    vsbackup.h    vscoordint.idl  vsmgmt.idl  vsprov.idl
>>> vss.idl    vsswprv.idl
>>> vdslun.idl  vscoordint.h  vsmgmt.h        vsprov.h    vss.h
>>> vsswprv.h  vswriter.h
>>> [mdroth@vm qemu-build]$ cat test.c
>>> #define __MIDL_user_allocate_free_DEFINED__
>>> #include <inc/win2003/vss.h>
>>> int main(void) { return VSS_CTX_BACKUP; }
>>> [mdroth@vm qemu-build]$ gcc -I ~/w/vsssdk/ -o test test.c
>>> In file included from test.c:2:0:
>>> /home/mdroth/w/vsssdk/inc/win2003/vss.h:25:17: fatal error: rpc.h: No
>>> such file or directory
>>> compilation terminated.
>>>
>>> I can't seem to locate any mingw or microsoft package that provides that.
>>> It's also not present anywhere on the Wine filesystem I installed the
>>> VSS SDK to.
>>>
>>
>> Hmm, I haven't seen this yet.
>> I am testing this on Fedora 18 x86_64 host, and it provides package
>> "mingw32-headers.noarch" or "mingw64-headers.noarch" which contains
>> the rpc.h
>> (filepath is /usr/x86_64-w64-mingw32/sys-root/mingw/include/rpc.h )
> 
> Thanks. I actually did have that header, but I was doing something silly
> (forgot to use cross-compiler for the test program). The configure issue
> I was hitting was also an error on my part (options with "~" weren't
> resolving to my home dir). I did end up missing ntverp.h however in
> vss-win32.h using Fedora 15. I made some progress trying the build
> without it however. Can you confirm all the headers in vss-win32.h are
> needed? 

Some of headers in vss-win32.h (nterp,h, rpc.h, rpcndr.h, etc) seems
needed to build qemu-ga.exe in a native build environment(mingw on Windows).
In my Fedora 18 environment, these don't cause errors, but it also
succeeded to build even without the headers.

> I went ahead and put together an FC18 environment, but would be
> nice if we can get this building for older environments (if possible).

I will try this with some of my old VMs and investigate which headers
are really needed.

Thanks,

Patch

diff --git a/.gitignore b/.gitignore
index 53fe9c3..3f450e8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -77,6 +77,7 @@  fsdev/virtfs-proxy-helper.pod
 *.la
 *.pc
 .libs
+.sdk
 *.swp
 *.orig
 .pc
diff --git a/Makefile b/Makefile
index 0d9099a..fab664f 100644
--- a/Makefile
+++ b/Makefile
@@ -252,6 +252,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
 
 KEYMAPS=da     en-gb  et  fr     fr-ch  is  lt  modifiers  no  pt-br  sv \
diff --git a/configure b/configure
index e279263..da49c52 100755
--- a/configure
+++ b/configure
@@ -220,6 +220,8 @@  usb_redir=""
 opengl=""
 zlib="yes"
 guest_agent="yes"
+guest_agent_with_vss="no"
+vss_win32_sdk=""
 want_tools="yes"
 libiscsi=""
 coroutine=""
@@ -884,6 +886,8 @@  for opt do
   ;;
   --disable-guest-agent) guest_agent="no"
   ;;
+  --with-vss-sdk=*) vss_win32_sdk="$optarg"
+  ;;
   --enable-tools) want_tools="yes"
   ;;
   --disable-tools) want_tools="no"
@@ -1142,6 +1146,7 @@  echo "  --disable-usb-redir      disable usb network redirection support"
 echo "  --enable-usb-redir       enable usb network redirection support"
 echo "  --disable-guest-agent    disable building of the QEMU Guest Agent"
 echo "  --enable-guest-agent     enable building of the QEMU Guest Agent"
+echo "  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent"
 echo "  --disable-seccomp        disable seccomp support"
 echo "  --enable-seccomp         enables seccomp support"
 echo "  --with-coroutine=BACKEND coroutine backend. Supported options:"
@@ -2897,6 +2902,38 @@  if test "$usb_redir" != "no" ; then
 fi
 
 ##########################################
+# check if we have VSS SDK headers for win
+
+if test "$mingw32" = "yes" -a "$guest_agent" = "yes" ; then
+  case "$vss_win32_sdk" in
+    "")   vss_win32_include="" ;;
+    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
+          # handle path with spaces. So we copy the headers into ".sdk/sdk".
+          vss_win32_include="-I$source_path/.sdk/vss"
+          symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
+	  ;;
+    *)    vss_win32_include="-I$vss_win32_sdk"
+  esac
+  cat > $TMPC << EOF
+#define __MIDL_user_allocate_free_DEFINED__
+#include <inc/win2003/vss.h>
+int main(void) { return VSS_CTX_BACKUP; }
+EOF
+  if compile_prog "$vss_win32_include" "" ; then
+    guest_agent_with_vss="yes"
+    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
+    libs_qga="-lole32 -loleaut32 -lshlwapi -luuid -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
+  else
+    if test "$vss_win32_sdk" != "" ; then
+      echo "ERROR: Please download and install Microsoft VSS SDK from"
+      echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
+      feature_not_found "VSS support"
+    fi
+    guest_agent_with_vss="no"
+  fi
+fi
+
+##########################################
 
 ##########################################
 # check if we have fdatasync
@@ -3343,6 +3380,7 @@  echo "usb net redir     $usb_redir"
 echo "OpenGL support    $opengl"
 echo "libiscsi support  $libiscsi"
 echo "build guest agent $guest_agent"
+echo "QGA VSS support   $guest_agent_with_vss"
 echo "seccomp support   $seccomp"
 echo "coroutine backend $coroutine_backend"
 echo "GlusterFS support $glusterfs"
@@ -3404,6 +3442,9 @@  if test "$mingw32" = "yes" ; then
   version_micro=0
   echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
   echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
+  if test "$guest_agent_with_vss" = "yes" ; then
+    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
+  fi
 else
   echo "CONFIG_POSIX=y" >> $config_host_mak
 fi