windows安装qemu-ga

虚拟机配置里添加virtio serial端口

#virsh edit instance-name

devices里添加下面这段配置,

1 <channel type='unix'>
2 <source mode='bind' path='/var/lib/libvirt/qemu/org.qemu.guest_agent.0.instance-name.sock'/>
3 <target type='virtio' name='org.qemu.guest_agent.0'/>
4 <address type='virtio-serial' controller='0' bus='0' port='1'/>
5 </channel>

安装Qemu Guest Agent服务

#wget https://fedorapeople.org/groups/virt/virtio-win/virtio-win.repo -O /etc/yum.repos.d/virtio-win.repo

#yum install virtio-win

安装virtio-win包,virtio-win里包含windows virtio设备驱动,及qemu-ga的安装包。

将msi安装文件和virtio-win.iso拷贝到windows下。

virtio-win.iso包含各个windows版本下的virtio serial驱动,安装对应版本的驱动。

安装对应版本qemu-ga.msi,至此,qga安装完毕。

qga功能扩展

搭建编译环境:

添加功能示例(添加内存使用率检测)

编辑qapi-schema.json,添加自定义结构体及命令声明。

 1     ##  结构体声明
2 # @GuestMemInfo
3 #
4 # Information about Memory usage.
5 #
6 # @total: total size of Memory
7 #
8 # @usage: Memory usage
9 #
10 # Since 2.6
11 ##
12 { 'struct': 'GuestMemInfo',
13 'data': { 'total': 'int', 'usage': 'int' } }
14
15 ## 命令声明
16 # @guest-get-mem-usage:
17 #
18 # Get the memory utilization rate.
19 #
20 # Returns: @GuestMemInfo on success.
21 #
22 # Since 2.6
23 ##
24 { 'command': 'guest-get-mem-usage',
25 'returns': 'GuestMemInfo' }

在commands-win32.c中添加命令实现:

1 GuestMemInfo *qmp_guest_get_mem_usage(Error **errp)
2 {
3 MEMORYSTATUS ms;
4 GuestMemInfo *meminfo = g_new0(GuestMemInfo, 1);
5 GlobalMemoryStatus(&ms);
6 meminfo->usage = (int64_t)ms.dwMemoryLoad;
7 meminfo->total = (int64_t)ms.dwTotalPhys;
8 return meminfo;
9 }

  在commands-posix.c中添加命令实现(直接返回QERR_UNSUPPORTED错误):

1 GuestMemInfo *qmp_guest_get_mem_usage(Error **errp)
2 {
3 error_setg(errp, QERR_UNSUPPORTED);
4 }

重新编译qemu-ga.exe,替换C:\Program Files\qemu-ga下的qemu-ga.exe,重启服务即可。

(dll依赖,在/usr/x86_64-w64-mingw32/sys-root/mingw/bin/下可找到。)

参考文献:

http://wiki.qemu.org/Features/QAPI/GuestAgent

http://wiki.libvirt.org/page/Qemu_guest_agent

http://fedoraproject.org/wiki/Windows_Virtio_Drivers

http://lists.gnu.org/archive/html/qemu-discuss/2014-11/msg00027.html

