All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH  v1 00/18] testing/next (vm, gitlab)
@ 2020-06-22 14:31 Alex Bennée
  2020-06-22 14:31 ` [PATCH v1 01/18] iotests: Fix 051 output after qdev_init_nofail() removal Alex Bennée
                   ` (17 more replies)
  0 siblings, 18 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, berrange, Alex Bennée, richard.henderson, f4bug, cota,
	aurelien

Hi,

This is the current state of my testing/next queue. In brief:

  - tests/vm updates for aarch64 VMs
  - moving check-acceptance to gitlab
  - some minor fixes going in via other trees

Most of tests/vm are well reviewed but I added a few clean-ups that
need review alongside the gitlab stuff:

 - .gitlab: add avocado asset caching
 - .gitlab: tag remaining jobs as builds
 - .gitlab: split fedora-misc-disabled
 - .gitlab: add acceptance testing to system builds
 - .gitignore: un-ignore .gitlab-ci.d
 - tests/docker: check for an parameters not empty string
 - tests/vm: allow us to take advantage of MTTCG
 - tests/vm: switch from optsparse to  argparse

Alex Bennée (8):
  tests/vm: switch from optsparse to  argparse
  tests/vm: allow us to take advantage of MTTCG
  tests/docker: check for an parameters not empty string
  .gitignore: un-ignore .gitlab-ci.d
  .gitlab: add acceptance testing to system builds
  .gitlab: split fedora-misc-disabled
  .gitlab: tag remaining jobs as builds
  .gitlab: add avocado asset caching

Philippe Mathieu-Daudé (1):
  iotests: Fix 051 output after qdev_init_nofail() removal

Robert Foley (9):
  tests/vm: pass args through to BaseVM's __init__
  tests/vm: Add configuration to basevm.py
  tests/vm: Added configuration file support
  tests/vm: Add common Ubuntu python module
  tests/vm: Added a new script for ubuntu.aarch64.
  tests/vm: Added a new script for centos.aarch64.
  tests/vm: change scripts to use self._config
  python/qemu: Add ConsoleSocket for optional use in QEMUMachine
  tests/vm: Add workaround to consume console

 configure                         |  29 +++
 .gitignore                        |   2 +-
 .gitlab-ci.yml                    | 149 +++++++++++++-
 .travis.yml                       |  23 ---
 python/qemu/console_socket.py     | 110 ++++++++++
 python/qemu/machine.py            |  23 ++-
 tests/docker/common.rc            |   2 +-
 tests/qemu-iotests/051.pc.out     |   4 +-
 tests/vm/Makefile.include         |  22 ++
 tests/vm/aarch64vm.py             | 106 ++++++++++
 tests/vm/basevm.py                | 332 ++++++++++++++++++++++--------
 tests/vm/centos-8-aarch64.ks      |  51 +++++
 tests/vm/centos.aarch64           | 227 ++++++++++++++++++++
 tests/vm/conf_example_aarch64.yml |  51 +++++
 tests/vm/conf_example_x86.yml     |  50 +++++
 tests/vm/fedora                   |  17 +-
 tests/vm/freebsd                  |  16 +-
 tests/vm/netbsd                   |  19 +-
 tests/vm/openbsd                  |  17 +-
 tests/vm/ubuntu.aarch64           |  68 ++++++
 tests/vm/ubuntu.i386              |  46 ++---
 tests/vm/ubuntuvm.py              |  60 ++++++
 22 files changed, 1230 insertions(+), 194 deletions(-)
 create mode 100644 python/qemu/console_socket.py
 create mode 100644 tests/vm/aarch64vm.py
 create mode 100644 tests/vm/centos-8-aarch64.ks
 create mode 100755 tests/vm/centos.aarch64
 create mode 100644 tests/vm/conf_example_aarch64.yml
 create mode 100644 tests/vm/conf_example_x86.yml
 create mode 100755 tests/vm/ubuntu.aarch64
 create mode 100644 tests/vm/ubuntuvm.py

-- 
2.20.1



^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v1 01/18] iotests: Fix 051 output after qdev_init_nofail() removal
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
@ 2020-06-22 14:31 ` Alex Bennée
  2020-06-22 17:52   ` John Snow
  2020-06-22 14:31 ` [PATCH v1 02/18] tests/vm: pass args through to BaseVM's __init__ Alex Bennée
                   ` (16 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, Kevin Wolf, Thomas Huth, berrange,
	open list:Block layer core, Philippe Mathieu-Daudé,
	richard.henderson, f4bug, Max Reitz, Alex Bennée, cota,
	aurelien

From: Philippe Mathieu-Daudé <philmd@redhat.com>

Commit 96927c744 replaced qdev_init_nofail() call by
isa_realize_and_unref() which has a different error
message. Update the test output accordingly.

Gitlab CI error after merging b77b5b3dc7:
https://gitlab.com/qemu-project/qemu/-/jobs/597414772#L4375

Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200616154949.6586-1-philmd@redhat.com>
---
 tests/qemu-iotests/051.pc.out | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out
index 0ea80d35f0e..da8ad871876 100644
--- a/tests/qemu-iotests/051.pc.out
+++ b/tests/qemu-iotests/051.pc.out
@@ -142,7 +142,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
 
 Testing: -drive if=ide
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: Initialization of device ide-hd failed: Device needs media, but drive is empty
+(qemu) QEMU_PROG: Device needs media, but drive is empty
 
 Testing: -drive if=virtio
 QEMU X.Y.Z monitor - type 'help' for more information
@@ -214,7 +214,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
 
 Testing: -drive file=TEST_DIR/t.qcow2,if=ide,readonly=on
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) QEMU_PROG: Initialization of device ide-hd failed: Block node is read-only
+(qemu) QEMU_PROG: Block node is read-only
 
 Testing: -drive file=TEST_DIR/t.qcow2,if=virtio,readonly=on
 QEMU X.Y.Z monitor - type 'help' for more information
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 02/18] tests/vm: pass args through to BaseVM's __init__
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
  2020-06-22 14:31 ` [PATCH v1 01/18] iotests: Fix 051 output after qdev_init_nofail() removal Alex Bennée
@ 2020-06-22 14:31 ` Alex Bennée
  2020-06-22 14:31 ` [PATCH v1 03/18] tests/vm: Add configuration to basevm.py Alex Bennée
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, berrange, Robert Foley, Alex Bennée, richard.henderson,
	f4bug, Philippe Mathieu-Daudé,
	cota, aurelien

From: Robert Foley <robert.foley@linaro.org>

Adding the args parameter to BaseVM's __init__.
We will shortly need to pass more parameters to the class
so let's just pass args rather than growing the parameter list.

Signed-off-by: Robert Foley <robert.foley@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200601211421.1277-2-robert.foley@linaro.org>
---
 tests/vm/basevm.py | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index a80b616a08d..5a58e6c3930 100644
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -61,11 +61,10 @@ class BaseVM(object):
     # 4 is arbitrary, but greater than 2,
     # since we found we need to wait more than twice as long.
     tcg_ssh_timeout_multiplier = 4
-    def __init__(self, debug=False, vcpus=None, genisoimage=None,
-                 build_path=None):
+    def __init__(self, args):
         self._guest = None
-        self._genisoimage = genisoimage
-        self._build_path = build_path
+        self._genisoimage = args.genisoimage
+        self._build_path = args.build_path
         self._tmpdir = os.path.realpath(tempfile.mkdtemp(prefix="vm-test-",
                                                          suffix=".tmp",
                                                          dir="."))
@@ -78,7 +77,7 @@ class BaseVM(object):
         self._ssh_pub_key_file = os.path.join(self._tmpdir, "id_rsa.pub")
         open(self._ssh_pub_key_file, "w").write(SSH_PUB_KEY)
 
-        self.debug = debug
+        self.debug = args.debug
         self._stderr = sys.stderr
         self._devnull = open(os.devnull, "w")
         if self.debug:
@@ -92,8 +91,8 @@ class BaseVM(object):
                        (",ipv6=no" if not self.ipv6 else ""),
             "-device", "virtio-net-pci,netdev=vnet",
             "-vnc", "127.0.0.1:0,to=20"]
-        if vcpus and vcpus > 1:
-            self._args += ["-smp", "%d" % vcpus]
+        if args.jobs and args.jobs > 1:
+            self._args += ["-smp", "%d" % args.jobs]
         if kvm_available(self.arch):
             self._args += ["-enable-kvm"]
         else:
@@ -456,8 +455,7 @@ def main(vmcls):
             return 1
         logging.basicConfig(level=(logging.DEBUG if args.debug
                                    else logging.WARN))
-        vm = vmcls(debug=args.debug, vcpus=args.jobs,
-                   genisoimage=args.genisoimage, build_path=args.build_path)
+        vm = vmcls(args)
         if args.build_image:
             if os.path.exists(args.image) and not args.force:
                 sys.stderr.writelines(["Image file exists: %s\n" % args.image,
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 03/18] tests/vm: Add configuration to basevm.py
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
  2020-06-22 14:31 ` [PATCH v1 01/18] iotests: Fix 051 output after qdev_init_nofail() removal Alex Bennée
  2020-06-22 14:31 ` [PATCH v1 02/18] tests/vm: pass args through to BaseVM's __init__ Alex Bennée
@ 2020-06-22 14:31 ` Alex Bennée
  2020-06-22 14:31 ` [PATCH v1 04/18] tests/vm: Added configuration file support Alex Bennée
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, berrange, Robert Foley, Alex Bennée, richard.henderson,
	f4bug, Philippe Mathieu-Daudé,
	cota, Peter Puhov, aurelien

From: Robert Foley <robert.foley@linaro.org>

Added use of a configuration to tests/vm/basevm.py.
The configuration provides parameters used to configure a VM.
This allows for providing alternate configurations to the VM being
created/launched. cpu, machine, memory, and NUMA configuration are all
examples of configuration which we might want to vary on the VM being created
or launched.
This will for example allow for creating an aarch64 vm.

Signed-off-by: Robert Foley <robert.foley@linaro.org>
Reviewed-by: Peter Puhov <peter.puhov@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200601211421.1277-3-robert.foley@linaro.org>
---
 tests/vm/basevm.py | 172 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 133 insertions(+), 39 deletions(-)

diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 5a58e6c3930..cfe20c58f7e 100644
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -29,16 +29,41 @@ import tempfile
 import shutil
 import multiprocessing
 import traceback
-
-SSH_KEY = open(os.path.join(os.path.dirname(__file__),
-               "..", "keys", "id_rsa")).read()
-SSH_PUB_KEY = open(os.path.join(os.path.dirname(__file__),
-                   "..", "keys", "id_rsa.pub")).read()
-
+import shlex
+
+SSH_KEY_FILE = os.path.join(os.path.dirname(__file__),
+               "..", "keys", "id_rsa")
+SSH_PUB_KEY_FILE = os.path.join(os.path.dirname(__file__),
+                   "..", "keys", "id_rsa.pub")
+
+# This is the standard configuration.
+# Any or all of these can be overridden by
+# passing in a config argument to the VM constructor.
+DEFAULT_CONFIG = {
+    'cpu'             : "max",
+    'machine'         : 'pc',
+    'guest_user'      : "qemu",
+    'guest_pass'      : "qemupass",
+    'root_pass'       : "qemupass",
+    'ssh_key_file'    : SSH_KEY_FILE,
+    'ssh_pub_key_file': SSH_PUB_KEY_FILE,
+    'memory'          : "4G",
+    'extra_args'      : [],
+    'qemu_args'       : "",
+    'dns'             : "",
+    'ssh_port'        : 0,
+    'install_cmds'    : "",
+    'boot_dev_type'   : "block",
+    'ssh_timeout'     : 1,
+}
+BOOT_DEVICE = {
+    'block' :  "-drive file={},if=none,id=drive0,cache=writeback "\
+               "-device virtio-blk,drive=drive0,bootindex=0",
+    'scsi'  :  "-device virtio-scsi-device,id=scsi "\
+               "-drive file={},format=raw,if=none,id=hd0 "\
+               "-device scsi-hd,drive=hd0,bootindex=0",
+}
 class BaseVM(object):
-    GUEST_USER = "qemu"
-    GUEST_PASS = "qemupass"
-    ROOT_PASS = "qemupass"
 
     envvars = [
         "https_proxy",
@@ -57,25 +82,38 @@ class BaseVM(object):
     poweroff = "poweroff"
     # enable IPv6 networking
     ipv6 = True
+    # This is the timeout on the wait for console bytes.
+    socket_timeout = 120
     # Scale up some timeouts under TCG.
     # 4 is arbitrary, but greater than 2,
     # since we found we need to wait more than twice as long.
     tcg_ssh_timeout_multiplier = 4
-    def __init__(self, args):
+    def __init__(self, args, config=None):
         self._guest = None
         self._genisoimage = args.genisoimage
         self._build_path = args.build_path
+        # Allow input config to override defaults.
+        self._config = DEFAULT_CONFIG.copy()
+        if config != None:
+            self._config.update(config)
+        self.validate_ssh_keys()
         self._tmpdir = os.path.realpath(tempfile.mkdtemp(prefix="vm-test-",
                                                          suffix=".tmp",
                                                          dir="."))
         atexit.register(shutil.rmtree, self._tmpdir)
-
-        self._ssh_key_file = os.path.join(self._tmpdir, "id_rsa")
-        open(self._ssh_key_file, "w").write(SSH_KEY)
-        subprocess.check_call(["chmod", "600", self._ssh_key_file])
-
-        self._ssh_pub_key_file = os.path.join(self._tmpdir, "id_rsa.pub")
-        open(self._ssh_pub_key_file, "w").write(SSH_PUB_KEY)
+        # Copy the key files to a temporary directory.
+        # Also chmod the key file to agree with ssh requirements.
+        self._config['ssh_key'] = \
+            open(self._config['ssh_key_file']).read().rstrip()
+        self._config['ssh_pub_key'] = \
+            open(self._config['ssh_pub_key_file']).read().rstrip()
+        self._ssh_tmp_key_file = os.path.join(self._tmpdir, "id_rsa")
+        open(self._ssh_tmp_key_file, "w").write(self._config['ssh_key'])
+        subprocess.check_call(["chmod", "600", self._ssh_tmp_key_file])
+
+        self._ssh_tmp_pub_key_file = os.path.join(self._tmpdir, "id_rsa.pub")
+        open(self._ssh_tmp_pub_key_file,
+             "w").write(self._config['ssh_pub_key'])
 
         self.debug = args.debug
         self._stderr = sys.stderr
@@ -84,11 +122,14 @@ class BaseVM(object):
             self._stdout = sys.stdout
         else:
             self._stdout = self._devnull
+        netdev = "user,id=vnet,hostfwd=:127.0.0.1:{}-:22"
         self._args = [ \
-            "-nodefaults", "-m", "4G",
-            "-cpu", "max",
-            "-netdev", "user,id=vnet,hostfwd=:127.0.0.1:0-:22" +
-                       (",ipv6=no" if not self.ipv6 else ""),
+            "-nodefaults", "-m", self._config['memory'],
+            "-cpu", self._config['cpu'],
+            "-netdev",
+            netdev.format(self._config['ssh_port']) +
+            (",ipv6=no" if not self.ipv6 else "") +
+            (",dns=" + self._config['dns'] if self._config['dns'] else ""),
             "-device", "virtio-net-pci,netdev=vnet",
             "-vnc", "127.0.0.1:0,to=20"]
         if args.jobs and args.jobs > 1:
@@ -99,6 +140,55 @@ class BaseVM(object):
             logging.info("KVM not available, not using -enable-kvm")
         self._data_args = []
 
+        if self._config['qemu_args'] != None:
+            qemu_args = self._config['qemu_args']
+            qemu_args = qemu_args.replace('\n',' ').replace('\r','')
+            # shlex groups quoted arguments together
+            # we need this to keep the quoted args together for when
+            # the QEMU command is issued later.
+            args = shlex.split(qemu_args)
+            self._config['extra_args'] = []
+            for arg in args:
+                if arg:
+                    # Preserve quotes around arguments.
+                    # shlex above takes them out, so add them in.
+                    if " " in arg:
+                        arg = '"{}"'.format(arg)
+                    self._config['extra_args'].append(arg)
+
+    def validate_ssh_keys(self):
+        """Check to see if the ssh key files exist."""
+        if 'ssh_key_file' not in self._config or\
+           not os.path.exists(self._config['ssh_key_file']):
+            raise Exception("ssh key file not found.")
+        if 'ssh_pub_key_file' not in self._config or\
+           not os.path.exists(self._config['ssh_pub_key_file']):
+               raise Exception("ssh pub key file not found.")
+
+    def wait_boot(self, wait_string=None):
+        """Wait for the standard string we expect
+           on completion of a normal boot.
+           The user can also choose to override with an
+           alternate string to wait for."""
+        if wait_string is None:
+            if self.login_prompt is None:
+                raise Exception("self.login_prompt not defined")
+            wait_string = self.login_prompt
+        # Intentionally bump up the default timeout under TCG,
+        # since the console wait below takes longer.
+        timeout = self.socket_timeout
+        if not kvm_available(self.arch):
+            timeout *= 8
+        self.console_init(timeout=timeout)
+        self.console_wait(wait_string)
+
+    def __getattr__(self, name):
+        # Support direct access to config by key.
+        # for example, access self._config['cpu'] by self.cpu
+        if name.lower() in self._config.keys():
+            return self._config[name.lower()]
+        return object.__getattribute__(self, name)
+
     def _download_with_cache(self, url, sha256sum=None, sha512sum=None):
         def check_sha256sum(fname):
             if not sha256sum:
@@ -130,8 +220,9 @@ class BaseVM(object):
                    "-t",
                    "-o", "StrictHostKeyChecking=no",
                    "-o", "UserKnownHostsFile=" + os.devnull,
-                   "-o", "ConnectTimeout=1",
-                   "-p", self.ssh_port, "-i", self._ssh_key_file]
+                   "-o",
+                   "ConnectTimeout={}".format(self._config["ssh_timeout"]),
+                   "-p", self.ssh_port, "-i", self._ssh_tmp_key_file]
         # If not in debug mode, set ssh to quiet mode to
         # avoid printing the results of commands.
         if not self.debug:
@@ -180,14 +271,14 @@ class BaseVM(object):
                             "virtio-blk,drive=%s,serial=%s,bootindex=1" % (name, name)]
 
     def boot(self, img, extra_args=[]):
-        args = self._args + [
-            "-drive", "file=%s,if=none,id=drive0,cache=writeback" % img,
-            "-device", "virtio-blk,drive=drive0,bootindex=0"]
-        args += self._data_args + extra_args
+        boot_dev = BOOT_DEVICE[self._config['boot_dev_type']]
+        boot_params = boot_dev.format(img)
+        args = self._args + boot_params.split(' ')
+        args += self._data_args + extra_args + self._config['extra_args']
         logging.debug("QEMU args: %s", " ".join(args))
         qemu_path = get_qemu_path(self.arch, self._build_path)
         guest = QEMUMachine(binary=qemu_path, args=args)
-        guest.set_machine('pc')
+        guest.set_machine(self._config['machine'])
         guest.set_console()
         try:
             guest.launch()
@@ -301,7 +392,8 @@ class BaseVM(object):
         self.console_send(command)
 
     def console_ssh_init(self, prompt, user, pw):
-        sshkey_cmd = "echo '%s' > .ssh/authorized_keys\n" % SSH_PUB_KEY.rstrip()
+        sshkey_cmd = "echo '%s' > .ssh/authorized_keys\n" \
+                     % self._config['ssh_pub_key'].rstrip()
         self.console_wait_send("login:",    "%s\n" % user)
         self.console_wait_send("Password:", "%s\n" % pw)
         self.console_wait_send(prompt,      "mkdir .ssh\n")
@@ -360,23 +452,23 @@ class BaseVM(object):
                           "local-hostname: {}-guest\n".format(name)])
         mdata.close()
         udata = open(os.path.join(cidir, "user-data"), "w")
-        print("guest user:pw {}:{}".format(self.GUEST_USER,
-                                           self.GUEST_PASS))
+        print("guest user:pw {}:{}".format(self._config['guest_user'],
+                                           self._config['guest_pass']))
         udata.writelines(["#cloud-config\n",
                           "chpasswd:\n",
                           "  list: |\n",
-                          "    root:%s\n" % self.ROOT_PASS,
-                          "    %s:%s\n" % (self.GUEST_USER,
-                                           self.GUEST_PASS),
+                          "    root:%s\n" % self._config['root_pass'],
+                          "    %s:%s\n" % (self._config['guest_user'],
+                                           self._config['guest_pass']),
                           "  expire: False\n",
                           "users:\n",
-                          "  - name: %s\n" % self.GUEST_USER,
+                          "  - name: %s\n" % self._config['guest_user'],
                           "    sudo: ALL=(ALL) NOPASSWD:ALL\n",
                           "    ssh-authorized-keys:\n",
-                          "    - %s\n" % SSH_PUB_KEY,
+                          "    - %s\n" % self._config['ssh_pub_key'],
                           "  - name: root\n",
                           "    ssh-authorized-keys:\n",
-                          "    - %s\n" % SSH_PUB_KEY,
+                          "    - %s\n" % self._config['ssh_pub_key'],
                           "locale: en_US.UTF-8\n"])
         proxy = os.environ.get("http_proxy")
         if not proxy is None:
@@ -447,15 +539,17 @@ def parse_args(vmcls):
     parser.disable_interspersed_args()
     return parser.parse_args()
 
-def main(vmcls):
+def main(vmcls, config=None):
     try:
+        if config == None:
+            config = {}
         args, argv = parse_args(vmcls)
         if not argv and not args.build_qemu and not args.build_image:
             print("Nothing to do?")
             return 1
         logging.basicConfig(level=(logging.DEBUG if args.debug
                                    else logging.WARN))
-        vm = vmcls(args)
+        vm = vmcls(args, config=config)
         if args.build_image:
             if os.path.exists(args.image) and not args.force:
                 sys.stderr.writelines(["Image file exists: %s\n" % args.image,
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 04/18] tests/vm: Added configuration file support
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (2 preceding siblings ...)
  2020-06-22 14:31 ` [PATCH v1 03/18] tests/vm: Add configuration to basevm.py Alex Bennée
