Qemu now has an official guest agent. Programs on a KVM host can now talk to guests using a virtual hardware channel (either virtio-serial or an emulated ISA serial port). Using this mechanism, it is now possible to reliably power down a guest, read and write files, and perform filesystem snapshotting. More information about the guest agent is here.
As of today, Memory Overcommitment Manager (MOM) can use the qemu guest agent for guest statistics collection. This has several key advantages:
- No need for host->guest network connectivity
- No need to map guest names to guest IP addresses
- Fast and secure hardware channel
- Uses a standard guest agent
Configuring MOM to use the qemu guest agent involves a few simple steps on the host and guest:
1. Update MOM
Download the latest version of MOM from github and install it on your host.
2. Reconfigure MOM
- Remove any existing name-to-ip setting from mom.conf
- Remove GuestNetworkDaemon from the list of guest collectors (if present)
- Add GuestQemuAgent to the list of guest collectors
2. Modify your guest domain.xml files to create the communication channels:
Place the following stanza into the devices section of each domain configuration file:
<serial type='unix'> <source mode='bind' path='/var/lib/libvirt/qemu/va-$NAME-isa.sock'/> <target port='1'/> </serial> <channel type='unix'> <source mode='bind' path='/var/lib/libvirt/qemu/va-$NAME-virtio.sock'/> <target type='virtio' name='org.qemu.guest_agent.0'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> </channel>
Replace $NAME with the guest’s name. Redefine/restart the domains to ensure the changes take effect. This will require a VM restart. Note: In this example we create both an ISA-serial channel and a virtio-serial channel. The MOM Collector will automatically connect to whichever of these channels is active. Always specifying both allows you to have a standardized libvirt XML configuration regardless of underlying guest support.
1. Build the guest agent binary on your guest
The guest agent is supported in qemu versions v0.15.0-rc0-413-g957f1f9 or later. Download and build the qemu source on your guest and find the binary ‘qemu-ga’.
2. Configure the guest agent to start automatically
The agent can be started on a guest that supports virtio-serial with no arguments. Follow your distribution’s recommendations to start the agent automatically at boot. If you were previously using the mom-guestd agent, you can use the same process for autostarting qemu-ga.
Testing it out
Assuming the above has gone ok, when you start up MOM on the host and start some guests, the mom log should show messages like “GuestMonitor-$NAME is ready” and your statistics should appear as usual.