qemu-ga windows下的安装及监控开发的更多相关文章

  1. Ruby入门--Linux/Windows下的安装、代码开发及Rails实战

    Ruby入门--Linux/Windows下的安装.代码开发及Rails实战 http://www.linuxidc.com/Linux/2014-04/100242.htm Ubuntu 13.04 ...

  2. Windows下快速安装CACTI流量监控

    Windows下快速安装CACTI流量监控 原文  http://os.51cto.com/art/201111/300977.htm CACTI是一套PHP程序,它利用SNMPGET采集数据,使用R ...

  3. flume 1.7在windows下的安装与运行

    flume 1.7在windows下的安装与运行 一.安装 安装java,配置环境变量. 安装flume,flume的官网http://flume.apache.org/,下载地址,下载后直接解压即可 ...

  4. memcache的windows下的安装和简单使用

    原文:memcache的windows下的安装和简单使用 memcache是为了解决网站访问量大,数据库压力倍增的解决方案之一,由于其简单实用,很多站点现在都在使用memcache,但是memcach ...

  5. Windows下pry安装和配置

    Windows下pry安装和配置 pry是一个增强型的交互式命令行工具,比irb强大. 有自动完成功能,自动缩进,有颜色.有更强大的调试功能. pry 安装很简单. 在终端输入: gem instal ...

  6. Windows下虚拟机安装Mac OS X ----- VM12安装Mac OS X 10.11

    Windows下虚拟机安装Mac OS X -– VM12安装Mac OS X 10.11 随着Iphone在国内大行其道,越来越多的开发者涌入iOS开发大军 中,但都苦于没有苹果机,本文即将介绍WI ...

  7. Windows下memcache安装使用

    Windows下Memcache安装 随着时间的推移,网上现在能找到的在 Windows下安装 Memcache 的文档大多已经过时.雪峰这里再简要介绍一下当下最新版的安装和配置方法. Memcach ...

  8. Windows 下如何安装配置Snort视频教程

    Windows 下如何安装配置Snort视频教程: 第一步: http://www.tudou.com/programs/view/UUbIQCng360/ 第二部: http://www.tudou ...

  9. 在windows下完美安装GitHub

    笔者最近在Windows下安装GitHub,过程中遇到不少问题.现在把安装的详细步骤分享给大家,免得大家走弯路. 笔者安装了GitHub for Windows程序,一切都运行顺利.但事情没有结束,首 ...

随机推荐

  1. Nifi:初识nifi

    写在前面: 第一次接触这一系统的时候,只有github上的一坨源码和官方的英文文档,用起来只能说是一步一个坑,一踩一个脚印,现在回想那段血泪史,只想 ***,现在用起来算是有了一些经验和总结,这里就做 ...

  2. spring为何要注入接口,而注入接口的实现类就会报错

    首先说明,注入的对象确实为实现类的对象.(并不是实现类的代理对象,注入并不涉及代理) 如果只是单纯注入是可以用实现类接收注入对象的,但是往往开发中会对实现类做增强,如事务,日志等,实现增强的AOP技术 ...

  3. Elastic Stack(ElasticSearch 、 Kibana 和 Logstash) 实现日志的自动采集、搜索和分析

    Elastic Stack 包括 Elasticsearch.Kibana.Beats 和 Logstash(也称为 ELK Stack).能够安全可靠地获取任何来源.任何格式的数据,然后实时地对数据 ...

  4. Flume 常用配置项

    注:以下配置项均为常见配置项,查询详细配置项可以访问 flume 官网 Source 常见配置项 Avro Source 配置项名称 默认值 描述 Channel – type – 组件类型名称,必须 ...

  5. 035.Python正则表达式

    正则表达式 一 介绍 拼正则表达式是什么? 它是约束字符串匹配某种形式的规则 正则表达式有什么用? 检测某个字符串是否符合规则比如:判断手机号,身份证号是否合法 提取网页字符串中想要的数据.比如:爬虫 ...

  6. scala :: , +:, :+ , ::: , ++ 的区别

    4 种操作符的区别和联系 :: 该方法被称为cons,意为构造,向队列的头部追加数据,创造新的列表.用法为 x::list,其中x为加入到头部的元素,无论x是列表与否,它都只将成为新生成列表的第一个元 ...

  7. python基础之常用模块一(sys、greenlet、pymysql、paramiko、pexpect、configparser)

    一.sys模块(内置模块) 用于提供对解释器相关的操作 import syssys.argv 命令行参数List,第一个元素是程序本身路径 sys.exit(n) 退出程序,正常退出时exit(0) ...

  8. MyBatis 各种参数传递方式

    MyBatis参数传递方式 情况一:Mapper映射器接口方法参数只有一个且为基本类型 接口方法: public List<UserEntity> selectUserByAge(int ...

  9. KVO后[obj class]与object_getClass(id obj)的结果竟会不一致?

    说说背景,研究下面的代码时,KVO后[obj class]与object_getClass(id obj)的结果竟会不一致? PersonModel *aPersonModel = [[PersonM ...

  10. Your branch and 'origin/master' have diverged, and have 1 and 1 different commits each, respectively

    On branch master Your branch and 'origin/master' have diverged, and have 1 and 1 different commits e ...