@ 2020-06-22 14:31 ` Alex Bennée
  2020-06-22 14:31 ` [PATCH v1 05/18] tests/vm: Add common Ubuntu python module Alex Bennée
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, berrange, Robert Foley, Alex Bennée, richard.henderson,
	f4bug, Philippe Mathieu-Daudé,
	cota, Peter Puhov, aurelien

From: Robert Foley <robert.foley@linaro.org>

Changes to tests/vm/basevm.py to allow accepting a configuration file
as a parameter. Allows for specifying VM options such as
cpu, machine, memory, and arbitrary qemu arguments for specifying options
such as NUMA configuration.
Also added an example conf_example_aarch64.yml and conf_example_x86.yml.

Signed-off-by: Robert Foley <robert.foley@linaro.org>
Reviewed-by: Peter Puhov <peter.puhov@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200601211421.1277-4-robert.foley@linaro.org>
---
 configure                         |  9 ++++++
 tests/vm/Makefile.include         |  6 ++++
 tests/vm/basevm.py                | 40 +++++++++++++++++++++++-
 tests/vm/conf_example_aarch64.yml | 51 +++++++++++++++++++++++++++++++
 tests/vm/conf_example_x86.yml     | 50 ++++++++++++++++++++++++++++++
 5 files changed, 155 insertions(+), 1 deletion(-)
 create mode 100644 tests/vm/conf_example_aarch64.yml
 create mode 100644 tests/vm/conf_example_x86.yml

diff --git a/configure b/configure
index ba88fd18244..6d14f2c2d6c 100755
--- a/configure
+++ b/configure
@@ -958,6 +958,13 @@ do
     fi
 done
 
+# Check for existence of python3 yaml, needed to
+# import yaml config files into vm-build.
+python_yaml="no"
+if $(python3 -c "import yaml" 2> /dev/null); then
+    python_yaml="yes"
+fi
+
 : ${smbd=${SMBD-/usr/sbin/smbd}}
 
 # Default objcc to clang if available, otherwise use CC
@@ -6751,6 +6758,7 @@ if test "$docs" != "no"; then
     echo "sphinx-build      $sphinx_build"
 fi
 echo "genisoimage       $genisoimage"
+echo "python_yaml       $python_yaml"
 echo "slirp support     $slirp $(echo_version $slirp $slirp_version)"
 if test "$slirp" != "no" ; then
     echo "smbd              $smbd"
@@ -7830,6 +7838,7 @@ echo "PYTHON=$python" >> $config_host_mak
 echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
 echo "SPHINX_WERROR=$sphinx_werror" >> $config_host_mak
 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
+echo "PYTHON_YAML=$python_yaml" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
 if $iasl -h > /dev/null 2>&1; then
   echo "IASL=$iasl" >> $config_host_mak
diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
index a253aba4579..f6c3892bb28 100644
--- a/tests/vm/Makefile.include
+++ b/tests/vm/Makefile.include
@@ -44,6 +44,12 @@ endif
 	@echo "    QEMU_LOCAL=1                 - Use QEMU binary local to this build."
 	@echo "    QEMU=/path/to/qemu		 - Change path to QEMU binary"
 	@echo "    QEMU_IMG=/path/to/qemu-img	 - Change path to qemu-img tool"
+ifeq ($(PYTHON_YAML),yes)
+	@echo "    QEMU_CONFIG=/path/conf.yml   - Change path to VM configuration .yml file."
+else
+	@echo "    (install python3-yaml to enable support for yaml file to configure a VM.)"
+endif
+	@echo "                                   See conf_example_*.yml for file format details."
 
 vm-build-all: $(addprefix vm-build-, $(IMAGES))
 
diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index cfe20c58f7e..fa56fbbb4b6 100644
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -481,7 +481,6 @@ class BaseVM(object):
                               cwd=cidir,
                               stdin=self._devnull, stdout=self._stdout,
                               stderr=self._stdout)
-
         return os.path.join(cidir, "cloud-init.iso")
 
 def get_qemu_path(arch, build_path=None):
@@ -497,6 +496,41 @@ def get_qemu_path(arch, build_path=None):
         qemu_path = "qemu-system-" + arch
     return qemu_path
 
+def parse_config(config, args):
+    """ Parse yaml config and populate our config structure.
+        The yaml config allows the user to override the
+        defaults for VM parameters.  In many cases these
+        defaults can be overridden without rebuilding the VM."""
+    if args.config:
+        config_file = args.config
+    elif 'QEMU_CONFIG' in os.environ:
+        config_file = os.environ['QEMU_CONFIG']
+    else:
+        return config
+    if not os.path.exists(config_file):
+        raise Exception("config file {} does not exist".format(config_file))
+    # We gracefully handle importing the yaml module
+    # since it might not be installed.
+    # If we are here it means the user supplied a .yml file,
+    # so if the yaml module is not installed we will exit with error.
+    try:
+        import yaml
+    except ImportError:
+        print("The python3-yaml package is needed "\
+              "to support config.yaml files")
+        # Instead of raising an exception we exit to avoid
+        # a raft of messy (expected) errors to stdout.
+        exit(1)
+    with open(config_file) as f:
+        yaml_dict = yaml.safe_load(f)
+
+    if 'qemu-conf' in yaml_dict:
+        config.update(yaml_dict['qemu-conf'])
+    else:
+        raise Exception("config file {} is not valid"\
+                        " missing qemu-conf".format(config_file))
+    return config
+
 def parse_args(vmcls):
 
     def get_default_jobs():
@@ -536,6 +570,9 @@ def parse_args(vmcls):
                       help="run tests with a snapshot")
     parser.add_option("--genisoimage", default="genisoimage",
                       help="iso imaging tool")
+    parser.add_option("--config", "-c", default=None,
+                      help="Provide config yaml for configuration. "\
+                           "See config_example.yaml for example.")
     parser.disable_interspersed_args()
     return parser.parse_args()
 
@@ -547,6 +584,7 @@ def main(vmcls, config=None):
         if not argv and not args.build_qemu and not args.build_image:
             print("Nothing to do?")
             return 1
+        config = parse_config(config, args)
         logging.basicConfig(level=(logging.DEBUG if args.debug
                                    else logging.WARN))
         vm = vmcls(args, config=config)
diff --git a/tests/vm/conf_example_aarch64.yml b/tests/vm/conf_example_aarch64.yml
new file mode 100644
index 00000000000..9d44ae356f7
--- /dev/null
+++ b/tests/vm/conf_example_aarch64.yml
@@ -0,0 +1,51 @@
+#
+# Example yaml for use by any of the scripts in tests/vm.
+# Can be provided as an environment variable QEMU_CONFIG
+#
+qemu-conf:
+
+    # If any of the below are not provided, we will just use the qemu defaults.
+
+    # Login username and password(has to be sudo enabled)
+    guest_user: qemu
+    guest_pass: "qemupass"
+
+    # Password for root user can be different from guest.
+    root_pass: "qemupass"
+
+    # If one key is provided, both must be provided.
+    #ssh_key: /complete/path/of/your/keyfile/id_rsa
+    #ssh_pub_key: /complete/path/of/your/keyfile/id_rsa.pub
+
+    cpu: max
+    machine: virt,gic-version=max
+    memory: 16G
+
+    # The below is a example for how to configure NUMA topology with
+    # 4 NUMA nodes and 2 different NUMA distances.
+    qemu_args: "-smp cpus=16,sockets=2,cores=8
+                -numa node,cpus=0-3,nodeid=0 -numa node,cpus=4-7,nodeid=1
+                -numa node,cpus=8-11,nodeid=2 -numa node,cpus=12-15,nodeid=3
+                -numa dist,src=0,dst=1,val=15 -numa dist,src=2,dst=3,val=15
+                -numa dist,src=0,dst=2,val=20 -numa dist,src=0,dst=3,val=20
+                -numa dist,src=1,dst=2,val=20 -numa dist,src=1,dst=3,val=20"
+
+    # By default we do not set the DNS.
+    # You override the defaults by setting the below.
+    #dns: 1.234.567.89
+
+    # By default we will use a "block" device, but
+    # you can also boot from a "scsi" device.
+    # Just keep in mind your scripts might need to change
+    # As you will have /dev/sda instead of /dev/vda (for block device)
+    boot_dev_type: "block"
+
+    # By default the ssh port is not fixed.
+    # A fixed ssh port makes it easier for automated tests.
+    #ssh_port: 5555
+
+    # To install a different set of packages, provide a command to issue
+    #install_cmds: "apt-get update ; apt-get build-dep -y qemu"
+
+    # Or to skip the install entirely, just provide ""
+    #install_cmds: ""
diff --git a/tests/vm/conf_example_x86.yml b/tests/vm/conf_example_x86.yml
new file mode 100644
index 00000000000..78d3f5830fa
--- /dev/null
+++ b/tests/vm/conf_example_x86.yml
@@ -0,0 +1,50 @@
+#
+# Example yaml for use by any of the x86 based scripts in tests/vm.
+# Can be provided as an environment variable QEMU_CONFIG
+#
+qemu-conf:
+
+    # If any of the below are not provided, we will just use the qemu defaults.
+
+    # Login username and password(has to be sudo enabled)
+    guest_user: "qemu"
+    guest_pass: "qemupass"
+
+    # Password for root user can be different from guest.
+    root_pass: "qemupass"
+
+    # Provide default ssh keys of current user.
+    # You need to edit the below for your user.
+    #ssh_key_file: /home/<user>/.ssh/id_rsa
+    #ssh_pub_key_file: /home/<user>/.ssh/id_rsa.pub
+
+    cpu: max
+    machine: pc
+    memory: 8G
+
+    # The below is a example for how to configure NUMA topology with
+    # 4 NUMA nodes and 2 different NUMA distances.
+    qemu_args: "-smp cpus=8,sockets=2,cores=4
+                -object memory-backend-ram,size=4G,policy=bind,host-nodes=0,id=ram-node0
+                -object memory-backend-ram,size=4G,policy=bind,host-nodes=0,id=ram-node1
+                -object memory-backend-ram,size=4G,policy=bind,host-nodes=1,id=ram-node2
+                -object memory-backend-ram,size=4G,policy=bind,host-nodes=1,id=ram-node3
+                -numa node,cpus=0-1,nodeid=0 -numa node,cpus=2-3,nodeid=1
+                -numa node,cpus=4-5,nodeid=2 -numa node,cpus=6-7,nodeid=3
+                -numa dist,src=0,dst=1,val=15 -numa dist,src=2,dst=3,val=15
+                -numa dist,src=0,dst=2,val=20 -numa dist,src=0,dst=3,val=20
+                -numa dist,src=1,dst=2,val=20 -numa dist,src=1,dst=3,val=20"
+
+    # By default we do not set the DNS.
+    # You override the defaults by setting the below.
+    #dns: "1.234.567.89"
+
+    # By default we will use a "block" device, but
+    # you can also boot from a "scsi" device.
+    # Just keep in mind your scripts might need to change
+    # As you will have /dev/sda instead of /dev/vda (for block device)
+    boot_dev_type: "block"
+
+    # By default the ssh port is not fixed.
+    # A fixed ssh port makes it easier for automated tests.
+    ssh_port: 5555
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 05/18] tests/vm: Add common Ubuntu python module
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (3 preceding siblings ...)
  2020-06-22 14:31 ` [PATCH v1 04/18] tests/vm: Added configuration file support Alex Bennée
@ 2020-06-22 14:31 ` Alex Bennée
  2020-06-22 14:31 ` [PATCH v1 06/18] tests/vm: Added a new script for ubuntu.aarch64 Alex Bennée
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, berrange, Robert Foley, Philippe Mathieu-Daudé,
	richard.henderson, f4bug, Alex Bennée, cota, aurelien

From: Robert Foley <robert.foley@linaro.org>

Add a common Ubuntu python module and make use of
it with the ubuntu.i386 script.
This is preparation for adding an Ubuntu script
ubuntu.aarch64.  Splitting out the common
logic such as build_image() will reduce duplication.

Signed-off-by: Robert Foley <robert.foley@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200601211421.1277-5-robert.foley@linaro.org>
---
 tests/vm/ubuntu.i386 | 46 +++++++++------------------------
 tests/vm/ubuntuvm.py | 60 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 34 deletions(-)
 create mode 100644 tests/vm/ubuntuvm.py

diff --git a/tests/vm/ubuntu.i386 b/tests/vm/ubuntu.i386
index 24527cc78c7..5ce72610a6c 100755
--- a/tests/vm/ubuntu.i386
+++ b/tests/vm/ubuntu.i386
@@ -11,15 +11,22 @@
 # the COPYING file in the top-level directory.
 #
 
-import os
 import sys
-import subprocess
 import basevm
-import time
+import ubuntuvm
 
-class UbuntuX86VM(basevm.BaseVM):
+DEFAULT_CONFIG = {
+    'install_cmds' : "apt-get update,"\
+                     "apt-get build-dep -y qemu,"\
+                     "apt-get install -y libfdt-dev language-pack-en",
+}
+
+class UbuntuX86VM(ubuntuvm.UbuntuVM):
     name = "ubuntu.i386"
     arch = "i386"
+    image_link="https://cloud-images.ubuntu.com/releases/bionic/"\
+               "release-20191114/ubuntu-18.04-server-cloudimg-i386.img"
+    image_sha256="28969840626d1ea80bb249c08eef1a4533e8904aa51a327b40f37ac4b4ff04ef"
     BUILD_SCRIPT = """
         set -e;
         cd $(mktemp -d);
@@ -29,34 +36,5 @@ class UbuntuX86VM(basevm.BaseVM):
         make --output-sync {target} -j{jobs} {verbose};
     """
 
-    def build_image(self, img):
-        cimg = self._download_with_cache(
-            "https://cloud-images.ubuntu.com/releases/bionic/release-20191114/ubuntu-18.04-server-cloudimg-i386.img",
-            sha256sum="28969840626d1ea80bb249c08eef1a4533e8904aa51a327b40f37ac4b4ff04ef")
-        img_tmp = img + ".tmp"
-        subprocess.check_call(["cp", "-f", cimg, img_tmp])
-        self.exec_qemu_img("resize", img_tmp, "50G")
-        self.boot(img_tmp, extra_args = [
-            "-device", "VGA",
-            "-cdrom", self.gen_cloud_init_iso()
-        ])
-        self.wait_ssh()
-        self.ssh_root_check("touch /etc/cloud/cloud-init.disabled")
-        self.ssh_root_check("apt-get update")
-        self.ssh_root_check("apt-get install -y cloud-initramfs-growroot")
-        # Don't check the status in case the guest hang up too quickly
-        self.ssh_root("sync && reboot")
-        time.sleep(5)
-        self.wait_ssh()
-        # The previous update sometimes doesn't survive a reboot, so do it again
-        self.ssh_root_check("sed -ie s/^#\ deb-src/deb-src/g /etc/apt/sources.list")
-        self.ssh_root_check("apt-get update")
-        self.ssh_root_check("apt-get build-dep -y qemu")
-        self.ssh_root_check("apt-get install -y libfdt-dev language-pack-en")
-        self.ssh_root("poweroff")
-        self.wait()
-        os.rename(img_tmp, img)
-        return 0
-
 if __name__ == "__main__":
-    sys.exit(basevm.main(UbuntuX86VM))
+    sys.exit(basevm.main(UbuntuX86VM, DEFAULT_CONFIG))
diff --git a/tests/vm/ubuntuvm.py b/tests/vm/ubuntuvm.py
new file mode 100644
index 00000000000..6689ad87aa8
--- /dev/null
+++ b/tests/vm/ubuntuvm.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python3
+#
+# Ubuntu VM testing library
+#
+# Copyright 2017 Red Hat Inc.
+# Copyright 2020 Linaro
+#
+# Authors:
+#  Robert Foley <robert.foley@linaro.org>
+#  Originally based on ubuntu.i386 Fam Zheng <famz@redhat.com>
+#
+# This code is licensed under the GPL version 2 or later.  See
+# the COPYING file in the top-level directory.
+
+import os
+import subprocess
+import basevm
+
+class UbuntuVM(basevm.BaseVM):
+
+    def __init__(self, args, config=None):
+        self.login_prompt = "ubuntu-{}-guest login:".format(self.arch)
+        basevm.BaseVM.__init__(self, args, config)
+
+    def build_image(self, img):
+        """Build an Ubuntu VM image.  The child class will
+           define the install_cmds to init the VM."""
+        os_img = self._download_with_cache(self.image_link,
+                                           sha256sum=self.image_sha256)
+        img_tmp = img + ".tmp"
+        subprocess.check_call(["cp", "-f", os_img, img_tmp])
+        self.exec_qemu_img("resize", img_tmp, "+50G")
+        ci_img = self.gen_cloud_init_iso()
+
+        self.boot(img_tmp, extra_args = [ "-device", "VGA", "-cdrom", ci_img, ])
+
+        # First command we issue is fix for slow ssh login.
+        self.wait_ssh(wait_root=True,
+                      cmd="chmod -x /etc/update-motd.d/*")
+        # Wait for cloud init to finish
+        self.wait_ssh(wait_root=True,
+                      cmd="ls /var/lib/cloud/instance/boot-finished")
+        self.ssh_root("touch /etc/cloud/cloud-init.disabled")
+        # Disable auto upgrades.
+        # We want to keep the VM system state stable.
+        self.ssh_root('sed -ie \'s/"1"/"0"/g\' '\
+                      '/etc/apt/apt.conf.d/20auto-upgrades')
+        self.ssh_root("sed -ie s/^#\ deb-src/deb-src/g /etc/apt/sources.list")
+
+        # If the user chooses not to do the install phase,
+        # then we will jump right to the graceful shutdown
+        if self._config['install_cmds'] != "":
+            # Issue the install commands.
+            # This can be overriden by the user in the config .yml.
+            install_cmds = self._config['install_cmds'].split(',')
+            for cmd in install_cmds:
+                self.ssh_root(cmd)
+        self.graceful_shutdown()
+        os.rename(img_tmp, img)
+        return 0
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 06/18] tests/vm: Added a new script for ubuntu.aarch64.
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (4 preceding siblings ...)
  2020-06-22 14:31 ` [PATCH v1 05/18] tests/vm: Add common Ubuntu python module Alex Bennée
