From nobody Tue Feb 10 01:34:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1594106159; cv=none; d=zohomail.com; s=zohoarc; b=CZdz00OU93F1PjML9mWtPtV2tk637RBGWz7gt2o0F2CTVUbCo5YVHeB4YI5p2hWGjx3Z/01+JX+AI9Aa/GIRSF+ii4wtHCxnUiCwcu28j2XrjK4vczM9tQ7D2/pljphKvwkJK4eq90y8I7A13MBpDD+jnlbhmHi3TfgQ4j/1cIo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594106159; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=y/qmE2rvdW+2X2fGtUlm2uoe3BCyY7VQ2o9+eHdvkyA=; b=IyJiqJSDYCZGxDYU28E8VQlD3OMt3hhoEAdnubB1MnEKpNUs+AizVHxJfKtm4K4Oy+4YzjKWzHWTWRRi7zyB52e2uZWGyzlcqS0ON6fSmZMmtUF4Ste4mTGEEBh2Gp78d/gRAVvTuSw++dp3acfhN/6CJatEF+7rHR+JzuybDHQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15941061597971004.1814886150297; Tue, 7 Jul 2020 00:15:59 -0700 (PDT) Received: from localhost ([::1]:35902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jshpd-0008Nz-Vz for importer@patchew.org; Tue, 07 Jul 2020 03:15:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jshj6-0004bN-Vt for qemu-devel@nongnu.org; Tue, 07 Jul 2020 03:09:13 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:50369) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jshj3-00044x-If for qemu-devel@nongnu.org; Tue, 07 Jul 2020 03:09:12 -0400 Received: by mail-wm1-x332.google.com with SMTP id l17so42117055wmj.0 for ; Tue, 07 Jul 2020 00:09:09 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z6sm2155864wmf.33.2020.07.07.00.09.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 00:09:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 123231FF92; Tue, 7 Jul 2020 08:08:59 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y/qmE2rvdW+2X2fGtUlm2uoe3BCyY7VQ2o9+eHdvkyA=; b=VO85lIIBVWBNwy4Rzco5/hd7alzrd37H7gQll84vVwymGS6kn+RAX14uX9zFVJR47u WjV1joSBV30r3ifE0zRN8Pze+nYnsAywfSX2zx1NLjRDbh9taoQY+qvyVOG0Ph5qDN9d vu4IzLVuXsSDKUWa82yw1xA4wdvxG/zTshkRVEse/XpnGBtKs5dgQ5PHSyDRXUrg8G9W REcOWUCO2A5jc8VlaNaBdr08l7wfhEkXMX6vnf4keQcS5/MsMWVy65wanlP2OeEbAunb FFqyN92jj0Kj6uP/JLkcqcAHClUia1lQpix8TvYCQOp8G1bEzR+fXWe2fH2PaDO4/OOC SeIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y/qmE2rvdW+2X2fGtUlm2uoe3BCyY7VQ2o9+eHdvkyA=; b=fMImh8RZ5InlhJdg5poUfzKD39WdaexxgUn54MkvG7huYqj/emETlqpSt6PolgKzm4 MXiHHNcPBRlToVizjoxvkGTx1XXdKvhUzqQOEC6241qcy/mNyvL+RUxBBau0tkrfwuA6 6Sb3TcajnVFrS96PiaUZgYNackh5G+AgxUVtrhLQXtsIASJZXE6biex6Yu7KwiwZJZnM UcKJsoFnUrn0C4rJmi7LGOlRqm9OW2m7BQgTMsdv48bHnRHpyW+RbZyg6sWAmILZJJVe xMKpQ5OEezLj8wq0ffOW0pmpWGOT8fW1HTUyw9K1ftWgyVM2GQsVYchBwscKmETjq84T ABzA== X-Gm-Message-State: AOAM530UlDqGODmUMIQFt54iJSy5x6zVl8h+sCx+E9YwPVWp76a1m74r CSQ5EcSMPJHmxOX0LG+osPasOQ== X-Google-Smtp-Source: ABdhPJyxg465cM8EkIYHeuDj3ZY11Enf5dSokVTMbwjGOZBxXgIL3psMBOVqKdYqh24Qo5SSTM9Z3Q== X-Received: by 2002:a7b:c0c9:: with SMTP id s9mr2505577wmh.166.1594105748078; Tue, 07 Jul 2020 00:09:08 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 06/41] tests/vm: Add common Ubuntu python module Date: Tue, 7 Jul 2020 08:08:23 +0100 Message-Id: <20200707070858.6622-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200707070858.6622-1-alex.bennee@linaro.org> References: <20200707070858.6622-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x332.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Robert Foley Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Robert Foley 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 Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alex Benn=C3=A9e Message-Id: <20200601211421.1277-5-robert.foley@linaro.org> Message-Id: <20200701135652.1366-9-alex.bennee@linaro.org> diff --git a/tests/vm/ubuntu.i386 b/tests/vm/ubuntu.i386 index 24527cc78c77..5ce72610a6c8 100755 --- a/tests/vm/ubuntu.i386 +++ b/tests/vm/ubuntu.i386 @@ -11,15 +11,22 @@ # the COPYING file in the top-level directory. # =20 -import os import sys -import subprocess import basevm -import time +import ubuntuvm =20 -class UbuntuX86VM(basevm.BaseVM): +DEFAULT_CONFIG =3D { + '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 =3D "ubuntu.i386" arch =3D "i386" + image_link=3D"https://cloud-images.ubuntu.com/releases/bionic/"\ + "release-20191114/ubuntu-18.04-server-cloudimg-i386.img" + image_sha256=3D"28969840626d1ea80bb249c08eef1a4533e8904aa51a327b40f37a= c4b4ff04ef" BUILD_SCRIPT =3D """ set -e; cd $(mktemp -d); @@ -29,34 +36,5 @@ class UbuntuX86VM(basevm.BaseVM): make --output-sync {target} -j{jobs} {verbose}; """ =20 - def build_image(self, img): - cimg =3D self._download_with_cache( - "https://cloud-images.ubuntu.com/releases/bionic/release-20191= 114/ubuntu-18.04-server-cloudimg-i386.img", - sha256sum=3D"28969840626d1ea80bb249c08eef1a4533e8904aa51a327b4= 0f37ac4b4ff04ef") - img_tmp =3D img + ".tmp" - subprocess.check_call(["cp", "-f", cimg, img_tmp]) - self.exec_qemu_img("resize", img_tmp, "50G") - self.boot(img_tmp, extra_args =3D [ - "-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/sour= ces.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-e= n") - self.ssh_root("poweroff") - self.wait() - os.rename(img_tmp, img) - return 0 - if __name__ =3D=3D "__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 000000000000..6689ad87aa83 --- /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 +# Originally based on ubuntu.i386 Fam Zheng +# +# 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=3DNone): + self.login_prompt =3D "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 =3D self._download_with_cache(self.image_link, + sha256sum=3Dself.image_sha256) + img_tmp =3D img + ".tmp" + subprocess.check_call(["cp", "-f", os_img, img_tmp]) + self.exec_qemu_img("resize", img_tmp, "+50G") + ci_img =3D self.gen_cloud_init_iso() + + self.boot(img_tmp, extra_args =3D [ "-device", "VGA", "-cdrom", ci= _img, ]) + + # First command we issue is fix for slow ssh login. + self.wait_ssh(wait_root=3DTrue, + cmd=3D"chmod -x /etc/update-motd.d/*") + # Wait for cloud init to finish + self.wait_ssh(wait_root=3DTrue, + cmd=3D"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.li= st") + + # If the user chooses not to do the install phase, + # then we will jump right to the graceful shutdown + if self._config['install_cmds'] !=3D "": + # Issue the install commands. + # This can be overriden by the user in the config .yml. + install_cmds =3D self._config['install_cmds'].split(',') + for cmd in install_cmds: + self.ssh_root(cmd) + self.graceful_shutdown() + os.rename(img_tmp, img) + return 0 --=20 2.20.1