[libvirt] [PATCH 0/2] qemu: Delete HMP cpu hotplug code

Peter Krempa (2): qemu: monitor: Remove text monitor support for cpu hot(un)plug qemu: Remove qemuMonitorTextSetCPU src/qemu/qemu_monitor_json.c | 15 ++++----------- src/qemu/qemu_monitor_text.c | 30 ------------------------------ src/qemu/qemu_monitor_text.h | 2 -- 3 files changed, 4 insertions(+), 43 deletions(-) -- 2.21.0

The "cpu-add" command is supported in all supported qemu versions and cpu unplug did not work at all until the new cpu unplug approach (using device_add/del) was implemented. Remove the support for falling back to the text monitor. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_monitor_json.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 4eca75ecc9..6d4f119a35 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2979,8 +2979,9 @@ int qemuMonitorJSONSetCPU(qemuMonitorPtr mon, "i:id", cpu, NULL); } else { - /* offlining is not yet implemented in qmp */ - goto fallback; + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("vCPU unplug is not supported by this qemu")); + goto cleanup; } if (!cmd) goto cleanup; @@ -2988,20 +2989,12 @@ int qemuMonitorJSONSetCPU(qemuMonitorPtr mon, if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0) goto cleanup; - if (qemuMonitorJSONHasError(reply, "CommandNotFound")) - goto fallback; - else - ret = qemuMonitorJSONCheckError(cmd, reply); + ret = qemuMonitorJSONCheckError(cmd, reply); cleanup: virJSONValueFree(cmd); virJSONValueFree(reply); return ret; - - fallback: - VIR_DEBUG("no QMP support for cpu_set, trying HMP"); - ret = qemuMonitorTextSetCPU(mon, cpu, online); - goto cleanup; } -- 2.21.0

On Thu, Jun 20, 2019 at 01:22:26PM +0200, Peter Krempa wrote:
The "cpu-add" command is supported in all supported qemu versions and cpu unplug did not work at all until the new cpu unplug approach (using device_add/del) was implemented.
Remove the support for falling back to the text monitor.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_monitor_json.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 4eca75ecc9..6d4f119a35 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2979,8 +2979,9 @@ int qemuMonitorJSONSetCPU(qemuMonitorPtr mon, "i:id", cpu, NULL); } else { - /* offlining is not yet implemented in qmp */ - goto fallback; + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("vCPU unplug is not supported by this qemu"));
s/qemu/QEMU/
+ goto cleanup; } if (!cmd) goto cleanup;
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

It's not used any more. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_monitor_text.c | 30 ------------------------------ src/qemu/qemu_monitor_text.h | 2 -- 2 files changed, 32 deletions(-) diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 280cc58840..a15c3df76e 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -32,36 +32,6 @@ VIR_LOG_INIT("qemu.qemu_monitor_text"); -int qemuMonitorTextSetCPU(qemuMonitorPtr mon, int cpu, bool online) -{ - char *cmd; - char *reply = NULL; - int ret = -1; - - if (virAsprintf(&cmd, "cpu_set %d %s", cpu, online ? "online" : "offline") < 0) - return -1; - - if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) - goto cleanup; - - /* If the command failed qemu prints: 'unknown command' - * No message is printed on success it seems */ - if (strstr(reply, "unknown command:")) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot change vcpu count of this domain")); - goto cleanup; - } - - ret = 0; - - cleanup: - VIR_FREE(reply); - VIR_FREE(cmd); - - return ret; -} - - int qemuMonitorTextAddDrive(qemuMonitorPtr mon, const char *drivestr) { diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h index 524bd1d5cb..ce6dd979a5 100644 --- a/src/qemu/qemu_monitor_text.h +++ b/src/qemu/qemu_monitor_text.h @@ -25,8 +25,6 @@ #include "qemu_monitor.h" -int qemuMonitorTextSetCPU(qemuMonitorPtr mon, int cpu, bool online); - int qemuMonitorTextAddDrive(qemuMonitorPtr mon, const char *drivestr); -- 2.21.0

On Thu, Jun 20, 2019 at 01:22:27PM +0200, Peter Krempa wrote:
It's not used any more.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_monitor_text.c | 30 ------------------------------ src/qemu/qemu_monitor_text.h | 2 -- 2 files changed, 32 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa