From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: [PULL 12/35] machine: Move QMP commands from monitor/ to hw/core/
Date: Fri, 3 Feb 2023 09:45:26 +0100 [thread overview]
Message-ID: <20230203084549.2622302-13-armbru@redhat.com> (raw)
In-Reply-To: <20230203084549.2622302-1-armbru@redhat.com>
This moves these commands from MAINTAINERS section "QMP" to "Machine
core".
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20230124121946.1139465-10-armbru@redhat.com>
---
hw/core/machine-qmp-cmds.c | 144 +++++++++++++++++++++++++++++++++++++
monitor/qmp-cmds.c | 140 ------------------------------------
2 files changed, 144 insertions(+), 140 deletions(-)
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 80d5e59651..44b5da8880 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -9,6 +9,9 @@
#include "qemu/osdep.h"
#include "hw/boards.h"
+#include "hw/intc/intc.h"
+#include "hw/mem/memory-device.h"
+#include "hw/rdma/rdma.h"
#include "qapi/error.h"
#include "qapi/qapi-builtin-visit.h"
#include "qapi/qapi-commands-machine.h"
@@ -17,11 +20,13 @@
#include "qapi/qobject-input-visitor.h"
#include "qapi/type-helpers.h"
#include "qemu/main-loop.h"
+#include "qemu/uuid.h"
#include "qom/qom-qobject.h"
#include "sysemu/hostmem.h"
#include "sysemu/hw_accel.h"
#include "sysemu/numa.h"
#include "sysemu/runstate.h"
+#include "sysemu/sysemu.h"
static void cpustate_to_cpuinfo_s390(CpuInfoS390 *info, const CPUState *cpu)
{
@@ -239,3 +244,142 @@ HumanReadableText *qmp_x_query_numa(Error **errp)
done:
return human_readable_text_from_str(buf);
}
+
+KvmInfo *qmp_query_kvm(Error **errp)
+{
+ KvmInfo *info = g_malloc0(sizeof(*info));
+
+ info->enabled = kvm_enabled();
+ info->present = accel_find("kvm");
+
+ return info;
+}
+
+UuidInfo *qmp_query_uuid(Error **errp)
+{
+ UuidInfo *info = g_malloc0(sizeof(*info));
+
+ info->UUID = qemu_uuid_unparse_strdup(&qemu_uuid);
+ return info;
+}
+
+void qmp_system_reset(Error **errp)
+{
+ qemu_system_reset_request(SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET);
+}
+
+void qmp_system_powerdown(Error **errp)
+{
+ qemu_system_powerdown_request();
+}
+
+void qmp_system_wakeup(Error **errp)
+{
+ if (!qemu_wakeup_suspend_enabled()) {
+ error_setg(errp,
+ "wake-up from suspend is not supported by this guest");
+ return;
+ }
+
+ qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, errp);
+}
+
+MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp)
+{
+ return qmp_memory_device_list();
+}
+
+MemoryInfo *qmp_query_memory_size_summary(Error **errp)
+{
+ MemoryInfo *mem_info = g_new0(MemoryInfo, 1);
+ MachineState *ms = MACHINE(qdev_get_machine());
+
+ mem_info->base_memory = ms->ram_size;
+
+ mem_info->plugged_memory = get_plugged_memory_size();
+ mem_info->has_plugged_memory =
+ mem_info->plugged_memory != (uint64_t)-1;
+
+ return mem_info;
+}
+
+static int qmp_x_query_rdma_foreach(Object *obj, void *opaque)
+{
+ RdmaProvider *rdma;
+ RdmaProviderClass *k;
+ GString *buf = opaque;
+
+ if (object_dynamic_cast(obj, INTERFACE_RDMA_PROVIDER)) {
+ rdma = RDMA_PROVIDER(obj);
+ k = RDMA_PROVIDER_GET_CLASS(obj);
+ if (k->format_statistics) {
+ k->format_statistics(rdma, buf);
+ } else {
+ g_string_append_printf(buf,
+ "RDMA statistics not available for %s.\n",
+ object_get_typename(obj));
+ }
+ }
+
+ return 0;
+}
+
+HumanReadableText *qmp_x_query_rdma(Error **errp)
+{
+ g_autoptr(GString) buf = g_string_new("");
+
+ object_child_foreach_recursive(object_get_root(),
+ qmp_x_query_rdma_foreach, buf);
+
+ return human_readable_text_from_str(buf);
+}
+
+HumanReadableText *qmp_x_query_ramblock(Error **errp)
+{
+ g_autoptr(GString) buf = ram_block_format();
+
+ return human_readable_text_from_str(buf);
+}
+
+static int qmp_x_query_irq_foreach(Object *obj, void *opaque)
+{
+ InterruptStatsProvider *intc;
+ InterruptStatsProviderClass *k;
+ GString *buf = opaque;
+
+ if (object_dynamic_cast(obj, TYPE_INTERRUPT_STATS_PROVIDER)) {
+ intc = INTERRUPT_STATS_PROVIDER(obj);
+ k = INTERRUPT_STATS_PROVIDER_GET_CLASS(obj);
+ uint64_t *irq_counts;
+ unsigned int nb_irqs, i;
+ if (k->get_statistics &&
+ k->get_statistics(intc, &irq_counts, &nb_irqs)) {
+ if (nb_irqs > 0) {
+ g_string_append_printf(buf, "IRQ statistics for %s:\n",
+ object_get_typename(obj));
+ for (i = 0; i < nb_irqs; i++) {
+ if (irq_counts[i] > 0) {
+ g_string_append_printf(buf, "%2d: %" PRId64 "\n", i,
+ irq_counts[i]);
+ }
+ }
+ }
+ } else {
+ g_string_append_printf(buf,
+ "IRQ statistics not available for %s.\n",
+ object_get_typename(obj));
+ }
+ }
+
+ return 0;
+}
+
+HumanReadableText *qmp_x_query_irq(Error **errp)
+{
+ g_autoptr(GString) buf = g_string_new("");
+
+ object_child_foreach_recursive(object_get_root(),
+ qmp_x_query_irq_foreach, buf);
+
+ return human_readable_text_from_str(buf);
+}
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index e5ab77f6c6..4a8d1e9a15 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -24,7 +24,6 @@
#include "qapi/error.h"
#include "qapi/qapi-commands-acpi.h"
#include "qapi/qapi-commands-control.h"
-#include "qapi/qapi-commands-machine.h"
#include "qapi/qapi-commands-misc.h"
#include "qapi/qapi-commands-stats.h"
#include "qapi/type-helpers.h"
@@ -42,24 +41,6 @@ NameInfo *qmp_query_name(Error **errp)
return info;
}
-KvmInfo *qmp_query_kvm(Error **errp)
-{
- KvmInfo *info = g_malloc0(sizeof(*info));
-
- info->enabled = kvm_enabled();
- info->present = accel_find("kvm");
-
- return info;
-}
-
-UuidInfo *qmp_query_uuid(Error **errp)
-{
- UuidInfo *info = g_malloc0(sizeof(*info));
-
- info->UUID = qemu_uuid_unparse_strdup(&qemu_uuid);
- return info;
-}
-
void qmp_quit(Error **errp)
{
shutdown_action = SHUTDOWN_ACTION_POWEROFF;
@@ -82,16 +63,6 @@ void qmp_stop(Error **errp)
}
}
-void qmp_system_reset(Error **errp)
-{
- qemu_system_reset_request(SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET);
-}
-
-void qmp_system_powerdown(Error **errp)
-{
- qemu_system_powerdown_request();
-}
-
void qmp_cont(Error **errp)
{
BlockBackend *blk;
@@ -145,17 +116,6 @@ void qmp_cont(Error **errp)
}
}
-void qmp_system_wakeup(Error **errp)
-{
- if (!qemu_wakeup_suspend_enabled()) {
- error_setg(errp,
- "wake-up from suspend is not supported by this guest");
- return;
- }
-
- qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, errp);
-}
-
void qmp_add_client(const char *protocol, const char *fdname,
bool has_skipauth, bool skipauth, bool has_tls, bool tls,
Error **errp)
@@ -196,11 +156,6 @@ void qmp_add_client(const char *protocol, const char *fdname,
}
}
-MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp)
-{
- return qmp_memory_device_list();
-}
-
ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)
{
bool ambig;
@@ -220,101 +175,6 @@ ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)
return head;
}
-MemoryInfo *qmp_query_memory_size_summary(Error **errp)
-{
- MemoryInfo *mem_info = g_new0(MemoryInfo, 1);
- MachineState *ms = MACHINE(qdev_get_machine());
-
- mem_info->base_memory = ms->ram_size;
-
- mem_info->plugged_memory = get_plugged_memory_size();
- mem_info->has_plugged_memory =
- mem_info->plugged_memory != (uint64_t)-1;
-
- return mem_info;
-}
-
-static int qmp_x_query_rdma_foreach(Object *obj, void *opaque)
-{
- RdmaProvider *rdma;
- RdmaProviderClass *k;
- GString *buf = opaque;
-
- if (object_dynamic_cast(obj, INTERFACE_RDMA_PROVIDER)) {
- rdma = RDMA_PROVIDER(obj);
- k = RDMA_PROVIDER_GET_CLASS(obj);
- if (k->format_statistics) {
- k->format_statistics(rdma, buf);
- } else {
- g_string_append_printf(buf,
- "RDMA statistics not available for %s.\n",
- object_get_typename(obj));
- }
- }
-
- return 0;
-}
-
-HumanReadableText *qmp_x_query_rdma(Error **errp)
-{
- g_autoptr(GString) buf = g_string_new("");
-
- object_child_foreach_recursive(object_get_root(),
- qmp_x_query_rdma_foreach, buf);
-
- return human_readable_text_from_str(buf);
-}
-
-HumanReadableText *qmp_x_query_ramblock(Error **errp)
-{
- g_autoptr(GString) buf = ram_block_format();
-
- return human_readable_text_from_str(buf);
-}
-
-static int qmp_x_query_irq_foreach(Object *obj, void *opaque)
-{
- InterruptStatsProvider *intc;
- InterruptStatsProviderClass *k;
- GString *buf = opaque;
-
- if (object_dynamic_cast(obj, TYPE_INTERRUPT_STATS_PROVIDER)) {
- intc = INTERRUPT_STATS_PROVIDER(obj);
- k = INTERRUPT_STATS_PROVIDER_GET_CLASS(obj);
- uint64_t *irq_counts;
- unsigned int nb_irqs, i;
- if (k->get_statistics &&
- k->get_statistics(intc, &irq_counts, &nb_irqs)) {
- if (nb_irqs > 0) {
- g_string_append_printf(buf, "IRQ statistics for %s:\n",
- object_get_typename(obj));
- for (i = 0; i < nb_irqs; i++) {
- if (irq_counts[i] > 0) {
- g_string_append_printf(buf, "%2d: %" PRId64 "\n", i,
- irq_counts[i]);
- }
- }
- }
- } else {
- g_string_append_printf(buf,
- "IRQ statistics not available for %s.\n",
- object_get_typename(obj));
- }
- }
-
- return 0;
-}
-
-HumanReadableText *qmp_x_query_irq(Error **errp)
-{
- g_autoptr(GString) buf = g_string_new("");
-
- object_child_foreach_recursive(object_get_root(),
- qmp_x_query_irq_foreach, buf);
-
- return human_readable_text_from_str(buf);
-}
-
typedef struct StatsCallbacks {
StatsProvider provider;
StatRetrieveFunc *stats_cb;
--
2.39.0
next prev parent reply other threads:[~2023-02-03 8:52 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-03 8:45 [PULL 00/35] Monitor patches for 2023-02-03 Markus Armbruster
2023-02-03 8:45 ` [PULL 01/35] MAINTAINERS: Cover userfaultfd Markus Armbruster
2023-02-03 8:45 ` [PULL 02/35] MAINTAINERS: Cover include/sysemu/accel-blocker.h Markus Armbruster
2023-02-03 8:45 ` [PULL 03/35] MAINTAINERS: Cover tpm.c again Markus Armbruster
2023-02-03 8:45 ` [PULL 04/35] monitor: Drop unnecessary includes Markus Armbruster
2023-02-03 8:45 ` [PULL 05/35] audio: Move HMP commands from monitor/ to audio/ Markus Armbruster
2023-02-03 8:45 ` [PULL 06/35] char: Move HMP commands from monitor/ to chardev/ Markus Armbruster
2023-02-03 8:45 ` [PULL 07/35] char: Factor out qmp_add_client() parts and move " Markus Armbruster
2023-02-03 8:45 ` [PULL 08/35] hmp: Drop redundant argument check from add_completion_option() Markus Armbruster
2023-02-03 8:45 ` [PULL 09/35] readline: Extract readline_add_completion_of() from monitor Markus Armbruster
2023-02-08 8:44 ` Philippe Mathieu-Daudé
2023-02-08 10:53 ` Markus Armbruster
2023-02-08 11:06 ` Philippe Mathieu-Daudé
2023-02-03 8:45 ` [PULL 10/35] hmp: Rename help_cmd() to hmp_help_cmd(), move declaration to hmp.h Markus Armbruster
2023-02-03 8:45 ` [PULL 11/35] trace: Move HMP commands from monitor/ to trace/ Markus Armbruster
2023-02-03 8:45 ` Markus Armbruster [this message]
2023-02-03 8:45 ` [PULL 13/35] machine: Move HMP commands from monitor/ to hw/core/ Markus Armbruster
2023-02-03 8:45 ` [PULL 14/35] qom: Move HMP commands from monitor/ to qom/ Markus Armbruster
2023-02-03 8:45 ` [PULL 15/35] block: Factor out hmp_change_medium(), and move to block/monitor/ Markus Armbruster
2023-02-03 8:45 ` [PULL 16/35] rocker: Move HMP commands from monitor to hw/net/rocker/ Markus Armbruster
2023-02-03 8:45 ` [PULL 17/35] hmp: Rewrite strlist_from_comma_list() as hmp_split_at_comma() Markus Armbruster
2023-02-03 8:45 ` [PULL 18/35] net: Move HMP commands from monitor to net/ Markus Armbruster
2023-02-03 8:45 ` [PULL 19/35] net: Move hmp_info_network() to net-hmp-cmds.c Markus Armbruster
2023-02-03 8:45 ` [PULL 20/35] migration: Move HMP commands from monitor/ to migration/ Markus Armbruster
2023-02-03 8:45 ` [PULL 21/35] migration: Move the QMP command " Markus Armbruster
2023-02-03 8:45 ` [PULL 22/35] virtio: Move HMP commands from monitor/ to hw/virtio/ Markus Armbruster
2023-02-03 8:45 ` [PULL 23/35] tpm: Move HMP commands from monitor/ to softmmu/ Markus Armbruster
2023-02-03 8:45 ` [PULL 24/35] runstate: " Markus Armbruster
2023-02-03 8:45 ` [PULL 25/35] stats: Move QMP commands from monitor/ to stats/ Markus Armbruster
2023-02-03 8:45 ` [PULL 26/35] stats: Move HMP " Markus Armbruster
2023-02-03 8:45 ` [PULL 27/35] acpi: Move the QMP command from monitor/ to hw/acpi/ Markus Armbruster
2023-02-03 8:45 ` [PULL 28/35] qdev: Move HMP command completion from monitor to softmmu/ Markus Armbruster
2023-02-03 8:45 ` [PULL 29/35] monitor: Split file descriptor passing stuff off misc.c Markus Armbruster
2023-02-03 8:45 ` [PULL 30/35] monitor: Move monitor_putc() next to monitor_puts & external linkage Markus Armbruster
2023-02-03 8:45 ` [PULL 31/35] monitor: Move target-dependent HMP commands to hmp-cmds-target.c Markus Armbruster
2023-02-03 8:45 ` [PULL 32/35] monitor: Move remaining HMP commands from misc.c to hmp-cmds.c Markus Armbruster
2023-02-03 8:45 ` [PULL 33/35] monitor: Move remaining QMP stuff from misc.c to qmp-cmds.c Markus Armbruster
2023-02-03 8:45 ` [PULL 34/35] monitor: Loosen coupling between misc.c and monitor.c slightly Markus Armbruster
2023-02-03 8:45 ` [PULL 35/35] monitor: Rename misc.c to hmp-target.c Markus Armbruster
2023-02-03 15:32 ` [PULL 00/35] Monitor patches for 2023-02-03 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230203084549.2622302-13-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).