Winodws版本

编译环境Fedora23

下载VSS SDK的setup.exe

下载地址

提取VSS SDK头文件

将下面的代码保存成extract-vsssdk-headers.sh脚本,然后放入setup.exe所在的/home/fedora/Downloads目录,然后执行./extract-vsssdk-headers.sh setup.exe

#! /bin/bash
# extract-vsssdk-headers
# Author: Paolo Bonzini <pbonzini@redhat.com> set -e
if test $# != 1 || ! test -f "$1"; then
echo 'Usage: extract-vsssdk-headers /path/to/setup.exe' >&2
exit 1
fi if ! command -v msiextract > /dev/null; then
echo 'msiextract not found. Please install msitools.' >&2
exit 1
fi if test -e inc; then
echo '"inc" already exists.' >&2
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')
tmpdir=$(mktemp -d)
trap 'rm -fr -- "$tmpdir" vsssdk.msi' EXIT HUP INT QUIT ALRM TERM
tail -c +$(($offset+1)) -- "$1" > vsssdk.msi # Now extract the files.
msiextract -C $tmpdir vsssdk.msi
mv "$tmpdir/Program Files/Microsoft/VSSSDK72/inc" inc
echo 'Extracted SDK headers into "inc" directory.'
exit 0

安装交叉编译依赖

下载qemu源文件

下载地址

安装依赖

  • 32位环境
[fedora@bogon ~]$ rpm -qa|grep mingw32
mingw32-gcc-c++-4.9.2-1.fc21.x86_64
mingw32-SDL-1.2.15-5.fc21.noarch
mingw32-termcap-1.3.1-17.fc21.noarch
mingw32-filesystem-100-1.fc21.noarch
mingw32-glib2-static-2.42.2-1.fc21.noarch
mingw32-winpthreads-4.0.1-1.fc21.noarch
mingw32-binutils-2.25-1.fc21.x86_64
mingw32-win-iconv-0.0.6-2.fc21.noarch
mingw32-gettext-0.18.3.2-2.fc21.noarch
mingw32-gmp-6.0.0-2.fc21.noarch
mingw32-zlib-static-1.2.8-3.fc21.noarch
mingw32-headers-4.0.1-1.fc21.noarch
mingw32-nsis-2.46-13.fc21.x86_64
mingw32-gcc-4.9.2-1.fc21.x86_64
mingw32-zlib-1.2.8-3.fc21.noarch
mingw32-winpthreads-static-4.0.1-1.fc21.noarch
mingw32-gettext-static-0.18.3.2-2.fc21.noarch
mingw32-cpp-4.9.2-1.fc21.x86_64
mingw32-libffi-3.0.13-5.fc21.noarch
mingw32-glib2-2.42.2-1.fc21.noarch
mingw32-crt-4.0.1-1.fc21.noarch
mingw32-pkg-config-0.28-4.fc21.x86_64
mingw32-pixman-0.32.6-1.fc21.noarch
  • 64位环境
[fedora@bogon ~]$ rpm -qa|grep mingw64
mingw64-binutils-2.25-1.fc21.x86_64
mingw64-glib2-2.42.2-1.fc21.noarch
mingw64-crt-4.0.1-1.fc21.noarch
mingw64-win-iconv-0.0.6-2.fc21.noarch
mingw64-gettext-static-0.18.3.2-2.fc21.noarch
mingw64-winpthreads-4.0.1-1.fc21.noarch
mingw64-gcc-4.9.2-1.fc21.x86_64
mingw64-termcap-1.3.1-17.fc21.noarch
mingw64-glib2-static-2.42.2-1.fc21.noarch
mingw64-headers-4.0.1-1.fc21.noarch
mingw64-gcc-c++-4.9.2-1.fc21.x86_64
mingw64-zlib-1.2.8-3.fc21.noarch
mingw64-gettext-0.18.3.2-2.fc21.noarch
mingw64-filesystem-100-1.fc21.noarch
mingw64-pkg-config-0.28-4.fc21.x86_64
mingw64-libffi-3.0.13-5.fc21.noarch
mingw64-zlib-static-1.2.8-3.fc21.noarch
mingw64-cpp-4.9.2-1.fc21.x86_64
mingw64-winpthreads-static-4.0.1-1.fc21.noarch

编译qemu-ga.exe

  • 32位编译指令
cd /home/fedora/Downloads/qemu-2.6.0 && ./configure --enable-guest-agent --cross-prefix=i686-w64-mingw32- --with-vss-sdk=/home/fedora/Downloads && make msi
  • 64位编译指令
cd /home/fedora/Downloads/qemu-2.6.0 && ./configure --enable-guest-agent --cross-prefix=x86_64-w64-mingw32- --with-vss-sdk=/home/fedora/Downloads && make msi

修改虚拟机配置

使用virsh edit 域名编辑配置文件,添加如下内容

<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/f16x86_64.agent'/>
<target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>

其中path对应的是主机上的文件,虚拟机启动时候自动创建,用于和虚拟机进行通信,文件名不能和其他虚拟机重复,但name为固定值不能修改

安装qemu-ga.exe

qemu-ga.exe只能安装到win7以上版本

标准方法

直接双击msi完成安装

手动手法
  • 安装virtio
  • 在虚拟机中创建C:\Program Files\QEMU\run目录
  • 拷贝qemu-ga.exeqga-vss.dllqga-vss.tlb文件到run目录
  • 使用管理员身份在run启动一个控制台,执行qemu-ga.exe –l "C:\Program Files\QEMU\run\log.txt" –s install命令,出现如下字样表示成功
Registering QEMU Guest Agent VSS Provider:
C:\Program Files\QEMU\run\qga-vss.dll
C:\Program Files\QEMU\run\qga-vss.tlb
Service was installed successfully
  • 执行net start qemu-ga启动服务,出现如下字样表示成功
QEMU Guest Agent 服务正在启动.
QEMU Guest Agent 服务已经启动成功.

Linux版本

编译环境Fedora23

下载qemu源文件

下载地址

编译qemu-ga

cd /home/fedora/Downloads/qemu-2.6.0 && ./configure --enable-guest-agent && make qemu-ga

修改虚拟机配置

使用virsh edit 域名编辑配置文件,添加如下内容

<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/f16x86_64.agent'/>
<target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>

其中path对应的是主机上的文件,虚拟机启动时候自动创建,用于和虚拟机进行通信,文件名不能和其他虚拟机重复,但name为固定值不能修改

安装qemu-ga

以下操作在虚拟机中执行

  • 安装virtio
  • 拷贝qemu-ga/usr/bin目录
  • 拷贝/home/fedora/Downloads/qemu-2.6.0/scripts/qemu-guest-agent/目录下的fsfreeze-hook文件和fsfreeze-hook.d目录到/usr/libexec/qemu-ga/目录
  • 将下面内容保存为qemu-ga文件,并放入/etc/sysconfig/目录
# Transport method may be one of following:
# * unix-listen
# * virtio-serial
# * isa-serial
# Default: virtio-serial
TRANSPORT_METHOD="virtio-serial" # You also can override the device/socket path
# Default: /dev/virtio-ports/org.qemu.guest_agent.0
DEVPATH="/dev/virtio-ports/org.qemu.guest_agent.0" # If logfile is unset it defaults to stderr but the daemon
# function of init script redirects stderr to /dev/null
LOGFILE="/var/log/qemu-ga/qemu-ga.log" # Override pidfile name
# Default: /var/run/qemu-ga.pid
PIDFILE="/var/run/qemu-ga.pid" # SELinux note:
# About guest arbitrary file read/write
#
# A new selinux policy is introduced on RHEL-6.4 to deny qemu-ga to
# read/write arbitrary guest files except the device file used to talk
# with host processes, LOGFILE and PIDFILE.
#
# You can disable this policy by "restorecon -R -v /usr/bin/qemu-ga" # Comma-separated blacklist of RPCs to disable or empty list to enable all
# Tip: You can get the list of RPC commands using `qemu-ga --blacklist ?`
# Default: blank list to enable all RPCs
# Note: There should be no spaces between commas and commands in the blacklist
BLACKLIST_RPC="guest-file-open,guest-file-close,guest-file-read,guest-file-write,guest-file-seek,guest-file-flush" # Enable fsfreeze hook. See the --fsfreeze-hook option in "qemu-ga --help".
FSFREEZE_HOOK_ENABLE=0 # Set the option argument for --fsfreeze-hook, which is the full pathname of
# the hook script. An empty or unset value designates the default script
# (invoke "qemu-ga --help" to interrogate).
#
# This setting (independently of value) takes effect only when
# FSFREEZE_HOOK_ENABLE is nonzero.
FSFREEZE_HOOK_PATHNAME=/usr/libexec/qemu-ga/fsfreeze-hook
  • 将下面内容保存为qemu-ga文件,并放入/etc/rc.d/init.d/目录
