]> xenbits.xensource.com Git - people/aperard/qemu-dm.git/commitdiff
contrib/plugins: avoid hanging program
authorAlex Bennée <alex.bennee@linaro.org>
Mon, 16 Sep 2024 08:54:00 +0000 (09:54 +0100)
committerAlex Bennée <alex.bennee@linaro.org>
Thu, 19 Sep 2024 14:58:01 +0000 (15:58 +0100)
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>

contrib/plugins/ips.c

index 29fa556d0ffeb301605f5591e22b300eca6387f0..e5297dbb01b1a391c7ce5ecd533feaf1dcd74f12 100644 (file)
@@ -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);