Installation guide

Chapter 16. QEMU Guest Agent
The QEMU Guest Agent allows the host machine to issue commands to the guest operating system.
The guest operating system then responds to those commands asynchronously.
This section covers the options and commands available to the guest agent in detail. It also covers
how to run the Guest Agent in the foreground, or as a daemon in the background.
16.1. Inst all and Enable t he Guest Agent
Install qemu-guest-agent on the guest virtual machine (yum i nstal l q emu-g uest-ag ent) and
make it run automatically at every boot as a service (qemu-guest-agent.service).
16.2. Set Up Communicat ion bet ween Guest Agent and Host
The host machine communicates with the Guest Agent through a VirtIO serial connection between the
host and guest machines. A VirtIO serial channel is connected to the host via a character device
driver (typically a Unix socket), and the guest listens on this serial channel. The following procedure
shows how to set up the host and guest machines for Guest Agent use.
Pro ced u re 16 .1. Set Up Ho st - Ag en t Co mmu n icat io n
1. Lau n ch Q EMU wit h a charact er d evice driver
Launch QEMU as usual, with additional definitions for the character device driver required to
communicate with the Guest Agent.
The following example launches QEMU to communicate over the Unix socket
/tmp/q g a. so ck.
/usr/libexec/qemu-kvm [...] -chardev
socket,path=/tmp/qga.sock,server,nowait,id=qga0 \
-device virtio-serial \
-device
virtserialport,chardev=qga0,name=org.qemu.guest_agent.0
2. St art t h e G u est Agent
On the guest, run the following command to start the Guest Agent:
qemu-ga --path device_path --method method
The Guest Agent now parses incoming QMP messages for commands, and acts upon them if
valid.
If no other method or path is specified with the --metho d or --path options respectively, the
Guest Agent listens over vi rti o -seri al , through the /d ev/vi rti o -
po rts/o rg . q emu. g uest_ag ent. 0 device path.
You can now communicate with the guest by sending valid QMP commands over the established
character device driver.
For further information about the Guest Agent, refer to the Red Hat Enterprise Linux 6 Virtualization
Administration Guide.
Chapt er 1 6 . Q EMU G uest Agent
121