aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2024-09-16 09:54:00 +0100
committerAlex Bennée <alex.bennee@linaro.org>2024-09-19 15:58:01 +0100
commit8148fb56c753908fcc41d52846f9d8e6ae5f7daf (patch)
treed6422561f1eb640e15ac73d2b778cbab53546c31
parentf2505260b35e811ce1d85678eaf020ee1b59d2d0 (diff)
downloadqemu-8148fb56c753908fcc41d52846f9d8e6ae5f7daf.zip
qemu-8148fb56c753908fcc41d52846f9d8e6ae5f7daf.tar.gz
qemu-8148fb56c753908fcc41d52846f9d8e6ae5f7daf.tar.bz2
contrib/plugins: avoid hanging program
Although we asks for instructions per second we work in quanta and that cannot be 0. Fail to load the plugin instead and report the minimum IPS we can handle. Reported-by: Elisha Hollander <just4now666666@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Message-Id: <20240916085400.1046925-19-alex.bennee@linaro.org>
-rw-r--r--contrib/plugins/ips.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/contrib/plugins/ips.c b/contrib/plugins/ips.c
index 29fa556..e5297db 100644
--- a/contrib/plugins/ips.c
+++ b/contrib/plugins/ips.c
@@ -152,6 +152,12 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
vcpus = qemu_plugin_scoreboard_new(sizeof(vCPUTime));
max_insn_per_quantum = max_insn_per_second / NUM_TIME_UPDATE_PER_SEC;
+ if (max_insn_per_quantum == 0) {
+ fprintf(stderr, "minimum of %d instructions per second needed\n",
+ NUM_TIME_UPDATE_PER_SEC);
+ return -1;
+ }
+
time_handle = qemu_plugin_request_time_control();
g_assert(time_handle);