QEMU Guest Agent
QEMU Guest Agent
It is a daemon program running inside the domain which is supposed to help management applications with executing functions which need assistance of the guest OS. For example, freezing and thawing filesystems, entering suspend. However, guest agent (GA) is not bullet proof, and hostile guest OS can send spurious replies.
Setting QEMU GA up
Currently, QEMU exposes GA via virtio serial port. There are some attempts to allow applications to use qemu monitor for communication with GA, but virtio serial port should remain supported. These are internals, though.
To be able to use GA users needs to create virtio serial port with special name org.qemu.guest_agent.0. In other words, one needs to add this to his/her domain XML under <devices>:
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/f16x86_64.agent'/>
<target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>
If you use libvirt 1.0.6 or newer, you can omit the path='...' attribute of the <source> element, and libvirt will manage things automatically on your behalf.
Usage
Libvirt does not guarantee any support of direct use of the guest agent. If you don't mind using libvirt-qemu.so, you can use the virDomainQemuAgentCommand API (exposed by virsh qemu-agent-command); but be aware that this is unsupported, and any changes you make to the agent that change state behind libvirt's back may cause libvirt to misbehave. Meanwhile, the guest agent may be used internally by several supported libvirt APIs, often by passing flags to request its use. For example, virDomainShutdownFlags supports:
VIR_DOMAIN_SHUTDOWN_DEFAULT = 0,
VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN = (1 << 0),
VIR_DOMAIN_SHUTDOWN_GUEST_AGENT = (1 << 1),
Simmilar applies for the reboot API:
VIR_DOMAIN_REBOOT_DEFAULT = 0,
VIR_DOMAIN_REBOOT_ACPI_POWER_BTN = (1 << 0),
VIR_DOMAIN_REBOOT_GUEST_AGENT = (1 << 1),
In virsh, users can select shutdown/reboot method via --mode acpi|agent:
virsh reboot --mode agent $DOMAIN
virsh shutdown --mode agent $DOMAIN
If users is creating snapshots he/she might want to freeze before and thaw filesystems after. This can be done by specifying VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE flag to virDomainSnapshotCreate API or:
virsh snapshot-create --quiesce $DOMAIN
virsh snapshot-create-as --quiesce $DOMAIN
in virsh.
Warning: Like any monitor command, GA commands can block indefinitely esp. when GA is not running. Currently, there is no reliable method/API to tell if GA is running. Libvirt implements some basic check to determine if there is a qemu-ga instance running or not. Basically a guest-sync command is issued prior every useful command. If it returns, then libvirt considers guest agent up and running and issues the real command. However, guest agent can die or be terminated meanwhile. The guest-sync command is issued with a timeout which if hit guest agent is considered as not present.
Configure guest agent without libvirt interference
In some cases, users might want to configure a guest agent in their domain XML but don't want libvirt to connect to guest agent socket at all. Because libvirt connects to a guest agent channel if and only if it is a virtio channel with org.qemu.guest_agent.0 name, all one need to do is void at least one of these conditions. However, the most feasible way is to change the target's name:
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/f16x86_64.agent'/>
<target type='virtio' name='org.qemu.guest_agent.1'/>
</channel>
If you do change name, you'll need to tell it to qemu GA as well:
# qemu-ga -p /dev/virtio-ports/$name
Guest requirements
One thing has been already mentioned - the domain configuration for virtio serial port. However, guest must have the GA installed. Fortunately, it is already distributed as rpm, so all one needs to do is:
yum install qemu-guest-agent
Related links
If you want to read further:
QEMU Guest Agent的更多相关文章
- 利用Qemu Guest Agent (Qemu-ga) 实现 Openstack 监控平台
经常使用vmWare的同学都知道有vmware-tools这个工具,这个安装在vm内部的工具,可以实现宿主机与虚拟机的通讯,大大增强了虚拟机的性能与功能, 如vmware现在的Unity mode下可 ...
- KVM 介绍(7):使用 libvirt 做 QEMU/KVM 快照和 Nova 实例的快照 (Nova Instances Snapshot Libvirt)
学习 KVM 的系列文章: (1)介绍和安装 (2)CPU 和 内存虚拟化 (3)I/O QEMU 全虚拟化和准虚拟化(Para-virtulizaiton) (4)I/O PCI/PCIe设备直接分 ...
- 使用QEMU创建虚拟机
下载安装: wget http://wiki.qemu-project.org/download/qemu-2.0.0.tar.bz2 tar xjvf qemu- ./configure --ena ...
- KVM(七)使用 libvirt 做 QEMU/KVM 快照和 Nova 实例的快照
本文将梳理 QEMU/KVM 快照相关的知识,以及在 OpenStack Nova 中使用 libvirt 来对 QEMU/KVM 虚机做快照的过程. 1. QEMU/KVM 快照 1.1 概念 QE ...
- KVM 虚拟化 初体验
KVM 是 Kernel-based Virtual Machine 的简称,是 Linux 下 x86 硬件平台上的全功能虚拟化解决方案: 使用 KVM ,可允许运行多个虚拟机,包括 Linux 和 ...
- 对consistencygroup的一些研究和实践
声明: 本博客欢迎转载,但请保留原作者信息! 作者:李人可 团队:华为杭州OpenStack团队 consistency group,直译是一致性组,是Juno版本号cinder新引进的一个概念.顾名 ...
- (转)如何阅读OpenStack源码
1 关于该项目 本项目使用在线绘图工具web sequencediagrams完成,目标是图形化OpenStack的所有操作流程,通过操作序列图能快速学习Openstack的工作原理,理清各个组件的关 ...
- 开源虚拟化KVM(一)搭建部署与概述
一,KVM概述 1.1 虚拟化概述 在计算机技术中,虚拟化意味着创建设备或资源的虚拟版本,如服务器,存储设备,网络或者操作系统等等 [x] 虚拟化技术分类: 系统虚拟化(我们主要讨论的反向) 存储虚拟 ...
- 【Linux】Cent OS 虚拟机开机自启动配置
一次断电,导致实体机关机了,虚拟机也连不上去,只好手动来起来. 我想增加一下自启动,让硬件开机的时候,自动启动虚拟机: 其实是有办法的,尝试了一下,也成功了,这里简单标记下. virsh autost ...
随机推荐
- Js数据类型之——Date
小猪曾经分享过一篇文章,主要是讲到后台使用c#将DataTime类型序列化到前台之后进行操作:具体请看传送门 今天小猪来分享在JS中的Data类型 类型说明 ECMAScript中的Data类型是在早 ...
- 小记:利用递归调用循环寻找MP3文件的方法。
private void findMp3Data(File mp3file) { File[] filelist = mp3file.listFiles(); if (filelist != null ...
- hdu 4632 Palindrome subsequence
http://acm.hdu.edu.cn/showproblem.php?pid=4632 简单DP 代码: #include<iostream> #include<cstdio& ...
- HDU 2255 二分图最佳匹配 模板题
题目大意: 给定每一个人能支付的房子价值,每个人最多且必须拥有一套房子,问最后分配房子可得到的最大收益 抄了个别人的KM模板,就这样了... #include <cstdio> #incl ...
- 傅里叶变换:MP3、JPEG和Siri背后的数学
九年前,当我还坐在学校的物理数学课的课堂里时,我的老师为我们讲授了一种新方法,给我留下了深刻映像.我认为,毫不夸张地说,这是对数学理论发现最广泛的应用.应用的领域包括:量子物理.射电天文学.MP3和J ...
- web安全测试-AppScan使用分享
这里主要分享如何使用AppScan对一大项目的部分功能进行安全扫描. ----------------------------------------------------------------- ...
- android开机启动过程
Android系统开机主要经历三个阶段: bootloader启动 Linux启动 Android启动 启动文件: 对于机器从通电到加载Linux系统一般需要三个文件:bootloader(引导文件) ...
- navtab方法参数以及事件
参数(options) DOM方式初始化navtab的,推荐使用集合属性data-options定义参数,如果使用data属性定义参数,注意转换成对应的名称. 名称 类型 默认值 描述 id stri ...
- Ogre骨骼动画
转自:http://blog.csdn.net/yanonsoftware/article/details/1281516 OGRE的基本动画控制是很简单的,设置一个动画的操作是这样: // Set ...
- [转]dev C++编写windows程序遇到问题
1.工具-编译选项-编译器-在连接器命令行加入以下命令: -mwindows 2.出现错误:undefined reference to `PlaySoundA@12' 解决办法:工具-编译选项-编译 ...