Skip to content

QEMU Guest Agent for Windows Build Environment

Daniel Gonzalez Marx edited this page Aug 22, 2018 · 1 revision

QEMU Guest Agent for Windows Build Environment

Using premade environment

This tutorial will explain how to use rebuild to create the build environment for QEMU guest agent (qemu-ga) for Windows virtual machines. To only use the build environment you can skip it and use the premade environment on dockerhub with only few simple steps (you might want to read how to use it in 'running an example' below):

rbld search
rbld deploy qemu-ga-win:v003 # replace v003 with latest version found
rbld run qemu-ga-win:v003

Setting up the environment

First, we will create a rebuild environment based on the latest stable version of Fedora (at the time of writing, Fedora 28):

rbld create --base fedora qemu-ga-win

Let's check that the process succeeded by listing the rebuild environments:

 rbld list

which should show

qemu-ga-win:initial

Now we will install the needed dependencies, we can do this through the interactive mode:

rbld modify qemu-ga-win:initial

We should now see something like this:

myuser@qemu-ga-win-initial-M ~]$

Now we have an interactive shell of the environment and can update the pre-installed packages and install dependencies for our build environment:

sudo dnf update -y
sudo dnf install -y git glib2-devel libfdt-devel pixman-devel zlib-devel \
python gcc findutils make msitools \
mingw*-glib2 mingw*-pixman mingw*-gmp mingw*-SDL2 mingw*-pkg-config \
mingw*-glib2-static mingw*-zlib-static \
mingw*-winpthreads-static mingw*-pcre-static \
flex bison

If you want to build for 32-bit machines only, you can replace mingw* with mingw32 (or mingw64 for 64-bit machines, equivalently). That's it! You now have an environment on which to build qemu and compile qemu-ga, so let's save it. First exit the interactive shell with CTRL-D. Then by using the following commands you commit the changes and (optionally) delete the initial environment:

rbld commit qemu-ga-win:initial --tag v003
rbld rm qemu-ga-win:initial

Running an example

Once you have the environment image, either by creating it yourself or deploying it from dockerhub, you can follow these steps to compile qemu-ga for Windows. (If you deployed the image from dockerhub, a script to automate the process can be found in /opt/setup-qemu-ga-win.sh within the container. Copy it to a folder for which you don't need sudo rights and take ownership of it first.)

First, check that you have the image available on your machine and run it by using:

rbld list
rbld run qemu-ga-win:v003

Within the container you can now download the latest version of qemu:

# clone qemu repository
git clone https://github.com/qemu/qemu.git

If you need them, download the VSS SDK from Microsoft's Download Center:

cd qemu
curl -o VSS_SDK_7.2_setup.exe https://download.microsoft.com/download/9/4/c/94c588cf-8176-4bdb-9d55-2597c76043c6/setup.exe
scripts/extract-vsssdk-headers  VSS_SDK_7.2_setup.exe

Which creates a folder named inc within the qemu directory and saves the VSS SDK there.

You can now compile qemu-ga eg for a 64-bit Windows VM statically using from within the qemu directory:

./configure --disable-docs --target-list=x86_64-softmmu --cross-prefix=x86_64-w64-mingw32- --static --enable-guest-agent-msi --with-vss-sdk
make qemu-ga

If you saved the headers somewhere other than the qemu directory, point to it like:

--with-vss-sdk=/path/to/VSSSDK72

If you want to compile for a 32-bit machine after compiling for a 64-bit version one (or vice versa), you need to first run

make clean
rm qemu-ga.exe

from within the qemu directory. Else VSS support might get disabled when installing qemu-ga on the Windows guest.