From nobody Mon Apr 29 11:09:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524157468586848.4437760916753; Thu, 19 Apr 2018 10:04:28 -0700 (PDT) Received: from localhost ([::1]:60828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9Cyo-0000UO-4g for importer@patchew.org; Thu, 19 Apr 2018 13:04:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9Ci9-0003HR-Gg for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9Ci5-0007Nl-4c for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:05 -0400 Received: from mail-qt0-x236.google.com ([2607:f8b0:400d:c0d::236]:36648) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f9Ci4-0007NH-PV; Thu, 19 Apr 2018 12:47:01 -0400 Received: by mail-qt0-x236.google.com with SMTP id q13-v6so6492299qtl.3; Thu, 19 Apr 2018 09:47:00 -0700 (PDT) Received: from x1.local ([138.117.48.212]) by smtp.gmail.com with ESMTPSA id k126sm3040039qkd.34.2018.04.19.09.46.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 09:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xhT5ROfY8LZcyd+1pK8riWs0EPxVOxzA6KMnTT2DnC4=; b=C+cDP+XNlFkduOxhOBJyHfXdzExcRgAcwJFjpfbXGDGcxcjO/UDYsoxY/WPlM/S9zm u/4q7zeATY5bqfvNmAY3jvBJBOeCpMnVfjQdsdwOc2yPmJQVYhT2QW1YUqUeRavJSk8Z HwsPwlGI3gy8MAbpdDV2qHWOBnClnkHuIeIzHjBWqmRIfqG8uwGQ338JuTtNfN8qnnUJ xnkndUcirc+Egb4re67cMYCEoLnoheeZ7gVQEwpmxqWVdSnjM7QcDELVs4Us83ANowcj u9lpyL+n8n3aFBhLLkSY0CxNrL/z2AIQz6v6rhCJe+5DT9eLg+YKheARVVA8kJg3Mp9i UU6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=xhT5ROfY8LZcyd+1pK8riWs0EPxVOxzA6KMnTT2DnC4=; b=IdOp2yotbYJgBFI8NIVFtHb+y4WKKN72eD7sD9C3GqZ6pzCM9xDocIGTY52ndWuk+p pHREXLgs0IncVRnTeaMXMq1lURfqPs3vxsHFT6f8h8m9CICmA/mC6uPH6EQcUCKo5JqQ ye/hToQdXw9YLbrybVXdRwqATRUiFGKqxQpryzA0gGxLIy1so/yIl5rr9sHjj9QrwwO1 Ge6OaOjVeVNONuy+R2BLmP1JCeFpog9C95f04l0JQsE3247OGDsA65FAJyBr9iPWaJMF GjLXjuMprRcecoMji4flzosLn78clDacBJkxq+e1EglfcWvhAeZ3yj5CS/TXFta8nOyG 8QgA== X-Gm-Message-State: ALQs6tAPkhJDL50rmWHvO2N0lwPdYK+ze3zeQzmC7PkCEM8NTvBGWxlw 87zE0F/obj0nSbapqtLyakM= X-Google-Smtp-Source: AIpwx4+wtoP1gKLJJDWvqRhTl1RNKi//1FVphLKlCXeRl4Vh8KlU5Mv6cLRgF1SUOHJ1ecvDWEjNVQ== X-Received: by 2002:ac8:7047:: with SMTP id y7-v6mr7034681qtm.208.1524156419188; Thu, 19 Apr 2018 09:46:59 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Cleber Rosa , Amador Pahim , Stefan Hajnoczi , Zheng Xiang Date: Thu, 19 Apr 2018 13:46:36 -0300 Message-Id: <20180419164642.9536-2-f4bug@amsat.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419164642.9536-1-f4bug@amsat.org> References: <20180419164642.9536-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::236 Subject: [Qemu-devel] [RFC PATCH 1/7] AVOCADO_QEMU: Snapshot commit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , Eduardo Habkost , "open list:Block layer core" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Alistair Francis , Max Reitz , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Amador Pahim Applied https://patch-diff.githubusercontent.com/raw/apahim/qemu/pull/17.pa= tch following http://lists.nongnu.org/archive/html/qemu-devel/2018-01/msg03891.= html. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qemu.py | 59 ++- tests/avocado/README.rst | 132 ++++++ tests/avocado/avocado_qemu/__init__.py | 0 tests/avocado/avocado_qemu/test.py | 418 ++++++++++++++++++ tests/avocado/parameters.yaml | 19 + tests/avocado/test_info_memdev_host_nodes.py | 66 +++ tests/avocado/test_nec-usb-xhci.py | 63 +++ .../test_nec-usb-xhci.py.data/parameters.yaml | 4 + tests/avocado/test_numa_hotplug.py | 120 +++++ tests/avocado/test_ovmf_with_240_vcpus.py | 70 +++ .../parameters.yaml | 2 + tests/avocado/variants.yaml | 62 +++ tests/qemu-iotests/iotests.py | 28 +- 13 files changed, 1019 insertions(+), 24 deletions(-) create mode 100644 tests/avocado/README.rst create mode 100644 tests/avocado/avocado_qemu/__init__.py create mode 100644 tests/avocado/avocado_qemu/test.py create mode 100644 tests/avocado/parameters.yaml create mode 100644 tests/avocado/test_info_memdev_host_nodes.py create mode 100644 tests/avocado/test_nec-usb-xhci.py create mode 100644 tests/avocado/test_nec-usb-xhci.py.data/parameters.yaml create mode 100644 tests/avocado/test_numa_hotplug.py create mode 100644 tests/avocado/test_ovmf_with_240_vcpus.py create mode 100644 tests/avocado/test_ovmf_with_240_vcpus.py.data/paramete= rs.yaml create mode 100644 tests/avocado/variants.yaml diff --git a/scripts/qemu.py b/scripts/qemu.py index 08a3e9af5a..bd66620f45 100644 --- a/scripts/qemu.py +++ b/scripts/qemu.py @@ -55,7 +55,7 @@ class QEMUMachine(object): =20 def __init__(self, binary, args=3DNone, wrapper=3DNone, name=3DNone, test_dir=3D"/var/tmp", monitor_address=3DNone, - socket_scm_helper=3DNone): + socket_scm_helper=3DNone, arch=3DNone): ''' Initialize a QEMUMachine =20 @@ -81,7 +81,7 @@ class QEMUMachine(object): self._qemu_log_file =3D None self._popen =3D None self._binary =3D binary - self._args =3D list(args) # Force copy args in case we modify = them + self.args =3D list(args) # Force copy args in case we modify t= hem self._wrapper =3D wrapper self._events =3D [] self._iolog =3D None @@ -91,6 +91,10 @@ class QEMUMachine(object): self._test_dir =3D test_dir self._temp_dir =3D None self._launched =3D False + if arch is None: + arch =3D binary.split('-')[-1] + self._arch =3D arch + self._console_address =3D None =20 # just in case logging wasn't configured by the main script: logging.basicConfig() @@ -105,8 +109,8 @@ class QEMUMachine(object): # This can be used to add an unused monitor instance. def add_monitor_telnet(self, ip, port): args =3D 'tcp:%s:%d,server,nowait,telnet' % (ip, port) - self._args.append('-monitor') - self._args.append(args) + self.args.append('-monitor') + self.args.append(args) =20 def add_fd(self, fd, fdset, opaque, opts=3D''): '''Pass a file descriptor to the VM''' @@ -116,8 +120,8 @@ class QEMUMachine(object): if opts: options.append(opts) =20 - self._args.append('-add-fd') - self._args.append(','.join(options)) + self.args.append('-add-fd') + self.args.append(','.join(options)) return self =20 def send_fd_scm(self, fd_file_path): @@ -179,6 +183,39 @@ class QEMUMachine(object): '-mon', 'chardev=3Dmon,mode=3Dcontrol', '-display', 'none', '-vga', 'none'] =20 + def _create_console(self, console_address): + for item in self.args: + for option in ['isa-serial', 'spapr-vty', 'sclpconsole']: + if option in item: + return [] + + chardev =3D 'socket,id=3Dconsole,{address},server,nowait' + if console_address is None: + console_address =3D tempfile.mktemp() + chardev =3D chardev.format(address=3D'path=3D%s' % + console_address) + elif isinstance(console_address, tuple): + chardev =3D chardev.format(address=3D'host=3D%s,port=3D%s' % + (console_address[0], + console_address[1])) + else: + chardev =3D chardev.format(address=3D'path=3D%s' % console_add= ress) + + self._console_address =3D console_address + + device =3D '{dev_type},chardev=3Dconsole' + if '86' in self._arch: + device =3D device.format(dev_type=3D'isa-serial') + elif 'ppc' in self._arch: + device =3D device.format(dev_type=3D'spapr-vty') + elif 's390x' in self._arch: + device =3D device.format(dev_type=3D'sclpconsole') + else: + return [] + + return ['-chardev', chardev, + '-device', device] + def _pre_launch(self): self._temp_dir =3D tempfile.mkdtemp(dir=3Dself._test_dir) if self._monitor_address is not None: @@ -206,7 +243,7 @@ class QEMUMachine(object): shutil.rmtree(self._temp_dir) self._temp_dir =3D None =20 - def launch(self): + def launch(self, console_address=3DNone): """ Launch the VM and make sure we cleanup and expose the command line/output in case of exception @@ -218,7 +255,7 @@ class QEMUMachine(object): self._iolog =3D None self._qemu_full_args =3D None try: - self._launch() + self._launch(console_address) self._launched =3D True except: self.shutdown() @@ -230,12 +267,14 @@ class QEMUMachine(object): LOG.debug('Output: %r', self._iolog) raise =20 - def _launch(self): + def _launch(self, console_address): '''Launch the VM and establish a QMP connection''' devnull =3D open(os.path.devnull, 'rb') self._pre_launch() + bargs =3D self._base_args() + bargs.extend(self._create_console(console_address)) self._qemu_full_args =3D (self._wrapper + [self._binary] + - self._base_args() + self._args) + bargs + self.args) self._popen =3D subprocess.Popen(self._qemu_full_args, stdin=3Ddevnull, stdout=3Dself._qemu_log_file, diff --git a/tests/avocado/README.rst b/tests/avocado/README.rst new file mode 100644 index 0000000000..a33c4a2577 --- /dev/null +++ b/tests/avocado/README.rst @@ -0,0 +1,132 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + QEMU tests using the Avocado Framework +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +This directory hosts functional tests written using Avocado Testing +Framework. + +Installation +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +To install Avocado and the dependencies needed for these tests, run:: + + pip install --user avocado-framework avocado-framework-plugin-variante= r-yaml-to-mux aexpect + +Alternatively, follow the instructions on this link:: + + http://avocado-framework.readthedocs.io/en/latest/GetStartedGuide.html= #installing-avocado + +Overview +=3D=3D=3D=3D=3D=3D=3D=3D + +In this directory, an ``avocado_qemu`` package is provided, containing +the ``test`` module, which inherits from ``avocado.Test`` and provides +a builtin and easy-to-use Qemu virtual machine. Here's a template that +can be used as reference to start writing your own tests:: + + from avocado_qemu import test + + class MyTest(test.QemuTest): + """ + :avocado: enable + """ + + def setUp(self): + self.vm.args.extend(['-m', '512']) + self.vm.launch() + + def test_01(self): + res =3D self.vm.qmp('human-monitor-command', + command_line=3D'info version') + self.assertIn('v2.9.0', res['return']) + + def tearDown(self): + self.vm.shutdown() + +To execute your test, run:: + + avocado run test_my_test.py + +To execute all tests, run:: + + avocado run . + +If you don't specify the Qemu binary to use, the ``avocado_qemu`` +package will automatically probe it. The probe will try to use the Qemu +binary from the git tree build directory, using the same architecture as +the local system (if the architecture is not specified). If the Qemu +binary is not available in the git tree build directory, the next try is +to use the system installed Qemu binary. + +You can define a number of optional parameters, providing them via YAML +file using the Avocado parameters system: + +- ``qemu_bin``: Use a given Qemu binary, skipping the automatic + probe. Example: ``qemu_bin: /usr/libexec/qemu-kvm``. +- ``qemu_dst_bin``: Use a given Qemu binary to create the destination VM + when the migration process takes place. If it's not provided, the same + binary used in the source VM will be used for the destination VM. + Example: ``qemu_dst_bin: /usr/libexec/qemu-kvm-binary2``. +- ``arch``: Probe the Qemu binary from a given architecture. It has no + effect if ``qemu_bin`` is specified. If not provided, the binary probe + will use the system architecture. Example: ``arch: x86_64`` +- ``image_path``: When a test requires (usually a bootable) image, this + parameter is used to define where the image is located. When undefined + it uses ``$QEMU_ROOT/bootable_image_$arch.qcow2``. The image is added + to the qemu command __only__ when the test requires an image. By + default ``,snapshot=3Don`` is used, but it can be altered by + ``image_snapshot`` parameter. +- ``image_user`` and ``image_pass``: When using a ``image_path``, if you + want to get the console from the Guest OS you have to define the Guest + OS credentials. Example: ``image_user: avocado`` and + ``image_pass: p4ssw0rd``. Both parameters have defaults to ``avocado``. +- ``machine_type``: Use this option to define a machine type for the VM. + Example: ``machine_type: pc`` +- ``machine_accel``: Use this option to define a machine acceleration + for the VM. Example: ``machine_accel: kvm``. +- ``machine_kvm_type``: Use this option to select the KVM type when the + ``accel`` is ``kvm`` and there are more than one KVM types available. + Example: ``machine_kvm_type: PR`` + +Run the test with:: + + $ avocado run test_my_test.py -m parameters.yaml + +Additionally, you can use a variants file to to set different values +for each parameter. Using the YAML tag ``!mux`` Avocado will execute the +tests once per combination of parameters. Example:: + + $ cat variants.yaml + architecture: !mux + x86_64: + arch: x86_64 + i386: + arch: i386 + +Run it the with:: + + $ avocado run test_my_test.py -m variants.yaml + +You can use both the parameters file and the variants file in the same +command line:: + + $ avocado run test_my_test.py -m parameters.yaml variants.yaml + +Avocado will then merge the parameters from both files and create the +proper variants. + +See ``avocado run --help`` and ``man avocado`` for several other +options, such as ``--filter-by-tags``, ``--show-job-log``, +``--failfast``, etc. + +Uninstallation +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +If you've followed the installation instructions above, you can easily +uninstall Avocado. Start by listing the packages you have installed:: + + pip list --user + +And remove any package you want with:: + + pip uninstall diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado= _qemu/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py new file mode 100644 index 0000000000..5a08dace45 --- /dev/null +++ b/tests/avocado/avocado_qemu/test.py @@ -0,0 +1,418 @@ +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See LICENSE for more details. +# +# Copyright (C) 2017 Red Hat Inc +# +# Authors: +# Amador Pahim +# +# Based on code from: +# https://github.com/avocado-framework/avocado-virt + + +""" +Avocado Qemu Test module to extend the Avocado Test module providing +extra features intended for Qemu testing. +""" + + +import logging +import os +import re +import sys +import tempfile +import time +import uuid + +import aexpect + +from avocado import Test +from avocado.utils import network +from avocado.utils import process +from avocado.utils import path as utils_path +from avocado.utils import wait + +QEMU_ROOT =3D os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirn= ame( + os.path.dirname(__file__))))) +sys.path.append(os.path.join(QEMU_ROOT, 'scripts')) +import qemu + + +class QEMULoginTimeoutError(Exception): + """ + If timeout expires + """ + + +class QEMULoginAuthenticationError(Exception): + """ + If authentication fails + """ + + +class QEMULoginProcessTerminatedError(Exception): + """ + If the client terminates during login + """ + + +class QEMULoginError(Exception): + """ + If some other error occurs + """ + + +class QEMUConsoleError(Exception): + """ + If some error with the console access happens + """ + + +class QEMUMigrationError(Exception): + """ + If some error with the migration happens + """ + + +class QEMUCloudinitError(Exception): + """ + If some error with the cloudinit happens + """ + + +def _get_qemu_bin(arch): + git_root =3D process.system_output('git rev-parse --show-toplevel', + ignore_status=3DTrue, + verbose=3DFalse) + qemu_binary =3D os.path.join(git_root, + "%s-softmmu" % arch, + "qemu-system-%s" % arch) + if not os.path.exists(qemu_binary): + qemu_binary =3D utils_path.find_command('qemu-system-%s' % arch) + return qemu_binary + + +def _handle_prompts(session, username, password, prompt, timeout=3D60, + debug=3DFalse): + """ + Connect to a remote host (guest) using SSH or Telnet or else. + + Wait for questions and provide answers. If timeout expires while + waiting for output from the child (e.g. a password prompt or + a shell prompt) -- fail. + + :param session: An Expect or ShellSession instance to operate on + :param username: The username to send in reply to a login prompt + :param password: The password to send in reply to a password prompt + :param prompt: The shell prompt that indicates a successful login + :param timeout: The maximal time duration (in seconds) to wait for each + step of the login procedure (i.e. the "Are you sure" prompt, t= he + password prompt, the shell prompt, etc) + :raise QEMULoginTimeoutError: If timeout expires + :raise QEMULoginAuthenticationError: If authentication fails + :raise QEMULoginProcessTerminatedError: If the client terminates durin= g login + :raise QEMULoginError: If some other error occurs + :return: If connect succeed return the output text to script for furth= er + debug. + """ + re_kernel_message =3D re.compile(r"^\[\s*\d+.\d+\] ") + + def get_last_nonempty_line(cont): + """Return last non-empty non-kernel line""" + nonempty_lines =3D [_ for _ in cont.splitlines() + if _.strip() and not re_kernel_message.match(_)] + if nonempty_lines: + return nonempty_lines[-1] + else: + return "" + + password_prompt_count =3D 0 + login_prompt_count =3D 0 + last_chance =3D False + # Send enter to refresh output (in case session was attached after boo= t) + session.sendline() + output =3D "" + while True: + try: + match, text =3D session.read_until_output_matches( + [r"[Aa]re you sure", r"[Pp]assword:\s*", + # Prompt of rescue mode for Red Hat. + r"\(or (press|type) Control-D to continue\):\s*", + r"[Gg]ive.*[Ll]ogin:\s*", # Prompt of rescue mode for SU= SE. + r"(? 0: + msg =3D "Got username prompt twice" + else: + msg =3D "Got username prompt after password prompt" + raise QEMULoginAuthenticationError(msg, text) + elif match =3D=3D 5: # "Connection closed" + raise QEMULoginError("Client said 'connection closed'", te= xt) + elif match =3D=3D 6: # "Connection refused" + raise QEMULoginError("Client said 'connection refused'", t= ext) + elif match =3D=3D 11: # Connection timeout + raise QEMULoginError("Client said 'connection timeout'", t= ext) + elif match =3D=3D 7: # "Please wait" + if debug: + logging.debug("Got 'Please wait'") + timeout =3D 30 + continue + elif match =3D=3D 8: # "Warning added RSA" + if debug: + logging.debug("Got 'Warning added RSA to known host li= st") + continue + elif match =3D=3D 12: # prompt + if debug: + logging.debug("Got shell prompt -- logged in") + break + elif match =3D=3D 13: # console prompt + logging.debug("Got console prompt, send return to show log= in") + session.sendline() + except aexpect.ExpectTimeoutError as details: + # sometimes, linux kernel print some message to console + # the message maybe impact match login pattern, so send + # a empty line to avoid unexpect login timeout + if not last_chance: + time.sleep(0.5) + session.sendline() + last_chance =3D True + continue + else: + raise QEMULoginTimeoutError(details.output) + except aexpect.ExpectProcessTerminatedError as details: + raise QEMULoginProcessTerminatedError(details.status, details.= output) + + return output + + +class _VM(qemu.QEMUMachine): + '''A QEMU VM''' + + def __init__(self, qemu_bin=3DNone, arch=3DNone, qemu_dst_bin=3DNone, + username=3DNone, password=3DNone): + if arch is None: + arch =3D os.uname()[4] + self.arch =3D arch + self.ports =3D network.PortTracker() + self.name =3D "qemu-%s" % str(uuid.uuid4())[:8] + if qemu_bin is None: + qemu_bin =3D _get_qemu_bin(arch) + if qemu_dst_bin is None: + qemu_dst_bin =3D qemu_bin + self.qemu_bin =3D qemu_bin + self.qemu_dst_bin =3D qemu_dst_bin + self.username =3D username + self.password =3D password + super(_VM, self).__init__(qemu_bin, name=3Dself.name, arch=3Darch) + logging.getLogger('QMP').setLevel(logging.INFO) + + def get_console(self, console_address=3DNone, prompt=3Dr"[\#\$] "): + """ + :param address: Socket address, can be either a unix socket path + (string) or a tuple in the form (address, port) + for a TCP connection + :param prompt: The regex to identify we reached the prompt. + """ + + if not all((self.username, self.password)): + raise QEMULoginError('Username or password not set.') + + if not self.is_running(): + raise QEMULoginError('VM is not running.') + + if console_address is None: + if self._console_address is None: + raise QEMUConsoleError("Can't determine the console addres= s " + "to connect to.") + else: + console_address =3D self._console_address + + nc_cmd =3D 'nc' + if isinstance(console_address, tuple): + nc_cmd +=3D ' %s %s' % (console_address[0], console_address[1]) + else: + nc_cmd +=3D ' -U %s' % console_address + + console =3D aexpect.ShellSession(nc_cmd) + try: + logging.info('Console: Waiting login prompt...') + _handle_prompts(console, self.username, self.password, prompt) + logging.info('Console: Ready!') + except: + console.close() + raise + + return console + + def migrate(self, console_address=3DNone, timeout=3D20): + def migrate_complete(): + cmd =3D 'info migrate' + res =3D self.qmp('human-monitor-command', command_line=3Dcmd) + if 'completed' in res['return']: + logging.info("Migration successful") + return True + elif 'failed' in res['return']: + logging.error(res) + raise QEMUMigrationError("Migration of %s failed" % self.n= ame) + return False + + port =3D self.ports.find_free_port() + newvm =3D _VM(self.qemu_dst_bin, self._arch, username=3Dself.usern= ame, + password=3Dself.password) + newvm.args =3D self.args + newvm.args.extend(['-incoming', 'tcp:0:%s' % port]) + newvm.username =3D self.username + newvm.password =3D self.password + + newvm.launch(console_address) + cmd =3D 'migrate -d tcp:0:%s' % port + self.qmp('human-monitor-command', command_line=3Dcmd) + mig_result =3D wait.wait_for(migrate_complete, timeout=3Dtimeout, + text=3D'Waiting for migration to comple= te') + + if mig_result is None: + raise QEMUMigrationError("Migration of %s did not complete aft= er " + "%s s" % (self.name, timeout)) + + return newvm + + def add_image(self, path, username=3DNone, password=3DNone, cloudinit= =3DFalse, + snapshot=3DTrue, extra=3DNone): + """ + Adds the '-drive' command line option and its parameters to + the Qemu VM + + :param path: Image path (i.e. /var/lib/images/guestos.qcow2) + :param username: The username to log into the Guest OS with + :param password: The password to log into the Guest OS with + :param cloudinit: Whether the cloudinit cdrom will be attached to + the image + :param snapshot: Whether the parameter snapshot=3Don will be used + :param extra: Extra parameters to the -drive option + """ + file_option =3D 'file=3D%s' % path + for item in self.args: + if file_option in item: + logging.error('Image %s already present', path) + return + + if extra is not None: + file_option +=3D ',%s' % extra + + if snapshot: + file_option +=3D ',snapshot=3Don' + + self.args.extend(['-drive', file_option]) + + if username is not None: + self.username =3D username + + if password is not None: + self.password =3D password + + if cloudinit: + self._cloudinit() + + def _cloudinit(self): + """ + Creates a CDROM Iso Image with the required cloudinit files + (meta-data and user-data) to make the initial Cloud Image + configuration, attaching the CDROM to the VM. + """ + try: + geniso_bin =3D utils_path.find_command('genisoimage') + except: + raise QEMUCloudinitError('Command not found (genisoimage)') + + data_dir =3D tempfile.mkdtemp() + + metadata_path =3D os.path.join(data_dir, 'meta-data') + metadata_content =3D ("instance-id: %s\n" + "local-hostname: %s\n" % (self.name, self.name= )) + with open(metadata_path, 'w') as metadata_file: + metadata_file.write(metadata_content) + + userdata_path =3D os.path.join(data_dir, 'user-data') + userdata_content =3D ("#cloud-config\n" + "password: %s\n" + "ssh_pwauth: True\n" + "chpasswd: { expire: False }\n" + "system_info:\n" + " default_user:\n" + " name: %s\n" % + (self.password, self.username)) + + with open(userdata_path, 'w') as userdata_file: + userdata_file.write(userdata_content) + + iso_path =3D os.path.join(data_dir, 'cdrom.iso') + process.run("%s -output %s -volid cidata -joliet -rock %s %s" % + (geniso_bin, iso_path, metadata_path, userdata_path)) + + self.args.extend(['-cdrom', iso_path]) + +class QemuTest(Test): + + def __init__(self, methodName=3DNone, name=3DNone, params=3DNone, + base_logdir=3DNone, job=3DNone, runner_queue=3DNone): + super(QemuTest, self).__init__(methodName=3DmethodName, name=3Dnam= e, + params=3Dparams, base_logdir=3Dbase= _logdir, + job=3Djob, runner_queue=3Drunner_qu= eue) + self.vm =3D _VM(qemu_bin=3Dself.params.get('qemu_bin'), + arch=3Dself.params.get('arch'), + qemu_dst_bin=3Dself.params.get('qemu_dst_bin'), + username=3Dself.params.get('image_user', + default=3D'avocado'), + password=3Dself.params.get('image_pass', + default=3D'avocado')) + + machine_type =3D self.params.get('machine_type') + machine_accel =3D self.params.get('machine_accel') + machine_kvm_type =3D self.params.get('machine_kvm_type') + machine =3D "" + if machine_type is not None: + machine +=3D "%s," % machine_type + if machine_accel is not None: + machine +=3D "accel=3D%s," % machine_accel + if machine_kvm_type is not None: + machine +=3D "kvm-type=3D%s," % machine_kvm_type + if machine: + self.vm.args.extend(['-machine', machine]) diff --git a/tests/avocado/parameters.yaml b/tests/avocado/parameters.yaml new file mode 100644 index 0000000000..03c4ed1416 --- /dev/null +++ b/tests/avocado/parameters.yaml @@ -0,0 +1,19 @@ +# Probe the Qemu binary from a given architecture. It has no effect if +# 'qemu_bin' is specified. If not provided, the binary probe will use +# the local system architecture. +arch: null + +# Use a given Qemu binary, skipping the automatic probe. +qemu_bin: null +# Use a given Qemu binary to create the destination VM when the +# migration process is called. If it's not provided, the same binary +# used in the source VM will be used for the destination VM. +qemu_dst_bin: null + +# Use this option to define a machine type for the VM. +machine_type: null +# Use this option to define a machine acceleration for the VM. +machine_accel: null +# Use this option to select the KVM type when the 'machine_accel' is set +# to 'kvm' and there are more than one KVM types available. +machine_kvm_type: null diff --git a/tests/avocado/test_info_memdev_host_nodes.py b/tests/avocado/t= est_info_memdev_host_nodes.py new file mode 100644 index 0000000000..69891b723d --- /dev/null +++ b/tests/avocado/test_info_memdev_host_nodes.py @@ -0,0 +1,66 @@ +from avocado import main +from avocado_qemu import test + + +class TestInfoMemdev(test.QemuTest): + """ + + :avocado: enable + :avocado: tags=3Dqmp,object_add,device_add,memdev + """ + + def setUp(self): + self.vm.args.extend(['-m', '4G,slots=3D32,maxmem=3D40G']) + self.vm.launch() + + def test_hotplug_memory_default_policy(self): + """ + According to the RHBZ1431939, the issue is 'host nodes' + returning '128'. It should return empty value when memory + hotplug default policy is used. + + Fixed in commit d81d857f4421d205395d55200425daa6591c28a5. + :avocado: tags=3DRHBZ1431939 + """ + + cmd =3D 'object_add memory-backend-ram,id=3Dmem1,size=3D1G' + res =3D self.vm.qmp('human-monitor-command', command_line=3Dcmd) + self.assertEqual('', res['return']) + + cmd =3D 'device_add pc-dimm,id=3Ddimm1,memdev=3Dmem1' + res =3D self.vm.qmp('human-monitor-command', command_line=3Dcmd) + self.assertEqual('', res['return']) + + cmd =3D 'info memdev' + res =3D self.vm.qmp('human-monitor-command', command_line=3Dcmd) + self.assertIn('policy: default\r', res['return']) + self.assertIn('host nodes: \r', res['return']) + + def test_hotplug_memory_bind_policy(self): + """ + According to the RHBZ1431939, the issue is 'host nodes' + returning '128'. It should return 0 when memory hotplug + bind policy is used. + + Fixed in commit d81d857f4421d205395d55200425daa6591c28a5. + :avocado: tags=3DRHBZ1431939 + """ + + cmd =3D 'object_add memory-backend-ram,id=3Dmem1,host-nodes=3D0,si= ze=3D2G,policy=3Dbind' + res =3D self.vm.qmp('human-monitor-command', command_line=3Dcmd) + self.assertEqual('', res['return']) + + cmd =3D 'device_add pc-dimm,id=3Ddimm1,memdev=3Dmem1' + res =3D self.vm.qmp('human-monitor-command', command_line=3Dcmd) + self.assertEqual('', res['return']) + + cmd =3D 'info memdev' + res =3D self.vm.qmp('human-monitor-command', command_line=3Dcmd) + self.assertIn('policy: bind\r', res['return']) + self.assertIn('host nodes: 0\r', res['return']) + + def tearDown(self): + self.vm.shutdown() + +if __name__ =3D=3D "__main__": + avocado.main() diff --git a/tests/avocado/test_nec-usb-xhci.py b/tests/avocado/test_nec-us= b-xhci.py new file mode 100644 index 0000000000..c29b5ebaa1 --- /dev/null +++ b/tests/avocado/test_nec-usb-xhci.py @@ -0,0 +1,63 @@ +import copy +import os +import tempfile + +from avocado_qemu import test +from avocado.utils import process +from avocado.utils import vmimage + +class TestNecUsbXhci(test.QemuTest): + """ + Run with: + + avocado run test_nec-usb-xhci.py \ + -m test_nec-usb-xhci.py.data/parameters.yaml + + :avocado: enable + :avocado: tags=3Dusbstorage + """ + + def setUp(self): + self.vm_dst =3D None + self.image =3D vmimage.get('Fedora') + self.vm.add_image(self.image.path, cloudinit=3DTrue, snapshot=3DFa= lse) + self.vm.args.extend(['-machine', 'accel=3Dkvm']) + + usbdevice =3D os.path.join(self.workdir, 'usb.img') + process.run('dd if=3D/dev/zero of=3D%s bs=3D1M count=3D10' % usbde= vice) + self.vm.args.extend(['-device', 'pci-bridge,id=3Dbridge1,chassis_n= r=3D1']) + self.vm.args.extend(['-device', 'nec-usb-xhci,id=3Dxhci1,bus=3Dbri= dge1,addr=3D0x3']) + self.vm.args.extend(['-drive', 'file=3D%s,format=3Draw,id=3Ddrive_= usb,if=3Dnone' % usbdevice]) + self.vm.args.extend(['-device', 'usb-storage,drive=3Ddrive_usb,id= =3Ddevice_usb,bus=3Dxhci1.0']) + self.vm.launch() + + def test_available_after_migration(self): + """ + According to the RHBZ1436616, the issue is: usb-storage device + under pci-bridge is unusable after migration. + + Fixed in commit 243afe858b95765b98d16a1f0dd50dca262858ad. + + :avocado: tags=3Dmigration,RHBZ1436616 + """ + + console =3D self.vm.get_console() + console.sendline('sudo fdisk -l') + result =3D console.read_up_to_prompt() + console.close() + self.assertIn('Disk /dev/sdb: 10 MiB, 10485760 bytes, 20480 sector= s', + result) + + self.vm_dst =3D self.vm.migrate() + console =3D self.vm_dst.get_console() + console.sendline('sudo fdisk -l') + result =3D console.read_up_to_prompt() + console.close() + self.assertIn('Disk /dev/sdb: 10 MiB, 10485760 bytes, 20480 sector= s', + result) + + def tearDown(self): + self.vm.shutdown() + if self.vm_dst is not None: + self.vm_dst.shutdown() + os.remove(self.image.path) diff --git a/tests/avocado/test_nec-usb-xhci.py.data/parameters.yaml b/test= s/avocado/test_nec-usb-xhci.py.data/parameters.yaml new file mode 100644 index 0000000000..37a4e9dc37 --- /dev/null +++ b/tests/avocado/test_nec-usb-xhci.py.data/parameters.yaml @@ -0,0 +1,4 @@ +machine_accel: kvm +image_path: /var/lib/images/fedora-25.img +image_user: root +image_pass: p4ssw0rd diff --git a/tests/avocado/test_numa_hotplug.py b/tests/avocado/test_numa_h= otplug.py new file mode 100644 index 0000000000..256ec0f49f --- /dev/null +++ b/tests/avocado/test_numa_hotplug.py @@ -0,0 +1,120 @@ +import re +import time + +from avocado_qemu import test +from avocado.utils import vmimage + + +class TestNumaHotplug(test.QemuTest): + """ + Verifies that "info numa" and "/sys/devices/system/node/" contains + correct values before/after inserting memory devices into default + and then into 13th numa node. + + Associated bug trackers: RHBZ1473203 + https://bugzilla.redhat.com/show_bug.cgi?id=3D1473203 + + Fixed in kernel commit dc421b200f91930c9c6a9586810ff8c232cf10fc. + + :avocado: enable + :avocado: tags=3DRHBZ1473203,requires_linux,numa,memory,ppc64le + """ + + def setUp(self): + self.image =3D vmimage.get('Fedora') + self.vm.add_image(self.image.path, cloudinit=3DTrue, snapshot=3DFa= lse) + + self.vm.args.extend(['-machine', 'accel=3Dkvm']) + self.vm.args.extend(["-m", "4G,slots=3D208,maxmem=3D80G"]) + self.vm.args.extend(["-numa", "node"] * 16) + self.vm.launch() + + def check_mem_console(self, console, exp): + """ + Verifies that memory layout is according to exp using console/ssh + + :param console: session + :param exp: list of MemTotals per node in MB, tolerance is +-100MB + """ + out =3D console.cmd_output_safe("echo /sys/devices/system/node/nod= e*") + nodes =3D re.findall(r"/sys/devices/system/node/node\d+", out) + self.assertEqual(len(nodes), len(exp), "Number of nodes is not " + "%s:\n%s" % (len(exp), out)) + for i in xrange(len(exp)): + out =3D console.cmd_output_safe("cat /sys/devices/system/node/" + "node%s/meminfo" % i) + mem =3D re.search(r"MemTotal:\s*(\d+) kB", out) + self.assertTrue(mem, "Failed to obtain node%s MemTotal:\n%s" + % (i, out)) + _exp =3D exp[i] * 1024 + mem =3D int(mem.group(1)) + self.assertGreater(mem, _exp - 102400, "TotalMem of node%s is = not " + "%s+-51200 kb (%s)" % (i, _exp, mem)) + self.assertLess(mem, _exp + 102400, "TotalMem of node%s is not= " + "%s+-51200 kb (%s)" % (i, _exp, mem)) + + def check_mem_monitor(self, monitor, exp): + """ + Verifies that memory layout is according to exp using QMP monitor + + :param console: session + :param exp: list of MemTotals per node in MB, tolerance is +-100MB + """ + ret =3D monitor("human-monitor-command", command_line=3D"info numa= ") + out =3D ret["return"] + self.assertTrue(out.startswith("%s nodes" % len(exp)), "Number of " + "nodes is not %s:\n%s" % (len(exp), out)) + for i in xrange(len(exp)): + _exp =3D "node %s size: %s MB" % (i, exp[i]) + self.assertIn(_exp, out, "%s is not in 'info numa' output, " + "probably wrong memory size reported:\n%s" + % (_exp, out)) + + @staticmethod + def _retry_until_timeout(timeout, func, *args, **kwargs): + """ + Repeat the function until it returns anything ignoring AssertionEr= ror. + After the deadline repeate the function one more time without igno= ring + timeout. + """ + end =3D time.time() + timeout + while time.time() < end: + try: + ret =3D func(*args, **kwargs) + except AssertionError: + continue + break + else: + ret =3D func(*args, **kwargs) + return ret + + def test_hotplug_mem_into_node(self): + console =3D self.vm.get_console() + exp =3D [256] * 16 + self.check_mem_monitor(self.vm.qmp, exp) + self.check_mem_console(console, exp) + cmd =3D "object_add memory-backend-ram,id=3Dmem2,size=3D1G" + res =3D self.vm.qmp("human-monitor-command", command_line=3Dcmd) + self.assertEqual(res["return"], "") + cmd =3D "device_add pc-dimm,id=3Ddimm2,memdev=3Dmem2" + res =3D self.vm.qmp("human-monitor-command", command_line=3Dcmd) + self.assertEqual(res["return"], "") + exp =3D [1280] + [256] * 15 + self.check_mem_monitor(self.vm.qmp, exp) + # Wait up to 10s to propagate the changes + self._retry_until_timeout(10, self.check_mem_console, console, exp) + cmd =3D "object_add memory-backend-ram,id=3Dmem8,size=3D1G" + res =3D self.vm.qmp("human-monitor-command", command_line=3Dcmd) + self.assertEqual(res["return"], "") + cmd =3D "device_add pc-dimm,id=3Ddimm8,memdev=3Dmem8,node=3D13" + res =3D self.vm.qmp("human-monitor-command", command_line=3Dcmd) + self.assertEqual(res["return"], "") + time.sleep(5) + exp =3D [1280] + [256] * 12 + [1280] + [256] * 2 + self.check_mem_monitor(self.vm.qmp, exp) + # Wait up to 10s to propagate the changes + self._retry_until_timeout(10, self.check_mem_console, console, exp) + console.close() + + def tearDown(self): + self.vm.shutdown() diff --git a/tests/avocado/test_ovmf_with_240_vcpus.py b/tests/avocado/test= _ovmf_with_240_vcpus.py new file mode 100644 index 0000000000..da688dbc76 --- /dev/null +++ b/tests/avocado/test_ovmf_with_240_vcpus.py @@ -0,0 +1,70 @@ +import os +import shutil +import sys + +from avocado import main +from avocado_qemu import test + + +class TestOvmfVcpus(test.QemuTest): + """ + Run with: + + avocado run test_ovmf_with_240_vcpus.py \ + -m test_ovmf_with_240_vcpus.py.data/parameters.yaml + + :avocado: enable + :avocado: tags=3Dovmf + """ + + def setUp(self): + ovmf_code_path =3D self.params.get('OVMF_CODE', + default=3D'/usr/share/edk2/ovmf/O= VMF_CODE.secboot.fd') + ovmf_vars_path =3D self.params.get('OVMF_VARS', + default=3D'/usr/share/edk2/ovmf/O= VMF_VARS.fd') + if not ovmf_code_path or not os.path.exists(ovmf_code_path): + basename =3D os.path.basename(__file__) + self.cancel('OVMF_CODE file not found. Set the correct ' + 'path on "%s.data/parameters.yaml" and run this te= st ' + 'with: "avocado run %s -m %s.data/parameters.yaml"= ' % + (basename, basename, basename)) + if not ovmf_vars_path or not os.path.exists(ovmf_vars_path): + basename =3D os.path.basename(__file__) + self.cancel('OVMF_VARS file not found. Set the correct ' + 'path on "%s.data/parameters.yaml" and run this te= st ' + 'with: "avocado run %s -m %s.data/parameters.yaml"= ' % + (basename, basename, basename)) + + ovmf_vars_tmp =3D os.path.join(self.workdir, + os.path.basename(ovmf_vars_path)) + if not os.path.exists(ovmf_vars_tmp): + shutil.copy(ovmf_vars_path, self.workdir) + + self.vm.args.extend(['-drive', + 'file=3D%s,if=3Dpflash,format=3Draw,readonly= =3Don,unit=3D0' % + ovmf_code_path]) + self.vm.args.extend(['-drive', + 'file=3D%s,if=3Dpflash,format=3Draw,unit=3D1'= % + ovmf_vars_tmp]) + + self.vm.args.extend(['-smp', '240']) + + def test_run_vm(self): + """ + According to the RHBZ1447027, the issue is: Guest cannot boot + with 240 or above vcpus when using ovmf. + Fixed in commit e85c0d14014514a2f0faeae5b4c23fab5b234de4. + + :avocado: tags=3DRHBZ1447027 + """ + + try: + self.vm.launch() + except Exception as details: + self.fail(details) + + def tearDown(self): + self.vm.shutdown() + +if __name__ =3D=3D "__main__": + avocado.main() diff --git a/tests/avocado/test_ovmf_with_240_vcpus.py.data/parameters.yaml= b/tests/avocado/test_ovmf_with_240_vcpus.py.data/parameters.yaml new file mode 100644 index 0000000000..79f6da1d29 --- /dev/null +++ b/tests/avocado/test_ovmf_with_240_vcpus.py.data/parameters.yaml @@ -0,0 +1,2 @@ +OVMF_CODE: /usr/share/edk2/ovmf/OVMF_CODE.secboot.fd +OVMF_VARS: /usr/share/edk2/ovmf/OVMF_VARS.fd diff --git a/tests/avocado/variants.yaml b/tests/avocado/variants.yaml new file mode 100644 index 0000000000..6fc689b3ba --- /dev/null +++ b/tests/avocado/variants.yaml @@ -0,0 +1,62 @@ +architecture: !mux + # Set the architecture of the qemu binary to execute tests + # with. This setting has no effect if you're using custom + # qemu_bin configuration. + x86_64: + arch: x86_64 + aarch64: + arch: aarch64 + alpha: + arch: alpha + arm: + arch: arm + cris: + arch: cris + i386: + arch: i386 + lm32: + arch: lm32 + m68k: + arch: m68k + microblazeel: + arch: microblazeel + microblaze: + arch: microblaze + mips64el: + arch: mips64el + mips64: + arch: mips64 + mipsel: + arch: mipsel + mips: + arch: mips + moxie: + arch: moxie + nios2: + arch: nios2 + or1k: + arch: or1k + ppc64: + arch: ppc64 + ppcemb: + arch: ppcemb + ppc: + arch: ppc + s390x: + arch: s390x + sh4eb: + arch: sh4eb + sh4: + arch: sh4 + sparc64: + arch: sparc64 + sparc: + arch: sparc + tricore: + arch: tricore + unicore32: + arch: unicore32 + xtensaeb: + arch: xtensaeb + xtensa: + arch: xtensa diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index b25d48a91b..a2e4f03743 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -293,18 +293,18 @@ class VM(qtest.QEMUQtestMachine): self._num_drives =3D 0 =20 def add_object(self, opts): - self._args.append('-object') - self._args.append(opts) + self.args.append('-object') + self.args.append(opts) return self =20 def add_device(self, opts): - self._args.append('-device') - self._args.append(opts) + self.args.append('-device') + self.args.append(opts) return self =20 def add_drive_raw(self, opts): - self._args.append('-drive') - self._args.append(opts) + self.args.append('-drive') + self.args.append(opts) return self =20 def add_drive(self, path, opts=3D'', interface=3D'virtio', format=3Dim= gfmt): @@ -322,27 +322,27 @@ class VM(qtest.QEMUQtestMachine): =20 if format =3D=3D 'luks' and 'key-secret' not in opts: # default luks support - if luks_default_secret_object not in self._args: + if luks_default_secret_object not in self.args: self.add_object(luks_default_secret_object) =20 options.append(luks_default_key_secret_opt) =20 - self._args.append('-drive') - self._args.append(','.join(options)) + self.args.append('-drive') + self.args.append(','.join(options)) self._num_drives +=3D 1 return self =20 def add_blockdev(self, opts): - self._args.append('-blockdev') + self.args.append('-blockdev') if isinstance(opts, str): - self._args.append(opts) + self.args.append(opts) else: - self._args.append(','.join(opts)) + self.args.append(','.join(opts)) return self =20 def add_incoming(self, addr): - self._args.append('-incoming') - self._args.append(addr) + self.args.append('-incoming') + self.args.append(addr) return self =20 def pause_drive(self, drive, event=3DNone): --=20 2.17.0 From nobody Mon Apr 29 11:09:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524157251000299.3156370714621; Thu, 19 Apr 2018 10:00:51 -0700 (PDT) Received: from localhost ([::1]:60628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9CvS-00067w-5C for importer@patchew.org; Thu, 19 Apr 2018 13:00:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9CiC-0003Hu-88 for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9Ci8-0007PY-5n for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:08 -0400 Received: from mail-qt0-x229.google.com ([2607:f8b0:400d:c0d::229]:42513) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f9Ci8-0007P9-0X; Thu, 19 Apr 2018 12:47:04 -0400 Received: by mail-qt0-x229.google.com with SMTP id j3-v6so6499091qtn.9; Thu, 19 Apr 2018 09:47:03 -0700 (PDT) Received: from x1.local ([138.117.48.212]) by smtp.gmail.com with ESMTPSA id k126sm3040039qkd.34.2018.04.19.09.46.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 09:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QO0osnrYgT45mBxQLv4e00Z78uT8KzTZuIsimkthMD0=; b=tSk1Uy7wCRo/j3wTId7pntjV4Z6iWBj5+bkXO1ILVfYVuPmEX0ej76sRneNu5Kzlhk F+2BbZMaGy4EMfEs8YXye1/HLfjUK/oKWZ96kBEkJlgTzZpDFv98tSXZpqVKP6b6TT1G mxi3x/bX8YkpV4gV2x2BWMR6YD+CWwMb59BUf9FbWy45EldS1VyHwAFNw66QRR9FkXqK /+OfQxWl/4YBRwu0xWdnEYJi7eHYC890oOh31o3TJsnm7Sa47bRJQEtysg1xleq6L/Wc w0oU/zEr+kaf2KYKMND2QKu6UROSyD7Pc5Eh5t8JkscQdweQ6484lhaFVu3adWXFkVIs mNZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=QO0osnrYgT45mBxQLv4e00Z78uT8KzTZuIsimkthMD0=; b=cYe1ajdnjjenR8GBLNBztHNRCTwJPTVvHJEWbdEmfbeYEBuWi78GEZMwss5i74BYBU bc5GuP6jZFWWcMVuEuLljl1lHWNSXkrFdKR6Pc/Acj1D1SmArNFhiOt75akiLiAOevYJ 9o/FxrqLKuPxtCgas974dYRD0KvYMn9pmznW4JyzphbTB6R7h09f0WuddjUoYljfjaMo LFkdw2TO+zLP8Yt/3FZU2fTWAXkjy9UI0jqMFKbxFIatWMVYfQu+s33HrwJgNx7qock1 rFysHjQ8sN/vz2ESrQQRFiQMJC+/JreVweAxxhcu0RhhXqR3IDxaRdo6PnzoKQUYspou 0Exg== X-Gm-Message-State: ALQs6tBkh9WqOp5+xYiosRxurLql5oZKRg6uJRdAwyAjUeYS5vnY/Abv A/QPuweY+riL4M96q+krtdixGG8w X-Google-Smtp-Source: AB8JxZrWosrlzDqvyMMlXbd6mlQA29ra3BzT2VcZ6K6PhEonBXhxJfGbc8g5satYqjgX69zRXp+Z0g== X-Received: by 2002:ac8:2912:: with SMTP id y18-v6mr3740250qty.336.1524156423321; Thu, 19 Apr 2018 09:47:03 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Cleber Rosa , Amador Pahim , Stefan Hajnoczi , Zheng Xiang Date: Thu, 19 Apr 2018 13:46:37 -0300 Message-Id: <20180419164642.9536-3-f4bug@amsat.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419164642.9536-1-f4bug@amsat.org> References: <20180419164642.9536-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::229 Subject: [Qemu-devel] [RFC PATCH 2/7] avocado: Update python scripts to upstream codebase X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , Eduardo Habkost , "open list:Block layer core" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Alistair Francis , Max Reitz , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 QEMUMachine arguments member is called '_args'. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- scripts/qemu.py | 14 +++++++------- tests/avocado/avocado_qemu/test.py | 12 ++++++------ tests/qemu-iotests/iotests.py | 28 ++++++++++++++-------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/scripts/qemu.py b/scripts/qemu.py index bd66620f45..0eecc44d09 100644 --- a/scripts/qemu.py +++ b/scripts/qemu.py @@ -81,7 +81,7 @@ class QEMUMachine(object): self._qemu_log_file =3D None self._popen =3D None self._binary =3D binary - self.args =3D list(args) # Force copy args in case we modify t= hem + self._args =3D list(args) # Force copy args in case we modify = them self._wrapper =3D wrapper self._events =3D [] self._iolog =3D None @@ -109,8 +109,8 @@ class QEMUMachine(object): # This can be used to add an unused monitor instance. def add_monitor_telnet(self, ip, port): args =3D 'tcp:%s:%d,server,nowait,telnet' % (ip, port) - self.args.append('-monitor') - self.args.append(args) + self._args.append('-monitor') + self._args.append(args) =20 def add_fd(self, fd, fdset, opaque, opts=3D''): '''Pass a file descriptor to the VM''' @@ -120,8 +120,8 @@ class QEMUMachine(object): if opts: options.append(opts) =20 - self.args.append('-add-fd') - self.args.append(','.join(options)) + self._args.append('-add-fd') + self._args.append(','.join(options)) return self =20 def send_fd_scm(self, fd_file_path): @@ -184,7 +184,7 @@ class QEMUMachine(object): '-display', 'none', '-vga', 'none'] =20 def _create_console(self, console_address): - for item in self.args: + for item in self._args: for option in ['isa-serial', 'spapr-vty', 'sclpconsole']: if option in item: return [] @@ -274,7 +274,7 @@ class QEMUMachine(object): bargs =3D self._base_args() bargs.extend(self._create_console(console_address)) self._qemu_full_args =3D (self._wrapper + [self._binary] + - bargs + self.args) + bargs + self._args) self._popen =3D subprocess.Popen(self._qemu_full_args, stdin=3Ddevnull, stdout=3Dself._qemu_log_file, diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index 5a08dace45..1ead917014 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -297,8 +297,8 @@ class _VM(qemu.QEMUMachine): port =3D self.ports.find_free_port() newvm =3D _VM(self.qemu_dst_bin, self._arch, username=3Dself.usern= ame, password=3Dself.password) - newvm.args =3D self.args - newvm.args.extend(['-incoming', 'tcp:0:%s' % port]) + newvm._args =3D self._args + newvm._args.extend(['-incoming', 'tcp:0:%s' % port]) newvm.username =3D self.username newvm.password =3D self.password =20 @@ -329,7 +329,7 @@ class _VM(qemu.QEMUMachine): :param extra: Extra parameters to the -drive option """ file_option =3D 'file=3D%s' % path - for item in self.args: + for item in self._args: if file_option in item: logging.error('Image %s already present', path) return @@ -340,7 +340,7 @@ class _VM(qemu.QEMUMachine): if snapshot: file_option +=3D ',snapshot=3Don' =20 - self.args.extend(['-drive', file_option]) + self._args.extend(['-drive', file_option]) =20 if username is not None: self.username =3D username @@ -387,7 +387,7 @@ class _VM(qemu.QEMUMachine): process.run("%s -output %s -volid cidata -joliet -rock %s %s" % (geniso_bin, iso_path, metadata_path, userdata_path)) =20 - self.args.extend(['-cdrom', iso_path]) + self._args.extend(['-cdrom', iso_path]) =20 class QemuTest(Test): =20 @@ -415,4 +415,4 @@ class QemuTest(Test): if machine_kvm_type is not None: machine +=3D "kvm-type=3D%s," % machine_kvm_type if machine: - self.vm.args.extend(['-machine', machine]) + self.vm._args.extend(['-machine', machine]) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index a2e4f03743..b25d48a91b 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -293,18 +293,18 @@ class VM(qtest.QEMUQtestMachine): self._num_drives =3D 0 =20 def add_object(self, opts): - self.args.append('-object') - self.args.append(opts) + self._args.append('-object') + self._args.append(opts) return self =20 def add_device(self, opts): - self.args.append('-device') - self.args.append(opts) + self._args.append('-device') + self._args.append(opts) return self =20 def add_drive_raw(self, opts): - self.args.append('-drive') - self.args.append(opts) + self._args.append('-drive') + self._args.append(opts) return self =20 def add_drive(self, path, opts=3D'', interface=3D'virtio', format=3Dim= gfmt): @@ -322,27 +322,27 @@ class VM(qtest.QEMUQtestMachine): =20 if format =3D=3D 'luks' and 'key-secret' not in opts: # default luks support - if luks_default_secret_object not in self.args: + if luks_default_secret_object not in self._args: self.add_object(luks_default_secret_object) =20 options.append(luks_default_key_secret_opt) =20 - self.args.append('-drive') - self.args.append(','.join(options)) + self._args.append('-drive') + self._args.append(','.join(options)) self._num_drives +=3D 1 return self =20 def add_blockdev(self, opts): - self.args.append('-blockdev') + self._args.append('-blockdev') if isinstance(opts, str): - self.args.append(opts) + self._args.append(opts) else: - self.args.append(','.join(opts)) + self._args.append(','.join(opts)) return self =20 def add_incoming(self, addr): - self.args.append('-incoming') - self.args.append(addr) + self._args.append('-incoming') + self._args.append(addr) return self =20 def pause_drive(self, drive, event=3DNone): --=20 2.17.0 From nobody Mon Apr 29 11:09:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524157229304396.8611302792059; Thu, 19 Apr 2018 10:00:29 -0700 (PDT) Received: from localhost ([::1]:60624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9Cv6-0005uw-HC for importer@patchew.org; Thu, 19 Apr 2018 13:00:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9CiC-0003IP-W6 for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9CiB-0007RY-Pi for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:09 -0400 Received: from mail-qt0-x22b.google.com ([2607:f8b0:400d:c0d::22b]:45202) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f9CiB-0007RE-KF for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:07 -0400 Received: by mail-qt0-x22b.google.com with SMTP id b13-v6so6485545qtp.12 for ; Thu, 19 Apr 2018 09:47:07 -0700 (PDT) Received: from x1.local ([138.117.48.212]) by smtp.gmail.com with ESMTPSA id k126sm3040039qkd.34.2018.04.19.09.47.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 09:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5rMypBEglsvAZFnjEzp/pe9q5f6nHe5/xb5qFlncpn0=; b=f4hkzIcX+hBr7o2t7XleCvaEPCC6nFiMx2de264cGDwy0LivhIMcs0NGyjFzd+1ghw mazWaf53R7BbWEBURJU+n0EiaHh5auxO+6fXFXHoZ3GRgXqj33fhJnNu01befXW26FUm E7uoQY59EtvFckCVcYDjLjmE7DbXnPK+poV2SuCgrH/0/kaZy84d8ReFs2auaYDXh3cX utgDQ/RoUmbvtCB2xef4vn/0hlxysn1zomPifpHy1lYax11rZk1HsrE0i/wD/Q8+oIfN KWjCjUslv52GJKEnIPV6/Yr5BwAGdgEcA5GWxEDbddpcQdYhtuMDba5YM9DtugDOSvLj LBnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=5rMypBEglsvAZFnjEzp/pe9q5f6nHe5/xb5qFlncpn0=; b=tX/KMmu4PtRFRPug7S94OzTha8v/mapkuvcg5Raxcd43TWDQnZ023nJ5ywA64stz2i E5Sl5co/D3IjKnDHaTUmb3NYxdD1qVgjvTBLDJpwYsEYTxspo1qW7AMEDgVcKYgY0Dgc 7XH99qhqOs5vEoGo+nygxxdc2CURKrvLWYtQWImgKllLy0G0YAIfnrIIjQbodFD9MLyt W0QuC7ILWF/MoXOSyQri4nYOgpcYH3W+rYw6SeYqhWsCCt4bEwqCr4bRE3E2TFhOu6Yt TzpdbqVZ/qmcr6Ve4fim3h9b9NCqZhkkEUBXkcuCCfkBhJ5Usb9zP0eNMjqcxYDSZtc0 GDTw== X-Gm-Message-State: ALQs6tA5d09HiZGIoH9EjZ2rXPdbwZkDGojoh9mlvgKrzOhvG97jkzVo iHkkvUzgWjKAiR49YUXypzg= X-Google-Smtp-Source: AIpwx49VdiGXhJDd6lQpPbZlxCh3xZ9fbYqiBlpoc/8ehIHKS2zUokKwY/HVVpXyoUmLTMmhaMxboA== X-Received: by 2002:ac8:701:: with SMTP id g1-v6mr6440102qth.397.1524156427043; Thu, 19 Apr 2018 09:47:07 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Cleber Rosa , Amador Pahim , Stefan Hajnoczi , Zheng Xiang Date: Thu, 19 Apr 2018 13:46:38 -0300 Message-Id: <20180419164642.9536-4-f4bug@amsat.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419164642.9536-1-f4bug@amsat.org> References: <20180419164642.9536-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::22b Subject: [Qemu-devel] [RFC PATCH 3/7] qemu.py: Check console arch is supported before calling mktemp() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Alistair Francis , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Cleber Rosa --- scripts/qemu.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/qemu.py b/scripts/qemu.py index 0eecc44d09..379767b62f 100644 --- a/scripts/qemu.py +++ b/scripts/qemu.py @@ -189,6 +189,16 @@ class QEMUMachine(object): if option in item: return [] =20 + device =3D '{dev_type},chardev=3Dconsole' + if '86' in self._arch: + device =3D device.format(dev_type=3D'isa-serial') + elif 'ppc' in self._arch: + device =3D device.format(dev_type=3D'spapr-vty') + elif 's390x' in self._arch: + device =3D device.format(dev_type=3D'sclpconsole') + else: + return [] + chardev =3D 'socket,id=3Dconsole,{address},server,nowait' if console_address is None: console_address =3D tempfile.mktemp() @@ -203,16 +213,6 @@ class QEMUMachine(object): =20 self._console_address =3D console_address =20 - device =3D '{dev_type},chardev=3Dconsole' - if '86' in self._arch: - device =3D device.format(dev_type=3D'isa-serial') - elif 'ppc' in self._arch: - device =3D device.format(dev_type=3D'spapr-vty') - elif 's390x' in self._arch: - device =3D device.format(dev_type=3D'sclpconsole') - else: - return [] - return ['-chardev', chardev, '-device', device] =20 --=20 2.17.0 From nobody Mon Apr 29 11:09:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524157667735187.77339784248352; Thu, 19 Apr 2018 10:07:47 -0700 (PDT) Received: from localhost ([::1]:60960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9D2A-0003Nx-JO for importer@patchew.org; Thu, 19 Apr 2018 13:07:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9CiF-0003LL-Pn for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9CiF-0007TH-1K for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:11 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:45373) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f9CiE-0007Sy-Tl for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:10 -0400 Received: by mail-qk0-x242.google.com with SMTP id c136so5941415qkb.12 for ; Thu, 19 Apr 2018 09:47:10 -0700 (PDT) Received: from x1.local ([138.117.48.212]) by smtp.gmail.com with ESMTPSA id k126sm3040039qkd.34.2018.04.19.09.47.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 09:47:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v020HuZupMg0grOIwkPTnAR9LWV7aq3UJqoFz5Fy1Ig=; b=qYtkFivjzYzdMjxF3Z2sFaGbL+aq2h3EikAOAJ9/aEfc7Nnxy/BkFdU4d70gTKR3W+ zAJ6h1gPK0FbGjfHf/lrGJ+DIvJNsYPSM9QJlc4FKs95JM9UxJ4Fb5Bh1/lHmdCc4jvC fEnLdKgdfyXQ77YOb2mLC3UmFUfBP25hMNEfTmAHO9pV0nYUhnOk+eZMdG1+k+8H+ash lIrNu7Q+YXcW5RKSDmuTnovQnGdTQ4jNgZdCpIx9/CMil5el+pfdVA9m4qOSTDl4gInM c40eGVI08ZFfFJbM7tg9KCu+/8jlchiBfdCHECaAr6VeN1CxN/2n+/Pzjwd9Zqqo/b9X bmFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=v020HuZupMg0grOIwkPTnAR9LWV7aq3UJqoFz5Fy1Ig=; b=dAwJBSr2h0CADDJJlAR69k9DVqfe52WyktnpsY51w97osRacu+I9pmhAbgQ8HJJkbm AIKw7sLoS7xSpA4ditaLnYJtPzC94Z1PEhT+dt2eUraedLkufZsLun1jtyrfpdEYLpZp KPwH/zMZ1Z5b47ea6X7chPX5rYap6vJj+SpMIlgLb6gLQp3kd6qM3xMk2YPU1KnBzCmT 3DFZS5+HlXYXCDPJlwu8rB3ArVi6iQXM+hmOmHLqnlRNCX0U68D1rssW18+NyncMAIka aR2Ybb5mGltqrKlSAvdYvm56Sw6SxgOp6bFhBAnEV0FRTnwT2Fvn1wUUhXpu6Map8c50 bQ+A== X-Gm-Message-State: ALQs6tAwp/ko062N7VEn/TJU4RwD4mfucLnmoikOsfDwE4CI6x7lJUSt lBmbb6yzybP8v3UhME80jPU= X-Google-Smtp-Source: AB8JxZoPicYTTzQGWUkowqrEhNxNowp1Z9cYPZNWK3lP4lyddCZrJ+uLNRfoa3UL+LHxBrUpu82Q1w== X-Received: by 10.233.216.67 with SMTP id u64mr6380694qkf.137.1524156430421; Thu, 19 Apr 2018 09:47:10 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Cleber Rosa , Amador Pahim , Stefan Hajnoczi , Zheng Xiang Date: Thu, 19 Apr 2018 13:46:39 -0300 Message-Id: <20180419164642.9536-5-f4bug@amsat.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419164642.9536-1-f4bug@amsat.org> References: <20180419164642.9536-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [RFC PATCH 4/7] qemu.py: Avoid deprecated tempfile.mktemp() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Alistair Francis , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 We already have secure temporary directory created with tempfile.mkdtemp(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Cleber Rosa --- scripts/qemu.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/qemu.py b/scripts/qemu.py index 379767b62f..26c4b1fd3b 100644 --- a/scripts/qemu.py +++ b/scripts/qemu.py @@ -201,7 +201,8 @@ class QEMUMachine(object): =20 chardev =3D 'socket,id=3Dconsole,{address},server,nowait' if console_address is None: - console_address =3D tempfile.mktemp() + console_address =3D os.path.join(self._temp_dir, + self._name + "-console.sock") chardev =3D chardev.format(address=3D'path=3D%s' % console_address) elif isinstance(console_address, tuple): --=20 2.17.0 From nobody Mon Apr 29 11:09:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524157468437356.0272936929101; Thu, 19 Apr 2018 10:04:28 -0700 (PDT) Received: from localhost ([::1]:60829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9Cyw-0000c5-3o for importer@patchew.org; Thu, 19 Apr 2018 13:04:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9CiM-0003SO-Hd for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9CiI-0007Uu-OH for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:18 -0400 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:40308) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f9CiI-0007Ud-Ji for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:14 -0400 Received: by mail-qk0-x243.google.com with SMTP id o64so5953555qkl.7 for ; Thu, 19 Apr 2018 09:47:14 -0700 (PDT) Received: from x1.local ([138.117.48.212]) by smtp.gmail.com with ESMTPSA id k126sm3040039qkd.34.2018.04.19.09.47.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 09:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V1yp/fwmPFgtruWFq14dNjIBmPFZxd/OMxav2t59eFM=; b=h/XQNUMllhtaLx4EfK2UL9AfmS2Qn8teOrTaAUStLMXBMGXSIfA+7+I6gc+507I8fc XuRomV32JALYORlcTgoNoeR3ruCSyc9pQS84AK2gutzoYhSMUdOualejoxaMHdm5MdLy W3wqQYkXkPozYInIgO9lIX8ug9Uq88XDmLzbvJFYelg8X98hSW6/YohHi7zxGVJGf0Rs akLyHRhef+RDHdZXzGOpkP9DAUOS3gVcAomK/o3ReHsqPSKT/qwDGPOk8/zycPNGWU/R 3HAUmkVVXqn/1d6QeGYeP9l1qrd8TBtdSj9bHk4Lx6DFYvVlP+TInoFXnDUHohKrh3w5 finw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=V1yp/fwmPFgtruWFq14dNjIBmPFZxd/OMxav2t59eFM=; b=UpNwgQv9DOZ+fldY8jHu5znBZkAQ8W3K9kExq39wTw99KPYU78b7gq9421to8jEFfv 5xD2D6b6y3h4vh5tt4Wo04XB7Fm9eSYE5+0B8/xieiLJ1bb/y9UecCwHWtNSDWw7l4wm SjnYiGt7p5q8/JY7sC7D2pZGJQ/lxDFIUn8WIfuKV2KGPJsfeYQQbZIv0QouuLN+RffM NkdzIBMkzvAWi8kHUJ6bk1V9g7FbknFuxjQ0t24X1K/pk/1l78mflGIFv3B9FO8ETkOv JXBIFlDmVs4razempCIN4D0eGr4lMnxMbGzhqkO+meEqNNFmEEZyp9BEL+yKJpd+cgQR IaYg== X-Gm-Message-State: ALQs6tDuCFfHSytg6trCNnfVUrZwMNa6A8Mzsx8QCDASIhpAc1eVyUV0 nHERmW6mcHNe8uc7Z04ETgM= X-Google-Smtp-Source: AIpwx48LB4kSrtjbRNTvbOukV2/DQWdwW1vxiZqhZoWLTdEQDr9ateVRPoUq8dl+a43O/sy266/4Lg== X-Received: by 10.55.153.7 with SMTP id b7mr5166411qke.307.1524156434072; Thu, 19 Apr 2018 09:47:14 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Cleber Rosa , Amador Pahim , Stefan Hajnoczi , Zheng Xiang Date: Thu, 19 Apr 2018 13:46:40 -0300 Message-Id: <20180419164642.9536-6-f4bug@amsat.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419164642.9536-1-f4bug@amsat.org> References: <20180419164642.9536-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::243 Subject: [Qemu-devel] [RFC PATCH 5/7] avocado: Add an optional flag 'login' to get_console() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Not all consoles require users to log in :/ Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Cleber Rosa --- tests/avocado/avocado_qemu/test.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index 1ead917014..ac8ee6d250 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -244,7 +244,7 @@ class _VM(qemu.QEMUMachine): super(_VM, self).__init__(qemu_bin, name=3Dself.name, arch=3Darch) logging.getLogger('QMP').setLevel(logging.INFO) =20 - def get_console(self, console_address=3DNone, prompt=3Dr"[\#\$] "): + def get_console(self, console_address=3DNone, prompt=3Dr"[\#\$] ", log= in=3DTrue): """ :param address: Socket address, can be either a unix socket path (string) or a tuple in the form (address, port) @@ -252,9 +252,6 @@ class _VM(qemu.QEMUMachine): :param prompt: The regex to identify we reached the prompt. """ =20 - if not all((self.username, self.password)): - raise QEMULoginError('Username or password not set.') - if not self.is_running(): raise QEMULoginError('VM is not running.') =20 @@ -272,13 +269,17 @@ class _VM(qemu.QEMUMachine): nc_cmd +=3D ' -U %s' % console_address =20 console =3D aexpect.ShellSession(nc_cmd) - try: - logging.info('Console: Waiting login prompt...') - _handle_prompts(console, self.username, self.password, prompt) - logging.info('Console: Ready!') - except: - console.close() - raise + if login: + if not all((self.username, self.password)): + raise QEMULoginError('Username or password not set.') + + try: + logging.info('Console: Waiting login prompt...') + _handle_prompts(console, self.username, self.password, pro= mpt) + except: + console.close() + raise + logging.info('Console: Ready!') =20 return console =20 --=20 2.17.0 From nobody Mon Apr 29 11:09:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152415753919133.52459983034248; Thu, 19 Apr 2018 10:05:39 -0700 (PDT) Received: from localhost ([::1]:60832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9D05-0001Xl-W4 for importer@patchew.org; Thu, 19 Apr 2018 13:05:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9CiN-0003TI-7a for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9CiM-0007WH-2i for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:19 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:41458) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f9CiL-0007WB-U9 for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:18 -0400 Received: by mail-qt0-x243.google.com with SMTP id d3-v6so6478408qth.8 for ; Thu, 19 Apr 2018 09:47:17 -0700 (PDT) Received: from x1.local ([138.117.48.212]) by smtp.gmail.com with ESMTPSA id k126sm3040039qkd.34.2018.04.19.09.47.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 09:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rj2GYQyn/sOuOjA9ca3Q5zopdYgrSee64mEenvGH0/A=; b=Q0puxMHhaub3GaPcwpdxzyRPChVhBRd47rVuI7w9TXg/EEt48nH7byASC3d8aT7S4w IO0TadIe4boiFP0vNrVT0tKsTPyB3W/Q75V0dENZH92ZsrOZ0IqbeQdThdsX+x0HtIo9 59qNmPS0VTmgN7w0CvB1OP7dFQD56b5zsNHMgn1iU/wLWoy28f3e4Vke8hy7FduAW/04 EgnGO7CW2LF9P7QRKeFgAbtJtjeDLiz7VBVby31pjSbhrVtGCOEgMXmox7zz84cFc8eO rK1ZnnA8pE1NIayelKANy10v3GXaCiQpm/Lyo6+456Os8HVb8VCyLIBorGU850GsIeFJ D8Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=rj2GYQyn/sOuOjA9ca3Q5zopdYgrSee64mEenvGH0/A=; b=o3YD2PVXyVsVCeOT+RSSbqxOFnguF38ADZVCPa7ymVmySV8kb+4b7MPIbTHyjM9Fl6 3XVX+vtcYYz41eSmMRCSiKbkiTSsAe4wUsNgtCRzn4Y7wqzjfUUbRFEr2fPDxEiqkB+G 2ZYkhAU8Z2TKZTPqsg+cgzCDDzAO/iW5z/Wykfj9LJermJN57Aa9xhwo8AplRA+Rsnp2 PE02mGtQs4VC5fhIl3hi67M3+Lvp/bTOIhtxONhOPjzXVwxDf+wsfbwALU9ZwW9dhhXT FMcUakxv/zlOASde2bOcV0Kd2UT1E41puoK1aQ2wOypXWXcgwMGXL4zBH74Ni/2wttKI y8OQ== X-Gm-Message-State: ALQs6tAfveNv/ILkmR/Yc0ikvm/m9WEVSn4AoIWTkzg0YaGXeZrypK9X 5/U0gDvug64IqS7kjw7dt68= X-Google-Smtp-Source: AIpwx49MAYV/7AKLnYAVhteZ4BFQc4HtTieWjtRZiqO0SICUSzBfepMyG2Xp72SsZyjZIDxdVegTfA== X-Received: by 2002:aed:2aa3:: with SMTP id t32-v6mr7139040qtd.33.1524156437352; Thu, 19 Apr 2018 09:47:17 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Cleber Rosa , Amador Pahim , Stefan Hajnoczi , Zheng Xiang Date: Thu, 19 Apr 2018 13:46:41 -0300 Message-Id: <20180419164642.9536-7-f4bug@amsat.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419164642.9536-1-f4bug@amsat.org> References: <20180419164642.9536-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [RFC PATCH 6/7] avocado: Add a test parsing Linux kernel booting console X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Alistair Francis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Booting an Alpha DP264 machine. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Richard Henderson --- tests/avocado/test_linux-boot-console.py | 88 +++++++++++++++++++ .../parameters.yaml | 3 + 2 files changed, 91 insertions(+) create mode 100644 tests/avocado/test_linux-boot-console.py create mode 100644 tests/avocado/test_linux-boot-console.py.data/parameter= s.yaml diff --git a/tests/avocado/test_linux-boot-console.py b/tests/avocado/test_= linux-boot-console.py new file mode 100644 index 0000000000..f54d10dd79 --- /dev/null +++ b/tests/avocado/test_linux-boot-console.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- +# +# Boot a Linux kernel on the Malta board and check the serial console outp= ut +# +# Copyright (C) 2018 Philippe Mathieu-Daud=C3=A9 +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Run with: +# +# avocado run test_linux-boot-console.py \ +# --mux-yaml test_linux-boot-console.py.data/parameters.yaml +# [--filter-by-tags arch_alpha ...] + +import os +import tempfile +import hashlib +import urllib2 +import gzip +import shutil + +from avocado import skipUnless +from avocado_qemu import test + +# XXX Use a cleaner CacheStorage or avocado.utils.[archive|kernel]? +def cachedfile(url, cachedir=3D'/tmp/mycachedir', gzip_compressed=3DFalse): + if not os.path.isdir(cachedir): + os.mkdir(cachedir) + key =3D hashlib.md5(url).hexdigest() + fbin =3D cachedir + "/" + key + ".bin" + if not os.path.isfile(fbin): + with open(cachedir + "/" + key + ".url", "w") as f: + f.write(url + '\n') + with open(fbin, "wb") as f: + content =3D urllib2.urlopen(url).read() + f.write(content) + if gzip_compressed: + fgz =3D cachedir + "/" + key + ".gz" + shutil.move(fbin, fgz) + with gzip.open(fgz, 'rb') as f_in, open(fbin, 'wb') as f_out: + shutil.copyfileobj(f_in, f_out) + return fbin + + +class TestAlphaClipperBoot2_6(test.QemuTest): + """ + :avocado: enable + :avocado: tags=3Darch_alpha + """ + ARCH =3D "alpha" + + def kernel_url(self): + return 'http://archive.debian.org/debian/dists/lenny/main/installe= r-alpha/current/images/cdrom/vmlinuz' + + def setUp(self): + self.console_path =3D tempfile.mkstemp()[1] + kernel_path =3D cachedfile(self.kernel_url(), gzip_compressed=3DTr= ue) + self.vm._args.extend(['-machine', 'clipper']) + self.vm._args.extend(['-m', '64']) + self.vm._args.extend(['-kernel', kernel_path]) + self.vm._args.extend(['-append', '"console=3DttyS0 printk.time=3D0= "']) + self.vm._args.extend(['-chardev', 'socket,id=3Dsrm,server,nowait,p= ath=3D' + self.console_path]) + self.vm._args.extend(['-serial', 'chardev:srm']) + # This kernel crashes without VGA display + self.vm._args.extend(['-vga', 'std']) + + def test_boot_console(self): + """ + :avocado: tags=3Duart,printk + """ + # TODO use skipUnless() + if self.params.get('arch') !=3D self.ARCH: + return + + self.vm.launch(self.console_path) + console =3D self.vm.get_console(console_address=3Dself.console_pat= h, login=3DFalse) + # no filesystem provided on purpose, wait for the Kernel panic + bootlog =3D console.read_until_any_line_matches(["Kernel panic - n= ot syncing: VFS: Unable to mount root fs"], timeout=3D30.0)[1] + console.close() + # check Super I/O + self.assertIn(u'ttyS0 at I/O 0x3f8 (irq =3D 4) is a 16550A', bootl= og) + self.assertIn(u'ttyS1 at I/O 0x2f8 (irq =3D 3) is a 16550A', bootl= og) + self.assertIn(u'i8042 KBD port at 0x60,0x64 irq 1', bootlog) + self.assertIn(u'i8042 AUX port at 0x60,0x64 irq 12', bootlog) + self.vm.shutdown() + + def tearDown(self): + os.remove(self.console_path) diff --git a/tests/avocado/test_linux-boot-console.py.data/parameters.yaml = b/tests/avocado/test_linux-boot-console.py.data/parameters.yaml new file mode 100644 index 0000000000..ed8c08058c --- /dev/null +++ b/tests/avocado/test_linux-boot-console.py.data/parameters.yaml @@ -0,0 +1,3 @@ +architecture: !mux + alpha: + arch: alpha --=20 2.17.0 From nobody Mon Apr 29 11:09:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524157859454350.12000814876274; Thu, 19 Apr 2018 10:10:59 -0700 (PDT) Received: from localhost ([::1]:32912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9D59-000641-Ad for importer@patchew.org; Thu, 19 Apr 2018 13:10:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9CiR-0003Wj-0e for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9CiP-0007Y4-Ij for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:23 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:45483) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f9CiP-0007Y0-Cp for qemu-devel@nongnu.org; Thu, 19 Apr 2018 12:47:21 -0400 Received: by mail-qt0-x241.google.com with SMTP id b13-v6so6486280qtp.12 for ; Thu, 19 Apr 2018 09:47:21 -0700 (PDT) Received: from x1.local ([138.117.48.212]) by smtp.gmail.com with ESMTPSA id k126sm3040039qkd.34.2018.04.19.09.47.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 09:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PU0K8WfxeChXdFdEAKTDVTT6855GiMFYJU/V1us4HHc=; b=i90h7Ap+eQdh8HmoKjQdZO+dsKq/HgKHgN61GAdKSR5kruU7Bcz0EoWM72sq5zD4e4 EbmHDE1WWw1nRpvBRMTWKakx8e1lgs42c8oVgbBQMjl7oxPj7BdCWMpMrAQssS8+ozjs QdCgTAPsYop8EhfEACPFriqMgD5+FKba/3x3HLi7Y+Ca7pxm2EYmdyZdTR2VkP7QKFBr KkbGKgRi0TCRAr/mUh/aqyEvxq2V0BCuV7BJRfjXCCC008eSq4pTjORRYiePG0ZjLJTQ xwjGBkGLwC0ZfzV7SX4WQnapN0286WX3j/MaPVyuXVoh+Kq08y6miz2UQ3UJCmvJS0lB KMYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=PU0K8WfxeChXdFdEAKTDVTT6855GiMFYJU/V1us4HHc=; b=fJTJYXAwekP5JBg6oMCzRkSb46AkYwAOlc2pXXuSYDL0iNqAyizZa3EMYgS7Fky2oF S2AXfxWJyyWlE4Ddbmp4u+8Yr+Nx3+BC4aXivfEqEYEgKVDP6IjfeBIqISgYwxfkDExX hnxLB0ryKeCODWyQxE5flPrF2GcmW7pSb3FqimT/BksJfC3k+unp1McXJhD9jhxOHa91 S7Z+rfWvTIrbfiaRAJvWwTgpVLRNy/EGUD8SfrIo8Gtpgdue/zQEMfpZvGMS4UbVeHxq ZGoamTrsqlPs4K8gJeyiT7RS8YxLHjSRy9bfCwAapsi10wVfJrKV+2Wh+QFoRg7VpsRI 0MgQ== X-Gm-Message-State: ALQs6tDMPMcUd+vtENYuHXeqNSF1jnacvDgefrBh0Td6XmDBbEifZwp1 72UjZYzUWyhBD/Do6JTAIqU= X-Google-Smtp-Source: AB8JxZoh7LrCfKzu6nMojwaC1WzG5dLo+yFmqrheR45VJNBvNr3VbWmX8JtxbQTDNjHfdadg/KhVNg== X-Received: by 2002:ac8:b0e:: with SMTP id e14-v6mr6742888qti.365.1524156440846; Thu, 19 Apr 2018 09:47:20 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Cleber Rosa , Amador Pahim , Stefan Hajnoczi , Zheng Xiang Date: Thu, 19 Apr 2018 13:46:42 -0300 Message-Id: <20180419164642.9536-8-f4bug@amsat.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419164642.9536-1-f4bug@amsat.org> References: <20180419164642.9536-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::241 Subject: [Qemu-devel] [RFC PATCH 7/7] avocado: Add tests booting the Malta machine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Alistair Francis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/avocado/test_linux-boot-console.py | 92 +++++++++++++++++++ .../parameters.yaml | 2 + 2 files changed, 94 insertions(+) diff --git a/tests/avocado/test_linux-boot-console.py b/tests/avocado/test_= linux-boot-console.py index f54d10dd79..4ae1e3bf37 100644 --- a/tests/avocado/test_linux-boot-console.py +++ b/tests/avocado/test_linux-boot-console.py @@ -86,3 +86,95 @@ class TestAlphaClipperBoot2_6(test.QemuTest): =20 def tearDown(self): os.remove(self.console_path) + + +class TestMips4kcMaltaBoot2_6(test.QemuTest): + """ + :avocado: enable + :avocado: tags=3Darch_mips + """ + ARCH =3D "mips" + + def kernel_url(self): + return 'http://people.debian.org/~aurel32/qemu/mips/vmlinux-2.6.32= -5-4kc-malta' + + def setUp(self): + self.console_path =3D tempfile.mkstemp()[1] + kernel_path =3D cachedfile(self.kernel_url()) + self.vm._args.extend(['-machine', 'malta']) + self.vm._args.extend(['-m', '64']) + self.vm._args.extend(['-kernel', kernel_path]) + self.vm._args.extend(['-append', '"console=3DttyS0 printk.time=3D0= "']) + self.vm._args.extend(['-chardev', 'socket,id=3Duart0,server,nowait= ,path=3D' + self.console_path]) + self.vm._args.extend(['-serial', 'chardev:uart0']) + self.vm._args.extend(['-nographic']) + + def test_boot_console(self): + """ + :avocado: tags=3Duart,printk + """ + if self.params.get('arch') !=3D self.ARCH: + return + + self.vm.launch(self.console_path) + console =3D self.vm.get_console(console_address=3Dself.console_pat= h, login=3DFalse) + # no filesystem provided on purpose, wait for the Kernel panic + bootlog =3D console.read_until_any_line_matches(["Kernel panic - n= ot syncing: VFS: Unable to mount root fs"], timeout=3D6.0)[1] + console.close() + # check Super I/O + self.assertIn(u'ttyS0 at I/O 0x3f8 (irq =3D 4) is a 16550A', bootl= og) + self.assertIn(u'ttyS1 at I/O 0x2f8 (irq =3D 3) is a 16550A', bootl= og) + self.assertIn(u'i8042 KBD port at 0x60,0x64 irq 1', bootlog) + self.assertIn(u'i8042 AUX port at 0x60,0x64 irq 12', bootlog) + # check PCI (network interface) + self.assertIn(u'registered as PCnet/PCI II 79C970A', bootlog) + self.vm.shutdown() + + def tearDown(self): + os.remove(self.console_path) + +# FIXME this is a copy of TestMips4kcMaltaBoot2_6 with a different the ker= nel url +class TestMips4kcMaltaBoot3_2(test.QemuTest): + """ + :avocado: enable + :avocado: tags=3Darch_mips + """ + ARCH =3D "mips" + + def kernel_url(self): + return 'http://people.debian.org/~aurel32/qemu/mips/vmlinux-3.2.0-= 4-4kc-malta' + + def setUp(self): + self.console_path =3D tempfile.mkstemp()[1] + kernel_path =3D cachedfile(self.kernel_url()) + self.vm._args.extend(['-machine', 'malta']) + self.vm._args.extend(['-m', '64']) + self.vm._args.extend(['-kernel', kernel_path]) + self.vm._args.extend(['-append', '"console=3DttyS0 printk.time=3D0= "']) + self.vm._args.extend(['-chardev', 'socket,id=3Duart0,server,nowait= ,path=3D' + self.console_path]) + self.vm._args.extend(['-serial', 'chardev:uart0']) + self.vm._args.extend(['-nographic']) + + def test_boot_console(self): + """ + :avocado: tags=3Duart,printk + """ + if self.params.get('arch') !=3D self.ARCH: + return + + self.vm.launch(self.console_path) + console =3D self.vm.get_console(console_address=3Dself.console_pat= h, login=3DFalse) + # no filesystem provided on purpose, wait for the Kernel panic + bootlog =3D console.read_until_any_line_matches(["Kernel panic - n= ot syncing: VFS: Unable to mount root fs"], timeout=3D6.0)[1] + console.close() + # check Super I/O + self.assertIn(u'ttyS0 at I/O 0x3f8 (irq =3D 4) is a 16550A', bootl= og) + self.assertIn(u'ttyS1 at I/O 0x2f8 (irq =3D 3) is a 16550A', bootl= og) + self.assertIn(u'i8042 KBD port at 0x60,0x64 irq 1', bootlog) + self.assertIn(u'i8042 AUX port at 0x60,0x64 irq 12', bootlog) + # check PCI (network interface) + self.assertIn(u'registered as PCnet/PCI II 79C970A', bootlog) + self.vm.shutdown() + + def tearDown(self): + os.remove(self.console_path) diff --git a/tests/avocado/test_linux-boot-console.py.data/parameters.yaml = b/tests/avocado/test_linux-boot-console.py.data/parameters.yaml index ed8c08058c..156f271a73 100644 --- a/tests/avocado/test_linux-boot-console.py.data/parameters.yaml +++ b/tests/avocado/test_linux-boot-console.py.data/parameters.yaml @@ -1,3 +1,5 @@ architecture: !mux alpha: arch: alpha + mips: + arch: mips --=20 2.17.0