tests/vm: Add a BaseVM::arch property

The 'arch' property gives a hint on which architecture the guest image runs.

This can be use to select the correct QEMU binary path.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20181013004034.6968-6-f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Fam Zheng <famz@redhat.com>
This commit is contained in:
Philippe Mathieu-Daudé 2018-10-13 02:40:30 +02:00 committed by Fam Zheng
parent f5d3d21847
commit 31719c37f5
6 changed files with 8 additions and 1 deletions

View File

@ -42,6 +42,8 @@ class BaseVM(object):
BUILD_SCRIPT = "" BUILD_SCRIPT = ""
# The guest name, to be overridden by subclasses # The guest name, to be overridden by subclasses
name = "#base" name = "#base"
# The guest architecture, to be overridden by subclasses
arch = "#arch"
def __init__(self, debug=False, vcpus=None): def __init__(self, debug=False, vcpus=None):
self._guest = None self._guest = None
self._tmpdir = os.path.realpath(tempfile.mkdtemp(prefix="vm-test-", self._tmpdir = os.path.realpath(tempfile.mkdtemp(prefix="vm-test-",
@ -151,7 +153,7 @@ class BaseVM(object):
"-device", "virtio-blk,drive=drive0,bootindex=0"] "-device", "virtio-blk,drive=drive0,bootindex=0"]
args += self._data_args + extra_args args += self._data_args + extra_args
logging.debug("QEMU args: %s", " ".join(args)) logging.debug("QEMU args: %s", " ".join(args))
qemu_bin = os.environ.get("QEMU", "qemu-system-x86_64") qemu_bin = os.environ.get("QEMU", "qemu-system-" + self.arch)
guest = QEMUMachine(binary=qemu_bin, args=args) guest = QEMUMachine(binary=qemu_bin, args=args)
try: try:
guest.launch() guest.launch()

View File

@ -19,6 +19,7 @@ import time
class CentosVM(basevm.BaseVM): class CentosVM(basevm.BaseVM):
name = "centos" name = "centos"
arch = "x86_64"
BUILD_SCRIPT = """ BUILD_SCRIPT = """
set -e; set -e;
cd $(mktemp -d); cd $(mktemp -d);

View File

@ -18,6 +18,7 @@ import basevm
class FreeBSDVM(basevm.BaseVM): class FreeBSDVM(basevm.BaseVM):
name = "freebsd" name = "freebsd"
arch = "x86_64"
BUILD_SCRIPT = """ BUILD_SCRIPT = """
set -e; set -e;
rm -rf /var/tmp/qemu-test.* rm -rf /var/tmp/qemu-test.*

View File

@ -18,6 +18,7 @@ import basevm
class NetBSDVM(basevm.BaseVM): class NetBSDVM(basevm.BaseVM):
name = "netbsd" name = "netbsd"
arch = "x86_64"
BUILD_SCRIPT = """ BUILD_SCRIPT = """
set -e; set -e;
rm -rf /var/tmp/qemu-test.* rm -rf /var/tmp/qemu-test.*

View File

@ -18,6 +18,7 @@ import basevm
class OpenBSDVM(basevm.BaseVM): class OpenBSDVM(basevm.BaseVM):
name = "openbsd" name = "openbsd"
arch = "x86_64"
BUILD_SCRIPT = """ BUILD_SCRIPT = """
set -e; set -e;
rm -rf /var/tmp/qemu-test.* rm -rf /var/tmp/qemu-test.*

View File

@ -19,6 +19,7 @@ import time
class UbuntuX86VM(basevm.BaseVM): class UbuntuX86VM(basevm.BaseVM):
name = "ubuntu.i386" name = "ubuntu.i386"
arch = "i386"
BUILD_SCRIPT = """ BUILD_SCRIPT = """
set -e; set -e;
cd $(mktemp -d); cd $(mktemp -d);