lost and found ( for me ? )

Fedora 19 KVM: CPU hotplug with qemu guest agent. ( guest-set-vcpus, guest-get-vcpus )

many thanks.

to add vCPU and enable “online” on that vCPU, I used following two commands.

on the KVM host
virsh # setvcpus f19-vm1 2  <- add vCPU ( still offline on the VM )
virsh # setvcpus f19-vm1 2 --guest <- ( online )

I could do above command without errors, when using KVM and VMs as below conditions.

KVM host:
Fedora 19, QEMU emulator version 1.6.0, virsh 1.1.3, qemu-guest-agent-1.6.0-8.fc19.x86_64

VM:
Fedora 19, qemu-guest-agent-1.6.0-8.fc19.x86_64



[ KVM host: Fedora 19, VM: CentOS 6 ]

KVM host info
I have installed KVM related packages from virt-preview repository.
# cat /etc/fedora-release ;uname -ri
Fedora release 19 (Schrödinger’s Cat)
3.11.2-201.fc19.x86_64 x86_64

# qemu-kvm --version
QEMU emulator version 1.6.0, Copyright (c) 2003-2008 Fabrice Bellard

# virsh --version
1.1.3

VM info
# cat /etc/centos-release ;uname -ri
CentOS release 6.4 (Final)
2.6.32-358.18.1.el6.x86_64 x86_64

# rpm -qa | grep qemu-guest-agent
qemu-guest-agent-0.12.1.2-2.355.0.1.el6_4.9.x86_64

at first, install qemu guest agent on the VM

see the following post about how to use qemu guest agent

make sure qemu-guest agent is running on your VM.

Here is the VM’s xml file

on the KVM host:

The current # of vCPUs is 1 and the maximum # of vCPUs is 2.
add a channel for qemu quest agent.
also qemu machine type needs to be greater than pc-1.5
virsh # dumpxml centos6-vm1
<domain type='kvm'>
 <name>centos6-vm1</name>
 <uuid>dddd2922-92bb-2d4e-049d-30352221acda</uuid>
 <memory unit='KiB'>524288</memory>
 <currentMemory unit='KiB'>524288</currentMemory>
 <vcpu placement='static' current='1'>2</vcpu>
 <os>
   <type arch='x86_64' machine='pc-i440fx-1.6'>hvm</type>
   <boot dev='hd'/>
 </os>
 <features>
   <acpi/>
   <apic/>
   <pae/>
 </features>
 <clock offset='utc'/>
 <on_poweroff>destroy</on_poweroff>
 <on_reboot>restart</on_reboot>
 <on_crash>restart</on_crash>
 <devices>
   <emulator>/usr/bin/qemu-kvm</emulator>
   <disk type='file' device='disk'>
     <driver name='qemu' type='raw'/>
     <source file='/var/lib/libvirt/images/centos6-vm1.img'/>
     <target dev='vda' bus='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
   </disk>
   <disk type='block' device='cdrom'>
     <driver name='qemu' type='raw'/>
     <target dev='hdc' bus='ide'/>
     <readonly/>
     <address type='drive' controller='0' bus='1' target='0' unit='0'/>
   </disk>
   <controller type='usb' index='0'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
   </controller>
   <controller type='pci' index='0' model='pci-root'/>
   <controller type='ide' index='0'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
   </controller>
   <controller type='virtio-serial' index='0'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
   </controller>
   <interface type='direct'>
     <mac address='52:54:00:10:ec:d9'/>
     <source dev='ovsbr0' mode='bridge'/>
     <model type='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
   </interface>
   <serial type='pty'>
     <target port='0'/>
   </serial>
   <console type='pty'>
     <target type='serial' port='0'/>
   </console>
   <channel type='spicevmc'>
     <target type='virtio' name='com.redhat.spice.0'/>
     <address type='virtio-serial' controller='0' bus='0' port='1'/>
   </channel>
   <channel type='unix'>
     <source mode='bind' path='/var/lib/libvirt/qemu/centos6-vm1.agent'/>
     <target type='virtio' name='org.qemu.guest_agent.0'/>
     <address type='virtio-serial' controller='0' bus='0' port='2'/>
   </channel>
   <input type='tablet' bus='usb'/>
   <input type='mouse' bus='ps2'/>
   <graphics type='spice' autoport='yes'/>
   <sound model='ich6'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
   </sound>
   <video>
     <model type='qxl' ram='65536' vram='65536' heads='1'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
   </video>
   <memballoon model='virtio'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
   </memballoon>
 </devices>
</domain>

virsh #



start the VM
on the KVM host
virsh # start centos6-vm1 --console

