icount_configure() rejects "shift=auto" combined with "align=on"
or "sleep=off", but the checks read the file-scope variables
icount_align_option and icount_sleep. Those are only assigned
from the parsed options after the checks, so at that point they
still hold their defaults (false and true). Neither check can
trigger, and both invalid combinations were silently accepted:
$ qemu-system-aarch64 -M virt -icount shift=auto,sleep=off
$ qemu-system-aarch64 -M virt -icount shift=auto,align=on
Test the values just parsed from the command line instead.
Both commands now fail with:
qemu-system-aarch64: -icount shift=auto,sleep=off: shift=auto and sleep=off
are incompatible
qemu-system-aarch64: -icount shift=auto,align=on: shift=auto and align=on are
incompatible
Valid combinations still accepted:
- shift=auto
- shift=3,sleep=off
- shift=3,align=on
Fixes: abc9bf69a66a ("cpus: Fix configure_icount() error API violation")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
accel/tcg/icount-common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/accel/tcg/icount-common.c b/accel/tcg/icount-common.c
index b1b6c005fe71..840ac418e658 100644
--- a/accel/tcg/icount-common.c
+++ b/accel/tcg/icount-common.c
@@ -441,10 +441,10 @@ bool icount_configure(QemuOpts *opts, Error **errp)
error_setg(errp, "icount: Invalid shift value");
return false;
}
- } else if (icount_align_option) {
+ } else if (align) {
error_setg(errp, "shift=auto and align=on are incompatible");
return false;
- } else if (!icount_sleep) {
+ } else if (!sleep) {
error_setg(errp, "shift=auto and sleep=off are incompatible");
return false;
}
--
2.55.0