From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524248554170599.2836416358188; Fri, 20 Apr 2018 11:22:34 -0700 (PDT) Received: from localhost ([::1]:50151 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ag1-0005q8-Ui for importer@patchew.org; Fri, 20 Apr 2018 14:22:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9adt-0004Sg-S2 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:20:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9ads-0004bT-M6 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:20:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39078) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9adr-0004Ws-Qg for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:20:16 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 193A17B133; Fri, 20 Apr 2018 18:20:15 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id CACE460F80; Fri, 20 Apr 2018 18:20:06 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:28 -0300 Message-Id: <20180420181951.7252-2-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 20 Apr 2018 18:20:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 01/24] qemu.py: Introduce _create_console() method 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Amador Pahim This patch adds the QEMUMachine._create_console() method, which returns a list with the chardev console device arguments to be used in the qemu command line. Signed-off-by: Amador Pahim [ehabkost: reword commit message] Signed-off-by: Eduardo Habkost --- scripts/qemu.py | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/scripts/qemu.py b/scripts/qemu.py index 08a3e9af5a..9e9d502543 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 @@ -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() @@ -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, --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524248586951716.4112079913713; Fri, 20 Apr 2018 11:23:06 -0700 (PDT) Received: from localhost ([::1]:50153 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9agb-0006KE-WB for importer@patchew.org; Fri, 20 Apr 2018 14:23:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9aeJ-0004q1-6L for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:20:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9aeF-0005Zs-8w for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:20:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53226) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9aeE-0005Y9-UC for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:20:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3DF9D3002A8B; Fri, 20 Apr 2018 18:20:38 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BB485D6A8; Fri, 20 Apr 2018 18:20:16 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:29 -0300 Message-Id: <20180420181951.7252-3-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 20 Apr 2018 18:20:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 02/24] Introduce the basic framework to run Avocado tests 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Amador Pahim Avocado Testing Framework can help with functional tests in qemu development process. This patch creates the basic infrastructure to use with Avocado tests. It contains: - A README file with the initial documentation. - The test module which inherits from avocado.Test and adds a VM object, created from scripts/qemu.py module. The QemuTest class is the test API for the actual Qemu tests to inherit from. - A parameters yaml file with the supported keys. - A variants yaml file with the Qemu supported architectures. After this commit, you can expect a series of real-world tests, written using this new framework. Signed-off-by: Amador Pahim Signed-off-by: Eduardo Habkost --- scripts/qemu.py | 12 +- tests/avocado/README.rst | 111 ++++++++++ tests/avocado/avocado_qemu/__init__.py | 0 tests/avocado/avocado_qemu/test.py | 365 +++++++++++++++++++++++++++++= ++++ tests/avocado/parameters.yaml | 28 +++ tests/avocado/variants.yaml | 62 ++++++ tests/qemu-iotests/iotests.py | 28 +-- 7 files changed, 586 insertions(+), 20 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/variants.yaml diff --git a/scripts/qemu.py b/scripts/qemu.py index 9e9d502543..bd66620f45 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 = 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 @@ -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 [] diff --git a/tests/avocado/README.rst b/tests/avocado/README.rst new file mode 100644 index 0000000000..f0e703fe06 --- /dev/null +++ b/tests/avocado/README.rst @@ -0,0 +1,111 @@ +This directory is hosting functional tests written using Avocado Testing +Framework. To install Avocado, follow the instructions from this link:: + + http://avocado-framework.readthedocs.io/en/latest/GetStartedGuide.html= #installing-avocado + +Tests here are written keeping the minimum amount of dependencies. To +run the tests, you need the Avocado core package (`python-avocado` on +Fedora, `avocado-framework` on pip). Extra dependencies should be +documented in this file. + +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``: VMs are defined without image. If the ``image_path`` + is specified, it will be used as the VM image. The ``-snapshot`` + option will then be used to avoid writing into the image. Example: + ``image_path: /var/lib/images/fedora-25.img`` +- ``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: root`` and + ``image_pass: p4ssw0rd`` +- ``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`` + +To use a parameters file, you have to install the yaml_to_mux plugin +(`python2-avocado-plugins-varianter-yaml-to-mux` on Fedora, +`avocado-framework-plugin-varianter-yaml-to-mux` on pip). + +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. 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..e74de97a3e --- /dev/null +++ b/tests/avocado/avocado_qemu/test.py @@ -0,0 +1,365 @@ +# 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 sys +import time +import uuid + +import aexpect + +from avocado import Test +from avocado.utils.data_structures import Borg +from avocado.utils import network +from avocado.utils import process +from avocado.utils import path as utils_path +from avocado.utils import wait +sys.path.append(os.path.join(os.path.dirname(__file__), + '..', '..', '..', 'scripts')) +import qemu + + +class QEMULoginTimeoutError(Exception): + """ + If timeout expires + """ + pass + + +class QEMULoginAuthenticationError(Exception): + """ + If authentication fails + """ + pass + + +class QEMULoginProcessTerminatedError(Exception): + """ + If the client terminates during login + """ + pass + + +class QEMULoginError(Exception): + """ + If some other error occurs + """ + pass + + +class QEMUConsoleError(Exception): + """ + If some error with the console access happens + """ + pass + + +class QEMUMigrationError(Exception): + """ + If some error with the migration happens + """ + pass + + +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=3D10, + 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. + """ + password_prompt_count =3D 0 + login_prompt_count =3D 0 + last_chance =3D False + + output =3D "" + while True: + try: + match, text =3D session.read_until_last_line_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 S= USE. + 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 _PortTracker(Borg): + + """ + Tracks ports used in the host machine. + """ + + def __init__(self): + Borg.__init__(self) + self.address =3D 'localhost' + self.start_port =3D 5000 + if not hasattr(self, 'retained_ports'): + self._reset_retained_ports() + + def __str__(self): + return 'Ports tracked: %r' % self.retained_ports + + def _reset_retained_ports(self): + self.retained_ports =3D [] + + def register_port(self, port): + if ((port not in self.retained_ports) and + (network.is_port_free(port, self.address))): + self.retained_ports.append(port) + else: + raise ValueError('Port %d in use' % port) + return port + + def find_free_port(self, start_port=3DNone): + if start_port is None: + start_port =3D self.start_port + port =3D start_port + while ((port in self.retained_ports) or + (not network.is_port_free(port, self.address))): + port +=3D 1 + self.retained_ports.append(port) + return port + + def release_port(self, port): + if port in self.retained: + self.retained.remove(port) + + +class _VM(qemu.QEMUMachine): + '''A QEMU VM''' + + def __init__(self, qemu_bin=3DNone, arch=3DNone, username=3DNone, pass= word=3DNone, + qemu_dst_bin=3DNone): + if arch is None: + arch =3D os.uname()[4] + self.ports =3D _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) + + def get_console(self, console_address=3DNone, prompt=3D"[\#\$]"): + """ + :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 self.is_running(): + raise QEMUConsoleError('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, "[\#\$]= ") + 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']: + raise QEMUMigrateError("Migration of %s failed" % self) + return False + + port =3D self.ports.find_free_port() + newvm =3D _VM(self.qemu_dst_bin, self._arch, self.username, self.p= assword) + newvm.args =3D self.args + newvm.args.extend(['-incoming', 'tcp:0:%s' % port]) + + 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 QEMUMigrateError("Migration of %s did not complete after= " + "%s s" % (self.name, timeout)) + + return newvm + + +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'), + username=3Dself.params.get('image_user'), + password=3Dself.params.get('image_pass'), + qemu_dst_bin=3Dself.params.get('qemu_dst_bin')) + + self.vm.image =3D self.params.get('image_path') + if self.vm.image is not None: + self.vm.args.extend(['-drive', 'file=3D%s' % self.vm.image]) + self.vm.args.append('-snapshot') + + 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..3c5a0f92e0 --- /dev/null +++ b/tests/avocado/parameters.yaml @@ -0,0 +1,28 @@ +# 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 + +# VMs are defined without image. If the 'image_path' is specified, it +# will be used as the VM image. The '-snapshot' option will then be used +# to avoid writing data to the image. +image_path: null +# Username used to get the console from the Guest OS. +image_user: null +# Password used to get the console from the Guest OS. +image_pass: 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/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.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524248778684652.787871229964; Fri, 20 Apr 2018 11:26:18 -0700 (PDT) Received: from localhost ([::1]:50252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ajh-0000rA-PE for importer@patchew.org; Fri, 20 Apr 2018 14:26:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9aeU-00051N-Vs for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:20:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9aeQ-00069W-2j for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:20:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39520) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9aeP-000677-So for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:20:50 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2FE353150088; Fri, 20 Apr 2018 18:20:49 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFB45600CC; Fri, 20 Apr 2018 18:20:39 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:30 -0300 Message-Id: <20180420181951.7252-4-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 20 Apr 2018 18:20:49 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 03/24] avocado_qemu: Improve handle_prompts to allow login after booted vm 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Luk=C3=A1=C5=A1 Doktor When the VM is booted before calling "vm.get_console" this command fails to login as there is no new output in the console. Let's just press enter (which should be relatively harmless as login asks for the user again and when already logged in we might "only" execute what's already written. Signed-off-by: Luk=C3=A1=C5=A1 Doktor Signed-off-by: Eduardo Habkost --- tests/avocado/avocado_qemu/test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index e74de97a3e..9cc163b3a8 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -123,7 +123,8 @@ def _handle_prompts(session, username, password, prompt= , timeout=3D10, 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: --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524248750583276.3122687875509; Fri, 20 Apr 2018 11:25:50 -0700 (PDT) Received: from localhost ([::1]:50244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ajC-0000GX-08 for importer@patchew.org; Fri, 20 Apr 2018 14:25:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9aef-00059W-T9 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9aeb-0006oE-03 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38200) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9aea-0006lQ-Qb for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:00 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1AA8C3164238; Fri, 20 Apr 2018 18:21:00 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1E555D9CD; Fri, 20 Apr 2018 18:20:50 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:31 -0300 Message-Id: <20180420181951.7252-5-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 20 Apr 2018 18:21:00 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 04/24] avocado_qemu: Be lenient towards poluted serial 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Luk=C3=A1=C5=A1 Doktor The serial console is frequently spammed kernel messages, let's not be so strict and match lines also containing other parts. There is still possibility of failure in case kernel injects message on a new line after the expected output producing non-matching last_line. Anyway checking for any-line would be a bit too prone to false-positives so let's just go with this at this point. Signed-off-by: Luk=C3=A1=C5=A1 Doktor Signed-off-by: Eduardo Habkost --- tests/avocado/avocado_qemu/test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index 9cc163b3a8..fb16785a20 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -131,9 +131,9 @@ def _handle_prompts(session, username, password, prompt= , timeout=3D10, match, text =3D session.read_until_last_line_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 S= USE. - r"(? Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524248749708519.8410533376824; Fri, 20 Apr 2018 11:25:49 -0700 (PDT) Received: from localhost ([::1]:50246 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ajE-0000KI-RE for importer@patchew.org; Fri, 20 Apr 2018 14:25:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9aeh-0005Bg-Vp for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9aeh-00077q-6O for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45810) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9aeg-000762-Vi for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:07 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3CA8028207; Fri, 20 Apr 2018 18:21:06 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C3715D780; Fri, 20 Apr 2018 18:21:01 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:32 -0300 Message-Id: <20180420181951.7252-6-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 20 Apr 2018 18:21:06 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 05/24] avocado_qemu: Increase the login timeout to 60s 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Luk=C3=A1=C5=A1 Doktor The 10s login is quite short, let's use 60s and see whether it fits. Signed-off-by: Luk=C3=A1=C5=A1 Doktor Signed-off-by: Eduardo Habkost --- tests/avocado/avocado_qemu/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index fb16785a20..e99c7e9e8d 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -97,7 +97,7 @@ def _get_qemu_bin(arch): return qemu_binary =20 =20 -def _handle_prompts(session, username, password, prompt, timeout=3D10, +def _handle_prompts(session, username, password, prompt, timeout=3D60, debug=3DFalse): """ Connect to a remote host (guest) using SSH or Telnet or else. --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524248944776113.79264187990611; Fri, 20 Apr 2018 11:29:04 -0700 (PDT) Received: from localhost ([::1]:50305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9amE-00037P-Ir for importer@patchew.org; Fri, 20 Apr 2018 14:28:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37775) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9aek-0005E7-5y for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9aej-0007Ec-7K for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9aej-0007CC-2Q for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:09 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 54D1F3133E96; Fri, 20 Apr 2018 18:21:08 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B9475D780; Fri, 20 Apr 2018 18:21:07 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:33 -0300 Message-Id: <20180420181951.7252-7-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 20 Apr 2018 18:21:08 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 06/24] avocado_qemu: Add " " after the default prompt regexp 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Luk=C3=A1=C5=A1 Doktor The prompt regexp is quite basic one (# or $), let's require at least one additional space afterwards, which is the case in most modern systems and decreases the probability of false-positives. Signed-off-by: Luk=C3=A1=C5=A1 Doktor Signed-off-by: Eduardo Habkost --- tests/avocado/avocado_qemu/test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index e99c7e9e8d..eeb759ec65 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -270,7 +270,7 @@ class _VM(qemu.QEMUMachine): self.password =3D password super(_VM, self).__init__(qemu_bin, name=3Dself.name, arch=3Darch) =20 - def get_console(self, console_address=3DNone, prompt=3D"[\#\$]"): + 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) @@ -297,7 +297,7 @@ class _VM(qemu.QEMUMachine): console =3D aexpect.ShellSession(nc_cmd) try: logging.info('Console: Waiting login prompt...') - _handle_prompts(console, self.username, self.password, "[\#\$]= ") + _handle_prompts(console, self.username, self.password, prompt) logging.info('Console: Ready!') except: console.close() --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152424897070340.72115017150827; Fri, 20 Apr 2018 11:29:30 -0700 (PDT) Received: from localhost ([::1]:50307 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9amn-0003Zx-Q5 for importer@patchew.org; Fri, 20 Apr 2018 14:29:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9af1-0005Ts-55 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9aex-0007wn-6S for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57536) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9aex-0007tb-0k for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:23 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4022030014C6; Fri, 20 Apr 2018 18:21:22 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3AA25D967; Fri, 20 Apr 2018 18:21:09 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:34 -0300 Message-Id: <20180420181951.7252-8-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 20 Apr 2018 18:21:22 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 07/24] avocado_qemu: Store "arch" in VM 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Luk=C3=A1=C5=A1 Doktor The "arch" is quite important info regarding the current VM, let's store it so tests can query for it. Signed-off-by: Luk=C3=A1=C5=A1 Doktor Signed-off-by: Eduardo Habkost --- tests/avocado/avocado_qemu/test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index eeb759ec65..6bf7825e55 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -258,6 +258,7 @@ class _VM(qemu.QEMUMachine): qemu_dst_bin=3DNone): if arch is None: arch =3D os.uname()[4] + self.arch =3D arch self.ports =3D _PortTracker() self.name =3D "qemu-%s" % str(uuid.uuid4())[:8] if qemu_bin is None: --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524249171782147.9704399228184; Fri, 20 Apr 2018 11:32:51 -0700 (PDT) Received: from localhost ([::1]:50367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9aq2-0006Nv-UV for importer@patchew.org; Fri, 20 Apr 2018 14:32:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9afD-0005cg-T5 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9af8-0000CO-Ui for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33476) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9af8-00009H-Oc for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:34 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0CEFB3182F5B; Fri, 20 Apr 2018 18:21:34 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id E346B601A4; Fri, 20 Apr 2018 18:21:23 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:35 -0300 Message-Id: <20180420181951.7252-9-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 20 Apr 2018 18:21:34 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 08/24] avocado_qemu: Provide defaults for user and pass 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Luk=C3=A1=C5=A1 Doktor For conveniency let's set default user to root and password to 123456 to avoid the need to always input those. This password is inspired by the default password of JeOS available from avocado-vt. Signed-off-by: Luk=C3=A1=C5=A1 Doktor Signed-off-by: Eduardo Habkost --- tests/avocado/avocado_qemu/test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index 6bf7825e55..9dc6c1ef91 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -344,8 +344,8 @@ class QemuTest(Test): job=3Djob, runner_queue=3Drunner_qu= eue) self.vm =3D _VM(qemu_bin=3Dself.params.get('qemu_bin'), arch=3Dself.params.get('arch'), - username=3Dself.params.get('image_user'), - password=3Dself.params.get('image_pass'), + username=3Dself.params.get('image_user', default=3D"= root"), + password=3Dself.params.get('image_pass', default=3D"= 123456"), qemu_dst_bin=3Dself.params.get('qemu_dst_bin')) =20 self.vm.image =3D self.params.get('image_path') --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524248944733141.58419811668387; Fri, 20 Apr 2018 11:29:04 -0700 (PDT) Received: from localhost ([::1]:50304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9amF-00037B-3R for importer@patchew.org; Fri, 20 Apr 2018 14:28:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9afU-0005vr-C4 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9afP-0001ED-EP for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36142) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9afP-0001AD-3A for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:21:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50F9B4A6F3; Fri, 20 Apr 2018 18:21:50 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91D415D721; Fri, 20 Apr 2018 18:21:35 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:36 -0300 Message-Id: <20180420181951.7252-10-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 20 Apr 2018 18:21:50 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 09/24] avocado_qemu: Ignore kernel messages on 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Luk=C3=A1=C5=A1 Doktor The get_console (and _handle_prompt) uses the last non-empty line to check what is going on, but when debug is enabled, kernel produces lots of lines spoiling the output. Let's also ignore the messages that looks like kernel debugs ([ $float] $msg). This significantly improves the results on my machine with JeOS and enabled debug. Signed-off-by: Luk=C3=A1=C5=A1 Doktor Signed-off-by: Eduardo Habkost --- tests/avocado/avocado_qemu/test.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index 9dc6c1ef91..966936a52f 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -26,6 +26,7 @@ extra features intended for Qemu testing. =20 import logging import os +import re import sys import time import uuid @@ -120,6 +121,17 @@ def _handle_prompts(session, username, password, promp= t, timeout=3D60, :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 @@ -128,7 +140,7 @@ def _handle_prompts(session, username, password, prompt= , timeout=3D60, output =3D "" while True: try: - match, text =3D session.read_until_last_line_matches( + 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*", @@ -137,7 +149,7 @@ def _handle_prompts(session, username, password, prompt= , timeout=3D60, r"[Cc]onnection.*closed", r"[Cc]onnection.*refused", r"[Pp]lease wait", r"[Ww]arning", r"[Ee]nter.*username", r"[Ee]nter.*password", r"[Cc]onnection timed out", prompt, - r"Escape character is.*"], + r"Escape character is.*"], get_last_nonempty_line, timeout=3Dtimeout, internal_timeout=3D0.5) output +=3D text if match =3D=3D 0: # "Are you sure you want to continue conne= cting" --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524249376872518.6713775863603; Fri, 20 Apr 2018 11:36:16 -0700 (PDT) Received: from localhost ([::1]:50425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9atL-0000kY-U4 for importer@patchew.org; Fri, 20 Apr 2018 14:36:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9afh-00066B-MU for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9afc-0001rv-O1 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52162) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9afc-0001qX-G1 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C38676146F; Fri, 20 Apr 2018 18:22:03 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id B16BD60172; Fri, 20 Apr 2018 18:21:51 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:37 -0300 Message-Id: <20180420181951.7252-11-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 20 Apr 2018 18:22:03 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 10/24] avocado_qemu: Add support to request image for testing 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Luk=C3=A1=C5=A1 Doktor Some of the tests require (usually bootable) image to be executed, let's add a helper function which uses the default params to define the image or provides useful default and explains what's going on in case the image is not available. Signed-off-by: Luk=C3=A1=C5=A1 Doktor Signed-off-by: Eduardo Habkost --- tests/avocado/README.rst | 12 ++++++----- tests/avocado/avocado_qemu/test.py | 44 ++++++++++++++++++++++++++++++++--= ---- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/tests/avocado/README.rst b/tests/avocado/README.rst index f0e703fe06..07852e790a 100644 --- a/tests/avocado/README.rst +++ b/tests/avocado/README.rst @@ -59,14 +59,16 @@ file using the Avocado parameters system: - ``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``: VMs are defined without image. If the ``image_path`` - is specified, it will be used as the VM image. The ``-snapshot`` - option will then be used to avoid writing into the image. Example: - ``image_path: /var/lib/images/fedora-25.img`` +- ``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: root`` and - ``image_pass: p4ssw0rd`` + ``image_pass: p4ssw0rd``. By default it uses ``root`` and ``123456``. - ``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 diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index 966936a52f..57c63b2853 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -39,8 +39,10 @@ from avocado.utils import network from avocado.utils import process from avocado.utils import path as utils_path from avocado.utils import wait -sys.path.append(os.path.join(os.path.dirname(__file__), - '..', '..', '..', 'scripts')) + +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 =20 =20 @@ -360,11 +362,6 @@ class QemuTest(Test): password=3Dself.params.get('image_pass', default=3D"= 123456"), qemu_dst_bin=3Dself.params.get('qemu_dst_bin')) =20 - self.vm.image =3D self.params.get('image_path') - if self.vm.image is not None: - self.vm.args.extend(['-drive', 'file=3D%s' % self.vm.image]) - self.vm.args.append('-snapshot') - 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') @@ -377,3 +374,36 @@ class QemuTest(Test): machine +=3D "kvm-type=3D%s," % machine_kvm_type if machine: self.vm.args.extend(['-machine', machine]) + + def request_image(self, path=3DNone, snapshot=3DNone, extra=3DNone): + """ + Add image to the `self.vm` using params or arguments. + + Unless it's overridden by arguments it uses following test params + to specify the image: + + * image_path - defines the path to the user-image. If not specified + it uses "QEMU_ROOT/boot_image_$arch.qcow2" + * image_snapshot - whether to use "snapshot=3Don" (snapshot=3Doff = is not + supplied) + * image_extra - free-form string to extend the "-drive" params + + :param path: Override the path ("image_path" param is used otherwi= se) + :param snapshot: Override the usage of snapshot + :param extra: Extra arguments to be added to drive definition + """ + if snapshot is None: + snapshot =3D self.params.get("image_snapshot", default=3DTrue) + if extra is None: + extra =3D self.params.get("image_extra", default=3D"") + if path is None: + path =3D self.params.get("image_path") + if path is None: + arch =3D self.vm.arch + path =3D os.path.join(QEMU_ROOT, "boot_image_%s.qcow2" % a= rch) + if not os.path.exists(path): + self.error("Require a bootable image, which was not found. " + "Please provide one in '%s'." % path) + if snapshot: + extra +=3D ",snapshot=3Don" + self.vm.args.extend(['-drive', 'file=3D%s%s' % (path, extra)]) --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524249137451328.8870523877199; Fri, 20 Apr 2018 11:32:17 -0700 (PDT) Received: from localhost ([::1]:50364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9apU-0005uO-KN for importer@patchew.org; Fri, 20 Apr 2018 14:32:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9afi-00066z-Ii for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9afh-00025K-MW for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33690) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9afh-00023v-GL for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:09 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C11B13182F59; Fri, 20 Apr 2018 18:22:08 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35D2F5D6A8; Fri, 20 Apr 2018 18:22:05 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:38 -0300 Message-Id: <20180420181951.7252-12-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 20 Apr 2018 18:22:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 11/24] avocado_qemu: Fix exception name in caller 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Amador Pahim There's a exception name mismatch when callin `QEMUMigrationError`. Fixing. Signed-off-by: Amador Pahim Signed-off-by: Eduardo Habkost --- tests/avocado/avocado_qemu/test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index 57c63b2853..f3c7091343 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -328,7 +328,7 @@ class _VM(qemu.QEMUMachine): logging.info("Migration successful") return True elif 'failed' in res['return']: - raise QEMUMigrateError("Migration of %s failed" % self) + raise QEMUMigrationError("Migration of %s failed" % self) return False =20 port =3D self.ports.find_free_port() @@ -343,8 +343,8 @@ class _VM(qemu.QEMUMachine): text=3D'Waiting for migration to comple= te') =20 if mig_result is None: - raise QEMUMigrateError("Migration of %s did not complete after= " - "%s s" % (self.name, timeout)) + raise QEMUMigrationError("Migration of %s did not complete aft= er " + "%s s" % (self.name, timeout)) =20 return newvm =20 --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524248750627174.4451726545493; Fri, 20 Apr 2018 11:25:50 -0700 (PDT) Received: from localhost ([::1]:50249 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ajF-0000Mj-PT for importer@patchew.org; Fri, 20 Apr 2018 14:25:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9afn-0006C9-Jq for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9afm-0002M7-Mc for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45404) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9afm-0002KZ-GO for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:14 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA942326228B; Fri, 20 Apr 2018 18:22:13 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E8CF5C88A; Fri, 20 Apr 2018 18:22:09 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:39 -0300 Message-Id: <20180420181951.7252-13-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 20 Apr 2018 18:22:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 12/24] avocado_qemu: Improve migration error message 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Amador Pahim Expose the QMP result on migration error. Signed-off-by: Amador Pahim Signed-off-by: Eduardo Habkost --- tests/avocado/avocado_qemu/test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index f3c7091343..5e42cac8d0 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -328,7 +328,8 @@ class _VM(qemu.QEMUMachine): logging.info("Migration successful") return True elif 'failed' in res['return']: - raise QEMUMigrationError("Migration of %s failed" % self) + logging.error(res) + raise QEMUMigrationError("Migration of %s failed" % self.n= ame) return False =20 port =3D self.ports.find_free_port() --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524249354776368.7821990998103; Fri, 20 Apr 2018 11:35:54 -0700 (PDT) Received: from localhost ([::1]:50417 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9asp-0000Dl-FP for importer@patchew.org; Fri, 20 Apr 2018 14:35:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ag5-0006R5-2D for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9ag0-000395-3y for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46310) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9afz-00036f-SB for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A59628210; Fri, 20 Apr 2018 18:22:27 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 419A85D9CD; Fri, 20 Apr 2018 18:22:15 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:40 -0300 Message-Id: <20180420181951.7252-14-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 20 Apr 2018 18:22:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 13/24] avocado_qemu: Functional test for RHBZ#1431939 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Amador Pahim This issue was fixed in commit d81d857. According to the RHBZ1431939, the issue is 'host nodes' returning '128'. It should return empty value when using default policy or 0 when using bind policy. Test consists in inspect the result of the 'info memdev' QMP command after hot-adding memory. Signed-off-by: Amador Pahim Signed-off-by: Eduardo Habkost --- tests/avocado/test_info_memdev_host_nodes.py | 66 ++++++++++++++++++++++++= ++++ 1 file changed, 66 insertions(+) create mode 100644 tests/avocado/test_info_memdev_host_nodes.py 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() --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524249137239773.667352964429; Fri, 20 Apr 2018 11:32:17 -0700 (PDT) Received: from localhost ([::1]:50365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9apU-0005ug-BG for importer@patchew.org; Fri, 20 Apr 2018 14:32:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9agI-0006b7-G5 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9agD-0003k7-Ho for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46404) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9agD-0003i4-9P for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:41 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8FF8328207; Fri, 20 Apr 2018 18:22:40 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 783C35EDE0; Fri, 20 Apr 2018 18:22:28 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:41 -0300 Message-Id: <20180420181951.7252-15-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 20 Apr 2018 18:22:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 14/24] avocado_qemu: Functional test for RHBZ#1447027 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Amador Pahim Fixed in commit e85c0d1. According to the RHBZ1447027, the issue is: guest cannot boot with 240 or above vcpus when using ovmf. Test consists in set the VM with 240 vcpus and the OVMF device to then check whether the VM can be started. A parameters.yaml file is provided in order to customize the OVMF files locations. Execute with: $ avocado run test_ovmf_with_240_vcpus.py -m \ test_ovmf_with_240_vcpus.py.data/parameters.yaml Signed-off-by: Amador Pahim Signed-off-by: Eduardo Habkost --- tests/avocado/test_ovmf_with_240_vcpus.py | 70 ++++++++++++++++++= ++++ .../parameters.yaml | 2 + 2 files changed, 72 insertions(+) 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 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 --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524249580717436.56094818928966; Fri, 20 Apr 2018 11:39:40 -0700 (PDT) Received: from localhost ([::1]:50751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9awd-0003pu-Ne for importer@patchew.org; Fri, 20 Apr 2018 14:39:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9agT-0006mO-MX for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9agR-0004MX-2H for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34008) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9agQ-0004Kz-R5 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:22:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 281523182F58; Fri, 20 Apr 2018 18:22:54 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09BBE60175; Fri, 20 Apr 2018 18:22:41 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:42 -0300 Message-Id: <20180420181951.7252-16-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 20 Apr 2018 18:22:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 15/24] avocado_qemu: Functional test for RHBZ#1436616 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Amador Pahim Fixed in commit 243afe858b95765b98d16a1f0dd50dca262858ad. According to the RHBZ1436616, the issue is: usb-storage device under pci-bridge is unusable after migration. Test consists in create a VM with an usb-storage device and check whether it's still available after a live migration. A parameters.yaml file is provided in order to customize the guest image location and credentials. Execute with: avocado run test_nec-usb-xhci.py \ -m test_nec-usb-xhci.py.data/parameters.yaml Signed-off-by: Amador Pahim Signed-off-by: Eduardo Habkost --- tests/avocado/test_nec-usb-xhci.py | 55 ++++++++++++++++++= ++++ .../test_nec-usb-xhci.py.data/parameters.yaml | 4 ++ 2 files changed, 59 insertions(+) create mode 100644 tests/avocado/test_nec-usb-xhci.py create mode 100644 tests/avocado/test_nec-usb-xhci.py.data/parameters.yaml 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..3f0d645032 --- /dev/null +++ b/tests/avocado/test_nec-usb-xhci.py @@ -0,0 +1,55 @@ +import copy +import os +import tempfile + +from avocado_qemu import test +from avocado.utils import process + +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): + usbdevice =3D os.path.join(self.workdir, 'usb.img') + self.request_image() + 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('fdisk -l') + result =3D console.read_nonblocking() + 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('fdisk -l') + result =3D console.read_nonblocking() + console.close() + self.assertIn('Disk /dev/sdb: 10 MiB, 10485760 bytes, 20480 sector= s', + result) + + def tearDown(self): + self.vm.shutdown() + self.vm_dst.shutdown() 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 --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524248945271517.7390210009177; Fri, 20 Apr 2018 11:29:05 -0700 (PDT) Received: from localhost ([::1]:50306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9amK-0003CP-L6 for importer@patchew.org; Fri, 20 Apr 2018 14:29:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9agi-00071Z-Al for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9agd-000532-9k for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35558) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9agd-0004zD-0z for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:07 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4ABC885547; Fri, 20 Apr 2018 18:23:06 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CD2B60606; Fri, 20 Apr 2018 18:22:55 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:43 -0300 Message-Id: <20180420181951.7252-17-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 20 Apr 2018 18:23:06 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 16/24] avocado_qemu: Functional test for RHBZ1473203 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Luk=C3=A1=C5=A1 Doktor Adds regresion test for RHBZ1473203 which runs VM with 16 numa nodes and then verifies memory allocation is accurate before and after hotplugging memory into default and 13th node. Signed-off-by: Luk=C3=A1=C5=A1 Doktor Signed-off-by: Eduardo Habkost --- tests/avocado/test_numa_hotplug.py | 116 +++++++++++++++++++++++++++++++++= ++++ 1 file changed, 116 insertions(+) create mode 100644 tests/avocado/test_numa_hotplug.py diff --git a/tests/avocado/test_numa_hotplug.py b/tests/avocado/test_numa_h= otplug.py new file mode 100644 index 0000000000..a99b8dcebf --- /dev/null +++ b/tests/avocado/test_numa_hotplug.py @@ -0,0 +1,116 @@ +import re +import time + +from avocado_qemu import test + + +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.request_image() + 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() --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524249745041847.7918305857776; Fri, 20 Apr 2018 11:42:25 -0700 (PDT) Received: from localhost ([::1]:51470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9azB-0006iA-Uq for importer@patchew.org; Fri, 20 Apr 2018 14:42:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ago-00076e-D9 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9agn-0005em-CD for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58162) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9agn-0005c9-47 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66AF430014B8; Fri, 20 Apr 2018 18:23:16 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE57F60BE0; Fri, 20 Apr 2018 18:23:07 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:44 -0300 Message-Id: <20180420181951.7252-18-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 20 Apr 2018 18:23:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 17/24] avocado_qemu: Remove duplicate PortTracker implementation 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Cleber Rosa The PortTracker class was introduced on Avocado's own utility libraries, starting with version 54.0, and it actually received fixes after that. Let's avoid this duplicate implementation and rely on the standard one. Signed-off-by: Cleber Rosa Signed-off-by: Eduardo Habkost --- tests/avocado/README.rst | 2 +- tests/avocado/avocado_qemu/test.py | 45 +---------------------------------= ---- 2 files changed, 2 insertions(+), 45 deletions(-) diff --git a/tests/avocado/README.rst b/tests/avocado/README.rst index 07852e790a..50bc865fc1 100644 --- a/tests/avocado/README.rst +++ b/tests/avocado/README.rst @@ -6,7 +6,7 @@ Framework. To install Avocado, follow the instructions from= this link:: Tests here are written keeping the minimum amount of dependencies. To run the tests, you need the Avocado core package (`python-avocado` on Fedora, `avocado-framework` on pip). Extra dependencies should be -documented in this file. +documented in this file. The current minimum required version is 54.0. =20 In this directory, an ``avocado_qemu`` package is provided, containing the ``test`` module, which inherits from ``avocado.Test`` and provides diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index 5e42cac8d0..dfffa2a03b 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -34,7 +34,6 @@ import uuid import aexpect =20 from avocado import Test -from avocado.utils.data_structures import Borg from avocado.utils import network from avocado.utils import process from avocado.utils import path as utils_path @@ -223,48 +222,6 @@ def _handle_prompts(session, username, password, promp= t, timeout=3D60, return output =20 =20 -class _PortTracker(Borg): - - """ - Tracks ports used in the host machine. - """ - - def __init__(self): - Borg.__init__(self) - self.address =3D 'localhost' - self.start_port =3D 5000 - if not hasattr(self, 'retained_ports'): - self._reset_retained_ports() - - def __str__(self): - return 'Ports tracked: %r' % self.retained_ports - - def _reset_retained_ports(self): - self.retained_ports =3D [] - - def register_port(self, port): - if ((port not in self.retained_ports) and - (network.is_port_free(port, self.address))): - self.retained_ports.append(port) - else: - raise ValueError('Port %d in use' % port) - return port - - def find_free_port(self, start_port=3DNone): - if start_port is None: - start_port =3D self.start_port - port =3D start_port - while ((port in self.retained_ports) or - (not network.is_port_free(port, self.address))): - port +=3D 1 - self.retained_ports.append(port) - return port - - def release_port(self, port): - if port in self.retained: - self.retained.remove(port) - - class _VM(qemu.QEMUMachine): '''A QEMU VM''' =20 @@ -273,7 +230,7 @@ class _VM(qemu.QEMUMachine): if arch is None: arch =3D os.uname()[4] self.arch =3D arch - self.ports =3D _PortTracker() + 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) --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524249140542787.9324218305763; Fri, 20 Apr 2018 11:32:20 -0700 (PDT) Received: from localhost ([::1]:50366 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9apX-0005xn-Ng for importer@patchew.org; Fri, 20 Apr 2018 14:32:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ah4-0007Kd-Pv for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9agz-0006NP-Vi for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51138) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9agz-0006K3-LV for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:29 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA8CA30015CD; Fri, 20 Apr 2018 18:23:28 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD8906313A; Fri, 20 Apr 2018 18:23:17 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:45 -0300 Message-Id: <20180420181951.7252-19-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 20 Apr 2018 18:23:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 18/24] avocado_qemu: Simplify the installation instructions 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Cleber Rosa Let's just give a single command line that can be reliably executed to install avocado and the dependencies we're aware for the existing tests. The installation approach chosen is the most universal one (pip) and one that impacts the least the developer's system, being limited to the user's home directory. Signed-off-by: Cleber Rosa Signed-off-by: Eduardo Habkost --- tests/avocado/README.rst | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/tests/avocado/README.rst b/tests/avocado/README.rst index 50bc865fc1..e2aa993501 100644 --- a/tests/avocado/README.rst +++ b/tests/avocado/README.rst @@ -1,12 +1,23 @@ -This directory is hosting functional tests written using Avocado Testing -Framework. To install Avocado, follow the instructions from this link:: +=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:: =20 http://avocado-framework.readthedocs.io/en/latest/GetStartedGuide.html= #installing-avocado =20 -Tests here are written keeping the minimum amount of dependencies. To -run the tests, you need the Avocado core package (`python-avocado` on -Fedora, `avocado-framework` on pip). Extra dependencies should be -documented in this file. The current minimum required version is 54.0. +Overview +=3D=3D=3D=3D=3D=3D=3D=3D =20 In this directory, an ``avocado_qemu`` package is provided, containing the ``test`` module, which inherits from ``avocado.Test`` and provides @@ -77,10 +88,6 @@ file using the Avocado parameters system: ``accel`` is ``kvm`` and there are more than one KVM types available. Example: ``machine_kvm_type: PR`` =20 -To use a parameters file, you have to install the yaml_to_mux plugin -(`python2-avocado-plugins-varianter-yaml-to-mux` on Fedora, -`avocado-framework-plugin-varianter-yaml-to-mux` on pip). - Run the test with:: =20 $ avocado run test_my_test.py -m parameters.yaml @@ -111,3 +118,15 @@ 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 --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524249818613386.957893406862; Fri, 20 Apr 2018 11:43:38 -0700 (PDT) Received: from localhost ([::1]:51604 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9b0T-0007cf-TH for importer@patchew.org; Fri, 20 Apr 2018 14:43:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ah4-0007Ke-Ux for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9ah1-0006Uo-TV for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37588) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9ah1-0006Rt-N3 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF11AC04AC4C; Fri, 20 Apr 2018 18:23:30 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 537196179B; Fri, 20 Apr 2018 18:23:30 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:46 -0300 Message-Id: <20180420181951.7252-20-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 20 Apr 2018 18:23:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 19/24] avocado_qemu: Clean unneeded 'pass' 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Amador Pahim The docstrings are enough. Let's remove the 'pass' instructions. Signed-off-by: Amador Pahim Signed-off-by: Eduardo Habkost --- tests/avocado/avocado_qemu/test.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index dfffa2a03b..b921151bae 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -49,42 +49,36 @@ class QEMULoginTimeoutError(Exception): """ If timeout expires """ - pass =20 =20 class QEMULoginAuthenticationError(Exception): """ If authentication fails """ - pass =20 =20 class QEMULoginProcessTerminatedError(Exception): """ If the client terminates during login """ - pass =20 =20 class QEMULoginError(Exception): """ If some other error occurs """ - pass =20 =20 class QEMUConsoleError(Exception): """ If some error with the console access happens """ - pass =20 =20 class QEMUMigrationError(Exception): """ If some error with the migration happens """ - pass =20 =20 def _get_qemu_bin(arch): --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524249353682783.4495135382654; Fri, 20 Apr 2018 11:35:53 -0700 (PDT) Received: from localhost ([::1]:50419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9asp-0000EU-E4 for importer@patchew.org; Fri, 20 Apr 2018 14:35:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ahF-0007UN-1f for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9ahA-0006tj-4c for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54438) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9ah9-0006rq-Vh for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:40 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5264A308210B; Fri, 20 Apr 2018 18:23:39 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E15560BE0; Fri, 20 Apr 2018 18:23:32 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:47 -0300 Message-Id: <20180420181951.7252-21-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 20 Apr 2018 18:23:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 20/24] avocado_qemu: Set QMP log level to INFO 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Amador Pahim Otherwise we will see the debug messages in our test logs. Signed-off-by: Amador Pahim Signed-off-by: Eduardo Habkost --- tests/avocado/avocado_qemu/test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index b921151bae..308fdfa514 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -235,6 +235,7 @@ class _VM(qemu.QEMUMachine): 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) =20 def get_console(self, console_address=3DNone, prompt=3Dr"[\#\$] "): """ --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152424954986569.19318083294786; Fri, 20 Apr 2018 11:39:09 -0700 (PDT) Received: from localhost ([::1]:50738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9aw9-0003Qu-0J for importer@patchew.org; Fri, 20 Apr 2018 14:39:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ahF-0007UQ-2K for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9ahC-00070V-Rq for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48938) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9ahC-0006z0-IW for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CFD74316422D; Fri, 20 Apr 2018 18:23:41 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id C83CF60BE0; Fri, 20 Apr 2018 18:23:40 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:48 -0300 Message-Id: <20180420181951.7252-22-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 20 Apr 2018 18:23:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 21/24] avocado_qemu: Introduce the add_image() VM API 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Amador Pahim Uses can not add an image to the virtual machine with the option to configure the user/password using cloudinit. Signed-off-by: Amador Pahim Signed-off-by: Eduardo Habkost --- tests/avocado/README.rst | 4 +- tests/avocado/avocado_qemu/test.py | 136 ++++++++++++++++++++++++++-------= ---- tests/avocado/parameters.yaml | 9 --- tests/avocado/test_nec-usb-xhci.py | 14 ++-- tests/avocado/test_numa_hotplug.py | 5 +- 5 files changed, 111 insertions(+), 57 deletions(-) diff --git a/tests/avocado/README.rst b/tests/avocado/README.rst index e2aa993501..a33c4a2577 100644 --- a/tests/avocado/README.rst +++ b/tests/avocado/README.rst @@ -78,8 +78,8 @@ file using the Avocado parameters system: ``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: root`` and - ``image_pass: p4ssw0rd``. By default it uses ``root`` and ``123456``. + 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 diff --git a/tests/avocado/avocado_qemu/test.py b/tests/avocado/avocado_qem= u/test.py index 308fdfa514..5a08dace45 100644 --- a/tests/avocado/avocado_qemu/test.py +++ b/tests/avocado/avocado_qemu/test.py @@ -28,6 +28,7 @@ import logging import os import re import sys +import tempfile import time import uuid =20 @@ -81,6 +82,12 @@ class QEMUMigrationError(Exception): """ =20 =20 +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, @@ -219,8 +226,8 @@ def _handle_prompts(session, username, password, prompt= , timeout=3D60, class _VM(qemu.QEMUMachine): '''A QEMU VM''' =20 - def __init__(self, qemu_bin=3DNone, arch=3DNone, username=3DNone, pass= word=3DNone, - qemu_dst_bin=3DNone): + 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 @@ -245,8 +252,11 @@ 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 QEMUConsoleError('VM is not running.') + raise QEMULoginError('VM is not running.') =20 if console_address is None: if self._console_address is None: @@ -285,9 +295,12 @@ class _VM(qemu.QEMUMachine): return False =20 port =3D self.ports.find_free_port() - newvm =3D _VM(self.qemu_dst_bin, self._arch, self.username, self.p= assword) + 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 =20 newvm.launch(console_address) cmd =3D 'migrate -d tcp:0:%s' % port @@ -301,6 +314,80 @@ class _VM(qemu.QEMUMachine): =20 return newvm =20 + 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]) =20 class QemuTest(Test): =20 @@ -311,9 +398,11 @@ class QemuTest(Test): job=3Djob, runner_queue=3Drunner_qu= eue) self.vm =3D _VM(qemu_bin=3Dself.params.get('qemu_bin'), arch=3Dself.params.get('arch'), - username=3Dself.params.get('image_user', default=3D"= root"), - password=3Dself.params.get('image_pass', default=3D"= 123456"), - qemu_dst_bin=3Dself.params.get('qemu_dst_bin')) + 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')) =20 machine_type =3D self.params.get('machine_type') machine_accel =3D self.params.get('machine_accel') @@ -327,36 +416,3 @@ class QemuTest(Test): machine +=3D "kvm-type=3D%s," % machine_kvm_type if machine: self.vm.args.extend(['-machine', machine]) - - def request_image(self, path=3DNone, snapshot=3DNone, extra=3DNone): - """ - Add image to the `self.vm` using params or arguments. - - Unless it's overridden by arguments it uses following test params - to specify the image: - - * image_path - defines the path to the user-image. If not specified - it uses "QEMU_ROOT/boot_image_$arch.qcow2" - * image_snapshot - whether to use "snapshot=3Don" (snapshot=3Doff = is not - supplied) - * image_extra - free-form string to extend the "-drive" params - - :param path: Override the path ("image_path" param is used otherwi= se) - :param snapshot: Override the usage of snapshot - :param extra: Extra arguments to be added to drive definition - """ - if snapshot is None: - snapshot =3D self.params.get("image_snapshot", default=3DTrue) - if extra is None: - extra =3D self.params.get("image_extra", default=3D"") - if path is None: - path =3D self.params.get("image_path") - if path is None: - arch =3D self.vm.arch - path =3D os.path.join(QEMU_ROOT, "boot_image_%s.qcow2" % a= rch) - if not os.path.exists(path): - self.error("Require a bootable image, which was not found. " - "Please provide one in '%s'." % path) - if snapshot: - extra +=3D ",snapshot=3Don" - self.vm.args.extend(['-drive', 'file=3D%s%s' % (path, extra)]) diff --git a/tests/avocado/parameters.yaml b/tests/avocado/parameters.yaml index 3c5a0f92e0..03c4ed1416 100644 --- a/tests/avocado/parameters.yaml +++ b/tests/avocado/parameters.yaml @@ -10,15 +10,6 @@ qemu_bin: null # used in the source VM will be used for the destination VM. qemu_dst_bin: null =20 -# VMs are defined without image. If the 'image_path' is specified, it -# will be used as the VM image. The '-snapshot' option will then be used -# to avoid writing data to the image. -image_path: null -# Username used to get the console from the Guest OS. -image_user: null -# Password used to get the console from the Guest OS. -image_pass: 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. diff --git a/tests/avocado/test_nec-usb-xhci.py b/tests/avocado/test_nec-us= b-xhci.py index 3f0d645032..1c4822544e 100644 --- a/tests/avocado/test_nec-usb-xhci.py +++ b/tests/avocado/test_nec-usb-xhci.py @@ -4,6 +4,7 @@ import tempfile =20 from avocado_qemu import test from avocado.utils import process +from avocado.utils import vmimage =20 class TestNecUsbXhci(test.QemuTest): """ @@ -17,8 +18,10 @@ class TestNecUsbXhci(test.QemuTest): """ =20 def setUp(self): + self.image =3D vmimage.get() + self.vm.add_image(self.image.path, cloudinit=3DTrue, snapshot=3DFa= lse) + usbdevice =3D os.path.join(self.workdir, 'usb.img') - self.request_image() 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']) @@ -35,17 +38,18 @@ class TestNecUsbXhci(test.QemuTest): =20 :avocado: tags=3Dmigration,RHBZ1436616 """ + console =3D self.vm.get_console() - console.sendline('fdisk -l') - result =3D console.read_nonblocking() + 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) =20 self.vm_dst =3D self.vm.migrate() console =3D self.vm_dst.get_console() - console.sendline('fdisk -l') - result =3D console.read_nonblocking() + 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) diff --git a/tests/avocado/test_numa_hotplug.py b/tests/avocado/test_numa_h= otplug.py index a99b8dcebf..ee43e60089 100644 --- a/tests/avocado/test_numa_hotplug.py +++ b/tests/avocado/test_numa_hotplug.py @@ -2,6 +2,7 @@ import re import time =20 from avocado_qemu import test +from avocado.utils import vmimage =20 =20 class TestNumaHotplug(test.QemuTest): @@ -20,7 +21,9 @@ class TestNumaHotplug(test.QemuTest): """ =20 def setUp(self): - self.request_image() + self.image =3D vmimage.get() + self.vm.add_image(self.image.path, cloudinit=3DTrue, snapshot=3DFa= lse) + self.vm.args.extend(["-m", "4G,slots=3D208,maxmem=3D80G"]) self.vm.args.extend(["-numa", "node"] * 16) self.vm.launch() --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524249519057938.3571594191449; Fri, 20 Apr 2018 11:38:39 -0700 (PDT) Received: from localhost ([::1]:50721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ave-00031m-9U for importer@patchew.org; Fri, 20 Apr 2018 14:38:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ahF-0007Ut-GK for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9ahE-000731-H3 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35798) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9ahE-00072b-Bh for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:44 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E80580479; Fri, 20 Apr 2018 18:23:43 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26BCC60BE0; Fri, 20 Apr 2018 18:23:42 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:49 -0300 Message-Id: <20180420181951.7252-23-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 20 Apr 2018 18:23:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 22/24] avocado_qemu: Tests fixes 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Amador Pahim - Using acell=3DKVM when we have a guest. - Better resilience for the cases where live-migration fails. Signed-off-by: Amador Pahim Signed-off-by: Eduardo Habkost --- tests/avocado/test_nec-usb-xhci.py | 6 +++++- tests/avocado/test_numa_hotplug.py | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/avocado/test_nec-usb-xhci.py b/tests/avocado/test_nec-us= b-xhci.py index 1c4822544e..d3a2716eb4 100644 --- a/tests/avocado/test_nec-usb-xhci.py +++ b/tests/avocado/test_nec-usb-xhci.py @@ -18,8 +18,10 @@ class TestNecUsbXhci(test.QemuTest): """ =20 def setUp(self): + self.vm_dst =3D None self.image =3D vmimage.get() self.vm.add_image(self.image.path, cloudinit=3DTrue, snapshot=3DFa= lse) + self.vm.args.extend(['-machine', 'accel=3Dkvm']) =20 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) @@ -56,4 +58,6 @@ class TestNecUsbXhci(test.QemuTest): =20 def tearDown(self): self.vm.shutdown() - self.vm_dst.shutdown() + if self.vm_dst is not None: + self.vm_dst.shutdown() + os.remove(self.image.path) diff --git a/tests/avocado/test_numa_hotplug.py b/tests/avocado/test_numa_h= otplug.py index ee43e60089..1993f9b159 100644 --- a/tests/avocado/test_numa_hotplug.py +++ b/tests/avocado/test_numa_hotplug.py @@ -24,6 +24,7 @@ class TestNumaHotplug(test.QemuTest): self.image =3D vmimage.get() self.vm.add_image(self.image.path, cloudinit=3DTrue, snapshot=3DFa= lse) =20 + 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() --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524249901887536.2875520254732; Fri, 20 Apr 2018 11:45:01 -0700 (PDT) Received: from localhost ([::1]:51678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9b1p-0008UB-3Z for importer@patchew.org; Fri, 20 Apr 2018 14:45:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ahW-0007lS-K5 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:24:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9ahR-0007pp-NG for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:24:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52848) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9ahR-0007lu-Gq for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:23:57 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC6BB61BB2; Fri, 20 Apr 2018 18:23:56 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 092985D960; Fri, 20 Apr 2018 18:23:44 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:50 -0300 Message-Id: <20180420181951.7252-24-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 20 Apr 2018 18:23:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 23/24] avocado_qemu: Force vmimage distro 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Amador Pahim Not all distros will support cloudinit. Let's use Fedora, which is proven to work. Signed-off-by: Amador Pahim Signed-off-by: Eduardo Habkost --- tests/avocado/test_nec-usb-xhci.py | 2 +- tests/avocado/test_numa_hotplug.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/avocado/test_nec-usb-xhci.py b/tests/avocado/test_nec-us= b-xhci.py index d3a2716eb4..c29b5ebaa1 100644 --- a/tests/avocado/test_nec-usb-xhci.py +++ b/tests/avocado/test_nec-usb-xhci.py @@ -19,7 +19,7 @@ class TestNecUsbXhci(test.QemuTest): =20 def setUp(self): self.vm_dst =3D None - self.image =3D vmimage.get() + 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']) =20 diff --git a/tests/avocado/test_numa_hotplug.py b/tests/avocado/test_numa_h= otplug.py index 1993f9b159..256ec0f49f 100644 --- a/tests/avocado/test_numa_hotplug.py +++ b/tests/avocado/test_numa_hotplug.py @@ -21,7 +21,7 @@ class TestNumaHotplug(test.QemuTest): """ =20 def setUp(self): - self.image =3D vmimage.get() + self.image =3D vmimage.get('Fedora') self.vm.add_image(self.image.path, cloudinit=3DTrue, snapshot=3DFa= lse) =20 self.vm.args.extend(['-machine', 'accel=3Dkvm']) --=20 2.14.3 From nobody Thu May 2 22:47:11 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524249353964750.6945102012145; Fri, 20 Apr 2018 11:35:53 -0700 (PDT) Received: from localhost ([::1]:50420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9asp-0000Ep-MH for importer@patchew.org; Fri, 20 Apr 2018 14:35:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9ahW-0007lR-K7 for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:24:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9ahU-0007xp-4U for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:24:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37704) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f9ahT-0007vx-Sy for qemu-devel@nongnu.org; Fri, 20 Apr 2018 14:24:00 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2DA8EC04B31F; Fri, 20 Apr 2018 18:23:59 +0000 (UTC) Received: from localhost (ovpn-116-52.gru2.redhat.com [10.97.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3ED205D9CD; Fri, 20 Apr 2018 18:23:58 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2018 15:19:51 -0300 Message-Id: <20180420181951.7252-25-ehabkost@redhat.com> In-Reply-To: <20180420181951.7252-1-ehabkost@redhat.com> References: <20180420181951.7252-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 20 Apr 2018 18:23:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 24/24] avocado_qemu: Add a few VNC related tests 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: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , Stefan Hajnoczi , Amador Pahim , Cleber Rosa , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Cleber Rosa These exercise the basics of firing up QEMU with and without a VNC device, and attempting to set the password when a VNC device and password is given (or not). Signed-off-by: Cleber Rosa Signed-off-by: Eduardo Habkost --- tests/avocado/test_vnc.py | 58 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 58 insertions(+) create mode 100644 tests/avocado/test_vnc.py diff --git a/tests/avocado/test_vnc.py b/tests/avocado/test_vnc.py new file mode 100644 index 0000000000..f5fe26ead6 --- /dev/null +++ b/tests/avocado/test_vnc.py @@ -0,0 +1,58 @@ +from avocado import main +from avocado_qemu import test + + +class Vnc(test.QemuTest): + """ + :avocado: enable + :avocado: tags=3Dvnc,quick + """ + def test_no_vnc(self): + self.vm.args =3D ['-nodefaults', '-S'] + self.vm.launch() + self.assertFalse(self.vm.qmp('query-vnc')['return']['enabled']) + + def test_no_vnc_change_password(self): + self.vm.args =3D ['-nodefaults', '-S'] + self.vm.launch() + self.assertFalse(self.vm.qmp('query-vnc')['return']['enabled']) + set_password_response =3D self.vm.qmp('change', + device=3D'vnc', + target=3D'password', + arg=3D'new_password') + self.assertIn('error', set_password_response) + self.assertEqual(set_password_response['error']['class'], + 'GenericError') + self.assertEqual(set_password_response['error']['desc'], + 'Could not set password') + + def test_vnc_change_password_requires_a_password(self): + self.vm.args =3D ['-nodefaults', '-S', '-vnc', ':0'] + self.vm.launch() + self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled']) + set_password_response =3D self.vm.qmp('change', + device=3D'vnc', + target=3D'password', + arg=3D'new_password') + self.assertIn('error', set_password_response) + self.assertEqual(set_password_response['error']['class'], + 'GenericError') + self.assertEqual(set_password_response['error']['desc'], + 'Could not set password') + + def test_vnc_change_password(self): + self.vm.args =3D ['-nodefaults', '-S', '-vnc', ':0,password'] + self.vm.launch() + self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled']) + set_password_response =3D self.vm.qmp('change', + device=3D'vnc', + target=3D'password', + arg=3D'new_password') + self.assertEqual(set_password_response['return'], {}) + + def tearDown(self): + self.vm.shutdown() + + +if __name__ =3D=3D '__main__': + main() --=20 2.14.3