#! /bin/sh
#
# qemu-ga Start/Stop qemu-ga daemon
#
# chkconfig: 345 30 30
# description: qemu guest agent daemon
# processname: qemu-ga # Source function library.
. /etc/init.d/functions # Check that we're a privileged user
[ `id -u` = 0 ] || exit 4 [ -f /etc/sysconfig/qemu-ga ] && . /etc/sysconfig/qemu-ga prog="qemu-ga" RETVAL=0
lockfile=/var/lock/subsys/$prog start() { # Check if binary is installed & executable
[ -f /usr/bin/$prog ] && [ -x /usr/bin/$prog ] || exit 5 # Check the device/path exists
[ -n "$DEVPATH" ] && [ -e "$DEVPATH" ] || exit 6 echo -n $"Starting $prog: "
ARGS="--daemonize"
[ ! -z "$TRANSPORT_METHOD" ] && ARGS="$ARGS --method $TRANSPORT_METHOD"
[ ! -z "$DEVPATH" ] && ARGS="$ARGS --path $DEVPATH"
[ ! -z "$LOGFILE" ] && ARGS="$ARGS --logfile $LOGFILE"
[ ! -z "$PIDFILE" ] && ARGS="$ARGS --pidfile $PIDFILE"
[ ! -z "$BLACKLIST_RPC" ] && ARGS="$ARGS --blacklist $BLACKLIST_RPC" if [ "$FSFREEZE_HOOK_ENABLE" -ne 0 ] 2>/dev/null; then
ARGS="$ARGS --fsfreeze-hook"
if [ -n "$FSFREEZE_HOOK_PATHNAME" ]; then
ARGS="$ARGS=$FSFREEZE_HOOK_PATHNAME"
fi
fi daemon /usr/bin/$prog $ARGS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $lockfile
return $RETVAL
} stop() {
echo -n $"Stopping $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $lockfile
return $RETVAL
} restart() {
stop
start
} # See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $prog
;;
restart|reload|force-reload)
restart
;;
condrestart|try-restart)
[ -f $lockfile ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac exit $?
  • 执行service qemu-ga start命令启动服务
  • 执行chkconfig qemu-ga on命令设置开机启动

Solaris版本

编译环境Solaris 10

下载qemu源文件

下载地址

需要在solaris系统中进行解压缩,拷贝进去会出现文件名全部变成小写的情况

设置编译环境

步骤 说明 命令
安装pkgutil 一种自动化安装工具,类似CentOS的yum pkgadd -d http://get.opencsw.org/now
设置bash环境 自动tab补齐 编辑/etc/passwdroot用户的/sbin/sh/bin/bash
设置编译bash环境 configure使用的bash 将系统自带的/usr/bin/sh保存为/usr/bin/sh.bak,然后建立/usr/bin/sh软链接到/usr/bin/bash
扩展PATH路径 设置pkgutil的可执行路径 拷贝/etc/skel/local.profile/.profile,然后修改PATH=/usr/bin:/usr/local/bin:/usr/ucb:/etc:/usr/sbin:/opt/csw/bin:/usr/ccs/bin:/usr/sfw/bin:.,最后添加export PS1='\u:\w#'
安装gcc 安装编译器 pkgutil -i gcc5core
安装glib 安装编译器 pkgutil -i glib2_devel_stub

编译qemu-ga

./configure --cc=gcc --install=/usr/ucb/install --target-list= --cpu= --enable-guest-agent --without-pixman --disable-tools --disable-system --disable-fdt && gmake qemu-ga

测试

在主机上执行virsh qemu-agent-command domain_name --cmd '{"execute":"guest-fsfreeze-status"}'命令测试虚拟机中的qemu-ga运行是否正常

调试

Winodws版本

  • 安装mingw32文件系统

    [fedora@fedora ~]$ sudo yum -y install mingw32-filesystem.noarch

  • 安装gdb

    [fedora@fedora ~]$ sudo yum -y install mingw32-gdb.noarch

  • /usr/i686-w64-mingw32/sys-root/mingw/bin/目录下提取gdb相关文件gdb.exe gdbserver.exe libexpat-1.dll zlib1.dll

  • 将gdb相关文件放入qemu-ga.exe所在目录

  • 到服务列表关闭已经启动的qemu相关服务,否则调试的时候会提示failed to initialize guest agent channel

  • 用管理员身份启动cmd,然后切换到qemu-ga.exe所在目录,使用gdb.exe qemu-ga.exe进行调试

  • 先执行run待程序能正常运行后使用ctrl+c暂停程序设置断点,由于没法加载源文件,只能去编译端查看要设置的断点位置,然后使用break filename:line的方式设置断点

  • 或者使用gdbserver.exe 0.0.0.0:2345 qemu-ga.exe开启远程调试,然后在编译端使用gdb qemu-ga.exe开启调试,然后使用target remote guest_ip:2345命令连接远程调试,这个的好处在于能加载编译端本地的源文件

交叉编译调试qemu_guest_agent的更多相关文章

  1. 01.ubuntu16.06编译安装Hi3518EV200 SDK

    转载,侵删 HI3518EV200 SDK安装并编译osdr. 1.开发环境 windows10电脑 + 虚拟机14 Pro + Ubuntu16.0.4 2.拷贝并解压.将 Hi3518E_SDK_ ...

  2. eclipse的C/C++开发搭建

    环境 宿主机:ubuntu 16.04 交叉编译:gcc-linaro-4.9-2014.11 ubuntu自带源 eclipse 安装(想使用新版直接跳过) 安装eclipse sudo apt-g ...

  3. codeblocks 配置交叉编译和调试环境

    我要用codeblocks交叉编译和调试arm开发板上的程序,宿主机是ubuntu12.04.开发板是嵌入式linux操作系统. 1.配置交叉编译环境 由上到下,1处直接选择即可.2处是你交叉编译器安 ...

  4. Linux下交叉编译gdb,gdbserver+gdb的使用以及通过gdb调试core文件

    交叉编译gdb和gdbserver 1.下载gdb:下载地址为:http://ftp.gnu.org/gnu/gdb/按照一般的想法,最新版本越好,因此下载7.2这个版本.当然,凡事无绝对.我们以gd ...

  5. 嵌入式arm-linux mips-linux 交叉编译GDB,结合vscode图形化调试使用,coredump定位段错误

    第一部分:使用GDB GDB源码下载路径:http://ftp.gnu.org/gnu/gdb/ 遇到的主要难点: 选择合适的GDB源码版本 我的mips-linux交叉编译器不支持C++11特性,所 ...

  6. linux应用调试技术之GDB和GDBServer

    1.调试原理 GDB调试是应用程序在开发板上运行,然后在PC机上对开发板上得应用程序进行调试,PC机运行GDB,开发板上运行GDBServer.在应用程序调试的时候,pc机上的gdb向开发板上的GDB ...

  7. Linux主机上使用交叉编译移植u-boot到树莓派

    0环境 Linux主机OS:Ubuntu14.04 64位,运行在wmware workstation 10虚拟机 树莓派版本:raspberry pi 2 B型. 树莓派OS: Debian Jes ...

  8. Linux 14.04lts 环境下搭建交叉编译环境arm-linux-gcc-4.5.1

    交叉编译工具链是为了编译.链接.处理和调试跨平台体系结构的程序代码,在该环境下编译出嵌入式Linux系统所需要的操作系统.应用程序等,然后再上传到目标板上. 首 先要明确gcc 和arm-linux- ...

  9. Windows7 64位系统搭建Cocos2d-x-2.2.1最新版以及Android交叉编译环境(详细教程)

    Windows7 64位系统搭建Cocos2d-x-2.2.1最新版以及Android交叉编译环境(详细教程) 声明:本教程在参考了以下博文,并经过自己的摸索后实际操作得出,本教程系本人原创,由于升级 ...

随机推荐

  1. d3 - bar chart

    用 D3.js 做一个简单的柱形图. 做柱形图有很多种方法,比如用 HTML 的 div 标签,或用 svg . 推荐用 SVG 来做各种图形.SVG 意为可缩放矢量图形(Scalable Vecto ...

  2. linux c编程:文件的操作

    在Linux系统中,系统是通过inode来获得这个文件的信息.在Linux系统中,inode的信息都是封装在stat这个结构体中.可以通过man 2 stat来查看stat的具体结构.从中可以看到包含 ...

  3. Node.js学习笔记(1):Node.js快速开始

    Node.js学习笔记(1):Node.js快速开始 Node.js的安装 下载 官方网址:https://nodejs.org/en/ 说明: 在Windows上安装时务必选择全部组件,包括勾选Ad ...

  4. Android Weekly Notes Issue #316

    July 1st, 2018 Android Weekly Issue #316 本期内容包含教你使用Kotlin通过Annotation Processor生成代码文件, JetPack中的Andr ...

  5. linux系统调用mount全过程分析【转】

    本文转载自:https://blog.csdn.net/skyflying2012/article/details/9748133 系统调用本身是软中断,使用系统调用,内核也陷入内核态,异常处理,找到 ...

  6. ASP.NET 4.0 页面 ValidateRequest="false" 失效不起作用

    当ASP.NET 2.0升级到 ASP.NET 4.0后,页面的 ValidateRequest="false" 不起作用. 因为 ASP.NET 4.0 请求验证被提前到IHtt ...

  7. Contiki进程间的交互

    之前都是从各个模块开始看起,从底层开始看起.应该改变一下思路,从高往下看,站得高看得远. 一.Main函数 源码:contiki-release-2-7\platform\stm32test\cont ...

  8. 左侧浮动html网页模板

    左侧浮动html网页模板是一款左侧导航菜单随网页滚动的html网站模板. 地址:http://www.huiyi8.com/sc/10617.html

  9. memcached高可用

    http://sourceforge.net/projects/repcached/ memcached-1.2.8-repcached-2.2.tar.gz tar zxvf memcached-1 ...

  10. L90

    On Motes and Beams 微尘与栋梁 It is curious that our own offenses should seem so much less heinous than t ...