mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-24 12:09:58 +00:00
Testing patches
One fix for mingw build and some improvements in VM based testing, many thanks to Paolo and Phil. -----BEGIN PGP SIGNATURE----- iQFEBAABCAAuFiEEUAN8t5cGD3bwIa1WyjViTGqRccYFAlvTIXEQHGZhbXpAcmVk aGF0LmNvbQAKCRDKNWJMapFxxlRqB/99FX5texTlvPy2yH8jC6eXWt1XzcqVc9Ei TPHJ3LLR7EqjTBD/NCgvRzed4D0U2uRm8rXssujJPUnqt9hmlpNPzIEqLeV650hB QBWWC8rrxzPMGKbQzBE0b/bbAaXW4KFsBXicmrTJz6MCN12S4yGwMJg3B7yAeXtp 2cVjhmoXiynx7qsWjKl8+hvSmCSMYvsfNygHGbFaLdr/CB8+ug/5fRg2yrhWz68U emcjljgHRiZpKy8Kn0F0lKTPqKCYi0EVxoDk424c2Ag+oGZsxvhJMolPooOWVXCX 8bfmzyRR2aPi9m8bfp42+yqYYopD/ncr2zF65+6OYtTA2GfxiywG =wIx1 -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/famz/tags/testing-pull-request' into staging Testing patches One fix for mingw build and some improvements in VM based testing, many thanks to Paolo and Phil. # gpg: Signature made Fri 26 Oct 2018 15:15:13 BST # gpg: using RSA key CA35624C6A9171C6 # gpg: Good signature from "Fam Zheng <famz@redhat.com>" # Primary key fingerprint: 5003 7CB7 9706 0F76 F021 AD56 CA35 624C 6A91 71C6 * remotes/famz/tags/testing-pull-request: tests/vm: Do not abuse parallelism when HOST != TARGET architecture tests/vm: Do not use -enable-kvm if HOST != TARGET architecture tests/vm: Let kvm_available() work in cross environments tests/vm: Add a BaseVM::arch property tests/vm: Display remaining seconds to wait for a VM to start tests/vm: Do not use the -smp option with a single cpu tests/vm: Do not abuse parallelism when KVM is not available tests/vm: Extract the kvm_available() handy function tests: docker: update test-mingw for GTK+ 2.0 removal Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
285278ca78
@ -26,6 +26,12 @@ import tempfile
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def kvm_available(target_arch=None):
|
||||
if target_arch and target_arch != os.uname()[4]:
|
||||
return False
|
||||
return os.access("/dev/kvm", os.R_OK | os.W_OK)
|
||||
|
||||
|
||||
#: Maps machine types to the preferred console device types
|
||||
CONSOLE_DEV_TYPES = {
|
||||
r'^clipper$': 'isa-serial',
|
||||
|
@ -28,8 +28,7 @@ for prefix in x86_64-w64-mingw32- i686-w64-mingw32-; do
|
||||
--enable-vnc \
|
||||
--enable-bzip2 \
|
||||
--enable-guest-agent \
|
||||
--with-sdlabi=2.0 \
|
||||
--with-gtkabi=3.0
|
||||
--with-sdlabi=2.0
|
||||
install_qemu
|
||||
make clean
|
||||
|
||||
|
@ -18,7 +18,7 @@ import logging
|
||||
import time
|
||||
import datetime
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "scripts"))
|
||||
from qemu import QEMUMachine
|
||||
from qemu import QEMUMachine, kvm_available
|
||||
import subprocess
|
||||
import hashlib
|
||||
import optparse
|
||||
@ -42,6 +42,8 @@ class BaseVM(object):
|
||||
BUILD_SCRIPT = ""
|
||||
# The guest name, to be overridden by subclasses
|
||||
name = "#base"
|
||||
# The guest architecture, to be overridden by subclasses
|
||||
arch = "#arch"
|
||||
def __init__(self, debug=False, vcpus=None):
|
||||
self._guest = None
|
||||
self._tmpdir = os.path.realpath(tempfile.mkdtemp(prefix="vm-test-",
|
||||
@ -70,9 +72,9 @@ class BaseVM(object):
|
||||
"-device", "virtio-net-pci,netdev=vnet",
|
||||
"-vnc", "127.0.0.1:0,to=20",
|
||||
"-serial", "file:%s" % os.path.join(self._tmpdir, "serial.out")]
|
||||
if vcpus:
|
||||
if vcpus and vcpus > 1:
|
||||
self._args += ["-smp", str(vcpus)]
|
||||
if os.access("/dev/kvm", os.R_OK | os.W_OK):
|
||||
if kvm_available(self.arch):
|
||||
self._args += ["-enable-kvm"]
|
||||
else:
|
||||
logging.info("KVM not available, not using -enable-kvm")
|
||||
@ -151,7 +153,7 @@ class BaseVM(object):
|
||||
"-device", "virtio-blk,drive=drive0,bootindex=0"]
|
||||
args += self._data_args + extra_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)
|
||||
try:
|
||||
guest.launch()
|
||||
@ -177,11 +179,14 @@ class BaseVM(object):
|
||||
|
||||
def wait_ssh(self, seconds=300):
|
||||
starttime = datetime.datetime.now()
|
||||
endtime = starttime + datetime.timedelta(seconds=seconds)
|
||||
guest_up = False
|
||||
while (datetime.datetime.now() - starttime).total_seconds() < seconds:
|
||||
while datetime.datetime.now() < endtime:
|
||||
if self.ssh("exit 0") == 0:
|
||||
guest_up = True
|
||||
break
|
||||
seconds = (endtime - datetime.datetime.now()).total_seconds()
|
||||
logging.debug("%ds before timeout", seconds)
|
||||
time.sleep(1)
|
||||
if not guest_up:
|
||||
raise Exception("Timeout while waiting for guest ssh")
|
||||
@ -195,7 +200,14 @@ class BaseVM(object):
|
||||
def qmp(self, *args, **kwargs):
|
||||
return self._guest.qmp(*args, **kwargs)
|
||||
|
||||
def parse_args(vm_name):
|
||||
def parse_args(vmcls):
|
||||
|
||||
def get_default_jobs():
|
||||
if kvm_available(vmcls.arch):
|
||||
return multiprocessing.cpu_count() / 2
|
||||
else:
|
||||
return 1
|
||||
|
||||
parser = optparse.OptionParser(
|
||||
description="VM test utility. Exit codes: "
|
||||
"0 = success, "
|
||||
@ -204,11 +216,11 @@ def parse_args(vm_name):
|
||||
"3 = test command failed")
|
||||
parser.add_option("--debug", "-D", action="store_true",
|
||||
help="enable debug output")
|
||||
parser.add_option("--image", "-i", default="%s.img" % vm_name,
|
||||
parser.add_option("--image", "-i", default="%s.img" % vmcls.name,
|
||||
help="image file name")
|
||||
parser.add_option("--force", "-f", action="store_true",
|
||||
help="force build image even if image exists")
|
||||
parser.add_option("--jobs", type=int, default=multiprocessing.cpu_count() / 2,
|
||||
parser.add_option("--jobs", type=int, default=get_default_jobs(),
|
||||
help="number of virtual CPUs")
|
||||
parser.add_option("--verbose", "-V", action="store_true",
|
||||
help="Pass V=1 to builds within the guest")
|
||||
@ -225,7 +237,7 @@ def parse_args(vm_name):
|
||||
|
||||
def main(vmcls):
|
||||
try:
|
||||
args, argv = parse_args(vmcls.name)
|
||||
args, argv = parse_args(vmcls)
|
||||
if not argv and not args.build_qemu and not args.build_image:
|
||||
print("Nothing to do?")
|
||||
return 1
|
||||
|
@ -19,6 +19,7 @@ import time
|
||||
|
||||
class CentosVM(basevm.BaseVM):
|
||||
name = "centos"
|
||||
arch = "x86_64"
|
||||
BUILD_SCRIPT = """
|
||||
set -e;
|
||||
cd $(mktemp -d);
|
||||
|
@ -18,6 +18,7 @@ import basevm
|
||||
|
||||
class FreeBSDVM(basevm.BaseVM):
|
||||
name = "freebsd"
|
||||
arch = "x86_64"
|
||||
BUILD_SCRIPT = """
|
||||
set -e;
|
||||
rm -rf /var/tmp/qemu-test.*
|
||||
|
@ -18,6 +18,7 @@ import basevm
|
||||
|
||||
class NetBSDVM(basevm.BaseVM):
|
||||
name = "netbsd"
|
||||
arch = "x86_64"
|
||||
BUILD_SCRIPT = """
|
||||
set -e;
|
||||
rm -rf /var/tmp/qemu-test.*
|
||||
|
@ -18,6 +18,7 @@ import basevm
|
||||
|
||||
class OpenBSDVM(basevm.BaseVM):
|
||||
name = "openbsd"
|
||||
arch = "x86_64"
|
||||
BUILD_SCRIPT = """
|
||||
set -e;
|
||||
rm -rf /var/tmp/qemu-test.*
|
||||
|
@ -19,6 +19,7 @@ import time
|
||||
|
||||
class UbuntuX86VM(basevm.BaseVM):
|
||||
name = "ubuntu.i386"
|
||||
arch = "i386"
|
||||
BUILD_SCRIPT = """
|
||||
set -e;
|
||||
cd $(mktemp -d);
|
||||
|
Loading…
Reference in New Issue
Block a user