Skip to content

Commit 92e28c0

Browse files
committed
monitor: move x-query-profile into accel/tcg to fix build
As --enable-profiler isn't defended in CI we missed this breakage. Move the qmp handler into accel/tcg so we have access to the helpers we need. While we are at it ensure we gate the feature on CONFIG_TCG. Signed-off-by: Alex Bennée <[email protected]> Suggested-by: Daniel P. Berrangé <[email protected]> Reported-by: Mark Cave-Ayland <[email protected]> Fixes: 37087fd ("qapi: introduce x-query-profile QMP command") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/773 Reviewed-by: Daniel P. Berrangé <[email protected]> Tested-by: Mark Cave-Ayland <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Message-Id: <[email protected]>
1 parent 33973e1 commit 92e28c0

File tree

4 files changed

+34
-31
lines changed

4 files changed

+34
-31
lines changed

accel/tcg/cpu-exec.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,4 +1090,35 @@ HumanReadableText *qmp_x_query_opcount(Error **errp)
10901090
return human_readable_text_from_str(buf);
10911091
}
10921092

1093+
#ifdef CONFIG_PROFILER
1094+
1095+
int64_t dev_time;
1096+
1097+
HumanReadableText *qmp_x_query_profile(Error **errp)
1098+
{
1099+
g_autoptr(GString) buf = g_string_new("");
1100+
static int64_t last_cpu_exec_time;
1101+
int64_t cpu_exec_time;
1102+
int64_t delta;
1103+
1104+
cpu_exec_time = tcg_cpu_exec_time();
1105+
delta = cpu_exec_time - last_cpu_exec_time;
1106+
1107+
g_string_append_printf(buf, "async time %" PRId64 " (%0.3f)\n",
1108+
dev_time, dev_time / (double)NANOSECONDS_PER_SECOND);
1109+
g_string_append_printf(buf, "qemu time %" PRId64 " (%0.3f)\n",
1110+
delta, delta / (double)NANOSECONDS_PER_SECOND);
1111+
last_cpu_exec_time = cpu_exec_time;
1112+
dev_time = 0;
1113+
1114+
return human_readable_text_from_str(buf);
1115+
}
1116+
#else
1117+
HumanReadableText *qmp_x_query_profile(Error **errp)
1118+
{
1119+
error_setg(errp, "Internal profiler not compiled");
1120+
return NULL;
1121+
}
1122+
#endif
1123+
10931124
#endif /* !CONFIG_USER_ONLY */

hmp-commands-info.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,15 @@ SRST
358358
Show host USB devices.
359359
ERST
360360

361+
#if defined(CONFIG_TCG)
361362
{
362363
.name = "profile",
363364
.args_type = "",
364365
.params = "",
365366
.help = "show profiling information",
366367
.cmd_info_hrt = qmp_x_query_profile,
367368
},
369+
#endif
368370

369371
SRST
370372
``info profile``

monitor/qmp-cmds.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -368,37 +368,6 @@ void qmp_display_reload(DisplayReloadOptions *arg, Error **errp)
368368
}
369369
}
370370

371-
#ifdef CONFIG_PROFILER
372-
373-
int64_t dev_time;
374-
375-
HumanReadableText *qmp_x_query_profile(Error **errp)
376-
{
377-
g_autoptr(GString) buf = g_string_new("");
378-
static int64_t last_cpu_exec_time;
379-
int64_t cpu_exec_time;
380-
int64_t delta;
381-
382-
cpu_exec_time = tcg_cpu_exec_time();
383-
delta = cpu_exec_time - last_cpu_exec_time;
384-
385-
g_string_append_printf(buf, "async time %" PRId64 " (%0.3f)\n",
386-
dev_time, dev_time / (double)NANOSECONDS_PER_SECOND);
387-
g_string_append_printf(buf, "qemu time %" PRId64 " (%0.3f)\n",
388-
delta, delta / (double)NANOSECONDS_PER_SECOND);
389-
last_cpu_exec_time = cpu_exec_time;
390-
dev_time = 0;
391-
392-
return human_readable_text_from_str(buf);
393-
}
394-
#else
395-
HumanReadableText *qmp_x_query_profile(Error **errp)
396-
{
397-
error_setg(errp, "Internal profiler not compiled");
398-
return NULL;
399-
}
400-
#endif
401-
402371
static int qmp_x_query_rdma_foreach(Object *obj, void *opaque)
403372
{
404373
RdmaProvider *rdma;

qapi/machine.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,7 @@
15031503
##
15041504
{ 'command': 'x-query-profile',
15051505
'returns': 'HumanReadableText',
1506+
'if': 'CONFIG_TCG',
15061507
'features': [ 'unstable' ] }
15071508

15081509
##

0 commit comments

Comments
 (0)