QEMU Guest Agent

Source: Internet
Author: User
Tags quiesce

QEMU Guest Agent

It is a daemon program running inside the domain which are supposed to help management applications with executing function s 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 is some attempts to allow applications to use QEMU Monitor for communication with GA, but virtio serial port should remain supported. These is internals, though.

To is 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 the 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 would m Anage things automatically on your behalf.

Usage

Libvirt does not guarantee any, the guest agent of direct use. If you don't mind using libvirt-qemu.so, you can use the virDomainQemuAgentCommand API (exposed by Virsh Qemu-agent-command); Aware that's unsupported, and any changes your make to the agent that's change state behind Libvirt's back may cause Li Bvirt to misbehave. Meanwhile, the guest agent May is 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 $DOMAINvirsh shutdown--mode Agent $DOMAIN

If users are creating snapshots he/she might want to freeze before and thaw filesystems after. This can is done by the specifying VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE flag to Virdomainsnapshotcreate API or:

Virsh snapshot-create--quiesce $DOMAINvirsh snapshot-create-as--quiesce $DOMAIN

In Virsh.

Warning: Like any monitor command, the GA commands can block indefinitely esp. when GA was not running. Currently, there is no reliable method/api to the IF GA is running. Libvirt implements some basic check to determine if there are 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 was 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's a virtio channel org.qemu.guest_agent.0 with name, any one need to D O is void at least one of these conditions. However, the most feasible-on-the-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 don't change the name, you'll need to the it to Qemu GA as well:

# qemu-ga-p/dev/virtio-ports/$name

Guest Requirements

One thing have been already mentioned-the domain configuration for virtio serial port. However, guest must has the GA installed. Fortunately, it is already distributed as RPM, so all one needs to doing is:

Yum Install Qemu-guest-agent

RELATED LINKS

If you want to read further:

    • Http://wiki.qemu.org/Features/QAPI/GuestAgent
Retrieved from "Http://wiki.libvirt.org/page/Qemu_guest_agent"

QEMU Guest Agent

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.