[libvirt] [PATCH] Support VCPU hotplug in QEMU guests
Cole Robinson
crobinso at redhat.com
Tue Feb 16 16:13:06 UTC 2010
On 02/16/2010 07:12 AM, Daniel P. Berrange wrote:
> QEMU has a monitor command 'set_cpu' which allows a specific
> CPU to be toggled between online& offline state. libvirt CPU
> hotplug does not work in terms of individual indexes CPUs.
> Thus to support this, we iteratively toggle the online state
> when the total number of vCPUs is adjusted via libvirt
>
> NB, currently untested since QEMU segvs when running this!
>
> * src/qemu/qemu_driver.c: Toggle online state for CPUs when
> doing hotplug
> * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
> src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
> src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
> monitor API for toggling a CPU's online status via 'set_cpu
> ---
> src/qemu/qemu_driver.c | 59 ++++++++++++++++++++++++++++++++++++-----
> src/qemu/qemu_monitor.c | 14 ++++++++++
> src/qemu/qemu_monitor.h | 2 +
> src/qemu/qemu_monitor_json.c | 44 +++++++++++++++++++++++++++++++
> src/qemu/qemu_monitor_json.h | 1 +
> src/qemu/qemu_monitor_text.c | 38 +++++++++++++++++++++++++++
> src/qemu/qemu_monitor_text.h | 1 +
> 7 files changed, 151 insertions(+), 8 deletions(-)
>
Whoops, this made me realize I didn't actually push my changes to
SetVcpus in the qemu driver. I've just done so.
...
> static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
> struct qemud_driver *driver = dom->conn->privateData;
> virDomainObjPtr vm;
> @@ -4228,12 +4273,6 @@ static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
> if (qemuDomainObjBeginJob(vm) < 0)
> goto cleanup;
>
> - if (virDomainObjIsActive(vm)) {
> - qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
> - _("cannot change vcpu count of an active domain"));
> - goto endjob;
> - }
> -
> if (!(type = virDomainVirtTypeToString(vm->def->virtType))) {
> qemuReportError(VIR_ERR_INTERNAL_ERROR,
> _("unknown virt type in domain definition '%d'"),
> @@ -4254,8 +4293,12 @@ static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
> goto endjob;
> }
>
> - vm->def->vcpus = nvcpus;
> - ret = 0;
> + if (virDomainObjIsActive(vm)) {
> + ret = qemudDomainHotplugVcpus(vm, nvcpus);
> + } else {
> + vm->def->vcpus = nvcpus;
> + ret = 0;
> + }
>
This portion will need to be rebased. Most important is to drop the
inactive fallback above.
Thanks,
Cole
More information about the libvir-list
mailing list