on the VM
# egrep -v ^# /etc/sysconfig/qemu-ga | grep -v ^$
TRANSPORT_METHOD="virtio-serial"
DEVPATH="/dev/virtio-ports/org.qemu.guest_agent.0"
LOGFILE="/var/log/qemu-ga.log"
PIDFILE="/var/run/qemu-ga.pid"
BLACKLIST_RPC="guest-file-open,guest-file-close,guest-file-read,guest-file-write,guest-file-seek,guest-file-flush"

# /etc/init.d/qemu-ga status
qemu-ga (pid  1178) is running...

on the KVM host
virsh # vcpucount centos6-vm1
maximum      config         2
maximum      live           2
current      config         1
current      live           1


virsh # qemu-monitor-command centos6-vm1 '{"execute":"query-kvm"}' --pretty
{
   "return": {
       "enabled": true,
       "present": true
   },
   "id": "libvirt-10"
}


virsh #

add vCPUs
error.
virsh # setvcpus centos6-vm1  2         

virsh # setvcpus centos6-vm1  2 --guest
error: 内部エラー: QEMU エージェントコマンド 'guest-get-vcpus' を実行できません: The command guest-get-vcpus has not been found

virsh #

about the error:

virsh # setvcpus centos6-vm1  2 --guest
error: 内部エラー: QEMU エージェントコマンド 'guest-get-vcpus' を実行できません: The command guest-get-vcpus has not been found



Googling this error, the seems to be cause by VM’s guest agent version which does not support guest-get-vcpus, guest-get-vcpus.

actually, this VM does not support “guest-set-vcpus”, “guest-set-vcpus”.
virsh # qemu-agent-command centos6-vm1 '{"execute":"guest-info"}'
{"return":{"version":"1.0","supported_commands":[{"enabled":true,"name":"guest-network-get-interfaces"},{"enabled":true,"name":"guest-suspend-hybrid"},{"enabled":true,"name":"guest-suspend-ram"},{"enabled":true,"name":"guest-suspend-disk"},{"enabled":true,"name":"guest-fsfreeze-thaw"},{"enabled":true,"name":"guest-fsfreeze-freeze"},{"enabled":true,"name":"guest-fsfreeze-status"},{"enabled":false,"name":"guest-file-flush"},{"enabled":false,"name":"guest-file-seek"},{"enabled":false,"name":"guest-file-write"},{"enabled":false,"name":"guest-file-read"},{"enabled":false,"name":"guest-file-close"},{"enabled":false,"name":"guest-file-open"},{"enabled":true,"name":"guest-shutdown"},{"enabled":true,"name":"guest-info"},{"enabled":true,"name":"guest-ping"},{"enabled":true,"name":"guest-sync"},{"enabled":true,"name":"guest-sync-delimited"}]}}

[ KVM host: Fedora 19, VM: Fedora 19 ]

Okey, try Fedora 19 VM.

on the F19 VM
# rpm -qa | grep qemu-guest-agent
qemu-guest-agent-1.4.2-11.fc19.x86_64

# systemctl status qemu-guest-agent.service
qemu-guest-agent.service - QEMU Guest Agent
  Loaded: loaded (/usr/lib/systemd/system/qemu-guest-agent.service; static)
  Active: active (running) since 土 2013-10-05 22:08:01 JST; 5min ago
Main PID: 357 (qemu-ga)
  CGroup: name=systemd:/system/qemu-guest-agent.service
          └─357 /usr/bin/qemu-ga

on the KVM host
no “guest-set-vcpus” and “guest-set-vcpus” in the list.
[root@localhost ~]# virsh qemu-agent-command f19-vm1 '{"execute":"guest-info"}'
{"return":{"version":"1.4.2","supported_commands":[{"enabled":true,"name":"guest-network-get-interfaces"},{"enabled":true,"name":"guest-suspend-hybrid"},{"enabled":true,"name":"guest-suspend-ram"},{"enabled":true,"name":"guest-suspend-disk"},{"enabled":true,"name":"guest-fstrim"},{"enabled":true,"name":"guest-fsfreeze-thaw"},{"enabled":true,"name":"guest-fsfreeze-freeze"},{"enabled":true,"name":"guest-fsfreeze-status"},{"enabled":true,"name":"guest-file-flush"},{"enabled":true,"name":"guest-file-seek"},{"enabled":true,"name":"guest-file-write"},{"enabled":true,"name":"guest-file-read"},{"enabled":true,"name":"guest-file-close"},{"enabled":true,"name":"guest-file-open"},{"enabled":true,"name":"guest-shutdown"},{"enabled":true,"name":"guest-info"},{"enabled":true,"name":"guest-ping"},{"enabled":true,"name":"guest-sync"},{"enabled":true,"name":"guest-sync-delimited"}]}}

