Basheer
Basheer

Reputation: 15

is it possible to add cpu to virtual machine and make it working without restarting?

Am using ( KVM Qemu//system ) as a hyper-visor and Libvirt to interface it so i want to know if there is anyway to add more CPU resources to online virtual machine and make it working without restarting?

i can add more CPU but the virtual machine should be restart then i can see it working so am searching for a way to make it working without restarting.

what am using now is the code bellow

from __future__ import print_function
import sys
import libvirt
domName = 'Fedora22-x86_64-1'
conn = libvirt.open('qemu:///system')
if conn == None:
    print('Failed to open connection to qemu:///system', file=sys.stderr)
    exit(1)
dom = conn.lookupName(domName)
if dom == None:
    print('Failed to find the domain '+domName, file=sys.stderr)
    exit(1)
dom.setVcpus(4)
conn.close()
exit(0)

Upvotes: 0

Views: 1855

Answers (1)

DanielB
DanielB

Reputation: 2816

QEMU/KVM do support CPU hot-add these days, however, you need to prepare the guest XML for it before hand.

<vcpus>8</vcpus>

will cause guest to start with 8 CPUs, all present. If you want to allow for hotplug of CPUs you need to change XML to something like

<vcpus current="8">16</vcpus>

This will cause the guest to start with 8 CPUs, and allow you to later hotplug upto 8 more, giving 16 in total.

Upvotes: 1

Related Questions