On Wed, 2015-01-21 at 10:27 +0100, Peter Krempa wrote:
On Wed, Jan 21, 2015 at 16:01:01 +0800, Zhu Guihua wrote:
> This patch implements live hotplug of a cpu device.
>
> Signed-off-by: Zhu Guihua <zhugh.fnst(a)cn.fujitsu.com>
> ---
> src/qemu/qemu_driver.c | 6 ++++++
> src/qemu/qemu_hotplug.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
> src/qemu/qemu_hotplug.h | 7 +++++++
> 3 files changed, 68 insertions(+)
>
...
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index f6d7667..bff0d14 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -1541,6 +1541,61 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
> return ret;
> }
>
> +int
> +qemuDomainCPUInsert(virDomainDefPtr vmdef,
> + virDomainCPUDefPtr cpu)
> +{
> + if (virDomainCPUFind(vmdef, cpu)) {
> + virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> + _("cpu already exists"));
> + return -1;
> + }
> +
> + if (virDomainCPUInsert(vmdef, cpu) < 0)
> + return -1;
> +
> + return 0;
> +}
> +
> +int qemuDomainAttachCPUDevice(virQEMUDriverPtr driver,
> + virDomainObjPtr vm,
> + virDomainCPUDefPtr cpu)
> +{
> + int ret = -1;
> + char *devstr = NULL;
> + qemuDomainObjPrivatePtr priv = vm->privateData;
> + virDomainDefPtr vmdef = vm->def;
> +
> + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
> + virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> + _("qemu does not support -device"));
> + goto cleanup;;
> + }
> +
> + if (qemuAssignDeviceCPUAlias(vmdef, cpu, -1) < 0)
> + goto cleanup;
> +
> + if (qemuBuildCPUDeviceStr(&devstr, cpu, priv->qemuCaps) < 0)
> + goto cleanup;
> +
> + if (qemuDomainCPUInsert(vmdef, cpu) < 0)
> + goto cleanup;
> +
> + qemuDomainObjEnterMonitor(driver, vm);
> + if (devstr && qemuMonitorAddDevice(priv->mon, devstr) < 0) {
> + qemuDomainObjExitMonitor(driver, vm);
> + goto cleanup;
> + }
> + qemuDomainObjExitMonitor(driver, vm);
This function recently changed it's prototype and requires the return
value to be checked. Rebasing to upstream will break build.
I will confirm it, thanks.
Regards,
Zhu
> +
> + ignore_value(virBitmapSetBit(vm->def->apic_id_map, cpu->apic_id));
> + ret = 0;
> +
> + cleanup:
> + VIR_FREE(devstr);
> + return ret;
> +}
> +
> static int
> qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver,
> virDomainObjPtr vm,a
Peter