Re: [PATCHv2 11/14] qemu: Implement new QMP command for cpu hotplug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05.06.2013 15:44, Peter Krempa wrote:
> This patch implements support for the "cpu-add" QMP command that plugs
> CPUs into a live guest. The "cpu-add" command was introduced in QEMU
> 1.5. For the hotplug to work machine type "pc-i440fx-1.5" is required.
> ---
>  src/qemu/qemu_monitor_json.c | 37 +++++++++++++++++++++++++++++++++++--
>  1 file changed, 35 insertions(+), 2 deletions(-)
> 
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 4a69fec..a415732 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -2089,9 +2089,42 @@ cleanup:
>  int qemuMonitorJSONSetCPU(qemuMonitorPtr mon,
>                            int cpu, bool online)
>  {
> -    /* XXX Update to use QMP, if QMP ever adds support for cpu hotplug */
> +    int ret = -1;
> +    virJSONValuePtr cmd = NULL;
> +    virJSONValuePtr reply = NULL;
> +
> +    if (online) {
> +        cmd = qemuMonitorJSONMakeCommand("cpu-add",
> +                                         "i:id", cpu,
> +                                         NULL);
> +    } else {
> +        /* offlining is not yet implemented in qmp */
> +        goto fallback;
> +    }
> +    if (!cmd)
> +        goto cleanup;
> +
> +    if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
> +        goto cleanup;
> +
> +    if (qemuMonitorJSONHasError(reply, "CommandNotFound"))
> +        goto fallback;
> +    else
> +        ret = qemuMonitorJSONCheckError(cmd, reply);
> +
> +    /* this function has non-standard return values, so adapt it */
> +    if (ret == 0)
> +        ret = 1;

Yeah, this is strange, but it bubbles all the way down to
qemuDomainHotplugVcpus in qemu_driver.c. Not worth refactoring for now.

> +
> +cleanup:
> +    virJSONValueFree(cmd);
> +    virJSONValueFree(reply);
> +    return ret;
> +
> +fallback:
>      VIR_DEBUG("no QMP support for cpu_set, trying HMP");
> -    return qemuMonitorTextSetCPU(mon, cpu, online);
> +    ret = qemuMonitorTextSetCPU(mon, cpu, online);
> +    goto cleanup;
>  }
> 
> 

ACK

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]