From: Andrew Cooper Date: Wed, 4 Dec 2019 21:30:29 +0000 (+0000) Subject: KVM X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=refs%2Fheads%2Fkvm;p=people%2Fandrewcoop%2Fxen-test-framework.git KVM --- diff --git a/arch/x86/hvm/traps.c b/arch/x86/hvm/traps.c index 6eee812..241ba45 100644 --- a/arch/x86/hvm/traps.c +++ b/arch/x86/hvm/traps.c @@ -146,6 +146,8 @@ void arch_init_traps(void) void __noreturn arch_crash_hard(void) { + outb(0, 0xf4); + /* * Clear interrupts and halt. Xen should catch this condition and shut * the VM down. If that fails, sit in a loop. diff --git a/arch/x86/setup.c b/arch/x86/setup.c index 3c84e96..d1cde76 100644 --- a/arch/x86/setup.c +++ b/arch/x86/setup.c @@ -235,12 +235,7 @@ static void qemu_console_write(const char *buf, size_t len) { asm volatile("rep; outsb" : "+S" (buf), "+c" (len) - : "d" (0x12)); -} - -static void xen_console_write(const char *buf, size_t len) -{ - hypercall_console_write(buf, len); + : "d" (0xe9)); } void arch_setup(void) @@ -248,14 +243,14 @@ void arch_setup(void) if ( IS_DEFINED(CONFIG_HVM) && !pvh_start_info ) register_console_callback(qemu_console_write); - register_console_callback(xen_console_write); - collect_cpuid(IS_DEFINED(CONFIG_PV) ? pv_cpuid_count : cpuid_count); sort_extable(); arch_init_traps(); + return; + init_hypercalls(); if ( !is_initdomain() ) diff --git a/build/common.mk b/build/common.mk index 644961c..ce6d74e 100644 --- a/build/common.mk +++ b/build/common.mk @@ -64,7 +64,7 @@ CFLAGS_$(1) := $$(CFLAGS_$($(1)_arch)) $$(COMMON_CFLAGS-$(1)) -DCONFIG_ENV_$(1) link-$(1) := $(ROOT)/arch/x86/link-$(1).lds -LDFLAGS_$(1) := -T $$(link-$(1)) -nostdlib $(LDFLAGS-y) +LDFLAGS_$(1) := -T $$(link-$(1)) -nostdlib -static -m32 $(LDFLAGS-y) # Needs to pick up test-provided obj-perenv and obj-perbits DEPS-$(1) = \ diff --git a/build/gen.mk b/build/gen.mk index df474a1..e292735 100644 --- a/build/gen.mk +++ b/build/gen.mk @@ -36,7 +36,7 @@ build: $(foreach env,$(TEST-ENVS),test-$(env)-$(NAME)) $(TEST-CFGS) build: info.json info.json: $(ROOT)/build/mkinfo.py Makefile - $(PYTHON) $< $@ "$(NAME)" "$(CATEGORY)" "$(TEST-ENVS)" "$(VARY-CFG)" + @$(PYTHON) $< $@.tmp "$(NAME)" "$(CATEGORY)" "$(filter-out pv%,$(TEST-ENVS))" "" .PHONY: install install-each-env install: install-each-env info.json @@ -55,7 +55,7 @@ else # hvm64 needs linking normally, then converting to elf32-x86-64 or elf32-i386 test-$(1)-$(NAME): $$(DEPS-$(1)) $$(link-$(1)) $(LD) $$(LDFLAGS_$(1)) $$(DEPS-$(1)) -o $$@.tmp - $(OBJCOPY) $$@.tmp -O $(hvm64-format) $$@ + $(OBJCOPY) $$@.tmp -O elf32-i386 $$@ rm -f $$@.tmp endif diff --git a/common/lib.c b/common/lib.c index 58f4965..ecc2571 100644 --- a/common/lib.c +++ b/common/lib.c @@ -25,7 +25,6 @@ void __noreturn panic(const char *fmt, ...) printk("******************************\n"); - hypercall_shutdown(SHUTDOWN_crash); arch_crash_hard(); } diff --git a/common/report.c b/common/report.c index ffdf098..d24635a 100644 --- a/common/report.c +++ b/common/report.c @@ -1,6 +1,7 @@ #include #include #include +#include enum test_status { STATUS_RUNNING, /**< Test not yet completed. */ @@ -124,7 +125,8 @@ bool xtf_status_reported(void) void xtf_exit(void) { xtf_report_status(); - hypercall_shutdown(SHUTDOWN_poweroff); + + outb(0, 0xf4); panic("xtf_exit(): hypercall_shutdown(SHUTDOWN_poweroff) returned\n"); } diff --git a/include/xen/arch-x86/xen.h b/include/xen/arch-x86/xen.h index 8774739..562ad08 100644 --- a/include/xen/arch-x86/xen.h +++ b/include/xen/arch-x86/xen.h @@ -145,10 +145,10 @@ struct arch_shared_info { * hypervisor's x86 emulator. */ #ifdef __ASSEMBLY__ -#define _ASM_XEN_FEP ud2a; .ascii "xen"; +#define _ASM_XEN_FEP ud2a; .ascii "kvm"; #else -#define _ASM_XEN_FEP "ud2a; .ascii \"xen\";" -#define _BIN_XEN_FEP "\x0f\x0bxen" +#define _ASM_XEN_FEP "ud2a; .ascii \"kvm\";" +#define _BIN_XEN_FEP "\x0f\x0bkvm" #endif #endif /* XEN_PUBLIC_ARCH_X86_XEN_H */ diff --git a/xtf-runner b/xtf-runner index 4a6e590..ba46c40 100755 --- a/xtf-runner +++ b/xtf-runner @@ -93,9 +93,12 @@ class TestInstance(object): """ Return the VM name as `xl` expects it. """ return repr(self) + def vm_path(self): + return path.join("tests", self.name, repr(self)) + def cfg_path(self): """ Return the path to the `xl` config file for this test. """ - return path.join("tests", self.name, repr(self) + ".cfg") + return self.vm_path() + ".cfg" def __repr__(self): if not self.variation: @@ -461,40 +464,17 @@ def interpret_result(logline): def run_test_console(opts, test): """ Run a specific, obtaining results via xenconsole """ - cmd = ['xl', 'create', '-p', test.cfg_path()] - if not opts.quiet: - print("Executing '{0}'".format(" ".join(cmd))) + cmd = ["qemu-system-x86_64", + "-nodefaults", "-nographic", "-cpu", "host", "-machine", "accel=kvm", + "-debugcon", "stdio", + "-device", "isa-debug-exit,iobase=0xf4,iosize=0x4", + "-kernel", test.vm_path()] - create = Popen(cmd, stdout = PIPE, stderr = PIPE) - _, stderr = create.communicate() - - if create.returncode: - if opts.quiet: - print("Executing '{0}'".format(" ".join(cmd))) - print(stderr) - raise RunnerError("Failed to create VM") - - cmd = ['xl', 'console', test.vm_name()] if not opts.quiet: print("Executing '{0}'".format(" ".join(cmd))) - console = Popen(cmd, stdout = PIPE) - - cmd = ['xl', 'unpause', test.vm_name()] - if not opts.quiet: - print("Executing '{0}'".format(" ".join(cmd))) - - rc = subproc_call(cmd) - if rc: - if opts.quiet: - print("Executing '{0}'".format(" ".join(cmd))) - raise RunnerError("Failed to unpause VM") - + console = Popen(cmd, stdout = PIPE, stderr = PIPE) stdout, _ = console.communicate() - - if console.returncode: - raise RunnerError("Failed to obtain VM console") - lines = stdout.splitlines() if lines: