lost and found ( for me ? )

Ubuntu 14.04 : qemu-guest-agent

Here are trial and error logs when setting up qemu-guest-agent.

KVM host : Ubuntu 14.04
Guest VMs : CentOS 6.6

KVM host
# uname –r
3.13.0-37-generic

# kvm --version
QEMU emulator version 2.0.0 (Debian 2.0.0+dfsg-2ubuntu1.7), Copyright (c) 2003-2008 Fabrice Bellard

install qemu-guest-agent on the VM.
# yum install qemu-guest-agent

# /etc/init.d/qemu-ga start

# /etc/init.d/qemu-ga status
qemu-ga is stopped

can not start qemu-ga.

reboot the VM.

# reboot

# /etc/init.d/qemu-ga status
qemu-ga is stopped

nnn, still can not start qemu-agent.


I forgot adding a channel for qemu-agent.

add following lines to the VM’s xml file.
<channel type='unix'>
     <source mode='bind' path='/var/lib/libvirt/qemu/centos6-vm.agent'/>
     <target type='virtio' name='org.qemu.guest_agent.0'/>
     <alias name='channel1'/>
     <address type='virtio-serial' controller='0' bus='0' port='2'/>
   </channel>

Here is an output of diff of VM’s xml file.
# diff /etc/libvirt/qemu/centos6-vm.xml /etc/libvirt/qemu/centos6-vm.xml.org
42,44d41
<     <controller type='virtio-serial' index='0'>
<       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
<     </controller>
57,61d53
<     <channel type='unix'>
<       <source mode='bind' path='/var/lib/libvirt/qemu/centos6-vm.agent'/>
<       <target type='virtio' name='org.qemu.guest_agent.0'/>
<       <address type='virtio-serial' controller='0' bus='0' port='2'/>
<     </channel>

Okay, qemu-ga is running on the VM.
# /etc/init.d/qemu-ga status
qemu-ga (pid  1086) is running...

on the KVM host
virsh # qemu-agent-command centos6-vm '{"execute":"guest-network-get-interfaces"}'
{"return":[{"name":"lo","ip-addresses":[{"ip-address-type":"ipv4","ip-address":"127.0.0.1","prefix":8}],"hardware-address":"00:00:00:00:00:00"},{"name":"eth0","ip-addresses":[{"ip-address-type":"ipv4","ip-address":"192.168.122.53","prefix":24}],"hardware-address":"MAC address"}]}

I was able to get information via qemu-agent-command.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.