lost and found ( for me ? )

Ubuntu 14.04 KVM : how to offline/online vCPU cores on virtual machines

Here is how to online/offline vCPU via virsh qemu-comamnd

assume you already set up qemu-guest-agent.

KV host : Ubuntu14.04
VM : CentOS 6.6

on the KVM host
virsh # qemu-agent-command centos6-vm1 '{"execute":"guest-get-vcpus"}'
{"return":[{"online":true,"can-offline":false,"logical-id":0},{"online":true,"can-offline":true,"logical-id":1},{"online":true,"can-offline":true,"logical-id":2},{"online":true,"can-offline":true,"logical-id":3},{"online":true,"can-offline":true,"logical-id":4},{"online":true,"can-offline":true,"logical-id":5},{"online":true,"can-offline":true,"logical-id":6},{"online":true,"can-offline":true,"logical-id":7}]}

offline logical-id 5
virsh # qemu-agent-command centos6-vm1 '{"execute":"guest-set-vcpus", "arguments" : { "vcpus" : [{"online":false,
"can-offline":false,"logical-id":5}]}}'
{"retur2n":1}

VM’s log ( dmesg )
CPU 5 is now offline

online logical id 5 again.
virsh # qemu-agent-command centos6-vm1 '{"execute":"guest-set-vcpus", "arguments" : { "vcpus" : [{"online":true,"
can-offline":false,"logical-id":5}]}}'
{"return":1}

VM’s log
Booting Node 0 Processor 5 APIC 0x5
kvm-clock: cpu 5, msr 0:28356841, secondary cpu clock
kvm-stealtime: cpu 5, msr 2834e880

offline multiple cores at one time.
virsh # qemu-agent-command centos6-vm1 '{"execute":"guest-set-vcpus", "arguments" : { "vcpus" : [{"online":false,"can-offline":false,"logical-id":5},{"online":false,"can-offline":false,"logical-id":6}]}}'
{"return":2}

No comments:

Post a Comment

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