[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 027/126] accel/tcg: Restrict 'qapi-commands-machine.h' to system e
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 027/126] accel/tcg: Restrict 'qapi-commands-machine.h' to system emulation |
Date: |
Mon, 27 Feb 2023 15:00:34 +0100 |
Since commit a0e61807a3 ("qapi: Remove QMP events and commands from
user-mode builds") we don't generate the "qapi-commands-machine.h"
header in a user-emulation-only build.
Rename 'hmp.c' as 'monitor.c' and move the QMP functions from
cpu-exec.c (which is always compiled) to monitor.c (which is only
compiled when system-emulation is selected).
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20221219170806.60580-4-philmd@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
accel/tcg/cpu-exec.c | 88 +----------------------------------
accel/tcg/hmp.c | 14 ------
accel/tcg/internal.h | 3 ++
accel/tcg/meson.build | 2 +-
accel/tcg/monitor.c | 106 ++++++++++++++++++++++++++++++++++++++++++
5 files changed, 112 insertions(+), 101 deletions(-)
delete mode 100644 accel/tcg/hmp.c
create mode 100644 accel/tcg/monitor.c
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 29b9bdac38..5c9e30a803 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -20,7 +20,6 @@
#include "qemu/osdep.h"
#include "qemu/qemu-print.h"
#include "qapi/error.h"
-#include "qapi/qapi-commands-machine.h"
#include "qapi/type-helpers.h"
#include "hw/core/tcg-cpu-ops.h"
#include "trace.h"
@@ -63,8 +62,8 @@ typedef struct SyncClocks {
#define MAX_DELAY_PRINT_RATE 2000000000LL
#define MAX_NB_PRINTS 100
-static int64_t max_delay;
-static int64_t max_advance;
+int64_t max_delay;
+int64_t max_advance;
static void align_clocks(SyncClocks *sc, CPUState *cpu)
{
@@ -1071,86 +1070,3 @@ void tcg_exec_unrealizefn(CPUState *cpu)
tlb_destroy(cpu);
g_free_rcu(cpu->tb_jmp_cache, rcu);
}
-
-#ifndef CONFIG_USER_ONLY
-
-static void dump_drift_info(GString *buf)
-{
- if (!icount_enabled()) {
- return;
- }
-
- g_string_append_printf(buf, "Host - Guest clock %"PRIi64" ms\n",
- (cpu_get_clock() - icount_get()) / SCALE_MS);
- if (icount_align_option) {
- g_string_append_printf(buf, "Max guest delay %"PRIi64" ms\n",
- -max_delay / SCALE_MS);
- g_string_append_printf(buf, "Max guest advance %"PRIi64" ms\n",
- max_advance / SCALE_MS);
- } else {
- g_string_append_printf(buf, "Max guest delay NA\n");
- g_string_append_printf(buf, "Max guest advance NA\n");
- }
-}
-
-HumanReadableText *qmp_x_query_jit(Error **errp)
-{
- g_autoptr(GString) buf = g_string_new("");
-
- if (!tcg_enabled()) {
- error_setg(errp, "JIT information is only available with accel=tcg");
- return NULL;
- }
-
- dump_exec_info(buf);
- dump_drift_info(buf);
-
- return human_readable_text_from_str(buf);
-}
-
-HumanReadableText *qmp_x_query_opcount(Error **errp)
-{
- g_autoptr(GString) buf = g_string_new("");
-
- if (!tcg_enabled()) {
- error_setg(errp, "Opcode count information is only available with
accel=tcg");
- return NULL;
- }
-
- tcg_dump_op_count(buf);
-
- return human_readable_text_from_str(buf);
-}
-
-#ifdef CONFIG_PROFILER
-
-int64_t dev_time;
-
-HumanReadableText *qmp_x_query_profile(Error **errp)
-{
- g_autoptr(GString) buf = g_string_new("");
- static int64_t last_cpu_exec_time;
- int64_t cpu_exec_time;
- int64_t delta;
-
- cpu_exec_time = tcg_cpu_exec_time();
- delta = cpu_exec_time - last_cpu_exec_time;
-
- g_string_append_printf(buf, "async time %" PRId64 " (%0.3f)\n",
- dev_time, dev_time /
(double)NANOSECONDS_PER_SECOND);
- g_string_append_printf(buf, "qemu time %" PRId64 " (%0.3f)\n",
- delta, delta / (double)NANOSECONDS_PER_SECOND);
- last_cpu_exec_time = cpu_exec_time;
- dev_time = 0;
-
- return human_readable_text_from_str(buf);
-}
-#else
-HumanReadableText *qmp_x_query_profile(Error **errp)
-{
- error_setg(errp, "Internal profiler not compiled");
- return NULL;
-}
-#endif
-
-#endif /* !CONFIG_USER_ONLY */
diff --git a/accel/tcg/hmp.c b/accel/tcg/hmp.c
deleted file mode 100644
index bb67941420..0000000000
--- a/accel/tcg/hmp.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "qemu/osdep.h"
-#include "qemu/error-report.h"
-#include "qapi/error.h"
-#include "qapi/qapi-commands-machine.h"
-#include "exec/exec-all.h"
-#include "monitor/monitor.h"
-
-static void hmp_tcg_register(void)
-{
- monitor_register_hmp_info_hrt("jit", qmp_x_query_jit);
- monitor_register_hmp_info_hrt("opcount", qmp_x_query_opcount);
-}
-
-type_init(hmp_tcg_register);
diff --git a/accel/tcg/internal.h b/accel/tcg/internal.h
index 6edff16fb0..130d7fd564 100644
--- a/accel/tcg/internal.h
+++ b/accel/tcg/internal.h
@@ -64,4 +64,7 @@ static inline target_ulong log_pc(CPUState *cpu, const
TranslationBlock *tb)
#endif
}
+extern int64_t max_delay;
+extern int64_t max_advance;
+
#endif /* ACCEL_TCG_INTERNAL_H */
diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
index 77740b1a0d..aeb20a6ef0 100644
--- a/accel/tcg/meson.build
+++ b/accel/tcg/meson.build
@@ -18,7 +18,7 @@ specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss)
specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files(
'cputlb.c',
- 'hmp.c',
+ 'monitor.c',
))
tcg_module_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files(
diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
new file mode 100644
index 0000000000..1450e160e9
--- /dev/null
+++ b/accel/tcg/monitor.c
@@ -0,0 +1,106 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * QEMU TCG monitor
+ *
+ * Copyright (c) 2003-2005 Fabrice Bellard
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qapi/type-helpers.h"
+#include "qapi/qapi-commands-machine.h"
+#include "monitor/monitor.h"
+#include "sysemu/cpus.h"
+#include "sysemu/cpu-timers.h"
+#include "sysemu/tcg.h"
+#include "internal.h"
+
+
+static void dump_drift_info(GString *buf)
+{
+ if (!icount_enabled()) {
+ return;
+ }
+
+ g_string_append_printf(buf, "Host - Guest clock %"PRIi64" ms\n",
+ (cpu_get_clock() - icount_get()) / SCALE_MS);
+ if (icount_align_option) {
+ g_string_append_printf(buf, "Max guest delay %"PRIi64" ms\n",
+ -max_delay / SCALE_MS);
+ g_string_append_printf(buf, "Max guest advance %"PRIi64" ms\n",
+ max_advance / SCALE_MS);
+ } else {
+ g_string_append_printf(buf, "Max guest delay NA\n");
+ g_string_append_printf(buf, "Max guest advance NA\n");
+ }
+}
+
+HumanReadableText *qmp_x_query_jit(Error **errp)
+{
+ g_autoptr(GString) buf = g_string_new("");
+
+ if (!tcg_enabled()) {
+ error_setg(errp, "JIT information is only available with accel=tcg");
+ return NULL;
+ }
+
+ dump_exec_info(buf);
+ dump_drift_info(buf);
+
+ return human_readable_text_from_str(buf);
+}
+
+HumanReadableText *qmp_x_query_opcount(Error **errp)
+{
+ g_autoptr(GString) buf = g_string_new("");
+
+ if (!tcg_enabled()) {
+ error_setg(errp,
+ "Opcode count information is only available with
accel=tcg");
+ return NULL;
+ }
+
+ tcg_dump_op_count(buf);
+
+ return human_readable_text_from_str(buf);
+}
+
+#ifdef CONFIG_PROFILER
+
+int64_t dev_time;
+
+HumanReadableText *qmp_x_query_profile(Error **errp)
+{
+ g_autoptr(GString) buf = g_string_new("");
+ static int64_t last_cpu_exec_time;
+ int64_t cpu_exec_time;
+ int64_t delta;
+
+ cpu_exec_time = tcg_cpu_exec_time();
+ delta = cpu_exec_time - last_cpu_exec_time;
+
+ g_string_append_printf(buf, "async time %" PRId64 " (%0.3f)\n",
+ dev_time, dev_time /
(double)NANOSECONDS_PER_SECOND);
+ g_string_append_printf(buf, "qemu time %" PRId64 " (%0.3f)\n",
+ delta, delta / (double)NANOSECONDS_PER_SECOND);
+ last_cpu_exec_time = cpu_exec_time;
+ dev_time = 0;
+
+ return human_readable_text_from_str(buf);
+}
+#else
+HumanReadableText *qmp_x_query_profile(Error **errp)
+{
+ error_setg(errp, "Internal profiler not compiled");
+ return NULL;
+}
+#endif
+
+static void hmp_tcg_register(void)
+{
+ monitor_register_hmp_info_hrt("jit", qmp_x_query_jit);
+ monitor_register_hmp_info_hrt("opcount", qmp_x_query_opcount);
+}
+
+type_init(hmp_tcg_register);
--
2.38.1
- [PULL 017/126] target/ppc: Fix warning with clang-15, (continued)
- [PULL 017/126] target/ppc: Fix warning with clang-15, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 018/126] target/riscv/cpu: Move Floating-Point fields closer, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 019/126] target/sparc/sysemu: Remove pointless CONFIG_USER_ONLY guard, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 020/126] target/xtensa/cpu: Include missing "memory.h" header, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 021/126] target/tricore: Remove unused fields from CPUTriCoreState, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 022/126] qom/object_interfaces: Fix QAPI headers included, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 023/126] trace: Do not try to include QMP commands in user emulation binaries, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 024/126] exec: Remove unused 'qemu/timer.h' timer, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 025/126] tcg: Silent -Wmissing-field-initializers warning, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 026/126] tcg/tcg-op-gvec: Remove unused "qemu/main-loop.h" header, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 027/126] accel/tcg: Restrict 'qapi-commands-machine.h' to system emulation,
Philippe Mathieu-Daudé <=
- [PULL 030/126] sysemu/kvm: Remove CONFIG_USER_ONLY guard, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 029/126] accel/kvm: Silent -Wmissing-field-initializers warning, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 028/126] accel/xen: Remove dead code, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 031/126] replay: Extract core API to 'exec/replay-core.h', Philippe Mathieu-Daudé, 2023/02/27
- [PULL 032/126] tests/unit: Restrict machine-smp.c test to system emulation, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 033/126] softmmu: Silent -Wmissing-field-initializers warning, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 035/126] qemu/typedefs: Sort in case-insensitive alphabetical order (again), Philippe Mathieu-Daudé, 2023/02/27
- [PULL 034/126] softmmu: Extract watchpoint API from physmem.c, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 036/126] hw/nubus/nubus-device: Fix memory leak in nubus_device_realize, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 037/126] hw/qdev: Constify DeviceState* argument of qdev_get_parent_bus(), Philippe Mathieu-Daudé, 2023/02/27