mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-09-04 12:41:37 +00:00
kvm: Add force exit from tests
To make so we write any value to port 0 and start kvm in --dbgtest mode so we are expecting for this exit. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
committed by
Will Deacon
parent
339c64c83a
commit
3db4f1beb3
@@ -79,7 +79,7 @@ bios/int10.o: bios/int10.S bios/int10-real.S
|
||||
|
||||
check: $(PROGRAM)
|
||||
$(MAKE) -C tests
|
||||
./$(PROGRAM) tests/pit/tick.bin
|
||||
./$(PROGRAM) --dbgtest tests/pit/tick.bin
|
||||
.PHONY: check
|
||||
|
||||
clean:
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
unsigned int dbgtest_mode;
|
||||
|
||||
static void usage(char *argv[])
|
||||
{
|
||||
fprintf(stderr, " usage: %s [--single-step] [--kernel=]<kernel-image>\n",
|
||||
fprintf(stderr, " usage: %s [--dbgtest] [--single-step] [--kernel=]<kernel-image>\n",
|
||||
argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
@@ -48,6 +50,9 @@ int main(int argc, char *argv[])
|
||||
} else if (!strncmp("--params=", argv[i], 9)) {
|
||||
kernel_cmdline = &argv[i][9];
|
||||
continue;
|
||||
} else if (!strncmp("--dbgtest", argv[i], 9)) {
|
||||
dbgtest_mode = 1;
|
||||
continue;
|
||||
} else if (!strncmp("--single-step", argv[i], 13)) {
|
||||
single_step = true;
|
||||
continue;
|
||||
@@ -126,6 +131,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
exit_kvm:
|
||||
|
||||
if (dbgtest_mode) {
|
||||
if (kvm->kvm_run->exit_reason == KVM_EXIT_IO &&
|
||||
kvm->kvm_run->io.port == 0)
|
||||
fprintf(stderr, "KVM: this is an expected IO error\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
fprintf(stderr, "KVM exit reason: %" PRIu32 " (\"%s\")\n",
|
||||
kvm->kvm_run->exit_reason, kvm_exit_reasons[kvm->kvm_run->exit_reason]);
|
||||
if (kvm->kvm_run->exit_reason == KVM_EXIT_UNKNOWN)
|
||||
@@ -135,7 +148,7 @@ exit_kvm:
|
||||
kvm__show_registers(kvm);
|
||||
kvm__show_code(kvm);
|
||||
kvm__show_page_tables(kvm);
|
||||
|
||||
out:
|
||||
kvm__delete(kvm);
|
||||
|
||||
return 0;
|
||||
|
||||
+5
-1
@@ -4,6 +4,8 @@
|
||||
#define TIMER_FREQ 1193182
|
||||
#define TIMER_DIV(x) ((TIMER_FREQ+(x)/2)/(x))
|
||||
|
||||
#define DBG_PORT 0
|
||||
|
||||
#define TEST_COUNT 0x0200
|
||||
|
||||
.code16gcc
|
||||
@@ -72,7 +74,9 @@ test_ok:
|
||||
cs lea msg2, %si
|
||||
mov $(msg2_end-msg2), %cx
|
||||
cs rep/outsb
|
||||
hlt
|
||||
|
||||
/* not a valid port to force exit */
|
||||
outb %al, $DBG_PORT
|
||||
|
||||
timer_isr:
|
||||
cli
|
||||
|
||||
Reference in New Issue
Block a user