install the newer qemu guest agent from virt-preview on the Fedora 19 VM.

on the Fedora 19 VM
add virt preview repo and install newer quest agent
# egrep -v ^# /etc/yum.repos.d/fedora-virt-preview.repo

[fedora-virt-preview]
name=Virtualization packages from Rawhide built for latest Fedora
baseurl=http://fedorapeople.org/groups/virt/virt-preview/fedora-$releasever/$basearch
enabled=1
skip_if_unavailable=1
gpgcheck=0

[fedora-virt-preview-debuginfo]
name=Fedora $releasever - $basearch - Debug
name=Virtualization packages from Rawhide built for latest Fedora - Debug
baseurl=http://fedorapeople.org/groups/virt/virt-preview/fedora-$releasever/debuginfo
enabled=0
skip_if_unavailable=1
gpgcheck=0

[fedora-virt-preview-source]
name=Virtualization packages from Rawhide built for latest Fedora - Source
baseurl=http://fedorapeople.org/groups/virt/virt-preview/fedora-$releasever/SRPMS
enabled=0
skip_if_unavailable=1
gpgcheck=0


# yum update -y

# reboot

# rpm -qa | grep qemu-guest-agent
qemu-guest-agent-1.6.0-8.fc19.x86_64



# systemctl status qemu-guest-agent.service
qemu-guest-agent.service - QEMU Guest Agent
  Loaded: loaded (/usr/lib/systemd/system/qemu-guest-agent.service; static)
  Active: active (running) since 土 2013-10-05 22:21:49 JST; 18s ago
Main PID: 359 (qemu-ga)
  CGroup: name=systemd:/system/qemu-guest-agent.service
          └─359 /usr/bin/qemu-ga





on the KVM host
okay, I can use both “guest-set-vcpus” and “guest-get-vcpus” commands.
[root@localhost ~]# virsh qemu-agent-command f19-vm1 '{"execute":"guest-info"}' | grep cpu
{"return":{"version":"1.6.0","supported_commands":[{"enabled":true,"name":"guest-set-vcpus"},{"enabled":true,"name":"guest-get-vcpus"},{"enabled":true,"name":"guest-network-get-interfaces"},{"enabled":true,"name":"guest-suspend-hybrid"},{"enabled":true,"name":"guest-suspend-ram"},{"enabled":true,"name":"guest-suspend-disk"},{"enabled":true,"name":"guest-fstrim"},{"enabled":true,"name":"guest-fsfreeze-thaw"},{"enabled":true,"name":"guest-fsfreeze-freeze"},{"enabled":true,"name":"guest-fsfreeze-status"},{"enabled":true,"name":"guest-file-flush"},{"enabled":true,"name":"guest-file-seek"},{"enabled":true,"name":"guest-file-write"},{"enabled":true,"name":"guest-file-read"},{"enabled":true,"name":"guest-file-close"},{"enabled":true,"name":"guest-file-open"},{"enabled":true,"name":"guest-shutdown"},{"enabled":true,"name":"guest-info"},{"enabled":true,"name":"guest-set-time"},{"enabled":true,"name":"guest-get-time"},{"enabled":true,"name":"guest-ping"},{"enabled":true,"nam


virsh # qemu-agent-command f19-vm1 '{"execute":"guest-get-vcpus"}' --pretty
{
   "return": [
       {
           "online": true,
           "can-offline": false,
           "logical-id": 0
       }
   ]
}

try vCPU hotplug.

on the KVM host

virsh # setvcpus f19-vm1 2  

virsh # setvcpus f19-vm1 2 --guest

virsh # qemu-agent-command f19-vm1 '{"execute":"guest-get-vcpus"}' --pretty
{
   "return": [
       {
           "online": true,
           "can-offline": false,
           "logical-id": 0
       },
       {
           "online": true,
           "can-offline": true,
           "logical-id": 1
       }
   ]
}



on the VM

dmesg.
[  513.381702] SMP alternatives: switching to SMP code
[  513.398729] smpboot: Booting Node 0 Processor 1 APIC 0x1
[    0.002000] kvm-clock: cpu 1, msr 0:3ffe8041, secondary cpu clock
[  513.410898] KVM setup async PF for cpu 1
[  513.410907] kvm-stealtime: cpu 1, msr 3fd0df00
[  513.410950] Will online and init hotplugged CPU: 1
[  513.416680] microcode: AMD CPU family 0x6 not supported

# egrep -i processor /proc/cpuinfo
processor : 0
processor : 1

No comments:

Post a Comment

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