@@ -2825,6 +2825,12 @@ static void user_register_global_props(void)
global_init_func, NULL, NULL);
}
+static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp)
+{
+ configure_icount(opts, errp);
+ return 0;
+}
+
int main(int argc, char **argv, char **envp)
{
int i;
@@ -4165,6 +4171,8 @@ int main(int argc, char **argv, char **envp)
* Note: uses machine properties such as kernel-irqchip, must run
* after machine_set_property().
*/
+ qemu_opts_foreach(qemu_find_opts("icount"),
+ do_configure_icount, NULL, &error_fatal);
configure_accelerator(current_machine, argv[0]);
/*
@@ -4250,13 +4258,9 @@ int main(int argc, char **argv, char **envp)
qemu_spice_init();
cpu_ticks_init();
- if (icount_opts) {
- if (!tcg_enabled()) {
- error_report("-icount is not allowed with hardware virtualization");
- exit(1);
- }
- configure_icount(icount_opts, &error_abort);
- qemu_opts_del(icount_opts);
+ if (!tcg_enabled() && use_icount) {
+ error_report("-icount is not allowed with hardware virtualization");
+ exit(1);
}
if (tcg_enabled()) {