@ 2020-06-22 14:31 ` Alex Bennée
  2020-06-22 14:31 ` [PATCH v1 07/18] tests/vm: Added a new script for centos.aarch64 Alex Bennée
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, berrange, Robert Foley, Alex Bennée, richard.henderson,
	f4bug, Philippe Mathieu-Daudé,
	cota, Peter Puhov, aurelien

From: Robert Foley <robert.foley@linaro.org>

ubuntu.aarch64 provides a script to create an Ubuntu 18.04 VM.
Another new file is also added aarch64vm.py, which is a module with
common methods used by aarch64 VMs, such as how to create the
flash images.

Signed-off-by: Robert Foley <robert.foley@linaro.org>
Reviewed-by: Peter Puhov <peter.puhov@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200601211421.1277-6-robert.foley@linaro.org>
---
 configure                 |  20 +++++++
 tests/vm/Makefile.include |  11 ++++
 tests/vm/aarch64vm.py     | 106 ++++++++++++++++++++++++++++++++++++++
 tests/vm/basevm.py        |  12 +++++
 tests/vm/ubuntu.aarch64   |  68 ++++++++++++++++++++++++
 5 files changed, 217 insertions(+)
 create mode 100644 tests/vm/aarch64vm.py
 create mode 100755 tests/vm/ubuntu.aarch64

diff --git a/configure b/configure
index 6d14f2c2d6c..b4420e0c2a2 100755
--- a/configure
+++ b/configure
@@ -417,6 +417,7 @@ prefix="/usr/local"
 mandir="\${prefix}/share/man"
 datadir="\${prefix}/share"
 firmwarepath="\${prefix}/share/qemu-firmware"
+efi_aarch64=""
 qemu_docdir="\${prefix}/share/doc/qemu"
 bindir="\${prefix}/bin"
 libdir="\${prefix}/lib"
@@ -1107,6 +1108,8 @@ for opt do
   ;;
   --firmwarepath=*) firmwarepath="$optarg"
   ;;
+  --efi-aarch64=*) efi_aarch64="$optarg"
+  ;;
   --host=*|--build=*|\
   --disable-dependency-tracking|\
   --sbindir=*|--sharedstatedir=*|\
@@ -1777,6 +1780,7 @@ Advanced options (experts only):
   --sysconfdir=PATH        install config in PATH$confsuffix
   --localstatedir=PATH     install local state in PATH (set at runtime on win32)
   --firmwarepath=PATH      search PATH for firmware files
+  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
   --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
   --with-pkgversion=VERS   use specified string as sub-version of the package
   --enable-debug           enable common debug build options
@@ -3593,6 +3597,20 @@ EOF
   fi
 fi
 
+############################################
+# efi-aarch64 probe
+# Check for efi files needed by aarch64 VMs.
+# By default we will use the efi included with QEMU.
+# Allow user to override the path for efi also.
+if ! test -f "$efi_aarch64"; then
+  if test -f $source_path/pc-bios/edk2-aarch64-code.fd.bz2; then
+    # valid after build
+    efi_aarch64=$PWD/pc-bios/edk2-aarch64-code.fd
+  else
+    efi_aarch64=""
+  fi
+fi
+
 ##########################################
 # libcap-ng library probe
 if test "$cap_ng" != "no" ; then
@@ -6758,6 +6776,7 @@ if test "$docs" != "no"; then
     echo "sphinx-build      $sphinx_build"
 fi
 echo "genisoimage       $genisoimage"
+echo "efi_aarch64       $efi_aarch64"
 echo "python_yaml       $python_yaml"
 echo "slirp support     $slirp $(echo_version $slirp $slirp_version)"
 if test "$slirp" != "no" ; then
@@ -7838,6 +7857,7 @@ echo "PYTHON=$python" >> $config_host_mak
 echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
 echo "SPHINX_WERROR=$sphinx_werror" >> $config_host_mak
 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
+echo "EFI_AARCH64=$efi_aarch64" >> $config_host_mak
 echo "PYTHON_YAML=$python_yaml" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
 if $iasl -h > /dev/null 2>&1; then
diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
index f6c3892bb28..4fa292765d5 100644
--- a/tests/vm/Makefile.include
+++ b/tests/vm/Makefile.include
@@ -5,6 +5,9 @@
 IMAGES := freebsd netbsd openbsd centos fedora
 ifneq ($(GENISOIMAGE),)
 IMAGES += ubuntu.i386 centos
+ifneq ($(EFI_AARCH64),)
+IMAGES += ubuntu.aarch64
+endif
 endif
 
 IMAGES_DIR := $(HOME)/.cache/qemu-vm/images
@@ -23,6 +26,11 @@ vm-help vm-test:
 ifneq ($(GENISOIMAGE),)
 	@echo "  vm-build-centos                 - Build QEMU in CentOS VM, with Docker"
 	@echo "  vm-build-ubuntu.i386            - Build QEMU in ubuntu i386 VM"
+ifneq ($(EFI_AARCH64),)
+	@echo "  vm-build-ubuntu.aarch64         - Build QEMU in ubuntu aarch64 VM"
+else
+	@echo "  (to build centos/ubuntu aarch64 images use configure --efi-aarch64)"
+endif
 else
 	@echo "  (install genisoimage to build centos/ubuntu images)"
 endif
@@ -65,6 +73,7 @@ $(IMAGES_DIR)/%.img:	$(SRC_PATH)/tests/vm/% \
 		$(if $(V)$(DEBUG), --debug) \
 		$(if $(GENISOIMAGE),--genisoimage $(GENISOIMAGE)) \
 		$(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
+		$(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
 		--image "$@" \
 		--force \
 		--build-image $@, \
@@ -80,6 +89,7 @@ vm-build-%: $(IMAGES_DIR)/%.img
 		$(if $(J),--jobs $(J)) \
 		$(if $(V),--verbose) \
 		$(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
+		$(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
 		--image "$<" \
 		$(if $(BUILD_TARGET),--build-target $(BUILD_TARGET)) \
 		--snapshot \
@@ -102,6 +112,7 @@ vm-boot-ssh-%: $(IMAGES_DIR)/%.img
 		$(if $(J),--jobs $(J)) \
 		$(if $(V)$(DEBUG), --debug) \
 		$(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
+		$(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
 		--image "$<" \
 		--interactive \
 		false, \
diff --git a/tests/vm/aarch64vm.py b/tests/vm/aarch64vm.py
new file mode 100644
index 00000000000..bb04cb19c91
--- /dev/null
+++ b/tests/vm/aarch64vm.py
@@ -0,0 +1,106 @@
+#!/usr/bin/env python3
+#
+# VM testing aarch64 library
+#
+# Copyright 2020 Linaro
+#
+# Authors:
+#  Robert Foley <robert.foley@linaro.org>
+#
+# This code is licensed under the GPL version 2 or later.  See
+# the COPYING file in the top-level directory.
+#
+import os
+import sys
+import subprocess
+import basevm
+from qemu.accel import kvm_available
+
+# This is the config needed for current version of QEMU.
+# This works for both kvm and tcg.
+CURRENT_CONFIG = {
+    'cpu'          : "max",
+    'machine'      : "virt,gic-version=max",
+}
+
+# The minimum minor version of QEMU we will support with aarch64 VMs is 3.
+# QEMU versions less than 3 have various issues running these VMs.
+QEMU_AARCH64_MIN_VERSION = 3
+
+# The DEFAULT_CONFIG will default to a version of
+# parameters that works for backwards compatibility.
+DEFAULT_CONFIG = {'kvm' : {'cpu'          : "host",
+                           'machine'      : "virt,gic-version=host"},
+                  'tcg' : {'cpu'          : "cortex-a57",
+                           'machine'      : "virt"},
+}
+
+def get_config_defaults(vmcls, default_config):
+    """Fetch the configuration defaults for this VM,
+       taking into consideration the defaults for
+       aarch64 first, followed by the defaults for this VM."""
+    config = default_config
+    config.update(aarch_get_config_defaults(vmcls))
+    return config
+
+def aarch_get_config_defaults(vmcls):
+    """Set the defaults for current version of QEMU."""
+    config = CURRENT_CONFIG
+    args, argv = basevm.parse_args(vmcls)
+    qemu_path = basevm.get_qemu_path(vmcls.arch, args.build_path)
+    qemu_version = basevm.get_qemu_version(qemu_path)
+    if qemu_version < QEMU_AARCH64_MIN_VERSION:
+        error = "\nThis major version of QEMU {} is to old for aarch64 VMs.\n"\
+                "The major version must be at least {}.\n"\
+                "To continue with the current build of QEMU, "\
+                "please restart with QEMU_LOCAL=1 .\n"
+        print(error.format(qemu_version, QEMU_AARCH64_MIN_VERSION))
+        exit(1)
+    if qemu_version == QEMU_AARCH64_MIN_VERSION:
+        # We have an older version of QEMU,
+        # set the config values for backwards compatibility.
+        if kvm_available('aarch64'):
+            config.update(DEFAULT_CONFIG['kvm'])
+        else:
+            config.update(DEFAULT_CONFIG['tcg'])
+    return config
+
+def create_flash_images(flash_dir="./", efi_img=""):
+    """Creates the appropriate pflash files
+       for an aarch64 VM."""
+    flash0_path = get_flash_path(flash_dir, "flash0")
+    flash1_path = get_flash_path(flash_dir, "flash1")
+    fd_null = open(os.devnull, 'w')
+    subprocess.check_call(["dd", "if=/dev/zero", "of={}".format(flash0_path),
+                           "bs=1M", "count=64"],
+                           stdout=fd_null, stderr=subprocess.STDOUT)
+    # A reliable way to get the QEMU EFI image is via an installed package or
+    # via the bios included with qemu.
+    if not os.path.exists(efi_img):
+        sys.stderr.write("*** efi argument is invalid ({})\n".format(efi_img))
+        sys.stderr.write("*** please check --efi-aarch64 argument or "\
+                         "install qemu-efi-aarch64 package\n")
+        exit(3)
+    subprocess.check_call(["dd", "if={}".format(efi_img),
+                           "of={}".format(flash0_path),
+                           "conv=notrunc"],
+                           stdout=fd_null, stderr=subprocess.STDOUT)
+    subprocess.check_call(["dd", "if=/dev/zero",
+                           "of={}".format(flash1_path),
+                           "bs=1M", "count=64"],
+                           stdout=fd_null, stderr=subprocess.STDOUT)
+    fd_null.close()
+
+def get_pflash_args(flash_dir="./"):
+    """Returns a string that can be used to
+       boot qemu using the appropriate pflash files
+       for aarch64."""
+    flash0_path = get_flash_path(flash_dir, "flash0")
+    flash1_path = get_flash_path(flash_dir, "flash1")
+    pflash_args_str = "-drive file={},format=raw,if=pflash "\
+                      "-drive file={},format=raw,if=pflash"
+    pflash_args = pflash_args_str.format(flash0_path, flash1_path)
+    return pflash_args.split(" ")
+
+def get_flash_path(flash_dir, name):
+    return os.path.join(flash_dir, "{}.img".format(name))
diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index fa56fbbb4b6..5fd66f6b26a 100644
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -92,6 +92,7 @@ class BaseVM(object):
         self._guest = None
         self._genisoimage = args.genisoimage
         self._build_path = args.build_path
+        self._efi_aarch64 = args.efi_aarch64
         # Allow input config to override defaults.
         self._config = DEFAULT_CONFIG.copy()
         if config != None:
@@ -496,6 +497,14 @@ def get_qemu_path(arch, build_path=None):
         qemu_path = "qemu-system-" + arch
     return qemu_path
 
+def get_qemu_version(qemu_path):
+    """Get the version number from the current QEMU,
+       and return the major number."""
+    output = subprocess.check_output([qemu_path, '--version'])
+    version_line = output.decode("utf-8")
+    version_num = re.split(' |\(', version_line)[3].split('.')[0]
+    return int(version_num)
+
 def parse_config(config, args):
     """ Parse yaml config and populate our config structure.
         The yaml config allows the user to override the
@@ -573,6 +582,9 @@ def parse_args(vmcls):
     parser.add_option("--config", "-c", default=None,
                       help="Provide config yaml for configuration. "\
                            "See config_example.yaml for example.")
+    parser.add_option("--efi-aarch64",
+                      default="/usr/share/qemu-efi-aarch64/QEMU_EFI.fd",
+                      help="Path to efi image for aarch64 VMs.")
     parser.disable_interspersed_args()
     return parser.parse_args()
 
diff --git a/tests/vm/ubuntu.aarch64 b/tests/vm/ubuntu.aarch64
new file mode 100755
index 00000000000..21d454c27f1
--- /dev/null
+++ b/tests/vm/ubuntu.aarch64
@@ -0,0 +1,68 @@
+#!/usr/bin/env python3
+#
+# Ubuntu aarch64 image
+#
+# Copyright 2020 Linaro
+#
+# Authors:
+#  Robert Foley <robert.foley@linaro.org>
+#  Originally based on ubuntu.i386 Fam Zheng <famz@redhat.com>
+#
+# This code is licensed under the GPL version 2 or later.  See
+# the COPYING file in the top-level directory.
+#
+
+import sys
+import basevm
+import aarch64vm
+import ubuntuvm
+
+DEFAULT_CONFIG = {
+    'cpu'          : "cortex-a57",
+    'machine'      : "virt,gic-version=3",
+    'install_cmds' : "apt-get update,"\
+                     "apt-get build-dep -y --arch-only qemu,"\
+                     "apt-get install -y libfdt-dev pkg-config language-pack-en",
+    # We increase beyond the default time since during boot
+    # it can take some time (many seconds) to log into the VM
+    # especially using softmmu.
+    'ssh_timeout'  : 60,
+}
+
+class UbuntuAarch64VM(ubuntuvm.UbuntuVM):
+    name = "ubuntu.aarch64"
+    arch = "aarch64"
+    image_name = "ubuntu-18.04-server-cloudimg-arm64.img"
+    image_link = "https://cloud-images.ubuntu.com/releases/18.04/release/" + image_name
+    image_sha256="0fdcba761965735a8a903d8b88df8e47f156f48715c00508e4315c506d7d3cb1"
+    BUILD_SCRIPT = """
+        set -e;
+        cd $(mktemp -d);
+        sudo chmod a+r /dev/vdb;
+        tar --checkpoint=.10 -xf /dev/vdb;
+        ./configure {configure_opts};
+        make --output-sync {target} -j{jobs} {verbose};
+    """
+    def boot(self, img, extra_args=None):
+        aarch64vm.create_flash_images(self._tmpdir, self._efi_aarch64)
+        default_args = aarch64vm.get_pflash_args(self._tmpdir)
+        if extra_args:
+            extra_args.extend(default_args)
+        else:
+            extra_args = default_args
+        # We always add these performance tweaks
+        # because without them, we boot so slowly that we
+        # can time out finding the boot efi device.
+        if '-smp' not in extra_args and \
+           '-smp' not in self._config['extra_args'] and \
+           '-smp' not in self._args:
+            # Only add if not already there to give caller option to change it.
+            extra_args.extend(["-smp", "8"])
+
+        # We have overridden boot() since aarch64 has additional parameters.
+        # Call down to the base class method.
+        super(UbuntuAarch64VM, self).boot(img, extra_args=extra_args)
+
+if __name__ == "__main__":
+    defaults = aarch64vm.get_config_defaults(UbuntuAarch64VM, DEFAULT_CONFIG)
+    sys.exit(basevm.main(UbuntuAarch64VM, defaults))
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 07/18] tests/vm: Added a new script for centos.aarch64.
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (5 preceding siblings ...)
  2020-06-22 14:31 ` [PATCH v1 06/18] tests/vm: Added a new script for ubuntu.aarch64 Alex Bennée
@ 2020-06-22 14:31 ` Alex Bennée
  2020-06-22 14:31 ` [PATCH v1 08/18] tests/vm: change scripts to use self._config Alex Bennée
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, berrange, Robert Foley, Alex Bennée, richard.henderson,
	f4bug, Philippe Mathieu-Daudé,
	cota, Peter Puhov, aurelien

From: Robert Foley <robert.foley@linaro.org>

centos.aarch64 creates a CentOS 8 image.
Also added a new kickstart script used to build the centos.aarch64 image.

Signed-off-by: Robert Foley <robert.foley@linaro.org>
Reviewed-by: Peter Puhov <peter.puhov@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200601211421.1277-7-robert.foley@linaro.org>
---
 tests/vm/Makefile.include    |   3 +-
 tests/vm/centos-8-aarch64.ks |  51 ++++++++
 tests/vm/centos.aarch64      | 227 +++++++++++++++++++++++++++++++++++
 3 files changed, 280 insertions(+), 1 deletion(-)
 create mode 100644 tests/vm/centos-8-aarch64.ks
 create mode 100755 tests/vm/centos.aarch64

diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
index 4fa292765d5..39f918a430a 100644
--- a/tests/vm/Makefile.include
+++ b/tests/vm/Makefile.include
@@ -6,7 +6,7 @@ IMAGES := freebsd netbsd openbsd centos fedora
 ifneq ($(GENISOIMAGE),)
 IMAGES += ubuntu.i386 centos
 ifneq ($(EFI_AARCH64),)
-IMAGES += ubuntu.aarch64
+IMAGES += ubuntu.aarch64 centos.aarch64
 endif
 endif
 
@@ -28,6 +28,7 @@ ifneq ($(GENISOIMAGE),)
 	@echo "  vm-build-ubuntu.i386            - Build QEMU in ubuntu i386 VM"
 ifneq ($(EFI_AARCH64),)
 	@echo "  vm-build-ubuntu.aarch64         - Build QEMU in ubuntu aarch64 VM"
+	@echo "  vm-build-centos.aarch64         - Build QEMU in CentOS aarch64 VM"
 else
 	@echo "  (to build centos/ubuntu aarch64 images use configure --efi-aarch64)"
 endif
diff --git a/tests/vm/centos-8-aarch64.ks b/tests/vm/centos-8-aarch64.ks
new file mode 100644
index 00000000000..fd6ebe4d49e
--- /dev/null
+++ b/tests/vm/centos-8-aarch64.ks
@@ -0,0 +1,51 @@
+# CentOS aarch64 image kickstart file.
+# This file is used by the CentOS installer to
+# script the generation of the image.
+#
+# Copyright 2020 Linaro
+#
+ignoredisk --only-use=vda
+# System bootloader configuration
+bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=vda
+autopart --type=plain
+# Partition clearing information
+clearpart --linux --initlabel --drives=vda
+# Use text mode install
+text
+repo --name="AppStream" --baseurl=file:///run/install/repo/AppStream
+# Use CDROM installation media
+cdrom
+# Keyboard layouts
+keyboard --vckeymap=us --xlayouts=''
+# System language
+lang en_US.UTF-8
+
+# Network information
+network  --bootproto=dhcp --device=enp0s1 --onboot=off --ipv6=auto --no-activate
+network  --hostname=localhost.localdomain
+# Run the Setup Agent on first boot
+firstboot --enable
+# Do not configure the X Window System
+skipx
+# System services
+services --enabled="chronyd"
+# System timezone
+timezone America/New_York --isUtc
+
+# Shutdown after installation is complete.
+shutdown
+
+%packages
+@^server-product-environment
+kexec-tools
+
+%end
+
+%addon com_redhat_kdump --enable --reserve-mb='auto'
+
+%end
+%anaconda
+pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
+pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
+pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
+%end
diff --git a/tests/vm/centos.aarch64 b/tests/vm/centos.aarch64
new file mode 100755
index 00000000000..d5232ecdb8c
--- /dev/null
+++ b/tests/vm/centos.aarch64
@@ -0,0 +1,227 @@
+#!/usr/bin/env python3
+#
+# Centos aarch64 image
+#
+# Copyright 2020 Linaro
+#
+# Authors:
+#  Robert Foley <robert.foley@linaro.org>
+#  Originally based on ubuntu.aarch64
+#
+# This code is licensed under the GPL version 2 or later.  See
+# the COPYING file in the top-level directory.
+#
+
+import os
+import sys
+import subprocess
+import basevm
+import time
+import traceback
+import aarch64vm
+
+DEFAULT_CONFIG = {
+    'cpu'          : "max",
+    'machine'      : "virt,gic-version=max",
+    'install_cmds' : "yum install -y make git python3 gcc gcc-c++ flex bison, "\
+        "yum install -y glib2-devel pixman-devel zlib-devel, "\
+        "yum install -y perl-Test-Harness, "\
+        "alternatives --set python /usr/bin/python3, "\
+        "sudo dnf config-manager "\
+        "--add-repo=https://download.docker.com/linux/centos/docker-ce.repo,"\
+        "sudo dnf install --nobest -y docker-ce.aarch64,"\
+        "systemctl enable docker",
+    # We increase beyond the default time since during boot
+    # it can take some time (many seconds) to log into the VM.
+    'ssh_timeout'  : 60,
+}
+
+class CentosAarch64VM(basevm.BaseVM):
+    name = "centos.aarch64"
+    arch = "aarch64"
+    login_prompt = "localhost login:"
+    prompt = '[root@localhost ~]#'
+    image_name = "CentOS-8-aarch64-1905-dvd1.iso"
+    image_link = "http://mirrors.usc.edu/pub/linux/distributions/centos/8.0.1905/isos/aarch64/"
+    image_link += image_name
+    BUILD_SCRIPT = """
+        set -e;
+        cd $(mktemp -d);
+        sudo chmod a+r /dev/vdb;
+        tar --checkpoint=.10 -xf /dev/vdb;
+        ./configure {configure_opts};
+        make --output-sync {target} -j{jobs} {verbose};
+    """
+    def set_key_perm(self):
+        """Set permissions properly on certain files to allow
+           ssh access."""
+        self.console_wait_send(self.prompt,
+                               "/usr/sbin/restorecon -R -v /root/.ssh\n")
+        self.console_wait_send(self.prompt,
+                "/usr/sbin/restorecon -R -v "\
+                "/home/{}/.ssh\n".format(self._config["guest_user"]))
+
+    def create_kickstart(self):
+        """Generate the kickstart file used to generate the centos image."""
+        # Start with the template for the kickstart.
+        ks_file = "../tests/vm/centos-8-aarch64.ks"
+        subprocess.check_call("cp {} ./ks.cfg".format(ks_file), shell=True)
+        # Append the ssh keys to the kickstart file
+        # as the post processing phase of installation.
+        with open("ks.cfg", "a") as f:
+            # Add in the root pw and guest user.
+            rootpw = "rootpw --plaintext {}\n"
+            f.write(rootpw.format(self._config["root_pass"]))
+            add_user = "user --groups=wheel --name={} "\
+                       "--password={} --plaintext\n"
+            f.write(add_user.format(self._config["guest_user"],
+                                    self._config["guest_pass"]))
+            # Add the ssh keys.
+            f.write("%post --log=/root/ks-post.log\n")
+            f.write("mkdir -p /root/.ssh\n")
+            addkey = 'echo "{}" >> /root/.ssh/authorized_keys\n'
+            addkey_cmd = addkey.format(self._config["ssh_pub_key"])
+            f.write(addkey_cmd)
+            f.write('mkdir -p /home/{}/.ssh\n'.format(self._config["guest_user"]))
+            addkey = 'echo "{}" >> /home/{}/.ssh/authorized_keys\n'
+            addkey_cmd = addkey.format(self._config["ssh_pub_key"],
+                                       self._config["guest_user"])
+            f.write(addkey_cmd)
+            f.write("%end\n")
+        # Take our kickstart file and create an .iso from it.
+        # The .iso will be provided to qemu as we boot
+        # from the install dvd.
+        # Anaconda will recognize the label "OEMDRV" and will
+        # start the automated installation.
+        gen_iso_img = 'genisoimage -output ks.iso -volid "OEMDRV" ks.cfg'
+        subprocess.check_call(gen_iso_img, shell=True)
+
+    def wait_for_shutdown(self):
+        """We wait for qemu to shutdown the VM and exit.
+           While this happens we display the console view
+           for easier debugging."""
+        # The image creation is essentially done,
+        # so whether or not the wait is successful we want to
+        # wait for qemu to exit (the self.wait()) before we return.
+        try:
+            self.console_wait("reboot: Power down")
+        except Exception as e:
+            sys.stderr.write("Exception hit\n")
+            if isinstance(e, SystemExit) and e.code == 0:
+                return 0
+            traceback.print_exc()
+        finally:
+            self.wait()
+
+    def build_base_image(self, dest_img):
+        """Run through the centos installer to create
+           a base image with name dest_img."""
+        # We create the temp image, and only rename
+        # to destination when we are done.
+        img = dest_img + ".tmp"
+        # Create an empty image.
+        # We will provide this as the install destination.
+        qemu_img_create = "qemu-img create {} 50G".format(img)
+        subprocess.check_call(qemu_img_create, shell=True)
+
+        # Create our kickstart file to be fed to the installer.
+        self.create_kickstart()
+        # Boot the install dvd with the params as our ks.iso
+        os_img = self._download_with_cache(self.image_link)
+        dvd_iso = "centos-8-dvd.iso"
+        subprocess.check_call(["cp", "-f", os_img, dvd_iso])
+        extra_args = "-cdrom ks.iso"
+        extra_args += " -drive file={},if=none,id=drive1,cache=writeback"
+        extra_args += " -device virtio-blk,drive=drive1,bootindex=1"
+        extra_args = extra_args.format(dvd_iso).split(" ")
+        self.boot(img, extra_args=extra_args)
+        self.console_wait_send("change the selection", "\n")
+        # We seem to need to hit esc (chr(27)) twice to abort the
+        # media check, which takes a long time.
+        # Waiting a bit seems to be more reliable before hitting esc.
+        self.console_wait("Checking")
+        time.sleep(5)
+        self.console_wait_send("Checking", chr(27))
+        time.sleep(5)
+        self.console_wait_send("Checking", chr(27))
+        print("Found Checking")
+        # Give sufficient time for the installer to create the image.
+        self.console_init(timeout=7200)
+        self.wait_for_shutdown()
+        os.rename(img, dest_img)
+        print("Done with base image build: {}".format(dest_img))
+
+    def check_create_base_img(self, img_base, img_dest):
+        """Create a base image using the installer.
+           We will use the base image if it exists.
+           This helps cut down on install time in case we
+           need to restart image creation,
+           since the base image creation can take a long time."""
+        if not os.path.exists(img_base):
+            print("Generate new base image: {}".format(img_base))
+            self.build_base_image(img_base);
+        else:
+            print("Use existing base image: {}".format(img_base))
+        # Save a copy of the base image and copy it to dest.
+        # which we will use going forward.
+        subprocess.check_call(["cp", img_base, img_dest])
+
+    def boot(self, img, extra_args=None):
+        aarch64vm.create_flash_images(self._tmpdir, self._efi_aarch64)
+        default_args = aarch64vm.get_pflash_args(self._tmpdir)
+        if extra_args:
+            extra_args.extend(default_args)
+        else:
+            extra_args = default_args
+        # We always add these performance tweaks
+        # because without them, we boot so slowly that we
+        # can time out finding the boot efi device.
+        if '-smp' not in extra_args and \
+           '-smp' not in self._config['extra_args'] and \
+           '-smp' not in self._args:
+            # Only add if not already there to give caller option to change it.
+            extra_args.extend(["-smp", "8"])
+        # We have overridden boot() since aarch64 has additional parameters.
+        # Call down to the base class method.
+        super(CentosAarch64VM, self).boot(img, extra_args=extra_args)
+
+    def build_image(self, img):
+        img_tmp = img + ".tmp"
+        self.check_create_base_img(img + ".base", img_tmp)
+
+        # Boot the new image for the first time to finish installation.
+        self.boot(img_tmp)
+        self.console_init()
+        self.console_wait_send(self.login_prompt, "root\n")
+        self.console_wait_send("Password:",
+                               "{}\n".format(self._config["root_pass"]))
+
+        self.set_key_perm()
+        self.console_wait_send(self.prompt, "rpm -q centos-release\n")
+        enable_adapter = "sed -i 's/ONBOOT=no/ONBOOT=yes/g'" \
+                         " /etc/sysconfig/network-scripts/ifcfg-enp0s1\n"
+        self.console_wait_send(self.prompt, enable_adapter)
+        self.console_wait_send(self.prompt, "ifup enp0s1\n")
+        self.console_wait_send(self.prompt,
+                               'echo "qemu  ALL=(ALL) NOPASSWD:ALL" | '\
+                               'sudo tee /etc/sudoers.d/qemu\n')
+        self.console_wait(self.prompt)
+
+        # Rest of the commands we issue through ssh.
+        self.wait_ssh(wait_root=True)
+
+        # If the user chooses *not* to do the second phase,
+        # then we will jump right to the graceful shutdown
+        if self._config['install_cmds'] != "":
+            install_cmds = self._config['install_cmds'].split(',')
+            for cmd in install_cmds:
+                self.ssh_root(cmd)
+        self.ssh_root("poweroff")
+        self.wait_for_shutdown()
+        os.rename(img_tmp, img)
+        print("image creation complete: {}".format(img))
+        return 0
+
+if __name__ == "__main__":
+    defaults = aarch64vm.get_config_defaults(CentosAarch64VM, DEFAULT_CONFIG)
+    sys.exit(basevm.main(CentosAarch64VM, defaults))
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 08/18] tests/vm: change scripts to use self._config
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (6 preceding siblings ...)
  2020-06-22 14:31 ` [PATCH v1 07/18] tests/vm: Added a new script for centos.aarch64 Alex Bennée
@ 2020-06-22 14:31 ` Alex Bennée
  2020-06-22 14:31 ` [PATCH v1 09/18] python/qemu: Add ConsoleSocket for optional use in QEMUMachine Alex Bennée
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, berrange, Robert Foley, Alex Bennée, richard.henderson,
	f4bug, Philippe Mathieu-Daudé,
	cota, Peter Puhov, aurelien

From: Robert Foley <robert.foley@linaro.org>

This change converts existing scripts to using for example self.ROOT_PASS,
to self._config['root_pass'].
We made similar changes for GUEST_USER, and GUEST_PASS.
This allows us also to remove the change in basevm.py,
which adds __getattr__ for backwards compatibility.

Signed-off-by: Robert Foley <robert.foley@linaro.org>
Reviewed-by: Peter Puhov <peter.puhov@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200601211421.1277-8-robert.foley@linaro.org>
---
 tests/vm/basevm.py | 11 ++---------
 tests/vm/fedora    | 17 +++++++++--------
 tests/vm/freebsd   | 16 ++++++++--------
 tests/vm/netbsd    | 19 ++++++++++---------
 tests/vm/openbsd   | 17 +++++++++--------
 5 files changed, 38 insertions(+), 42 deletions(-)

diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 5fd66f6b26a..f716798b405 100644
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -183,13 +183,6 @@ class BaseVM(object):
         self.console_init(timeout=timeout)
         self.console_wait(wait_string)
 
-    def __getattr__(self, name):
-        # Support direct access to config by key.
-        # for example, access self._config['cpu'] by self.cpu
-        if name.lower() in self._config.keys():
-            return self._config[name.lower()]
-        return object.__getattribute__(self, name)
-
     def _download_with_cache(self, url, sha256sum=None, sha512sum=None):
         def check_sha256sum(fname):
             if not sha256sum:
@@ -239,13 +232,13 @@ class BaseVM(object):
         return r
 
     def ssh(self, *cmd):
-        return self._ssh_do(self.GUEST_USER, cmd, False)
+        return self._ssh_do(self._config["guest_user"], cmd, False)
 
     def ssh_root(self, *cmd):
         return self._ssh_do("root", cmd, False)
 
     def ssh_check(self, *cmd):
-        self._ssh_do(self.GUEST_USER, cmd, True)
+        self._ssh_do(self._config["guest_user"], cmd, True)
 
     def ssh_root_check(self, *cmd):
         self._ssh_do("root", cmd, True)
diff --git a/tests/vm/fedora b/tests/vm/fedora
index a9195670f4b..b2b478fdbca 100755
--- a/tests/vm/fedora
+++ b/tests/vm/fedora
@@ -108,20 +108,20 @@ class FedoraVM(basevm.BaseVM):
 
         self.console_wait_send("7) [!] Root password",     "7\n")
         self.console_wait("Password:")
-        self.console_send("%s\n" % self.ROOT_PASS)
+        self.console_send("%s\n" % self._config["root_pass"])
         self.console_wait("Password (confirm):")
-        self.console_send("%s\n" % self.ROOT_PASS)
+        self.console_send("%s\n" % self._config["root_pass"])
 
         self.console_wait_send("8) [ ] User creation",     "8\n")
         self.console_wait_send("1) [ ] Create user",       "1\n")
         self.console_wait_send("3) User name",             "3\n")
-        self.console_wait_send("ENTER:", "%s\n" % self.GUEST_USER)
+        self.console_wait_send("ENTER:", "%s\n" % self._config["guest_user"])
         self.console_wait_send("4) [ ] Use password",      "4\n")
         self.console_wait_send("5) Password",              "5\n")
         self.console_wait("Password:")
-        self.console_send("%s\n" % self.GUEST_PASS)
+        self.console_send("%s\n" % self._config["guest_pass"])
         self.console_wait("Password (confirm):")
-        self.console_send("%s\n" % self.GUEST_PASS)
+        self.console_send("%s\n" % self._config["guest_pass"])
         self.console_wait_send("7) Groups",                "c\n")
 
         while True:
@@ -139,7 +139,7 @@ class FedoraVM(basevm.BaseVM):
             if good:
                 break
             time.sleep(10)
-            self.console_send("r\n" % self.GUEST_PASS)
+            self.console_send("r\n" % self._config["guest_pass"])
 
         self.console_wait_send("'b' to begin install",     "b\n")
 
@@ -150,12 +150,13 @@ class FedoraVM(basevm.BaseVM):
 
         # setup qemu user
         prompt = " ~]$"
-        self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS)
+        self.console_ssh_init(prompt, self._config["guest_user"],
+                                      self._config["guest_pass"])
         self.console_wait_send(prompt, "exit\n")
 
         # setup root user
         prompt = " ~]#"
-        self.console_ssh_init(prompt, "root", self.ROOT_PASS)
+        self.console_ssh_init(prompt, "root", self._config["root_pass"])
         self.console_sshd_config(prompt)
 
         # setup virtio-blk #1 (tarfile)
diff --git a/tests/vm/freebsd b/tests/vm/freebsd
index f87db2b126e..29252fa4a64 100755
--- a/tests/vm/freebsd
+++ b/tests/vm/freebsd
@@ -113,9 +113,9 @@ class FreeBSDVM(basevm.BaseVM):
 
         # post-install configuration
         self.console_wait("New Password:")
-        self.console_send("%s\n" % self.ROOT_PASS)
+        self.console_send("%s\n" % self._config["root_pass"])
         self.console_wait("Retype New Password:")
-        self.console_send("%s\n" % self.ROOT_PASS)
+        self.console_send("%s\n" % self._config["root_pass"])
 
         self.console_wait_send("Network Configuration", "\n")
         self.console_wait_send("IPv4",                  "y")
@@ -134,9 +134,9 @@ class FreeBSDVM(basevm.BaseVM):
         # qemu user
         self.console_wait_send("Add User Accounts", "y")
         self.console_wait("Username")
-        self.console_send("%s\n" % self.GUEST_USER)
+        self.console_send("%s\n" % self._config["guest_user"])
         self.console_wait("Full name")
-        self.console_send("%s\n" % self.GUEST_USER)
+        self.console_send("%s\n" % self._config["guest_user"])
         self.console_wait_send("Uid",                   "\n")
         self.console_wait_send("Login group",           "\n")
         self.console_wait_send("Login group",           "\n")
@@ -148,9 +148,9 @@ class FreeBSDVM(basevm.BaseVM):
         self.console_wait_send("Use an empty password", "\n")
         self.console_wait_send("Use a random password", "\n")
         self.console_wait("Enter password:")
-        self.console_send("%s\n" % self.GUEST_PASS)
+        self.console_send("%s\n" % self._config["guest_pass"])
         self.console_wait("Enter password again:")
-        self.console_send("%s\n" % self.GUEST_PASS)
+        self.console_send("%s\n" % self._config["guest_pass"])
         self.console_wait_send("Lock out",              "\n")
         self.console_wait_send("OK",                    "yes\n")
         self.console_wait_send("Add another user",      "no\n")
@@ -164,12 +164,12 @@ class FreeBSDVM(basevm.BaseVM):
 
         # setup qemu user
         prompt = "$"
-        self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS)
+        self.console_ssh_init(prompt, self._config["guest_user"], self._config["guest_pass"])
         self.console_wait_send(prompt, "exit\n")
 
         # setup root user
         prompt = "root@freebsd:~ #"
-        self.console_ssh_init(prompt, "root", self.ROOT_PASS)
+        self.console_ssh_init(prompt, "root", self._config["root_pass"])
         self.console_sshd_config(prompt)
 
         # setup serial console
diff --git a/tests/vm/netbsd b/tests/vm/netbsd
index cdac502dad8..dc0e45c1d45 100755
--- a/tests/vm/netbsd
+++ b/tests/vm/netbsd
@@ -120,24 +120,24 @@ class NetBSDVM(basevm.BaseVM):
         self.console_wait_send("d: Change root password",  "d\n")
         self.console_wait_send("a: Yes",                   "a\n")
         self.console_wait("New password:")
-        self.console_send("%s\n" % self.ROOT_PASS)
+        self.console_send("%s\n" % self._config["root_pass"])
         self.console_wait("New password:")
-        self.console_send("%s\n" % self.ROOT_PASS)
+        self.console_send("%s\n" % self._config["root_pass"])
         self.console_wait("Retype new password:")
-        self.console_send("%s\n" % self.ROOT_PASS)
+        self.console_send("%s\n" % self._config["root_pass"])
 
         self.console_wait_send("o: Add a user",            "o\n")
         self.console_wait("username")
-        self.console_send("%s\n" % self.GUEST_USER)
+        self.console_send("%s\n" % self._config["guest_pass"])
         self.console_wait("to group wheel")
         self.console_wait_send("a: Yes",                   "a\n")
         self.console_wait_send("a: /bin/sh",               "a\n")
         self.console_wait("New password:")
-        self.console_send("%s\n" % self.GUEST_PASS)
+        self.console_send("%s\n" % self._config["guest_pass"])
         self.console_wait("New password:")
-        self.console_send("%s\n" % self.GUEST_PASS)
+        self.console_send("%s\n" % self._config["guest_pass"])
         self.console_wait("Retype new password:")
-        self.console_send("%s\n" % self.GUEST_PASS)
+        self.console_send("%s\n" % self._config["guest_pass"])
 
         self.console_wait_send("a: Configure network",     "a\n")
         self.console_wait_send("a: vioif0",                "a\n")
@@ -170,12 +170,13 @@ class NetBSDVM(basevm.BaseVM):
 
         # setup qemu user
         prompt = "localhost$"
-        self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS)
+        self.console_ssh_init(prompt, self._config["guest_user"],
+                                      self._config["guest_pass"])
         self.console_wait_send(prompt, "exit\n")
 
         # setup root user
         prompt = "localhost#"
-        self.console_ssh_init(prompt, "root", self.ROOT_PASS)
+        self.console_ssh_init(prompt, "root", self._config["root_pass"])
         self.console_sshd_config(prompt)
 
         # setup virtio-blk #1 (tarfile)
diff --git a/tests/vm/openbsd b/tests/vm/openbsd
index 13e7f9a6d56..dfe633e4532 100755
--- a/tests/vm/openbsd
+++ b/tests/vm/openbsd
@@ -98,9 +98,9 @@ class OpenBSDVM(basevm.BaseVM):
         self.console_wait_send("Which network interface", "done\n")
         self.console_wait_send("DNS domain name",         "localnet\n")
         self.console_wait("Password for root account")
-        self.console_send("%s\n" % self.ROOT_PASS)
+        self.console_send("%s\n" % self._config["root_pass"])
         self.console_wait("Password for root account")
-        self.console_send("%s\n" % self.ROOT_PASS)
+        self.console_send("%s\n" % self._config["root_pass"])
         self.console_wait_send("Start sshd(8)",           "yes\n")
         self.console_wait_send("X Window System",         "\n")
         self.console_wait_send("xenodm",                  "\n")
@@ -108,13 +108,13 @@ class OpenBSDVM(basevm.BaseVM):
         self.console_wait_send("Which speed",             "\n")
 
         self.console_wait("Setup a user")
-        self.console_send("%s\n" % self.GUEST_USER)
+        self.console_send("%s\n" % self._config["guest_user"])
         self.console_wait("Full name")
-        self.console_send("%s\n" % self.GUEST_USER)
+        self.console_send("%s\n" % self._config["guest_user"])
         self.console_wait("Password")
-        self.console_send("%s\n" % self.GUEST_PASS)
+        self.console_send("%s\n" % self._config["guest_pass"])
         self.console_wait("Password")
-        self.console_send("%s\n" % self.GUEST_PASS)
+        self.console_send("%s\n" % self._config["guest_pass"])
 
         self.console_wait_send("Allow root ssh login",    "yes\n")
         self.console_wait_send("timezone",                "UTC\n")
@@ -135,12 +135,13 @@ class OpenBSDVM(basevm.BaseVM):
 
         # setup qemu user
         prompt = "$"
-        self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS)
+        self.console_ssh_init(prompt, self._config["guest_user"],
+                                      self._config["guest_pass"])
         self.console_wait_send(prompt, "exit\n")
 
         # setup root user
         prompt = "openbsd#"
-        self.console_ssh_init(prompt, "root", self.ROOT_PASS)
+        self.console_ssh_init(prompt, "root", self._config["root_pass"])
         self.console_sshd_config(prompt)
 
         # setup virtio-blk #1 (tarfile)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v1 09/18] python/qemu: Add ConsoleSocket for optional use in QEMUMachine
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (7 preceding siblings ...)
  2020-06-22 14:31 ` [PATCH v1 08/18] tests/vm: change scripts to use self._config Alex Bennée
@ 2020-06-22 14:31 ` Alex Bennée
  2020-06-22 14:31 ` [PATCH v1 10/18] tests/vm: Add workaround to consume console Alex Bennée
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, berrange, Robert Foley, Alex Bennée, richard.henderson,
	f4bug, Philippe Mathieu-Daudé,
	cota, Cleber Rosa, Peter Puhov, aurelien, Eduardo Habkost

From: Robert Foley <robert.foley@linaro.org>

We add the ConsoleSocket object, which has a socket interface
and which will consume all arriving characters on the
socket, placing them into an in memory buffer.
This will also provide those chars via recv() as
would a regular socket.
ConsoleSocket also has the option of dumping
the console bytes to a log file.

We also give QEMUMachine the option of using ConsoleSocket
to drain and to use for logging console to a file.
By default QEMUMachine does not use ConsoleSocket.

This is added in preparation for use by basevm.py in a later commit.
This is a workaround we found was needed for basevm.py since
there is a known issue where QEMU will hang waiting
for console characters to be consumed.

Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Cleber Rosa <crosa@redhat.com>
Signed-off-by: Robert Foley <robert.foley@linaro.org>
Reviewed-by: Peter Puhov <peter.puhov@linaro.org>
Acked-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200601211421.1277-9-robert.foley@linaro.org>
---
 python/qemu/console_socket.py | 110 ++++++++++++++++++++++++++++++++++
 python/qemu/machine.py        |  23 +++++--
 2 files changed, 129 insertions(+), 4 deletions(-)
 create mode 100644 python/qemu/console_socket.py

diff --git a/python/qemu/console_socket.py b/python/qemu/console_socket.py
new file mode 100644
index 00000000000..830cb7c6282
--- /dev/null
+++ b/python/qemu/console_socket.py
@@ -0,0 +1,110 @@
+#!/usr/bin/env python3
+#
+# This python module implements a ConsoleSocket object which is
+# designed always drain the socket itself, and place
+# the bytes into a in memory buffer for later processing.
+#
+# Optionally a file path can be passed in and we will also
+# dump the characters to this file for debug.
+#
+# Copyright 2020 Linaro
+#
+# Authors:
+#  Robert Foley <robert.foley@linaro.org>
+#
+# This code is licensed under the GPL version 2 or later.  See
+# the COPYING file in the top-level directory.
+#
+import asyncore
+import socket
+import threading
+import io
+import os
+import sys
+from collections import deque
+import time
+import traceback
+
+class ConsoleSocket(asyncore.dispatcher):
+
+    def __init__(self, address, file=None):
+        self._recv_timeout_sec = 300
+        self._buffer = deque()
+        self._asyncore_thread = None
+        self._sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+        self._sock.connect(address)
+        self._logfile = None
+        if file:
+            self._logfile = open(file, "w")
+        asyncore.dispatcher.__init__(self, sock=self._sock)
+        self._open = True
+        self._thread_start()
+
+    def _thread_start(self):
+        """Kick off a thread to wait on the asyncore.loop"""
+        if self._asyncore_thread is not None:
+            return
+        self._asyncore_thread = threading.Thread(target=asyncore.loop,
+                                                 kwargs={'timeout':1})
+        self._asyncore_thread.daemon = True
+        self._asyncore_thread.start()
+
+    def handle_close(self):
+        """redirect close to base class"""
+        # Call the base class close, but not self.close() since
+        # handle_close() occurs in the context of the thread which
+        # self.close() attempts to join.
+        asyncore.dispatcher.close(self)
+
+    def close(self):
+        """Close the base object and wait for the thread to terminate"""
+        if self._open:
+            self._open = False
+            asyncore.dispatcher.close(self)
+            if self._asyncore_thread is not None:
+                thread, self._asyncore_thread = self._asyncore_thread, None
+                thread.join()
+            if self._logfile:
+                self._logfile.close()
+                self._logfile = None
+
+    def handle_read(self):
+        """process arriving characters into in memory _buffer"""
+        try:
+            data = asyncore.dispatcher.recv(self, 1)
+            # latin1 is needed since there are some chars
+            # we are receiving that cannot be encoded to utf-8
+            # such as 0xe2, 0x80, 0xA6.
+            string = data.decode("latin1")
+        except:
+            print("Exception seen.")
+            traceback.print_exc()
+            return
+        if self._logfile:
+            self._logfile.write("{}".format(string))
+            self._logfile.flush()
+        for c in string:
+            self._buffer.extend(c)
+
+    def recv(self, n=1, sleep_delay_s=0.1):
+        """Return chars from in memory buffer"""
+        start_time = time.time()
+        while len(self._buffer) < n:
+            time.sleep(sleep_delay_s)
+            elapsed_sec = time.time() - start_time
+            if elapsed_sec > self._recv_timeout_sec:
+                raise socket.timeout
+        chars = ''.join([self._buffer.popleft() for i in range(n)])
+        # We choose to use latin1 to remain consistent with
+        # handle_read() and give back the same data as the user would
+        # receive if they were reading directly from the
+        # socket w/o our intervention.
+        return chars.encode("latin1")
+
+    def set_blocking(self):
+        """Maintain compatibility with socket API"""
+        pass
+
+    def settimeout(self, seconds):
+        """Set current timeout on recv"""
+        self._recv_timeout_sec = seconds
diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index 041c615052e..c25f0b42cf6 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -26,6 +26,7 @@ import socket
 import tempfile
 from typing import Optional, Type
 from types import TracebackType
+from qemu.console_socket import ConsoleSocket
 
 from . import qmp
 
@@ -75,7 +76,8 @@ class QEMUMachine:
 
     def __init__(self, binary, args=None, wrapper=None, name=None,
                  test_dir="/var/tmp", monitor_address=None,
-                 socket_scm_helper=None, sock_dir=None):
+                 socket_scm_helper=None, sock_dir=None,
+                 drain_console=False, console_log=None):
         '''
         Initialize a QEMUMachine
 
@@ -86,6 +88,9 @@ class QEMUMachine:
         @param test_dir: where to create socket and log file
         @param monitor_address: address for QMP monitor
         @param socket_scm_helper: helper program, required for send_fd_scm()
+        @param sock_dir: where to create socket (overrides test_dir for sock)
+        @param console_log: (optional) path to console log file
+        @param drain_console: (optional) True to drain console socket to buffer
         @note: Qemu process is not started until launch() is used.
         '''
         if args is None:
@@ -122,6 +127,12 @@ class QEMUMachine:
         self._console_address = None
         self._console_socket = None
         self._remove_files = []
+        self._console_log_path = console_log
+        if self._console_log_path:
+            # In order to log the console, buffering needs to be enabled.
+            self._drain_console = True
+        else:
+            self._drain_console = drain_console
 
     def __enter__(self):
         return self
@@ -580,7 +591,11 @@ class QEMUMachine:
         Returns a socket connected to the console
         """
         if self._console_socket is None:
-            self._console_socket = socket.socket(socket.AF_UNIX,
-                                                 socket.SOCK_STREAM)
-            self._console_socket.connect(self._console_address)
+            if self._drain_console:
+                self._console_socket = ConsoleSocket(self._console_address,
+                                                    file=self._console_log_path)
+            else:
+                self._console_socket = socket.socket(socket.AF_UNIX,
+                                                     socket.SOCK_STREAM)
+                self._console_socket.connect(self._console_address)
         return self._console_socket
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 10/18] tests/vm: Add workaround to consume console
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (8 preceding siblings ...)
  2020-06-22 14:31 ` [PATCH v1 09/18] python/qemu: Add ConsoleSocket for optional use in QEMUMachine Alex Bennée
@ 2020-06-22 14:31 ` Alex Bennée
  2020-06-22 14:31 ` [PATCH v1 11/18] tests/vm: switch from optsparse to argparse Alex Bennée
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, berrange, Robert Foley, Alex Bennée, richard.henderson,
	f4bug, Philippe Mathieu-Daudé,
	cota, Peter Puhov, aurelien

From: Robert Foley <robert.foley@linaro.org>

This adds support to basevm.py so that we always
drain the console chars.  This makes use of
support added in an earlier commit that allows
QEMUMachine to use the ConsoleSocket.

This is a workaround we found was needed since
there is a known issue where QEMU will hang waiting
for console characters to be consumed.

We also added the option of logging the console to a file.
LOG_CONSOLE=1 will now log the output to a file.

Signed-off-by: Robert Foley <robert.foley@linaro.org>
Reviewed-by: Peter Puhov <peter.puhov@linaro.org>
Acked-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200601211421.1277-10-robert.foley@linaro.org>
---
 tests/vm/Makefile.include |  4 ++++
 tests/vm/basevm.py        | 21 +++++++++++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
index 39f918a430a..f21948c46a5 100644
--- a/tests/vm/Makefile.include
+++ b/tests/vm/Makefile.include
@@ -49,6 +49,7 @@ endif
 	@echo '    EXTRA_CONFIGURE_OPTS="..."'
 	@echo "    J=[0..9]*            	 - Override the -jN parameter for make commands"
 	@echo "    DEBUG=1              	 - Enable verbose output on host and interactive debugging"
+	@echo "    LOG_CONSOLE=1        	 - Log console to file in: ~/.cache/qemu-vm "
 	@echo "    V=1				 - Enable verbose ouput on host and guest commands"
 	@echo "    QEMU_LOCAL=1                 - Use QEMU binary local to this build."
 	@echo "    QEMU=/path/to/qemu		 - Change path to QEMU binary"
@@ -75,6 +76,7 @@ $(IMAGES_DIR)/%.img:	$(SRC_PATH)/tests/vm/% \
 		$(if $(GENISOIMAGE),--genisoimage $(GENISOIMAGE)) \
 		$(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
 		$(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
+		$(if $(LOG_CONSOLE),--log-console) \
 		--image "$@" \
 		--force \
 		--build-image $@, \
@@ -91,6 +93,7 @@ vm-build-%: $(IMAGES_DIR)/%.img
 		$(if $(V),--verbose) \
 		$(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
 		$(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
+		$(if $(LOG_CONSOLE),--log-console) \
 		--image "$<" \
 		$(if $(BUILD_TARGET),--build-target $(BUILD_TARGET)) \
 		--snapshot \
@@ -114,6 +117,7 @@ vm-boot-ssh-%: $(IMAGES_DIR)/%.img
 		$(if $(V)$(DEBUG), --debug) \
 		$(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
 		$(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
+		$(if $(LOG_CONSOLE),--log-console) \
 		--image "$<" \
 		--interactive \
 		false, \
diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index f716798b405..04d083409a5 100644
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -117,6 +117,11 @@ class BaseVM(object):
              "w").write(self._config['ssh_pub_key'])
 
         self.debug = args.debug
+        self._console_log_path = None
+        if args.log_console:
+                self._console_log_path = \
+                         os.path.join(os.path.expanduser("~/.cache/qemu-vm"),
+                                      "{}.install.log".format(self.name))
         self._stderr = sys.stderr
         self._devnull = open(os.devnull, "w")
         if self.debug:
@@ -271,7 +276,13 @@ class BaseVM(object):
         args += self._data_args + extra_args + self._config['extra_args']
         logging.debug("QEMU args: %s", " ".join(args))
         qemu_path = get_qemu_path(self.arch, self._build_path)
-        guest = QEMUMachine(binary=qemu_path, args=args)
+
+        # Since console_log_path is only set when the user provides the
+        # log_console option, we will set drain_console=True so the
+        # console is always drained.
+        guest = QEMUMachine(binary=qemu_path, args=args,
+                            console_log=self._console_log_path,
+                            drain_console=True)
         guest.set_machine(self._config['machine'])
         guest.set_console()
         try:
@@ -285,6 +296,8 @@ class BaseVM(object):
             raise
         atexit.register(self.shutdown)
         self._guest = guest
+        # Init console so we can start consuming the chars.
+        self.console_init()
         usernet_info = guest.qmp("human-monitor-command",
                                  command_line="info usernet")
         self.ssh_port = None
@@ -296,7 +309,9 @@ class BaseVM(object):
             raise Exception("Cannot find ssh port from 'info usernet':\n%s" % \
                             usernet_info)
 
-    def console_init(self, timeout = 120):
+    def console_init(self, timeout = None):
+        if timeout == None:
+            timeout = self.socket_timeout
         vm = self._guest
         vm.console_socket.settimeout(timeout)
         self.console_raw_path = os.path.join(vm._temp_dir,
@@ -578,6 +593,8 @@ def parse_args(vmcls):
     parser.add_option("--efi-aarch64",
                       default="/usr/share/qemu-efi-aarch64/QEMU_EFI.fd",
                       help="Path to efi image for aarch64 VMs.")
+    parser.add_option("--log-console", action="store_true",
+                      help="Log console to file.")
     parser.disable_interspersed_args()
     return parser.parse_args()
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 11/18] tests/vm: switch from optsparse to  argparse
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (9 preceding siblings ...)
  2020-06-22 14:31 ` [PATCH v1 10/18] tests/vm: Add workaround to consume console Alex Bennée
@ 2020-06-22 14:31 ` Alex Bennée
  2020-06-22 17:11   ` Robert Foley
  2020-06-22 17:20   ` Daniel P. Berrangé
  2020-06-22 14:31 ` [PATCH v1 12/18] tests/vm: allow us to take advantage of MTTCG Alex Bennée
                   ` (6 subsequent siblings)
  17 siblings, 2 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, berrange, Alex Bennée, richard.henderson, f4bug,
	Philippe Mathieu-Daudé,
	cota, aurelien

optparse has been deprecated since version 3.2 and argparse is the
blessed replacement. Take the opportunity to enhance our help output
showing defaults when called.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/vm/basevm.py | 84 +++++++++++++++++++++++-----------------------
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 04d083409a5..93859362606 100644
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -23,7 +23,7 @@ from qemu.accel import kvm_available
 from qemu.machine import QEMUMachine
 import subprocess
 import hashlib
-import optparse
+import argparse
 import atexit
 import tempfile
 import shutil
@@ -556,47 +556,47 @@ def parse_args(vmcls):
         else:
             return 1
 
-    parser = optparse.OptionParser(
-        description="VM test utility.  Exit codes: "
-                    "0 = success, "
-                    "1 = command line error, "
-                    "2 = environment initialization failed, "
-                    "3 = test command failed")
-    parser.add_option("--debug", "-D", action="store_true",
-                      help="enable debug output")
-    parser.add_option("--image", "-i", default="%s.img" % vmcls.name,
-                      help="image file name")
-    parser.add_option("--force", "-f", action="store_true",
-                      help="force build image even if image exists")
-    parser.add_option("--jobs", type=int, default=get_default_jobs(),
-                      help="number of virtual CPUs")
-    parser.add_option("--verbose", "-V", action="store_true",
-                      help="Pass V=1 to builds within the guest")
-    parser.add_option("--build-image", "-b", action="store_true",
-                      help="build image")
-    parser.add_option("--build-qemu",
-                      help="build QEMU from source in guest")
-    parser.add_option("--build-target",
-                      help="QEMU build target", default="check")
-    parser.add_option("--build-path", default=None,
-                      help="Path of build directory, "\
-                           "for using build tree QEMU binary. ")
-    parser.add_option("--interactive", "-I", action="store_true",
-                      help="Interactively run command")
-    parser.add_option("--snapshot", "-s", action="store_true",
-                      help="run tests with a snapshot")
-    parser.add_option("--genisoimage", default="genisoimage",
-                      help="iso imaging tool")
-    parser.add_option("--config", "-c", default=None,
-                      help="Provide config yaml for configuration. "\
-                           "See config_example.yaml for example.")
-    parser.add_option("--efi-aarch64",
-                      default="/usr/share/qemu-efi-aarch64/QEMU_EFI.fd",
-                      help="Path to efi image for aarch64 VMs.")
-    parser.add_option("--log-console", action="store_true",
-                      help="Log console to file.")
-    parser.disable_interspersed_args()
-    return parser.parse_args()
+    parser = argparse.ArgumentParser(
+        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
+        description="Utility for provisioning VMs and running builds",
+        epilog="""Remaining arguments are passed to the command.
+        Exit codes: 0 = success, 1 = command line error,
+        2 = environment initialization failed,
+        3 = test command failed""")
+    parser.add_argument("--debug", "-D", action="store_true",
+                        help="enable debug output")
+    parser.add_argument("--image", "-i", default="%s.img" % vmcls.name,
+                        help="image file name")
+    parser.add_argument("--force", "-f", action="store_true",
+                        help="force build image even if image exists")
+    parser.add_argument("--jobs", type=int, default=get_default_jobs(),
+                        help="number of virtual CPUs")
+    parser.add_argument("--verbose", "-V", action="store_true",
+                        help="Pass V=1 to builds within the guest")
+    parser.add_argument("--build-image", "-b", action="store_true",
+                        help="build image")
+    parser.add_argument("--build-qemu",
+                        help="build QEMU from source in guest")
+    parser.add_argument("--build-target",
+                        help="QEMU build target", default="check")
+    parser.add_argument("--build-path", default=None,
+                        help="Path of build directory, "\
+                        "for using build tree QEMU binary. ")
+    parser.add_argument("--interactive", "-I", action="store_true",
+                        help="Interactively run command")
+    parser.add_argument("--snapshot", "-s", action="store_true",
+                        help="run tests with a snapshot")
+    parser.add_argument("--genisoimage", default="genisoimage",
+                        help="iso imaging tool")
+    parser.add_argument("--config", "-c", default=None,
+                        help="Provide config yaml for configuration. "\
+                        "See config_example.yaml for example.")
+    parser.add_argument("--efi-aarch64",
+                        default="/usr/share/qemu-efi-aarch64/QEMU_EFI.fd",
+                        help="Path to efi image for aarch64 VMs.")
+    parser.add_argument("--log-console", action="store_true",
+                        help="Log console to file.")
+    return parser.parse_known_args()
 
 def main(vmcls, config=None):
     try:
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 12/18] tests/vm: allow us to take advantage of MTTCG
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (10 preceding siblings ...)
  2020-06-22 14:31 ` [PATCH v1 11/18] tests/vm: switch from optsparse to argparse Alex Bennée
@ 2020-06-22 14:31 ` Alex Bennée
  2020-06-22 14:52   ` Robert Foley
  2020-06-26 18:30   ` Richard Henderson
  2020-06-22 14:31 ` [PATCH v1 13/18] tests/docker: check for an parameters not empty string Alex Bennée
                   ` (5 subsequent siblings)
  17 siblings, 2 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, berrange, Alex Bennée, richard.henderson, f4bug,
	Philippe Mathieu-Daudé,
	cota, aurelien

We currently limit TCG guests to -smp 1 but now we have added some
aarch64 guests we can do better when running on x86_64 hardware.
Raise the limit for TCG guests when it is safe to do so.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/vm/basevm.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 93859362606..dd96a6d4af6 100644
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -553,6 +553,12 @@ def parse_args(vmcls):
     def get_default_jobs():
         if kvm_available(vmcls.arch):
             return multiprocessing.cpu_count() // 2
+        elif os.uname().machine == "x86_64" and \
+             vmcls.arch in ["aarch64", "x86_64", "i386"]:
+            # MTTCG is available on these arches and we can allow more cores.
+            # But only up to a reasonable limit. User can always override
+            # these limits with --jobs.
+            return min(multiprocessing.cpu_count() // 2, 8)
         else:
             return 1
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v1 13/18] tests/docker: check for an parameters not empty string
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (11 preceding siblings ...)
  2020-06-22 14:31 ` [PATCH v1 12/18] tests/vm: allow us to take advantage of MTTCG Alex Bennée
@ 2020-06-22 14:31 ` Alex Bennée
  2020-06-22 14:46   ` Philippe Mathieu-Daudé
  2020-06-29 16:15   ` Eric Blake
  2020-06-22 14:32 ` [PATCH v1 14/18] .gitignore: un-ignore .gitlab-ci.d Alex Bennée
                   ` (4 subsequent siblings)
  17 siblings, 2 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, berrange, Alex Bennée, richard.henderson, f4bug,
	Philippe Mathieu-Daudé,
	cota, aurelien

Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/docker/common.rc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/docker/common.rc b/tests/docker/common.rc
index 02cd67a8c5e..b27ce17e333 100755
--- a/tests/docker/common.rc
+++ b/tests/docker/common.rc
@@ -47,7 +47,7 @@ build_qemu()
 check_qemu()
 {
     # default to make check unless the caller specifies
-    if test -z "$@"; then
+    if [ $# == 0 ]; then
         INVOCATION="check"
     else
         INVOCATION="$@"
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 14/18] .gitignore: un-ignore .gitlab-ci.d
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (12 preceding siblings ...)
  2020-06-22 14:31 ` [PATCH v1 13/18] tests/docker: check for an parameters not empty string Alex Bennée
@ 2020-06-22 14:32 ` Alex Bennée
  2020-06-22 16:29   ` Daniel P. Berrangé
  2020-06-22 14:32 ` [PATCH v1 15/18] .gitlab: add acceptance testing to system builds Alex Bennée
                   ` (3 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, berrange, Alex Bennée, richard.henderson, f4bug, cota,
	aurelien

The sooner we deprecate in-tree builds the sooner this mess of regexes
can be thrown away.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 .gitignore | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 90acb4347d4..9016ee0a0b4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -92,7 +92,7 @@
 *.toc
 *.tp
 *.vr
-*.d
+!\.*.d
 !/scripts/qemu-guest-agent/fsfreeze-hook.d
 *.o
 .sdk
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 15/18] .gitlab: add acceptance testing to system builds
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (13 preceding siblings ...)
  2020-06-22 14:32 ` [PATCH v1 14/18] .gitignore: un-ignore .gitlab-ci.d Alex Bennée
@ 2020-06-22 14:32 ` Alex Bennée
  2020-06-22 14:32 ` [PATCH v1 16/18] .gitlab: split fedora-misc-disabled Alex Bennée
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, Thomas Huth, berrange, Alex Bennée, richard.henderson,
	f4bug, Wainer dos Santos Moschetta, Philippe Mathieu-Daudé,
	cota, aurelien

As part of migrating things from Travis to GitLab add the acceptance
tests. To do this:

  - split system1 into ubuntu-main and debian-alt
  - use artifacts to save build stage
  - rename system2 to fedora-misc
  - split into build/check/acceptance
  - remove -j from check stages
  - add packages needed for acceptance
  - add post acceptance template and use

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 .gitlab-ci.yml | 122 ++++++++++++++++++++++++++++++++++++++++++++++---
 .travis.yml    |  23 ----------
 2 files changed, 115 insertions(+), 30 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 349c77aa580..fc3a561d9bc 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,3 +1,15 @@
+#
+# Currently we have two build stages:
+#  - build (for traditional build and test or first stage build)
+#  - test (for test stages, using build artefacts from a build stage)
+stages:
+  - build
+  - test
+
+variables:
+  BASE_CONFIG: "--disable-docs"
+  MAIN_SOFTMMU_TARGETS: "aarch64-softmmu,mips64-softmmu,ppc64-softmmu,riscv64-softmmu,s390x-softmmu,x86_64-softmmu"
+
 include:
   - local: '/.gitlab-ci.d/edk2.yml'
   - local: '/.gitlab-ci.d/opensbi.yml'
@@ -16,22 +28,93 @@ include:
         make python3 perl-podlators perl-Test-Harness pixman-devel zlib-devel
   - JOBS=$(expr $(nproc) + 1)
 
-build-system1:
+.post_acceptance_template: &post_acceptance
+  after_script:
+    - python3 -c 'import json; r = json.load(open("tests/results/latest/results.json")); [print(t["logfile"]) for t in r["tests"] if t["status"] not in ("PASS", "SKIP")]' | xargs cat
+      - du -chs $HOME/avocado/data/cache
+
+build:system-ubuntu-main:
  image: ubuntu:19.10
+ stage: build
  <<: *before_script_apt
  script:
  - apt-get install -y -qq libgtk-3-dev libvte-dev nettle-dev libcacard-dev
       libusb-dev libvde-dev libspice-protocol-dev libgl1-mesa-dev libvdeplug-dev
  - mkdir build
  - cd build
- - ../configure --enable-werror --target-list="aarch64-softmmu alpha-softmmu
-      cris-softmmu hppa-softmmu lm32-softmmu moxie-softmmu microblazeel-softmmu
-      mips64el-softmmu m68k-softmmu ppc-softmmu riscv64-softmmu sparc-softmmu"
+ - ../configure ${BASE_CONFIG} --enable-werror --target-list="${MAIN_SOFTMMU_TARGETS}"
  - make -j"$JOBS"
- - make -j"$JOBS" check
+ artifacts:
+   paths:
+     - build
 
-build-system2:
+check:system-ubuntu-main:
+ image: ubuntu:19.10
+ stage: test
+ dependencies:
+ - build:system-ubuntu-main
+ <<: *before_script_apt
+ script:
+ - cd build
+ - make check
+
+acceptance:system-ubuntu-main:
+ image: ubuntu:19.10
+ stage: test
+ dependencies:
+ - build:system-ubuntu-main
+ <<: *before_script_apt
+ script:
+ - DEBIAN_FRONTEND=noninteractive apt-get install -y -qq
+    python3-pil python3-pip python3-numpy python3-opencv python3-venv
+    rpm2cpio tesseract-ocr tesseract-ocr-eng
+ - cd build
+ - make check-acceptance
+ <<: *post_acceptance
+
+build:system-debian-alt:
+ image: debian:buster-slim
+ stage: build
+ <<: *before_script_apt
+ script:
+ - apt-get install -y -qq libgtk-3-dev libvte-dev nettle-dev libcacard-dev
+      libusb-dev libvde-dev libspice-protocol-dev libgl1-mesa-dev libvdeplug-dev
+ - mkdir build
+ - cd build
+ - ../configure ${BASE_CONFIG} --enable-werror --disable-user
+     --target-list-exclude="${MAIN_SOFTMMU_TARGETS}"
+ - make -j"$JOBS"
+ artifacts:
+   paths:
+     - build
+
+check:system-debian-alt:
+ image: debian:buster-slim
+ stage: test
+ dependencies:
+ - build:system-debian-alt
+ <<: *before_script_apt
+ script:
+ - cd build
+ - make check
+
+acceptance:system-debian-alt:
+ image: debian:buster-slim
+ stage: test
+ dependencies:
+ - build:system-debian-alt
+ <<: *before_script_apt
+ script:
+ - DEBIAN_FRONTEND=noninteractive apt-get install -y -qq
+    python3-pil python3-pip python3-numpy python3-opencv python3-venv
+    rpm2cpio tesseract-ocr tesseract-ocr-eng
+ - cd build
+ - make check-acceptance
+ <<: *post_acceptance
+
+build:system-fedora-misc:
  image: fedora:latest
+ stage: build
  <<: *before_script_dnf
  script:
  - yum install -y SDL2-devel libgcrypt-devel brlapi-devel libaio-devel
@@ -43,7 +126,32 @@ build-system2:
       microblaze-softmmu mips-softmmu riscv32-softmmu s390x-softmmu sh4-softmmu
       sparc64-softmmu x86_64-softmmu xtensa-softmmu nios2-softmmu or1k-softmmu"
  - make -j"$JOBS"
- - make -j"$JOBS" check
+ artifacts:
+   paths:
+     - build
+
+check:system-fedora-misc:
+ image: fedora:latest
+ stage: test
+ dependencies:
+ - build:system-fedora-misc
+ <<: *before_script_dnf
+ script:
+ - cd build
+ - make check
+
+acceptance:system-fedora-misc:
+ image: fedora:latest
+ stage: test
+ dependencies:
+ - build:system-fedora-misc
+ <<: *before_script_dnf
+ script:
+ - yum install -y python3-pillow python3-pip python3-numpy python3-opencv
+       python3-virtualenv tesseract tesseract-langpack-eng
+ - cd build
+ - make check-acceptance
+ <<: *post_acceptance
 
 build-disabled:
  image: fedora:latest
diff --git a/.travis.yml b/.travis.yml
index 74158f741b1..c24dfbe377f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -289,29 +289,6 @@ jobs:
       python: 3.6
 
 
-    # Acceptance (Functional) tests
-    - name: "GCC check-acceptance"
-      dist: bionic
-      env:
-        - CONFIG="--enable-tools --target-list=aarch64-softmmu,alpha-softmmu,arm-softmmu,m68k-softmmu,microblaze-softmmu,mips-softmmu,mips64el-softmmu,nios2-softmmu,or1k-softmmu,ppc-softmmu,ppc64-softmmu,s390x-softmmu,sh4-softmmu,sparc-softmmu,x86_64-softmmu,xtensa-softmmu"
-        - TEST_CMD="make check-acceptance"
-        - CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-acceptance"
-      after_script:
-        - python3 -c 'import json; r = json.load(open("tests/results/latest/results.json")); [print(t["logfile"]) for t in r["tests"] if t["status"] not in ("PASS", "SKIP")]' | xargs cat
-        - du -chs $HOME/avocado/data/cache
-      addons:
-        apt:
-          packages:
-            - python3-pil
-            - python3-pip
-            - python3-numpy
-            - python3-opencv
-            - python3-venv
-            - rpm2cpio
-            - tesseract-ocr
-            - tesseract-ocr-eng
-
-
     # Using newer GCC with sanitizers
     - name: "GCC9 with sanitizers (softmmu)"
       addons:
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 16/18] .gitlab: split fedora-misc-disabled
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (14 preceding siblings ...)
  2020-06-22 14:32 ` [PATCH v1 15/18] .gitlab: add acceptance testing to system builds Alex Bennée
@ 2020-06-22 14:32 ` Alex Bennée
  2020-06-22 14:32 ` [PATCH v1 17/18] .gitlab: tag remaining jobs as builds Alex Bennée
  2020-06-22 14:32 ` [PATCH v1 18/18] .gitlab: add avocado asset caching Alex Bennée
  17 siblings, 0 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, Thomas Huth, berrange, Alex Bennée, richard.henderson,
	f4bug, Wainer dos Santos Moschetta, Philippe Mathieu-Daudé,
	cota, aurelien

As we run check-qtest in "SLOW" mode this can timeout so split into
two jobs.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 .gitlab-ci.yml | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fc3a561d9bc..5c863562913 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -153,8 +153,9 @@ acceptance:system-fedora-misc:
  - make check-acceptance
  <<: *post_acceptance
 
-build-disabled:
+build:system-fedora-misc-disabled:
  image: fedora:latest
+ stage: build
  <<: *before_script_dnf
  script:
  - mkdir build
@@ -167,7 +168,19 @@ build-disabled:
       --disable-vhost-net --disable-vhost-crypto --disable-vhost-user
       --target-list="i386-softmmu ppc64-softmmu mips64-softmmu i386-linux-user"
  - make -j"$JOBS"
- - make -j"$JOBS" check-qtest SPEED=slow
+ artifacts:
+   paths:
+     - build
+
+qtest:system-fedora-misc-disabled:
+ image: fedora:latest
+ stage: test
+ dependencies:
+ - build:system-fedora-misc-disabled
+ <<: *before_script_dnf
+ script:
+ - cd build
+ - make check-qtest SPEED=slow
 
 build-tcg-disabled:
  image: centos:8
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 17/18] .gitlab: tag remaining jobs as builds
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (15 preceding siblings ...)
  2020-06-22 14:32 ` [PATCH v1 16/18] .gitlab: split fedora-misc-disabled Alex Bennée
@ 2020-06-22 14:32 ` Alex Bennée
  2020-06-22 14:32 ` [PATCH v1 18/18] .gitlab: add avocado asset caching Alex Bennée
  17 siblings, 0 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, Thomas Huth, berrange, Alex Bennée, richard.henderson,
	f4bug, Wainer dos Santos Moschetta, Philippe Mathieu-Daudé,
	cota, aurelien

Technically these are build and test but there is no reason they need
to wait for other builds to finish to get going. They might get split
latter if the job ever gets too long.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 .gitlab-ci.yml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5c863562913..7816f1434c3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -184,6 +184,7 @@ qtest:system-fedora-misc-disabled:
 
 build-tcg-disabled:
  image: centos:8
+ stage: build
  <<: *before_script_dnf
  script:
  - dnf install -y clang gtk3-devel libusbx-devel libgcrypt-devel
@@ -203,6 +204,7 @@ build-tcg-disabled:
             260 261 262 263 264 270 272 273 277 279
 
 build-user:
+ stage: build
  <<: *before_script_apt
  script:
  - mkdir build
@@ -214,6 +216,7 @@ build-user:
 
 build-clang:
  image: fedora:latest
+ stage: build
  <<: *before_script_dnf
  script:
  - yum install -y clang SDL2-devel libattr-devel libcap-ng-devel xfsprogs-devel
@@ -228,6 +231,7 @@ build-clang:
 
 build-tci:
  image: centos:8
+ stage: build
  <<: *before_script_dnf
  script:
  - TARGETS="aarch64 alpha arm hppa m68k microblaze moxie ppc64 s390x x86_64"
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH  v1 18/18] .gitlab: add avocado asset caching
  2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
                   ` (16 preceding siblings ...)
  2020-06-22 14:32 ` [PATCH v1 17/18] .gitlab: tag remaining jobs as builds Alex Bennée
@ 2020-06-22 14:32 ` Alex Bennée
  2020-06-22 14:45   ` Philippe Mathieu-Daudé
  17 siblings, 1 reply; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 14:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, Thomas Huth, berrange, Alex Bennée, richard.henderson,
	f4bug, Wainer dos Santos Moschetta, Philippe Mathieu-Daudé,
	cota, aurelien

These can be quite big so lets cache them. I couldn't find any nots on
ccache in the gitlab docs so I've just ignored it for now.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 .gitlab-ci.yml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7816f1434c3..693ecad770f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -14,6 +14,12 @@ include:
   - local: '/.gitlab-ci.d/edk2.yml'
   - local: '/.gitlab-ci.d/opensbi.yml'
 
+# We assume GitLab has it's own caching set up for RPM/APT repositories so we
+# just take care of avocado assets here.
+cache:
+  paths:
+    - $HOME/avocado/data/cache
+
 .update_apt_template: &before_script_apt
  before_script:
   - apt-get update -qq
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH v1 18/18] .gitlab: add avocado asset caching
  2020-06-22 14:32 ` [PATCH v1 18/18] .gitlab: add avocado asset caching Alex Bennée
@ 2020-06-22 14:45   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 33+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-06-22 14:45 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel
  Cc: fam, Thomas Huth, berrange, Philippe Mathieu-Daudé,
	richard.henderson, Wainer dos Santos Moschetta, cota, aurelien

On 6/22/20 4:32 PM, Alex Bennée wrote:
> These can be quite big so lets cache them. I couldn't find any nots on

typo "notes"?

> ccache in the gitlab docs so I've just ignored it for now.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>  .gitlab-ci.yml | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index 7816f1434c3..693ecad770f 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -14,6 +14,12 @@ include:
>    - local: '/.gitlab-ci.d/edk2.yml'
>    - local: '/.gitlab-ci.d/opensbi.yml'
>  
> +# We assume GitLab has it's own caching set up for RPM/APT repositories so we
> +# just take care of avocado assets here.
> +cache:
> +  paths:
> +    - $HOME/avocado/data/cache
> +
>  .update_apt_template: &before_script_apt
>   before_script:
>    - apt-get update -qq
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v1 13/18] tests/docker: check for an parameters not empty string
  2020-06-22 14:31 ` [PATCH v1 13/18] tests/docker: check for an parameters not empty string Alex Bennée
@ 2020-06-22 14:46   ` Philippe Mathieu-Daudé
  2020-06-29 16:15   ` Eric Blake
  1 sibling, 0 replies; 33+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-06-22 14:46 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel
  Cc: fam, berrange, Philippe Mathieu-Daudé,
	richard.henderson, cota, aurelien

On 6/22/20 4:31 PM, Alex Bennée wrote:
> Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/docker/common.rc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/docker/common.rc b/tests/docker/common.rc
> index 02cd67a8c5e..b27ce17e333 100755
> --- a/tests/docker/common.rc
> +++ b/tests/docker/common.rc
> @@ -47,7 +47,7 @@ build_qemu()
>  check_qemu()
>  {
>      # default to make check unless the caller specifies
> -    if test -z "$@"; then
> +    if [ $# == 0 ]; then
>          INVOCATION="check"
>      else
>          INVOCATION="$@"
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v1 12/18] tests/vm: allow us to take advantage of MTTCG
  2020-06-22 14:31 ` [PATCH v1 12/18] tests/vm: allow us to take advantage of MTTCG Alex Bennée
@ 2020-06-22 14:52   ` Robert Foley
  2020-06-26 18:30   ` Richard Henderson
  1 sibling, 0 replies; 33+ messages in thread
From: Robert Foley @ 2020-06-22 14:52 UTC (permalink / raw)
  To: Alex Bennée
  Cc: Fam Zheng, Daniel P. Berrangé,
	Richard Henderson, QEMU Developers, f4bug, Emilio G. Cota,
	Philippe Mathieu-Daudé,
	Aurelien Jarno

Reviewed-by: Robert Foley <robert.foley@linaro.org>

On Mon, 22 Jun 2020 at 10:38, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> We currently limit TCG guests to -smp 1 but now we have added some
> aarch64 guests we can do better when running on x86_64 hardware.
> Raise the limit for TCG guests when it is safe to do so.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/vm/basevm.py | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
> index 93859362606..dd96a6d4af6 100644
> --- a/tests/vm/basevm.py
> +++ b/tests/vm/basevm.py
> @@ -553,6 +553,12 @@ def parse_args(vmcls):
>      def get_default_jobs():
>          if kvm_available(vmcls.arch):
>              return multiprocessing.cpu_count() // 2
> +        elif os.uname().machine == "x86_64" and \
> +             vmcls.arch in ["aarch64", "x86_64", "i386"]:
> +            # MTTCG is available on these arches and we can allow more cores.
> +            # But only up to a reasonable limit. User can always override
> +            # these limits with --jobs.
> +            return min(multiprocessing.cpu_count() // 2, 8)
>          else:
>              return 1
>
> --
> 2.20.1
>
>


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH  v1 14/18] .gitignore: un-ignore .gitlab-ci.d
  2020-06-22 14:32 ` [PATCH v1 14/18] .gitignore: un-ignore .gitlab-ci.d Alex Bennée
@ 2020-06-22 16:29   ` Daniel P. Berrangé
  0 siblings, 0 replies; 33+ messages in thread
From: Daniel P. Berrangé @ 2020-06-22 16:29 UTC (permalink / raw)
  To: Alex Bennée
  Cc: fam, richard.henderson, qemu-devel, f4bug, cota, aurelien

On Mon, Jun 22, 2020 at 03:32:00PM +0100, Alex Bennée wrote:
> The sooner we deprecate in-tree builds the sooner this mess of regexes
> can be thrown away.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  .gitignore | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/.gitignore b/.gitignore
> index 90acb4347d4..9016ee0a0b4 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -92,7 +92,7 @@
>  *.toc
>  *.tp
>  *.vr
> -*.d
> +!\.*.d

This doesn't look quite right to me. After this all the .d files are
marked as untracked.

I think you need something more like

  *.d
  !/.gitlab-ci.d


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v1 11/18] tests/vm: switch from optsparse to argparse
  2020-06-22 14:31 ` [PATCH v1 11/18] tests/vm: switch from optsparse to argparse Alex Bennée
@ 2020-06-22 17:11   ` Robert Foley
  2020-06-22 17:20   ` Daniel P. Berrangé
  1 sibling, 0 replies; 33+ messages in thread
From: Robert Foley @ 2020-06-22 17:11 UTC (permalink / raw)
  To: Alex Bennée
  Cc: Fam Zheng, Daniel P. Berrangé,
	Richard Henderson, QEMU Developers, f4bug, Emilio G. Cota,
	Philippe Mathieu-Daudé,
	Aurelien Jarno

Reviewed-by: Robert Foley <robert.foley@linaro.org>

On Mon, 22 Jun 2020 at 10:41, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> optparse has been deprecated since version 3.2 and argparse is the
> blessed replacement. Take the opportunity to enhance our help output
> showing defaults when called.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/vm/basevm.py | 84 +++++++++++++++++++++++-----------------------
>  1 file changed, 42 insertions(+), 42 deletions(-)
>
> diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
> index 04d083409a5..93859362606 100644
> --- a/tests/vm/basevm.py
> +++ b/tests/vm/basevm.py
> @@ -23,7 +23,7 @@ from qemu.accel import kvm_available
>  from qemu.machine import QEMUMachine
>  import subprocess
>  import hashlib
> -import optparse
> +import argparse
>  import atexit
>  import tempfile
>  import shutil
> @@ -556,47 +556,47 @@ def parse_args(vmcls):
>          else:
>              return 1
>
> -    parser = optparse.OptionParser(
> -        description="VM test utility.  Exit codes: "
> -                    "0 = success, "
> -                    "1 = command line error, "
> -                    "2 = environment initialization failed, "
> -                    "3 = test command failed")
> -    parser.add_option("--debug", "-D", action="store_true",
> -                      help="enable debug output")
> -    parser.add_option("--image", "-i", default="%s.img" % vmcls.name,
> -                      help="image file name")
> -    parser.add_option("--force", "-f", action="store_true",
> -                      help="force build image even if image exists")
> -    parser.add_option("--jobs", type=int, default=get_default_jobs(),
> -                      help="number of virtual CPUs")
> -    parser.add_option("--verbose", "-V", action="store_true",
> -                      help="Pass V=1 to builds within the guest")
> -    parser.add_option("--build-image", "-b", action="store_true",
> -                      help="build image")
> -    parser.add_option("--build-qemu",
> -                      help="build QEMU from source in guest")
> -    parser.add_option("--build-target",
> -                      help="QEMU build target", default="check")
> -    parser.add_option("--build-path", default=None,
> -                      help="Path of build directory, "\
> -                           "for using build tree QEMU binary. ")
> -    parser.add_option("--interactive", "-I", action="store_true",
> -                      help="Interactively run command")
> -    parser.add_option("--snapshot", "-s", action="store_true",
> -                      help="run tests with a snapshot")
> -    parser.add_option("--genisoimage", default="genisoimage",
> -                      help="iso imaging tool")
> -    parser.add_option("--config", "-c", default=None,
> -                      help="Provide config yaml for configuration. "\
> -                           "See config_example.yaml for example.")
> -    parser.add_option("--efi-aarch64",
> -                      default="/usr/share/qemu-efi-aarch64/QEMU_EFI.fd",
> -                      help="Path to efi image for aarch64 VMs.")
> -    parser.add_option("--log-console", action="store_true",
> -                      help="Log console to file.")
> -    parser.disable_interspersed_args()
> -    return parser.parse_args()
> +    parser = argparse.ArgumentParser(
> +        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
> +        description="Utility for provisioning VMs and running builds",
> +        epilog="""Remaining arguments are passed to the command.
> +        Exit codes: 0 = success, 1 = command line error,
> +        2 = environment initialization failed,
> +        3 = test command failed""")
> +    parser.add_argument("--debug", "-D", action="store_true",
> +                        help="enable debug output")
> +    parser.add_argument("--image", "-i", default="%s.img" % vmcls.name,
> +                        help="image file name")
> +    parser.add_argument("--force", "-f", action="store_true",
> +                        help="force build image even if image exists")
> +    parser.add_argument("--jobs", type=int, default=get_default_jobs(),
> +                        help="number of virtual CPUs")
> +    parser.add_argument("--verbose", "-V", action="store_true",
> +                        help="Pass V=1 to builds within the guest")
> +    parser.add_argument("--build-image", "-b", action="store_true",
> +                        help="build image")
> +    parser.add_argument("--build-qemu",
> +                        help="build QEMU from source in guest")
> +    parser.add_argument("--build-target",
> +                        help="QEMU build target", default="check")
> +    parser.add_argument("--build-path", default=None,
> +                        help="Path of build directory, "\
> +                        "for using build tree QEMU binary. ")
> +    parser.add_argument("--interactive", "-I", action="store_true",
> +                        help="Interactively run command")
> +    parser.add_argument("--snapshot", "-s", action="store_true",
> +                        help="run tests with a snapshot")
> +    parser.add_argument("--genisoimage", default="genisoimage",
> +                        help="iso imaging tool")
> +    parser.add_argument("--config", "-c", default=None,
> +                        help="Provide config yaml for configuration. "\
> +                        "See config_example.yaml for example.")
> +    parser.add_argument("--efi-aarch64",
> +                        default="/usr/share/qemu-efi-aarch64/QEMU_EFI.fd",
> +                        help="Path to efi image for aarch64 VMs.")
> +    parser.add_argument("--log-console", action="store_true",
> +                        help="Log console to file.")
> +    return parser.parse_known_args()
>
>  def main(vmcls, config=None):
>      try:
> --
> 2.20.1
>
>


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH  v1 11/18] tests/vm: switch from optsparse to  argparse
  2020-06-22 14:31 ` [PATCH v1 11/18] tests/vm: switch from optsparse to argparse Alex Bennée
  2020-06-22 17:11   ` Robert Foley
@ 2020-06-22 17:20   ` Daniel P. Berrangé
  1 sibling, 0 replies; 33+ messages in thread
From: Daniel P. Berrangé @ 2020-06-22 17:20 UTC (permalink / raw)
  To: Alex Bennée
  Cc: fam, Philippe Mathieu-Daudé,
	richard.henderson, qemu-devel, f4bug, cota, aurelien

Trivial typo in $SUBJECT  s/optsparse/optparse/

On Mon, Jun 22, 2020 at 03:31:57PM +0100, Alex Bennée wrote:
> optparse has been deprecated since version 3.2 and argparse is the
> blessed replacement. Take the opportunity to enhance our help output
> showing defaults when called.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/vm/basevm.py | 84 +++++++++++++++++++++++-----------------------
>  1 file changed, 42 insertions(+), 42 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v1 01/18] iotests: Fix 051 output after qdev_init_nofail() removal
  2020-06-22 14:31 ` [PATCH v1 01/18] iotests: Fix 051 output after qdev_init_nofail() removal Alex Bennée
@ 2020-06-22 17:52   ` John Snow
  2020-06-22 17:57     ` Philippe Mathieu-Daudé
  2020-06-22 18:23     ` Alex Bennée
  0 siblings, 2 replies; 33+ messages in thread
From: John Snow @ 2020-06-22 17:52 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel
  Cc: fam, Kevin Wolf, Thomas Huth, berrange,
	open list:Block layer core, richard.henderson, f4bug, Max Reitz,
	cota, Philippe Mathieu-Daudé,
	aurelien



On 6/22/20 10:31 AM, Alex Bennée wrote:
> From: Philippe Mathieu-Daudé <philmd@redhat.com>
> 
> Commit 96927c744 replaced qdev_init_nofail() call by
> isa_realize_and_unref() which has a different error
> message. Update the test output accordingly.
> 
> Gitlab CI error after merging b77b5b3dc7:
> https://gitlab.com/qemu-project/qemu/-/jobs/597414772#L4375
> 
> Reported-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Message-Id: <20200616154949.6586-1-philmd@redhat.com>
> ---
>  tests/qemu-iotests/051.pc.out | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out
> index 0ea80d35f0e..da8ad871876 100644
> --- a/tests/qemu-iotests/051.pc.out
> +++ b/tests/qemu-iotests/051.pc.out
> @@ -142,7 +142,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
>  
>  Testing: -drive if=ide
>  QEMU X.Y.Z monitor - type 'help' for more information
> -(qemu) QEMU_PROG: Initialization of device ide-hd failed: Device needs media, but drive is empty
> +(qemu) QEMU_PROG: Device needs media, but drive is empty
>  
>  Testing: -drive if=virtio
>  QEMU X.Y.Z monitor - type 'help' for more information
> @@ -214,7 +214,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
>  
>  Testing: -drive file=TEST_DIR/t.qcow2,if=ide,readonly=on
>  QEMU X.Y.Z monitor - type 'help' for more information
> -(qemu) QEMU_PROG: Initialization of device ide-hd failed: Block node is read-only
> +(qemu) QEMU_PROG: Block node is read-only
>  
>  Testing: -drive file=TEST_DIR/t.qcow2,if=virtio,readonly=on
>  QEMU X.Y.Z monitor - type 'help' for more information
> 

Just ran into this and wrote an identical fix. The error is not in
051.out so the pc-only fix appears to be fine.

Reviewed-by: John Snow <jsnow@redhat.com>

(There seem to be other problems with the CI at the moment, but the
failures I am seeing are not related to this, so I think it's probably fine)



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v1 01/18] iotests: Fix 051 output after qdev_init_nofail() removal
  2020-06-22 17:52   ` John Snow
@ 2020-06-22 17:57     ` Philippe Mathieu-Daudé
  2020-06-22 18:23     ` Alex Bennée
  1 sibling, 0 replies; 33+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-06-22 17:57 UTC (permalink / raw)
  To: John Snow, Alex Bennée, qemu-devel
  Cc: fam, Kevin Wolf, Thomas Huth, berrange,
	open list:Block layer core, richard.henderson, f4bug, Max Reitz,
	cota, aurelien

On 6/22/20 7:52 PM, John Snow wrote:
> 
> 
> On 6/22/20 10:31 AM, Alex Bennée wrote:
>> From: Philippe Mathieu-Daudé <philmd@redhat.com>
>>
>> Commit 96927c744 replaced qdev_init_nofail() call by
>> isa_realize_and_unref() which has a different error
>> message. Update the test output accordingly.
>>
>> Gitlab CI error after merging b77b5b3dc7:
>> https://gitlab.com/qemu-project/qemu/-/jobs/597414772#L4375
>>
>> Reported-by: Thomas Huth <thuth@redhat.com>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> Message-Id: <20200616154949.6586-1-philmd@redhat.com>
>> ---
>>  tests/qemu-iotests/051.pc.out | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out
>> index 0ea80d35f0e..da8ad871876 100644
>> --- a/tests/qemu-iotests/051.pc.out
>> +++ b/tests/qemu-iotests/051.pc.out
>> @@ -142,7 +142,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
>>  
>>  Testing: -drive if=ide
>>  QEMU X.Y.Z monitor - type 'help' for more information
>> -(qemu) QEMU_PROG: Initialization of device ide-hd failed: Device needs media, but drive is empty
>> +(qemu) QEMU_PROG: Device needs media, but drive is empty
>>  
>>  Testing: -drive if=virtio
>>  QEMU X.Y.Z monitor - type 'help' for more information
>> @@ -214,7 +214,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
>>  
>>  Testing: -drive file=TEST_DIR/t.qcow2,if=ide,readonly=on
>>  QEMU X.Y.Z monitor - type 'help' for more information
>> -(qemu) QEMU_PROG: Initialization of device ide-hd failed: Block node is read-only
>> +(qemu) QEMU_PROG: Block node is read-only
>>  
>>  Testing: -drive file=TEST_DIR/t.qcow2,if=virtio,readonly=on
>>  QEMU X.Y.Z monitor - type 'help' for more information
>>
> 
> Just ran into this and wrote an identical fix. The error is not in
> 051.out so the pc-only fix appears to be fine.
> 
> Reviewed-by: John Snow <jsnow@redhat.com>

Also:

Reviewed-by: Thomas Huth <thuth@redhat.com>

> 
> (There seem to be other problems with the CI at the moment, but the
> failures I am seeing are not related to this, so I think it's probably fine)
> 



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v1 01/18] iotests: Fix 051 output after qdev_init_nofail() removal
  2020-06-22 17:52   ` John Snow
  2020-06-22 17:57     ` Philippe Mathieu-Daudé
@ 2020-06-22 18:23     ` Alex Bennée
  1 sibling, 0 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-22 18:23 UTC (permalink / raw)
  To: John Snow
  Cc: fam, Kevin Wolf, Thomas Huth, berrange,
	open list:Block layer core, richard.henderson, qemu-devel, f4bug,
	cota, Max Reitz, Philippe Mathieu-Daudé,
	aurelien


John Snow <jsnow@redhat.com> writes:

> On 6/22/20 10:31 AM, Alex Bennée wrote:
>> From: Philippe Mathieu-Daudé <philmd@redhat.com>
>> 
>> Commit 96927c744 replaced qdev_init_nofail() call by
>> isa_realize_and_unref() which has a different error
>> message. Update the test output accordingly.
>> 
>> Gitlab CI error after merging b77b5b3dc7:
>> https://gitlab.com/qemu-project/qemu/-/jobs/597414772#L4375
>> 
>> Reported-by: Thomas Huth <thuth@redhat.com>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> Message-Id: <20200616154949.6586-1-philmd@redhat.com>
>> ---
>>  tests/qemu-iotests/051.pc.out | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out
>> index 0ea80d35f0e..da8ad871876 100644
>> --- a/tests/qemu-iotests/051.pc.out
>> +++ b/tests/qemu-iotests/051.pc.out
>> @@ -142,7 +142,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
>>  
>>  Testing: -drive if=ide
>>  QEMU X.Y.Z monitor - type 'help' for more information
>> -(qemu) QEMU_PROG: Initialization of device ide-hd failed: Device needs media, but drive is empty
>> +(qemu) QEMU_PROG: Device needs media, but drive is empty
>>  
>>  Testing: -drive if=virtio
>>  QEMU X.Y.Z monitor - type 'help' for more information
>> @@ -214,7 +214,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
>>  
>>  Testing: -drive file=TEST_DIR/t.qcow2,if=ide,readonly=on
>>  QEMU X.Y.Z monitor - type 'help' for more information
>> -(qemu) QEMU_PROG: Initialization of device ide-hd failed: Block node is read-only
>> +(qemu) QEMU_PROG: Block node is read-only
>>  
>>  Testing: -drive file=TEST_DIR/t.qcow2,if=virtio,readonly=on
>>  QEMU X.Y.Z monitor - type 'help' for more information
>> 
>
> Just ran into this and wrote an identical fix. The error is not in
> 051.out so the pc-only fix appears to be fine.
>
> Reviewed-by: John Snow <jsnow@redhat.com>
>
> (There seem to be other problems with the CI at the moment, but the
> failures I am seeing are not related to this, so I think it's probably fine)

It's queued via Max's tree - it's just easier to keep them in
testing/next while I'm testing. I assume his PR will beat the eventual
PR from this.

-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v1 12/18] tests/vm: allow us to take advantage of MTTCG
  2020-06-22 14:31 ` [PATCH v1 12/18] tests/vm: allow us to take advantage of MTTCG Alex Bennée
  2020-06-22 14:52   ` Robert Foley
@ 2020-06-26 18:30   ` Richard Henderson
  2020-06-26 19:37     ` Alex Bennée
  2020-06-29 14:41     ` Alex Bennée
  1 sibling, 2 replies; 33+ messages in thread
From: Richard Henderson @ 2020-06-26 18:30 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel
  Cc: fam, berrange, Philippe Mathieu-Daudé, f4bug, cota, aurelien

On 6/22/20 7:31 AM, Alex Bennée wrote:
>          if kvm_available(vmcls.arch):
>              return multiprocessing.cpu_count() // 2
> +        elif os.uname().machine == "x86_64" and \
> +             vmcls.arch in ["aarch64", "x86_64", "i386"]:
> +            # MTTCG is available on these arches and we can allow more cores.
> +            # But only up to a reasonable limit. User can always override
> +            # these limits with --jobs.
> +            return min(multiprocessing.cpu_count() // 2, 8)
>          else:

And if multiprocessing.cpu_count() == 1?
Seems like we should add max(count, 1) as well.


r~


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v1 12/18] tests/vm: allow us to take advantage of MTTCG
  2020-06-26 18:30   ` Richard Henderson
@ 2020-06-26 19:37     ` Alex Bennée
  2020-06-29 14:41     ` Alex Bennée
  1 sibling, 0 replies; 33+ messages in thread
From: Alex Bennée @ 2020-06-26 19:37 UTC (permalink / raw)
  To: Richard Henderson
  Cc: fam, berrange, Philippe Mathieu-Daudé,
	qemu-devel, f4bug, cota, aurelien


Richard Henderson <richard.henderson@linaro.org> writes:

> On 6/22/20 7:31 AM, Alex Bennée wrote:
>>          if kvm_available(vmcls.arch):
>>              return multiprocessing.cpu_count() // 2
>> +        elif os.uname().machine == "x86_64" and \
>> +             vmcls.arch in ["aarch64", "x86_64", "i386"]:
>> +            # MTTCG is available on these arches and we can allow more cores.
>> +            # But only up to a reasonable limit. User can always override
>> +            # these limits with --jobs.
>> +            return min(multiprocessing.cpu_count() // 2, 8)
>>          else:
>
> And if multiprocessing.cpu_count() == 1?
> Seems like we should add max(count, 1) as well.

Or maybe?

   min(math.ceil(multiprocessing.cpu_count() / 2), 8)
>
>
> r~


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v1 12/18] tests/vm: allow us to take advantage of MTTCG
  2020-06-26 18:30   ` Richard Henderson
  2020-06-26 19:37     ` Alex Bennée
@ 2020-06-29 14:41     ` Alex Bennée
  2020-06-29 14:45       ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 33+ messages in thread
From: Alex Bennée @ 2020-06-29 14:41 UTC (permalink / raw)
  To: Richard Henderson
  Cc: fam, berrange, Philippe Mathieu-Daudé,
	qemu-devel, f4bug, cota, aurelien


Richard Henderson <richard.henderson@linaro.org> writes:

> On 6/22/20 7:31 AM, Alex Bennée wrote:
>>          if kvm_available(vmcls.arch):
>>              return multiprocessing.cpu_count() // 2
>> +        elif os.uname().machine == "x86_64" and \
>> +             vmcls.arch in ["aarch64", "x86_64", "i386"]:
>> +            # MTTCG is available on these arches and we can allow more cores.
>> +            # But only up to a reasonable limit. User can always override
>> +            # these limits with --jobs.
>> +            return min(multiprocessing.cpu_count() // 2, 8)
>>          else:
>
> And if multiprocessing.cpu_count() == 1?
> Seems like we should add max(count, 1) as well.

As it also affects KVM:

    def get_default_jobs():
        if multiprocessing.cpu_count > 1:
            if kvm_available(vmcls.arch):
                return multiprocessing.cpu_count() // 2
            elif os.uname().machine == "x86_64" and \
                 vmcls.arch in ["aarch64", "x86_64", "i386"]:
                # MTTCG is available on these arches and we can allow more cores.
                # But only up to a reasonable limit. User can always override
                # these limits with --jobs.
                return min(multiprocessing.cpu_count() // 2, 8)
        else:
            return 1


>
>
> r~


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v1 12/18] tests/vm: allow us to take advantage of MTTCG
  2020-06-29 14:41     ` Alex Bennée
@ 2020-06-29 14:45       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 33+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-06-29 14:45 UTC (permalink / raw)
  To: Alex Bennée, Richard Henderson
  Cc: fam, berrange, Philippe Mathieu-Daudé, qemu-devel, cota, aurelien

On 6/29/20 4:41 PM, Alex Bennée wrote:
> 
> Richard Henderson <richard.henderson@linaro.org> writes:
> 
>> On 6/22/20 7:31 AM, Alex Bennée wrote:
>>>          if kvm_available(vmcls.arch):
>>>              return multiprocessing.cpu_count() // 2
>>> +        elif os.uname().machine == "x86_64" and \
>>> +             vmcls.arch in ["aarch64", "x86_64", "i386"]:
>>> +            # MTTCG is available on these arches and we can allow more cores.
>>> +            # But only up to a reasonable limit. User can always override
>>> +            # these limits with --jobs.
>>> +            return min(multiprocessing.cpu_count() // 2, 8)
>>>          else:
>>
>> And if multiprocessing.cpu_count() == 1?
>> Seems like we should add max(count, 1) as well.
> 
> As it also affects KVM:
> 
>     def get_default_jobs():
>         if multiprocessing.cpu_count > 1:
>             if kvm_available(vmcls.arch):
>                 return multiprocessing.cpu_count() // 2
>             elif os.uname().machine == "x86_64" and \
>                  vmcls.arch in ["aarch64", "x86_64", "i386"]:
>                 # MTTCG is available on these arches and we can allow more cores.
>                 # But only up to a reasonable limit. User can always override
>                 # these limits with --jobs.
>                 return min(multiprocessing.cpu_count() // 2, 8)
>         else:
>             return 1

For this hunk:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> 
> 
>>
>>
>> r~
> 
> 



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v1 13/18] tests/docker: check for an parameters not empty string
  2020-06-22 14:31 ` [PATCH v1 13/18] tests/docker: check for an parameters not empty string Alex Bennée
  2020-06-22 14:46   ` Philippe Mathieu-Daudé
@ 2020-06-29 16:15   ` Eric Blake
  1 sibling, 0 replies; 33+ messages in thread
From: Eric Blake @ 2020-06-29 16:15 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel
  Cc: fam, berrange, richard.henderson, f4bug, cota,
	Philippe Mathieu-Daudé,
	aurelien

On 6/22/20 9:31 AM, Alex Bennée wrote:
> Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>   tests/docker/common.rc | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/docker/common.rc b/tests/docker/common.rc
> index 02cd67a8c5e..b27ce17e333 100755
> --- a/tests/docker/common.rc
> +++ b/tests/docker/common.rc
> @@ -47,7 +47,7 @@ build_qemu()
>   check_qemu()
>   {
>       # default to make check unless the caller specifies
> -    if test -z "$@"; then
> +    if [ $# == 0 ]; then

This is a bashism, but in a file marked #!/bin/sh.  You need to spell it 
= instead of ==.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2020-06-29 16:16 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22 14:31 [PATCH v1 00/18] testing/next (vm, gitlab) Alex Bennée
2020-06-22 14:31 ` [PATCH v1 01/18] iotests: Fix 051 output after qdev_init_nofail() removal Alex Bennée
2020-06-22 17:52   ` John Snow
2020-06-22 17:57     ` Philippe Mathieu-Daudé
2020-06-22 18:23     ` Alex Bennée
2020-06-22 14:31 ` [PATCH v1 02/18] tests/vm: pass args through to BaseVM's __init__ Alex Bennée
2020-06-22 14:31 ` [PATCH v1 03/18] tests/vm: Add configuration to basevm.py Alex Bennée
2020-06-22 14:31 ` [PATCH v1 04/18] tests/vm: Added configuration file support Alex Bennée
2020-06-22 14:31 ` [PATCH v1 05/18] tests/vm: Add common Ubuntu python module Alex Bennée
2020-06-22 14:31 ` [PATCH v1 06/18] tests/vm: Added a new script for ubuntu.aarch64 Alex Bennée
2020-06-22 14:31 ` [PATCH v1 07/18] tests/vm: Added a new script for centos.aarch64 Alex Bennée
2020-06-22 14:31 ` [PATCH v1 08/18] tests/vm: change scripts to use self._config Alex Bennée
2020-06-22 14:31 ` [PATCH v1 09/18] python/qemu: Add ConsoleSocket for optional use in QEMUMachine Alex Bennée
2020-06-22 14:31 ` [PATCH v1 10/18] tests/vm: Add workaround to consume console Alex Bennée
2020-06-22 14:31 ` [PATCH v1 11/18] tests/vm: switch from optsparse to argparse Alex Bennée
2020-06-22 17:11   ` Robert Foley
2020-06-22 17:20   ` Daniel P. Berrangé
2020-06-22 14:31 ` [PATCH v1 12/18] tests/vm: allow us to take advantage of MTTCG Alex Bennée
2020-06-22 14:52   ` Robert Foley
2020-06-26 18:30   ` Richard Henderson
2020-06-26 19:37     ` Alex Bennée
2020-06-29 14:41     ` Alex Bennée
2020-06-29 14:45       ` Philippe Mathieu-Daudé
2020-06-22 14:31 ` [PATCH v1 13/18] tests/docker: check for an parameters not empty string Alex Bennée
2020-06-22 14:46   ` Philippe Mathieu-Daudé
2020-06-29 16:15   ` Eric Blake
2020-06-22 14:32 ` [PATCH v1 14/18] .gitignore: un-ignore .gitlab-ci.d Alex Bennée
2020-06-22 16:29   ` Daniel P. Berrangé
2020-06-22 14:32 ` [PATCH v1 15/18] .gitlab: add acceptance testing to system builds Alex Bennée
2020-06-22 14:32 ` [PATCH v1 16/18] .gitlab: split fedora-misc-disabled Alex Bennée
2020-06-22 14:32 ` [PATCH v1 17/18] .gitlab: tag remaining jobs as builds Alex Bennée
2020-06-22 14:32 ` [PATCH v1 18/18] .gitlab: add avocado asset caching Alex Bennée
2020-06-22 14:45   ` Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.