From nobody Mon May 6 08:18:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560746512; cv=none; d=zoho.com; s=zohoarc; b=I6QMWqd4tKEC1K3qtQKQmGdLm+dl4aDjkgXvEkV/rLH5wKVkV0ErkelaYh9vUWskrsIRNwGBF9RN1UF9QFtBfa7pQPBQs7giwUEff/PiDOwFO34szvwIMVBRqegXcgEpGlOOQouDLbUkttokkWM7A7rCMPYWPCvyw0L+NGoJA44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560746512; 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:ARC-Authentication-Results; bh=utDjEteOdfsya3lCSieSLAEjROCHY0wbBHzDTHLgC+g=; b=eMgUkSD7I7ZFAvbiNwd2O5efUIGH8SNyAUxrwsDwncb9hTtvJIMGSBCoSSanp7RCjhhqqfMPgGMEfLYjX6nxlhnThaCZP5J8c4aGSliUxCasOSrpDB3HDOLzuwmf14XxelQ1PrRdS1lKcC4odjWE8q633rWZWpWQB2VbJKteFLo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560746512239895.4465397987661; Sun, 16 Jun 2019 21:41:52 -0700 (PDT) Received: from localhost ([::1]:44204 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjSd-0003NJ-Ee for importer@patchew.org; Mon, 17 Jun 2019 00:41:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60162) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjQE-0001P0-Fj for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcjQC-0005rm-5y for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35642) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcjQB-0005oM-Dd for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:07 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E78223086222; Mon, 17 Jun 2019 04:39:04 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id C057582A0C; Mon, 17 Jun 2019 04:38:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E184816E19; Mon, 17 Jun 2019 06:38:58 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 06:38:48 +0200 Message-Id: <20190617043858.8290-2-kraxel@redhat.com> In-Reply-To: <20190617043858.8290-1-kraxel@redhat.com> References: <20190617043858.8290-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 17 Jun 2019 04:39:05 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 01/11] tests/vm: send proxy environment variables over ssh 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 , Ed Maste , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Kamil Rytarowski , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Li-Wen Hsu , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Packages are fetched via proxy that way, if configured on the host. That might be required to pass firewalls, and it allows to route package downloads through a caching proxy server. Needs AcceptEnv setup in sshd_config on the guest side to work. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Thomas Huth --- tests/vm/basevm.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 4847549592d5..5e30bac66154 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -38,6 +38,13 @@ class BaseVM(object): GUEST_PASS =3D "qemupass" ROOT_PASS =3D "qemupass" =20 + envvars =3D [ + "https_proxy", + "http_proxy", + "ftp_proxy", + "no_proxy", + ] + # The script to run in the guest that builds QEMU BUILD_SCRIPT =3D "" # The guest name, to be overridden by subclasses @@ -106,6 +113,8 @@ class BaseVM(object): "-o", "UserKnownHostsFile=3D" + os.devnull, "-o", "ConnectTimeout=3D1", "-p", self.ssh_port, "-i", self._ssh_key_file] + for var in self.envvars: + ssh_cmd +=3D ['-o', "SendEnv=3D%s" % var ] if interactive: ssh_cmd +=3D ['-t'] assert not isinstance(cmd, str) --=20 2.18.1 From nobody Mon May 6 08:18:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560746517; cv=none; d=zoho.com; s=zohoarc; b=NehMVsqBWQIEYRRhfomlajz2WZoGhu4bFWaWkDFSJSSYTgxyRpz/AewjsZiNpd5//ZxkBDo2r5yPDLuCnJM8CNLdfVEXztVK+I6NsXh/4qn/7cSh7QppxYaC5pYJasuXv7OsvAD/POewgAdQRH/gEBwL6Tm8H3MI7nzMFbkHb7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560746517; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=prSBAkGzAoYLd9YD8ojLbKojDPQfgRQHNv0+LMi1J+M=; b=O+pLyWW2hSynpE0HapJpY2iyikSkPskx2BS6ao9wtjsB2pkhuToz9dZEi2OZ6xgyXTrhW9dEE1Fodv+MVyabTP/9pRJR2Nw0xZuYMAjrbx0zKS5ACSMhhR34d6Awmwtp0yDrn4qmaNOGuF1Nn/B0dfWbpOSRXy87kWZuVr7vfdo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1560746517355728.196196650037; Sun, 16 Jun 2019 21:41:57 -0700 (PDT) Received: from localhost ([::1]:44206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjSd-0003Pg-Qd for importer@patchew.org; Mon, 17 Jun 2019 00:41:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60172) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjQE-0001P7-Pw for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcjQC-0005rt-8H for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58866) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcjQB-0005oH-Dd for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:07 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DA90D3162900; Mon, 17 Jun 2019 04:39:04 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id C05FB82A11; Mon, 17 Jun 2019 04:38:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E99BF16E1A; Mon, 17 Jun 2019 06:38:58 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 06:38:49 +0200 Message-Id: <20190617043858.8290-3-kraxel@redhat.com> In-Reply-To: <20190617043858.8290-1-kraxel@redhat.com> References: <20190617043858.8290-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 17 Jun 2019 04:39:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 02/11] tests/vm: use ssh with pty unconditionally 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 , Ed Maste , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Kamil Rytarowski , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Li-Wen Hsu , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Allways ask ssh to run with a pseudo terminal. Not having a terminal causes problems now and then. Signed-off-by: Gerd Hoffmann Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- tests/vm/basevm.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 5e30bac66154..395eefaec948 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -107,16 +107,14 @@ class BaseVM(object): os.rename(fname + ".download", fname) return fname =20 - def _ssh_do(self, user, cmd, check, interactive=3DFalse): - ssh_cmd =3D ["ssh", "-q", + def _ssh_do(self, user, cmd, check): + ssh_cmd =3D ["ssh", "-q", "-t", "-o", "StrictHostKeyChecking=3Dno", "-o", "UserKnownHostsFile=3D" + os.devnull, "-o", "ConnectTimeout=3D1", "-p", self.ssh_port, "-i", self._ssh_key_file] for var in self.envvars: ssh_cmd +=3D ['-o', "SendEnv=3D%s" % var ] - if interactive: - ssh_cmd +=3D ['-t'] assert not isinstance(cmd, str) ssh_cmd +=3D ["%s@127.0.0.1" % user] + list(cmd) logging.debug("ssh_cmd: %s", " ".join(ssh_cmd)) @@ -128,9 +126,6 @@ class BaseVM(object): def ssh(self, *cmd): return self._ssh_do(self.GUEST_USER, cmd, False) =20 - def ssh_interactive(self, *cmd): - return self._ssh_do(self.GUEST_USER, cmd, False, True) - def ssh_root(self, *cmd): return self._ssh_do("root", cmd, False) =20 @@ -284,9 +279,9 @@ def main(vmcls): return 2 =20 if args.interactive: - if vm.ssh_interactive(*cmd) =3D=3D 0: + if vm.ssh(*cmd) =3D=3D 0: return 0 - vm.ssh_interactive() + vm.ssh() return 3 else: if vm.ssh(*cmd) !=3D 0: --=20 2.18.1 From nobody Mon May 6 08:18:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560746902; cv=none; d=zoho.com; s=zohoarc; b=VwXgMaXRBddB/O5FeIvNCqUUIYR0x9Fs6i9+9OUQWQli9AJTo9F9Rjoo1X9jK67UnQiR6he3p9YKZOPLYRHHnm7xaZwJZphulltvjwY3JVBJTaOWxCEZXlwr9vqMEqVHuVospJnvAmQadslv/lupoTgmff8dPZ5pXH9uMFCWdgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560746902; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=9Y1BDs3B5Gvq9gxDTp822SI5R/5d75Ri7QWv9VoL3Ms=; b=OHesa3t1DY4RcbWe778e3dIsabzixQMOqplrbZWAGv2w/4Tc+xjgq1ZY5JOTTgM6a9X32trw+bXdFM8M5USPGyF/A3RiFREeUfYg016EXWG+uqLxKN8qbiU3XZFflRLmdNHKykY1Y1WCyEWkFfFo8SdbqRMJmdHihgkrq3SAaq0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560746902963634.6213319705156; Sun, 16 Jun 2019 21:48:22 -0700 (PDT) Received: from localhost ([::1]:44254 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjYx-00018h-0O for importer@patchew.org; Mon, 17 Jun 2019 00:48:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60254) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjQH-0001Pm-3E for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcjQE-0005uP-2a for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42982) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcjQC-0005r3-WE for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:09 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 410293024552; Mon, 17 Jun 2019 04:39:07 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id C022F79441; Mon, 17 Jun 2019 04:38:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id F1AC616E2D; Mon, 17 Jun 2019 06:38:58 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 06:38:50 +0200 Message-Id: <20190617043858.8290-4-kraxel@redhat.com> In-Reply-To: <20190617043858.8290-1-kraxel@redhat.com> References: <20190617043858.8290-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 17 Jun 2019 04:39:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 03/11] tests/vm: run test builds on snapshot 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 , Ed Maste , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Kamil Rytarowski , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Li-Wen Hsu , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The build script doesn't shutdown the guest VMs properly, which results in filesystem corruption and guest boot failures sooner or later. Use the --snapshot to run builds on a snapshot, That way killing the VM doesn't corrupt the base image. Signed-off-by: Gerd Hoffmann Tested-by: Thomas Huth Acked-by: Ed Maste Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- tests/vm/Makefile.include | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index c59411bee012..276b870216c4 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -57,6 +57,7 @@ vm-build-%: $(IMAGES_DIR)/%.img $(if $(V),--verbose) \ --image "$<" \ $(if $(BUILD_TARGET),--build-target $(BUILD_TARGET)) \ + --snapshot \ --build-qemu $(SRC_PATH) -- \ $(if $(TARGET_LIST),--target-list=3D$(TARGET_LIST)) \ $(if $(EXTRA_CONFIGURE_OPTS),$(EXTRA_CONFIGURE_OPTS)), \ --=20 2.18.1 From nobody Mon May 6 08:18:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560746512; cv=none; d=zoho.com; s=zohoarc; b=HNd+Esj797DWLOE3fDegSnQIyFZKKndZ7UHCskdCg/FBkww260awKny8gzeW1bBwnWTgOAn6wHLo+maVPPZQi1suGmlXPsrZBBQLIY/lEggbur3eczHGJ5JBSuhnPnqQ5VefY/wbcEZ5IjLNhBvArwkL87ZdLKQ/HOibctdMOfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560746512; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=8mmG7WDhnghMB56LeVz+gz9rDoyHrUm0WozusK87zvE=; b=XxL1UhmI/gx/tl6AMnNUO2FBl7CyjYVUF6yunN4nuv3Rsobzox9jMHGv54N4gm0f9XufsPb+i10k9FCTGA8TJ5R0kQ545/a+6tt1ZQzW02CPttimYglisZl/shc6Th9tfgMiuUU/IJMV7y+JjpEje6Ec7XX/YDGmrWvXMCBYi0A= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560746512747429.50336134571637; Sun, 16 Jun 2019 21:41:52 -0700 (PDT) Received: from localhost ([::1]:44208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjSf-0003T4-7J for importer@patchew.org; Mon, 17 Jun 2019 00:41:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60159) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjQE-0001Oy-E1 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcjQC-0005rg-6R for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58342) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcjQB-0005oc-Dc for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:07 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06E87330265; Mon, 17 Jun 2019 04:39:05 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id C06389F2E8; Mon, 17 Jun 2019 04:38:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 059F316E36; Mon, 17 Jun 2019 06:38:59 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 06:38:51 +0200 Message-Id: <20190617043858.8290-5-kraxel@redhat.com> In-Reply-To: <20190617043858.8290-1-kraxel@redhat.com> References: <20190617043858.8290-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 17 Jun 2019 04:39:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 04/11] tests/vm: proper guest shutdown 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 , Ed Maste , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Kamil Rytarowski , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Li-Wen Hsu , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When not running in snapshot mode ask the guest to poweroff and wait for this to finish instead of simply quitting qemu, so the guest can flush pending updates to disk. Signed-off-by: Gerd Hoffmann Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- tests/vm/basevm.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 395eefaec948..f27178f3c7c2 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -51,6 +51,8 @@ class BaseVM(object): name =3D "#base" # The guest architecture, to be overridden by subclasses arch =3D "#arch" + # command to halt the guest, can be overridden by subclasses + poweroff =3D "poweroff" def __init__(self, debug=3DFalse, vcpus=3DNone): self._guest =3D None self._tmpdir =3D os.path.realpath(tempfile.mkdtemp(prefix=3D"vm-te= st-", @@ -202,6 +204,10 @@ class BaseVM(object): def wait(self): self._guest.wait() =20 + def graceful_shutdown(self): + self.ssh_root(self.poweroff) + self._guest.wait() + def qmp(self, *args, **kwargs): return self._guest.qmp(*args, **kwargs) =20 @@ -278,11 +284,13 @@ def main(vmcls): traceback.print_exc() return 2 =20 - if args.interactive: - if vm.ssh(*cmd) =3D=3D 0: - return 0 + exitcode =3D 0 + if vm.ssh(*cmd) !=3D 0: + exitcode =3D 3 + if exitcode !=3D 0 and args.interactive: vm.ssh() - return 3 - else: - if vm.ssh(*cmd) !=3D 0: - return 3 + + if not args.snapshot: + vm.graceful_shutdown() + + return exitcode --=20 2.18.1 From nobody Mon May 6 08:18:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560746711; cv=none; d=zoho.com; s=zohoarc; b=M4xMMOkzY6e6VGjmRRW0nsjMw07dBbahtycTolf++laf6X9SZsb8qUe1+VuA5WI7o1Uo6+DEwgPqE2T3ONkRa7sEnOydPoLyxrTQGayJIgSPXAGJX2VeUepPRMPXDGkhsCQ38x/JcuRqBFFRbqRxprxHp/EyoCqfFeJPnhqJ6yU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560746711; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=MUlUa6PzbBpe3qh5b4qKJVG/ndlMIDY18aCkfK7UXWk=; b=feCzQ2vAJhXlLF5p9jj9Dwu9IPaTxkR60L3tpEnev6Gd9hEO53vkTPdF6CtQm1xWXKnIyZ2X9TYDkDHVxIXODQA9Jnm67F7h/15+OdLOjTEO55yrnsqDPsxumTpuggrZcpFxMooFZdqEKvNUsYs/BxdtE3GxGz5AoemmbHVYl1g= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1560746711155330.4161824106975; Sun, 16 Jun 2019 21:45:11 -0700 (PDT) Received: from localhost ([::1]:44228 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjW0-0006mp-5M for importer@patchew.org; Mon, 17 Jun 2019 00:45:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60322) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjQJ-0001Sh-CY for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcjQH-0005xr-1v for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34122) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcjQG-0005w2-EZ for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:12 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D24DC86658; Mon, 17 Jun 2019 04:39:10 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id B55C57DDA0; Mon, 17 Jun 2019 04:39:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 0D95317446; Mon, 17 Jun 2019 06:38:59 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 06:38:52 +0200 Message-Id: <20190617043858.8290-6-kraxel@redhat.com> In-Reply-To: <20190617043858.8290-1-kraxel@redhat.com> References: <20190617043858.8290-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 17 Jun 2019 04:39:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 05/11] tests/vm: add vm-boot-{ssh, serial}- targets 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 , Ed Maste , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Kamil Rytarowski , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Li-Wen Hsu , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For testing/troubleshooting convinience. make vm-boot-serial- Boot guest, with the serial console on stdio. make vm-boot-ssh- Boot guest, login via ssh. Signed-off-by: Gerd Hoffmann Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- tests/vm/Makefile.include | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index 276b870216c4..e329129bd658 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -20,6 +20,10 @@ vm-test: @echo " vm-build-all - Build QEMU in all VMs" @echo " vm-clean-all - Clean up VM images" @echo + @echo "For trouble-shooting:" + @echo " vm-boot-serial- - Boot guest, serial console on = stdio" + @echo " vm-boot-ssh- - Boot guest and login via ssh" + @echo @echo "Special variables:" @echo " BUILD_TARGET=3Dfoo - Override the build target" @echo " TARGET_LIST=3Da,b,c - Override target list in builds" @@ -63,3 +67,18 @@ vm-build-%: $(IMAGES_DIR)/%.img $(if $(EXTRA_CONFIGURE_OPTS),$(EXTRA_CONFIGURE_OPTS)), \ " VM-BUILD $*") =20 +vm-boot-serial-%: $(IMAGES_DIR)/%.img + qemu-system-x86_64 -enable-kvm -m 4G -smp 2 -nographic \ + -drive if=3Dnone,id=3Dvblk,cache=3Dwriteback,file=3D"$<" \ + -netdev user,id=3Dvnet \ + -device virtio-blk-pci,drive=3Dvblk \ + -device virtio-net-pci,netdev=3Dvnet \ + || true + +vm-boot-ssh-%: $(IMAGES_DIR)/%.img + $(call quiet-command, \ + $(SRC_PATH)/tests/vm/$* \ + --image "$<" \ + --interactive \ + false, \ + " VM-BOOT-SSH $*") --=20 2.18.1 From nobody Mon May 6 08:18:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560746901; cv=none; d=zoho.com; s=zohoarc; b=gmmmm5HdyDNMpzrTa20+YfAxXJ1s/8UuOHpsZSEMVifgv3jgM+ry3EHiCliSv3LmelGcx15yPd5ICc0dYzYThJfFnwINBsOGse15zGvnJaWNbdm1EwpDbGG5yQiAazBZ5WhTUo+GUtm6uANBQduEoSvkfUPuKpOqvsTUp3kYsao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560746901; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ByhTqfY21WA+CTvkEm++WCqlrMJlyQbqljMI4NXH38s=; b=DLT5DyFD/SVD6P2tvlbKk9L+U7wM0ceAtzvgq+Wzcr6ckVSGItZOUFXGyuEMzFacOFEe0eLQVBRCTZQB2M2dhskrFNonhEg4fV984k18Sflhr5UrkBWPY7Ef9s7Xr0qYhdekg/7bcIceXVAc2LUdbQqzrUGOZJrHGSt9H1WPD34= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560746901333743.1047441438191; Sun, 16 Jun 2019 21:48:21 -0700 (PDT) Received: from localhost ([::1]:44250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjYv-00014u-08 for importer@patchew.org; Mon, 17 Jun 2019 00:48:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60228) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjQG-0001PR-BD for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcjQC-0005t3-UQ for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56936) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcjQC-0005qA-1h for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:08 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B44C309265C; Mon, 17 Jun 2019 04:39:06 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB893166A9; Mon, 17 Jun 2019 04:39:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 15E2617472; Mon, 17 Jun 2019 06:38:59 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 06:38:53 +0200 Message-Id: <20190617043858.8290-7-kraxel@redhat.com> In-Reply-To: <20190617043858.8290-1-kraxel@redhat.com> References: <20190617043858.8290-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 17 Jun 2019 04:39:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 06/11] tests/vm: serial console support helpers 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 , Ed Maste , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Kamil Rytarowski , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Li-Wen Hsu , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a bunch of helpers to talk to the guest using the serial console. Also drop the hard-coded -serial parameter for the vm so QEMUMachine.set_console() actually works. Signed-off-by: Gerd Hoffmann Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- tests/vm/basevm.py | 86 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index f27178f3c7c2..592a3447735f 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -2,10 +2,11 @@ # # VM testing base class # -# Copyright 2017 Red Hat Inc. +# Copyright 2017-2019 Red Hat Inc. # # Authors: # Fam Zheng +# Gerd Hoffmann # # This code is licensed under the GPL version 2 or later. See # the COPYING file in the top-level directory. @@ -13,7 +14,9 @@ =20 from __future__ import print_function import os +import re import sys +import socket import logging import time import datetime @@ -79,8 +82,7 @@ class BaseVM(object): "-cpu", "max", "-netdev", "user,id=3Dvnet,hostfwd=3D:127.0.0.1:0-:22", "-device", "virtio-net-pci,netdev=3Dvnet", - "-vnc", "127.0.0.1:0,to=3D20", - "-serial", "file:%s" % os.path.join(self._tmpdir, "serial.out"= )] + "-vnc", "127.0.0.1:0,to=3D20"] if vcpus and vcpus > 1: self._args +=3D ["-smp", "%d" % vcpus] if kvm_available(self.arch): @@ -162,6 +164,8 @@ class BaseVM(object): logging.debug("QEMU args: %s", " ".join(args)) qemu_bin =3D os.environ.get("QEMU", "qemu-system-" + self.arch) guest =3D QEMUMachine(binary=3Dqemu_bin, args=3Dargs) + guest.set_machine('pc') + guest.set_console() try: guest.launch() except: @@ -184,6 +188,82 @@ class BaseVM(object): raise Exception("Cannot find ssh port from 'info usernet':\n%s= " % \ usernet_info) =20 + def console_init(self, timeout =3D 120): + vm =3D self._guest + vm.console_socket.settimeout(timeout) + + def console_log(self, text): + for line in re.split("[\r\n]", text): + # filter out terminal escape sequences + line =3D re.sub("\x1b\[[0-9;?]*[a-zA-Z]", "", line) + line =3D re.sub("\x1b\([0-9;?]*[a-zA-Z]", "", line) + # replace unprintable chars + line =3D re.sub("\x1b", "", line) + line =3D re.sub("[\x00-\x1f]", ".", line) + line =3D re.sub("[\x80-\xff]", ".", line) + if line =3D=3D "": + continue + # log console line + sys.stderr.write("con recv: %s\n" % line) + + def console_wait(self, expect): + vm =3D self._guest + output =3D "" + while True: + try: + chars =3D vm.console_socket.recv(1) + except socket.timeout: + sys.stderr.write("console: *** read timeout ***\n") + sys.stderr.write("console: waiting for: '%s'\n" % expect) + sys.stderr.write("console: line buffer:\n") + sys.stderr.write("\n") + self.console_log(output.rstrip()) + sys.stderr.write("\n") + raise + output +=3D chars.decode("latin1") + if expect in output: + break + if "\r" in output or "\n" in output: + lines =3D re.split("[\r\n]", output) + output =3D lines.pop() + if self.debug: + self.console_log("\n".join(lines)) + if self.debug: + self.console_log(output) + + def console_send(self, command): + vm =3D self._guest + if self.debug: + logline =3D re.sub("\n", "", command) + logline =3D re.sub("[\x00-\x1f]", ".", logline) + sys.stderr.write("con send: %s\n" % logline) + for char in list(command): + vm.console_socket.send(char.encode("utf-8")) + time.sleep(0.01) + + def console_wait_send(self, wait, command): + self.console_wait(wait) + self.console_send(command) + + def console_ssh_init(self, prompt, user, pw): + sshkey_cmd =3D "echo '%s' > .ssh/authorized_keys\n" % 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") + self.console_wait_send(prompt, sshkey_cmd) + self.console_wait_send(prompt, "chmod 755 .ssh\n") + self.console_wait_send(prompt, "chmod 644 .ssh/authorized_key= s\n") + + def console_sshd_config(self, prompt): + self.console_wait(prompt) + self.console_send("echo 'PermitRootLogin yes' >> /etc/ssh/sshd_con= fig\n") + for var in self.envvars: + self.console_wait(prompt) + self.console_send("echo 'AcceptEnv %s' >> /etc/ssh/sshd_config= \n" % var) + + def print_step(self, text): + sys.stderr.write("### %s ...\n" % text) + def wait_ssh(self, seconds=3D300): starttime =3D datetime.datetime.now() endtime =3D starttime + datetime.timedelta(seconds=3Dseconds) --=20 2.18.1 From nobody Mon May 6 08:18:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560747033; cv=none; d=zoho.com; s=zohoarc; b=lSeH6d6LnD4h3l6t8pWhjEIKnajGPElLszGzYHnWFacvtslFCFUjO2qqzfdTusVo9I+Vm2uAoClEBezSa/sYPb5JWMwN3Gz+LPl1ewdzVIjKci3eX8left6q0CdBsAer8ui+M7+o2q7BHMiiTv5aOA4kQJxB877EaCmS6tij2oU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560747033; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=2QojH6PLM7riHsXScVELwacCv2kS3yLXFALCa4MCVcM=; b=U256y8XSFc3blfwpPy3DwKNuzxAHRX/QkWzlEb9Y/SAytptuq5+9TcdqFlnma95hFJLljvqANKlnOXw0orDf4Bj9HIN4mrd9IjvmylMZZVnVlw7TS8kNnJ1+FAfvWdeJ0bZcGR7Ztm+D+y3ev4hBDm2YjTs8OM4JfTT6dY6GZdU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1560747033625797.0013822687877; Sun, 16 Jun 2019 21:50:33 -0700 (PDT) Received: from localhost ([::1]:44270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjbE-0003s4-NM for importer@patchew.org; Mon, 17 Jun 2019 00:50:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60401) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjQL-0001WQ-LA for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcjQH-0005xw-9d for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34140) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcjQG-0005wK-Mj for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:12 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 266B9820E9; Mon, 17 Jun 2019 04:39:11 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9AA4101E69C; Mon, 17 Jun 2019 04:39:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1E40117473; Mon, 17 Jun 2019 06:38:59 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 06:38:54 +0200 Message-Id: <20190617043858.8290-8-kraxel@redhat.com> In-Reply-To: <20190617043858.8290-1-kraxel@redhat.com> References: <20190617043858.8290-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 17 Jun 2019 04:39:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 07/11] tests/vm: openbsd autoinstall, using serial console 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 , Ed Maste , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Kamil Rytarowski , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Li-Wen Hsu , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Instead of fetching the prebuilt image from patchew download the install iso and prepare the image locally. Install to disk, using the serial console. Create qemu user, configure ssh login. Install packages needed for qemu builds. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- tests/vm/openbsd | 159 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 146 insertions(+), 13 deletions(-) diff --git a/tests/vm/openbsd b/tests/vm/openbsd index 2105c01a267a..b92c39f89a6f 100755 --- a/tests/vm/openbsd +++ b/tests/vm/openbsd @@ -2,10 +2,11 @@ # # OpenBSD VM image # -# Copyright 2017 Red Hat Inc. +# Copyright 2017-2019 Red Hat Inc. # # Authors: # Fam Zheng +# Gerd Hoffmann # # This code is licensed under the GPL version 2 or later. See # the COPYING file in the top-level directory. @@ -13,34 +14,166 @@ =20 import os import sys +import socket import subprocess import basevm =20 class OpenBSDVM(basevm.BaseVM): name =3D "openbsd" arch =3D "x86_64" + + link =3D "https://cdn.openbsd.org/pub/OpenBSD/6.5/amd64/install65.iso" + csum =3D "38d1f8cadd502f1c27bf05c5abde6cc505dd28f3f34f8a941048ff9a54f9= f608" + size =3D "20G" + pkgs =3D [ + # tools + "git", + "pkgconf", + "bzip2", "xz", + + # gnu tools + "bash", + "gmake", + "gsed", + "bison", + + # libs: usb + "libusb1", + + # libs: crypto + "gnutls", + + # libs: images + "jpeg", + "png", + + # libs: ui + "sdl2", + "gtk+3", + "libxkbcommon", + ] + BUILD_SCRIPT =3D """ set -e; - rm -rf /var/tmp/qemu-test.* - cd $(mktemp -d /var/tmp/qemu-test.XXXXXX); + rm -rf /home/qemu/qemu-test.* + cd $(mktemp -d /home/qemu/qemu-test.XXXXXX); + mkdir src build; cd src; tar -xf /dev/rsd1c; - ./configure --cc=3Dx86_64-unknown-openbsd6.1-gcc-4.9.4 --python=3D= python2.7 {configure_opts}; - gmake --output-sync -j{jobs} {verbose}; - # XXX: "gmake check" seems to always hang or fail - #gmake --output-sync -j{jobs} check {verbose}; + cd ../build + ../src/configure --cc=3Dcc --python=3Dpython3 {configure_opts}; + gmake --output-sync -j{jobs} {target} {verbose}; """ + poweroff =3D "halt -p" =20 def build_image(self, img): - cimg =3D self._download_with_cache("http://download.patchew.org/op= enbsd-6.1-amd64.img.xz", - sha256sum=3D'8c6cedc483e602cfee5e04f0406c64eb99138495e8ca5= 80bc0293bcf0640c1bf') - img_tmp_xz =3D img + ".tmp.xz" + self.print_step("Downloading install iso") + cimg =3D self._download_with_cache(self.link, sha256sum=3Dself.csu= m) img_tmp =3D img + ".tmp" - sys.stderr.write("Extracting the image...\n") - subprocess.check_call(["cp", "-f", cimg, img_tmp_xz]) - subprocess.check_call(["xz", "-dvf", img_tmp_xz]) + iso =3D img + ".install.iso" + + self.print_step("Preparing iso and disk image") + subprocess.check_call(["cp", "-f", cimg, iso]) + subprocess.check_call(["qemu-img", "create", "-f", "qcow2", + img_tmp, self.size]) + + self.print_step("Booting installer") + self.boot(img_tmp, extra_args =3D [ + "-bios", "pc-bios/bios-256k.bin", + "-machine", "graphics=3Doff", + "-cdrom", iso + ]) + self.console_init() + self.console_wait_send("boot>", "set tty com0\n") + self.console_wait_send("boot>", "\n") + + # pre-install configuration + self.console_wait_send("(I)nstall", "i\n") + self.console_wait_send("Terminal type", "xterm\n") + self.console_wait_send("System hostname", "openbsd\n") + self.console_wait_send("Which network interface", "vio0\n") + self.console_wait_send("IPv4 address", "dhcp\n") + self.console_wait_send("IPv6 address", "none\n") + 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_wait("Password for root account") + self.console_send("%s\n" % self.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") + self.console_wait_send("console to com0", "\n") + self.console_wait_send("Which speed", "\n") + + self.console_wait("Setup a user") + self.console_send("%s\n" % self.GUEST_USER) + self.console_wait("Full name") + self.console_send("%s\n" % self.GUEST_USER) + self.console_wait("Password") + self.console_send("%s\n" % self.GUEST_PASS) + self.console_wait("Password") + self.console_send("%s\n" % self.GUEST_PASS) + + self.console_wait_send("Allow root ssh login", "yes\n") + self.console_wait_send("timezone", "UTC\n") + self.console_wait_send("root disk", "\n") + self.console_wait_send("(W)hole disk", "\n") + self.console_wait_send("(A)uto layout", "\n") + self.console_wait_send("Location of sets", "cd0\n") + self.console_wait_send("Pathname to the sets", "\n") + self.console_wait_send("Set name(s)", "\n") + self.console_wait_send("without verification", "yes\n") + + self.print_step("Installation started now, this will take a while") + self.console_wait_send("Location of sets", "done\n") + + self.console_wait("successfully completed") + self.print_step("Installation finished, rebooting") + self.console_wait_send("(R)eboot", "reboot\n") + + # setup qemu user + prompt =3D "$" + self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS) + self.console_wait_send(prompt, "exit\n") + + # setup root user + prompt =3D "openbsd#" + self.console_ssh_init(prompt, "root", self.ROOT_PASS) + self.console_sshd_config(prompt) + + # setup virtio-blk #1 (tarfile) + self.console_wait(prompt) + self.console_send("echo 'chmod 666 /dev/rsd1c' >> /etc/rc.local\n") + + # enable w+x for /home + self.console_wait(prompt) + self.console_send("sed -i -e '/home/s/rw,/rw,wxallowed,/' /etc/fst= ab\n") + + # tweak datasize limit + self.console_wait(prompt) + self.console_send("sed -i -e 's/\\(datasize[^=3D]*\\)=3D[^:]*/\\1= =3Dinfinity/' /etc/login.conf\n") + + # use http (be proxy cache friendly) + self.console_wait(prompt) + self.console_send("sed -i -e 's/https/http/' /etc/installurl\n") + + self.print_step("Configuration finished, rebooting") + self.console_wait_send(prompt, "reboot\n") + self.console_wait("login:") + self.wait_ssh() + + self.print_step("Installing packages") + self.ssh_root_check("pkg_add %s\n" % " ".join(self.pkgs)) + + # shutdown + self.ssh_root(self.poweroff) + self.wait() + if os.path.exists(img): os.remove(img) os.rename(img_tmp, img) + os.remove(iso) + self.print_step("All done") =20 if __name__ =3D=3D "__main__": sys.exit(basevm.main(OpenBSDVM)) --=20 2.18.1 From nobody Mon May 6 08:18:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560746902; cv=none; d=zoho.com; s=zohoarc; b=MAqHVHFfxFX0lxC++OsDvJPm1DGXI5OubxWEX1v+pVS6CHs1iijxofALCXxbFzF1/Iqxjp+aZh/FhOdODPtU3Y4JbA1C5XhOFvmRTH/acyeLhxAGEqrkqX2gEVQ1J2n3wwDoY3gOu2xcPAgBuH1V4h0obq6ZfSRQXBWSqThqFX4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560746902; 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:ARC-Authentication-Results; bh=pWCnQhLDRc675GTBZXT3NCLAy25yPQFJiqh2djACTVQ=; b=l8Ea+eieSl5BFCUufnGT1ayB3fC5JzR+L7CN9nY9NJwwoCU+zfuH9TrxJM33i9cbg3QvVm7dYwpLh49tcKVY2afPJCOeKhDg3OptCIcdKUeK6xhvfmCem9Tp3zITDITuegac3coEnbMVbZlh24WmL6TnPa/INW5O/Gub8pKjpzY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560746902057259.91497096370153; Sun, 16 Jun 2019 21:48:22 -0700 (PDT) Received: from localhost ([::1]:44252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjYw-000156-1C for importer@patchew.org; Mon, 17 Jun 2019 00:48:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60424) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjQM-0001XR-Di for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcjQH-0005yF-Ey for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56458) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcjQG-0005wB-GJ for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:12 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E94473082AF2; Mon, 17 Jun 2019 04:39:10 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDA71101E841; Mon, 17 Jun 2019 04:39:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 26A2817474; Mon, 17 Jun 2019 06:38:59 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 06:38:55 +0200 Message-Id: <20190617043858.8290-9-kraxel@redhat.com> In-Reply-To: <20190617043858.8290-1-kraxel@redhat.com> References: <20190617043858.8290-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 17 Jun 2019 04:39:11 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 08/11] tests/vm: freebsd autoinstall, using serial console 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 , Ed Maste , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Kamil Rytarowski , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Li-Wen Hsu , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Instead of fetching the prebuilt image from patchew download the install iso and prepare the image locally. Install to disk, using the serial console. Create qemu user, configure ssh login. Install packages needed for qemu builds. Note that freebsd package downloads are delivered as non-cachable content, so I had to configure squid with "ignore-no-store ignore-private ignore-reload" for pkgmir.geo.freebsd.org to make the caching actually work. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Thomas Huth --- tests/vm/freebsd | 180 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 170 insertions(+), 10 deletions(-) diff --git a/tests/vm/freebsd b/tests/vm/freebsd index b0066017a617..2a19461a9098 100755 --- a/tests/vm/freebsd +++ b/tests/vm/freebsd @@ -2,43 +2,203 @@ # # FreeBSD VM image # -# Copyright 2017 Red Hat Inc. +# Copyright 2017-2019 Red Hat Inc. # # Authors: # Fam Zheng +# Gerd Hoffmann # # This code is licensed under the GPL version 2 or later. See # the COPYING file in the top-level directory. # =20 import os +import re import sys +import time +import socket import subprocess import basevm =20 class FreeBSDVM(basevm.BaseVM): name =3D "freebsd" arch =3D "x86_64" + + link =3D "https://download.freebsd.org/ftp/releases/ISO-IMAGES/12.0/Fr= eeBSD-12.0-RELEASE-amd64-disc1.iso.xz" + csum =3D "1d40015bea89d05b8bd13e2ed80c40b522a9ec1abd8e7c8b80954fb485fb= 99db" + size =3D "20G" + pkgs =3D [ + # build tools + "git", + "pkgconf", + "bzip2", + + # gnu tools + "bash", + "gmake", + "gsed", + "flex", "bison", + + # libs: crypto + "gnutls", + + # libs: images + "jpeg-turbo", + "png", + + # libs: ui + "sdl2", + "gtk3", + "libxkbcommon", + + # libs: opengl + "libepoxy", + "mesa-libs", + ] + BUILD_SCRIPT =3D """ set -e; - rm -rf /var/tmp/qemu-test.* - cd $(mktemp -d /var/tmp/qemu-test.XXXXXX); + rm -rf /home/qemu/qemu-test.* + cd $(mktemp -d /home/qemu/qemu-test.XXXXXX); + mkdir src build; cd src; tar -xf /dev/vtbd1; - ./configure {configure_opts}; + cd ../build + ../src/configure --python=3Dpython3.6 {configure_opts}; gmake --output-sync -j{jobs} {target} {verbose}; """ =20 + def console_boot_serial(self): + self.console_wait_send("Autoboot", "3") + self.console_wait_send("OK", "set console=3Dcomconsole\n") + self.console_wait_send("OK", "boot\n") + def build_image(self, img): - cimg =3D self._download_with_cache("http://download.patchew.org/fr= eebsd-11.1-amd64.img.xz", - sha256sum=3D'adcb771549b37bc63826c501f05121a206ed3d9f55f49= 145908f7e1432d65891') - img_tmp_xz =3D img + ".tmp.xz" + self.print_step("Downloading install iso") + cimg =3D self._download_with_cache(self.link, sha256sum=3Dself.csu= m) img_tmp =3D img + ".tmp" - sys.stderr.write("Extracting the image...\n") - subprocess.check_call(["cp", "-f", cimg, img_tmp_xz]) - subprocess.check_call(["xz", "-dvf", img_tmp_xz]) + iso =3D img + ".install.iso" + iso_xz =3D iso + ".xz" + + self.print_step("Preparing iso and disk image") + subprocess.check_call(["cp", "-f", cimg, iso_xz]) + subprocess.check_call(["xz", "-dvf", iso_xz]) + subprocess.check_call(["qemu-img", "create", "-f", "qcow2", + img_tmp, self.size]) + + self.print_step("Booting installer") + self.boot(img_tmp, extra_args =3D [ + "-bios", "pc-bios/bios-256k.bin", + "-machine", "graphics=3Doff", + "-cdrom", iso + ]) + self.console_init() + self.console_boot_serial() + self.console_wait_send("Console type", "xterm\n") + + # pre-install configuration + self.console_wait_send("Welcome", "\n") + self.console_wait_send("Keymap Selection", "\n") + self.console_wait_send("Set Hostname", "freebsd\n") + self.console_wait_send("Distribution Select", "\n") + self.console_wait_send("Partitioning", "\n") + self.console_wait_send("Partition", "\n") + self.console_wait_send("Scheme", "\n") + self.console_wait_send("Editor", "f") + self.console_wait_send("Confirmation", "c") + + self.print_step("Installation started now, this will take a while") + + # post-install configuration + self.console_wait("New Password:") + self.console_send("%s\n" % self.ROOT_PASS) + self.console_wait("Retype New Password:") + self.console_send("%s\n" % self.ROOT_PASS) + + self.console_wait_send("Network Configuration", "\n") + self.console_wait_send("IPv4", "y") + self.console_wait_send("DHCP", "y") + self.console_wait_send("IPv6", "n") + self.console_wait_send("Resolver", "\n") + + self.console_wait_send("Time Zone Selector", "a\n") + self.console_wait_send("Confirmation", "y") + self.console_wait_send("Time & Date", "\n") + self.console_wait_send("Time & Date", "\n") + + self.console_wait_send("System Configuration", "\n") + self.console_wait_send("System Hardening", "\n") + + # qemu user + self.console_wait_send("Add User Accounts", "y") + self.console_wait("Username") + self.console_send("%s\n" % self.GUEST_USER) + self.console_wait("Full name") + self.console_send("%s\n" % self.GUEST_USER) + self.console_wait_send("Uid", "\n") + self.console_wait_send("Login group", "\n") + self.console_wait_send("Login group", "\n") + self.console_wait_send("Login class", "\n") + self.console_wait_send("Shell", "\n") + self.console_wait_send("Home directory", "\n") + self.console_wait_send("Home directory perm", "\n") + self.console_wait_send("Use password", "\n") + 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_wait("Enter password again:") + self.console_send("%s\n" % self.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") + + self.console_wait_send("Final Configuration", "\n") + self.console_wait_send("Manual Configuration", "\n") + self.console_wait_send("Complete", "\n") + + self.print_step("Installation finished, rebooting") + self.console_boot_serial() + + # setup qemu user + prompt =3D "$" + self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS) + self.console_wait_send(prompt, "exit\n") + + # setup root user + prompt =3D "root@freebsd:~ #" + self.console_ssh_init(prompt, "root", self.ROOT_PASS) + self.console_sshd_config(prompt) + + # setup serial console + self.console_wait(prompt) + self.console_send("echo 'console=3Dcomconsole' >> /boot/loader.con= f\n") + + # setup boot delay + self.console_wait(prompt) + self.console_send("echo 'autoboot_delay=3D1' >> /boot/loader.conf\= n") + + # setup virtio-blk #1 (tarfile) + self.console_wait(prompt) + self.console_send("echo 'chmod 666 /dev/vtbd1' >> /etc/rc.local\n") + + self.print_step("Configuration finished, rebooting") + self.console_wait_send(prompt, "reboot\n") + self.console_wait("login:") + self.wait_ssh() + + self.print_step("Installing packages") + self.ssh_root_check("pkg install -y %s\n" % " ".join(self.pkgs)) + + # shutdown + self.ssh_root(self.poweroff) + self.console_wait("Uptime:") + self.wait() + if os.path.exists(img): os.remove(img) os.rename(img_tmp, img) + os.remove(iso) + self.print_step("All done") =20 if __name__ =3D=3D "__main__": sys.exit(basevm.main(FreeBSDVM)) --=20 2.18.1 From nobody Mon May 6 08:18:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560746954; cv=none; d=zoho.com; s=zohoarc; b=gdOG81pj2LskpSYiJ03n+Xidr//TAyEQJpt6xaYz8nshU+Ls1CmW6e2pmqjjjRJGYrQHuXsJOhu0lDqsEztHln54oyNk+XCppBChhHrV8aYxwMUwBlzLkeEPONSk3JUdjzB3gat/5mLYCc0xj4FzuwQBjiC156xjHGRPXU5UD6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560746954; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=opLUwolBYKUdohLfw105cnCU9CaHCLTOplQtObnJZDg=; b=KeGVK0dnDE1SCOEGz09kLRXfnWfXcNXxBMyjiFXQxgcdmLNkrE6oWOAKURo+F6ci5pR0aZ1bOsBpX3F62e0HdwUQzcJ9BfE/0b5Ss8TYOl5VXnS+ArofgkMR45YTscP/knsBUt0q+cbjZbaGDjaJX5m1JWXynFuWB8T8YSZ91A4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1560746954443772.076788606338; Sun, 16 Jun 2019 21:49:14 -0700 (PDT) Received: from localhost ([::1]:44264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjZx-0002wR-IP for importer@patchew.org; Mon, 17 Jun 2019 00:49:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60445) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjQM-0001YK-V8 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcjQH-0005yq-VP for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34152) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcjQH-0005wf-2w for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:13 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 631EA811BD; Mon, 17 Jun 2019 04:39:11 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id D58CA7DDF9; Mon, 17 Jun 2019 04:39:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2F28A17536; Mon, 17 Jun 2019 06:38:59 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 06:38:56 +0200 Message-Id: <20190617043858.8290-10-kraxel@redhat.com> In-Reply-To: <20190617043858.8290-1-kraxel@redhat.com> References: <20190617043858.8290-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 17 Jun 2019 04:39:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 09/11] tests/vm: netbsd autoinstall, using serial console 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 , Ed Maste , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Kamil Rytarowski , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Li-Wen Hsu , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Instead of fetching the prebuilt image from patchew download the install iso and prepare the image locally. Install to disk, using the serial console. Create qemu user, configure ssh login. Install packages needed for qemu builds. Signed-off-by: Gerd Hoffmann Reviewed-by: Kamil Rytarowski Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- tests/vm/netbsd | 187 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 177 insertions(+), 10 deletions(-) diff --git a/tests/vm/netbsd b/tests/vm/netbsd index 4c6624ea5ed5..be59a2c1da1d 100755 --- a/tests/vm/netbsd +++ b/tests/vm/netbsd @@ -2,10 +2,11 @@ # # NetBSD VM image # -# Copyright 2017 Red Hat Inc. +# Copyright 2017-2019 Red Hat Inc. # # Authors: # Fam Zheng +# Gerd Hoffmann # # This code is licensed under the GPL version 2 or later. See # the COPYING file in the top-level directory. @@ -13,32 +14,198 @@ =20 import os import sys +import time import subprocess import basevm =20 class NetBSDVM(basevm.BaseVM): name =3D "netbsd" arch =3D "x86_64" + + link =3D "https://cdn.netbsd.org/pub/NetBSD/NetBSD-8.0/images/NetBSD-8= .0-amd64.iso" + size =3D "20G" + pkgs =3D [ + # tools + "git-base", + "pkgconf", + "xz", + "python37", + + # gnu tools + "bash", + "gmake", + "gsed", + "flex", "bison", + + # libs: crypto + "gnutls", + + # libs: images + "jpeg", + "png", + + # libs: ui + "SDL2", + "gtk3+", + "libxkbcommon", + ] + BUILD_SCRIPT =3D """ set -e; - rm -rf /var/tmp/qemu-test.* - cd $(mktemp -d /var/tmp/qemu-test.XXXXXX); + rm -rf /home/qemu/qemu-test.* + cd $(mktemp -d /home/qemu/qemu-test.XXXXXX); + mkdir src build; cd src; tar -xf /dev/rld1a; - ./configure --python=3Dpython2.7 {configure_opts}; + cd ../build + ../src/configure --python=3Dpython3.7 --disable-opengl {configure_= opts}; gmake --output-sync -j{jobs} {target} {verbose}; """ + poweroff =3D "/sbin/poweroff" =20 def build_image(self, img): - cimg =3D self._download_with_cache("http://download.patchew.org/ne= tbsd-7.1-amd64.img.xz", - sha256sum=3D'b633d565b0eac3d02015= cd0c81440bd8a7a8df8512615ac1ee05d318be015732') - img_tmp_xz =3D img + ".tmp.xz" + cimg =3D self._download_with_cache(self.link) img_tmp =3D img + ".tmp" - sys.stderr.write("Extracting the image...\n") - subprocess.check_call(["cp", "-f", cimg, img_tmp_xz]) - subprocess.check_call(["xz", "-dvf", img_tmp_xz]) + iso =3D img + ".install.iso" + + self.print_step("Preparing iso and disk image") + subprocess.check_call(["cp", "-f", cimg, iso]) + subprocess.check_call(["qemu-img", "create", "-f", "qcow2", + img_tmp, self.size]) + + self.print_step("Booting installer") + self.boot(img_tmp, extra_args =3D [ + "-bios", "pc-bios/bios-256k.bin", + "-machine", "graphics=3Doff", + "-cdrom", iso + ]) + self.console_init() + self.console_wait("Primary Bootstrap") + + # serial console boot menu output doesn't work for some + # reason, so we have to fly blind ... + for char in list("5consdev com0\n"): + time.sleep(0.2) + self.console_send(char) + self.console_wait("") + self.console_wait_send("> ", "boot\n") + + self.console_wait_send("Terminal type", "xterm\n") + self.console_wait_send("a: Installation messages", "a\n") + self.console_wait_send("b: US-English", "b\n") + self.console_wait_send("a: Install NetBSD", "a\n") + self.console_wait("Shall we continue?") + self.console_wait_send("b: Yes", "b\n") + + self.console_wait_send("a: ld0", "a\n") + self.console_wait_send("a: This is the correct", "a\n") + self.console_wait_send("b: Use the entire disk", "b\n") + self.console_wait("NetBSD bootcode") + self.console_wait_send("a: Yes", "a\n") + self.console_wait_send("b: Use existing part", "b\n") + self.console_wait_send("x: Partition sizes ok", "x\n") + self.console_wait_send("for your NetBSD disk", "\n") + self.console_wait("Shall we continue?") + self.console_wait_send("b: Yes", "b\n") + + self.console_wait_send("b: Use serial port com0", "b\n") + self.console_wait_send("f: Set serial baud rate", "f\n") + self.console_wait_send("a: 9600", "a\n") + self.console_wait_send("x: Exit", "x\n") + + self.console_wait_send("a: Full installation", "a\n") + self.console_wait_send("a: CD-ROM", "a\n") + + self.print_step("Installation started now, this will take a while") + self.console_wait_send("Hit enter to continue", "\n") + + 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_wait("New password:") + self.console_send("%s\n" % self.ROOT_PASS) + self.console_wait("Retype new password:") + self.console_send("%s\n" % self.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_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_wait("New password:") + self.console_send("%s\n" % self.GUEST_PASS) + self.console_wait("Retype new password:") + self.console_send("%s\n" % self.GUEST_PASS) + + self.console_wait_send("a: Configure network", "a\n") + self.console_wait_send("a: vioif0", "a\n") + self.console_wait_send("Network media type", "\n") + self.console_wait("autoconfiguration") + self.console_wait_send("a: Yes", "a\n") + self.console_wait_send("DNS domain", "localnet\n") + self.console_wait("Are they OK?") + self.console_wait_send("a: Yes", "a\n") + self.console_wait("installed in /etc") + self.console_wait_send("a: Yes", "a\n") + + self.console_wait_send("e: Enable install", "e\n") + proxy =3D os.environ.get("http_proxy") + if not proxy is None: + self.console_wait_send("f: Proxy", "f\n") + self.console_wait("Proxy") + self.console_send("%s\n" % proxy) + self.console_wait_send("x: Install pkgin", "x\n") + self.console_init(1200) + self.console_wait_send("Hit enter to continue", "\n") + self.console_init() + + self.console_wait_send("g: Enable sshd", "g\n") + self.console_wait_send("x: Finished conf", "x\n") + self.console_wait_send("Hit enter to continue", "\n") + + self.print_step("Installation finished, rebooting") + self.console_wait_send("d: Reboot the computer", "d\n") + + # setup qemu user + prompt =3D "localhost$" + self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS) + self.console_wait_send(prompt, "exit\n") + + # setup root user + prompt =3D "localhost#" + self.console_ssh_init(prompt, "root", self.ROOT_PASS) + self.console_sshd_config(prompt) + + # setup virtio-blk #1 (tarfile) + self.console_wait(prompt) + self.console_send("echo 'chmod 666 /dev/rld1a' >> /etc/rc.local\n") + + # turn off mprotect (conflicts with tcg) + self.console_wait(prompt) + self.console_send("echo security.pax.mprotect.enabled=3D0 >> /etc/= sysctl.conf\n") + + self.print_step("Configuration finished, rebooting") + self.console_wait_send(prompt, "reboot\n") + self.console_wait("login:") + self.wait_ssh() + + self.print_step("Installing packages") + self.ssh_root_check("pkgin update\n") + self.ssh_root_check("pkgin -y install %s\n" % " ".join(self.pkgs)) + + # shutdown + self.ssh_root(self.poweroff) + self.console_wait("entering state S5") + self.wait() + if os.path.exists(img): os.remove(img) os.rename(img_tmp, img) + os.remove(iso) + self.print_step("All done") =20 if __name__ =3D=3D "__main__": sys.exit(basevm.main(NetBSDVM)) --=20 2.18.1 From nobody Mon May 6 08:18:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560746512; cv=none; d=zoho.com; s=zohoarc; b=KoISgpQurAvFsFMMuPHvWITGzVVKVFzpDpGd/AqChzajaeJiThiaoFYzgYrKzAwYbsPn8qBiVdhJV9bWyiyn0TjOP/quwdoRHU+6kth3zhG/aGChLYn/n+VFHdqgcL+6/aNMJBFPMIn8yzQjF5jt8n58Dz2eKeU26e9V/nw18Gg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560746512; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=1i84izkdu20eZgHvrh4c0IwD6kNxGk4p+KALLs7dNaM=; b=kO8DPEnTH5c3F14YVku3XWtNoeJs8sYFGtIa/TkJ64EjKbyBGFLRtiMbbRUoSCoPws5cCz0qNTPk5SIwwe8gqDgJrMkqGft8nLBf1SVOiBCvTzNkrnaOsuMGDlZc9u9SLYeG5OGIIQ2EPH7aS2NS0PoWkfZnb+qj3gN3bVU9VIY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1560746512241304.9556040138099; Sun, 16 Jun 2019 21:41:52 -0700 (PDT) Received: from localhost ([::1]:44210 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjSk-0003hS-9p for importer@patchew.org; Mon, 17 Jun 2019 00:41:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60296) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjQI-0001Qz-Hk for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcjQC-0005sr-Sg for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58910) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcjQB-0005qQ-Vz for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:08 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 84B2D31628FC; Mon, 17 Jun 2019 04:39:06 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA56A18506; Mon, 17 Jun 2019 04:39:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3A9A217538; Mon, 17 Jun 2019 06:38:59 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 06:38:57 +0200 Message-Id: <20190617043858.8290-11-kraxel@redhat.com> In-Reply-To: <20190617043858.8290-1-kraxel@redhat.com> References: <20190617043858.8290-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 17 Jun 2019 04:39:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 10/11] tests/vm: fedora autoinstall, using serial console 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 , Ed Maste , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Kamil Rytarowski , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Li-Wen Hsu , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Download the install iso and prepare the image locally. Install to disk, using the serial console. Create qemu user, configure ssh login. Install packages needed for qemu builds. Yes, we have docker images for fedora. But for trouble-shooting it might be helpful to have a vm too. When vm builds fail you can use it to figure whenever the vm setup or the guest os is the problem. Signed-off-by: Gerd Hoffmann Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- tests/vm/basevm.py | 9 +- tests/vm/Makefile.include | 3 +- tests/vm/fedora | 189 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 199 insertions(+), 2 deletions(-) create mode 100755 tests/vm/fedora diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 592a3447735f..3d717da49831 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -206,7 +206,7 @@ class BaseVM(object): # log console line sys.stderr.write("con recv: %s\n" % line) =20 - def console_wait(self, expect): + def console_wait(self, expect, expectalt =3D None): vm =3D self._guest output =3D "" while True: @@ -215,6 +215,8 @@ class BaseVM(object): except socket.timeout: sys.stderr.write("console: *** read timeout ***\n") sys.stderr.write("console: waiting for: '%s'\n" % expect) + if not expectalt is None: + sys.stderr.write("console: waiting for: '%s' (alt)\n" = % expectalt) sys.stderr.write("console: line buffer:\n") sys.stderr.write("\n") self.console_log(output.rstrip()) @@ -223,6 +225,8 @@ class BaseVM(object): output +=3D chars.decode("latin1") if expect in output: break + if not expectalt is None and expectalt in output: + break if "\r" in output or "\n" in output: lines =3D re.split("[\r\n]", output) output =3D lines.pop() @@ -230,6 +234,9 @@ class BaseVM(object): self.console_log("\n".join(lines)) if self.debug: self.console_log(output) + if not expectalt is None and expectalt in output: + return False + return True =20 def console_send(self, command): vm =3D self._guest diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index e329129bd658..52f071c7a403 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -2,7 +2,7 @@ =20 .PHONY: vm-build-all vm-clean-all =20 -IMAGES :=3D ubuntu.i386 freebsd netbsd openbsd centos +IMAGES :=3D ubuntu.i386 freebsd netbsd openbsd centos fedora IMAGES_DIR :=3D $(HOME)/.cache/qemu-vm/images IMAGE_FILES :=3D $(patsubst %, $(IMAGES_DIR)/%.img, $(IMAGES)) =20 @@ -16,6 +16,7 @@ vm-test: @echo " vm-build-netbsd - Build QEMU in NetBSD VM" @echo " vm-build-openbsd - Build QEMU in OpenBSD VM" @echo " vm-build-centos - Build QEMU in CentOS VM, with = Docker" + @echo " vm-build-fedora - Build QEMU in Fedora VM" @echo "" @echo " vm-build-all - Build QEMU in all VMs" @echo " vm-clean-all - Clean up VM images" diff --git a/tests/vm/fedora b/tests/vm/fedora new file mode 100755 index 000000000000..e8fa5bf0d21c --- /dev/null +++ b/tests/vm/fedora @@ -0,0 +1,189 @@ +#!/usr/bin/env python +# +# Fedora VM image +# +# Copyright 2019 Red Hat Inc. +# +# Authors: +# Gerd Hoffmann +# +# This code is licensed under the GPL version 2 or later. See +# the COPYING file in the top-level directory. +# + +import os +import re +import sys +import time +import socket +import subprocess +import basevm + +class FedoraVM(basevm.BaseVM): + name =3D "fedora" + arch =3D "x86_64" + + base =3D "http://dl.fedoraproject.org/pub/fedora/linux/releases/30/" + link =3D base + "Server/x86_64/iso/Fedora-Server-netinst-x86_64-30-1.2= .iso" + repo =3D base + "Server/x86_64/os/" + full =3D base + "Everything/x86_64/os/" + csum =3D "5e4eac4566d8c572bfb3bcf54b7d6c82006ec3c6c882a2c9235c6d3494d7= b100" + size =3D "20G" + pkgs =3D [ + # tools + 'git-core', + 'flex', 'bison', + 'gcc', 'binutils', 'make', + + # perl + 'perl-Test-Harness', + + # libs: usb + '"pkgconfig(libusb-1.0)"', + '"pkgconfig(libusbredirparser-0.5)"', + + # libs: crypto + '"pkgconfig(gnutls)"', + + # libs: ui + '"pkgconfig(sdl2)"', + '"pkgconfig(gtk+-3.0)"', + '"pkgconfig(ncursesw)"', + + # libs: audio + '"pkgconfig(libpulse)"', + '"pkgconfig(alsa)"', + ] + + BUILD_SCRIPT =3D """ + set -e; + rm -rf /home/qemu/qemu-test.* + cd $(mktemp -d /home/qemu/qemu-test.XXXXXX); + mkdir src build; cd src; + tar -xf /dev/vdb; + cd ../build + ../src/configure --python=3Dpython3 {configure_opts}; + gmake --output-sync -j{jobs} {target} {verbose}; + """ + + def build_image(self, img): + self.print_step("Downloading install iso") + cimg =3D self._download_with_cache(self.link, sha256sum=3Dself.csu= m) + img_tmp =3D img + ".tmp" + iso =3D img + ".install.iso" + + self.print_step("Preparing iso and disk image") + subprocess.check_call(["cp", "-f", cimg, iso]) + subprocess.check_call(["qemu-img", "create", "-f", "qcow2", + img_tmp, self.size]) + + self.print_step("Booting installer") + self.boot(img_tmp, extra_args =3D [ + "-bios", "pc-bios/bios-256k.bin", + "-machine", "graphics=3Doff", + "-cdrom", iso + ]) + self.console_init(300) + self.console_wait("installation process.") + time.sleep(0.3) + self.console_send("\t") + time.sleep(0.3) + self.console_send(" console=3DttyS0") + proxy =3D os.environ.get("http_proxy") + if not proxy is None: + self.console_send(" proxy=3D%s" % proxy) + self.console_send(" inst.proxy=3D%s" % proxy) + self.console_send(" inst.repo=3D%s" % self.repo) + self.console_send("\n") + + self.console_wait_send("2) Use text mode", "2\n") + + self.console_wait_send("5) [!] Installation Dest", "5\n") + self.console_wait_send("1) [x]", "c\n") + self.console_wait_send("2) [ ] Use All Space", "2\n") + self.console_wait_send("2) [x] Use All Space", "c\n") + self.console_wait_send("1) [ ] Standard Part", "1\n") + self.console_wait_send("1) [x] Standard Part", "c\n") + + self.console_wait_send("7) [!] Root password", "7\n") + self.console_wait("Password:") + self.console_send("%s\n" % self.ROOT_PASS) + self.console_wait("Password (confirm):") + self.console_send("%s\n" % self.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("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_wait("Password (confirm):") + self.console_send("%s\n" % self.GUEST_PASS) + self.console_wait_send("7) Groups", "c\n") + + while True: + good =3D self.console_wait("3) [x] Installation", + "3) [!] Installation") + self.console_send("r\n") + if good: + break + time.sleep(10) + + while True: + good =3D self.console_wait("4) [x] Software", + "4) [!] Software") + self.console_send("r\n") + if good: + break + time.sleep(10) + self.console_send("r\n" % self.GUEST_PASS) + + self.console_wait_send("'b' to begin install", "b\n") + + self.print_step("Installation started now, this will take a while") + + self.console_wait_send("Installation complete", "\n") + self.print_step("Installation finished, rebooting") + + # setup qemu user + prompt =3D " ~]$" + self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS) + self.console_wait_send(prompt, "exit\n") + + # setup root user + prompt =3D " ~]#" + self.console_ssh_init(prompt, "root", self.ROOT_PASS) + self.console_sshd_config(prompt) + + # setup virtio-blk #1 (tarfile) + self.console_wait(prompt) + self.console_send("echo 'KERNEL=3D=3D\"vdb\" MODE=3D\"666\"' >> %s= \n" % + "/etc/udev/rules.d/99-qemu.rules") + + self.print_step("Configuration finished, rebooting") + self.console_wait_send(prompt, "reboot\n") + self.console_wait("login:") + self.wait_ssh() + + self.print_step("Installing packages") + self.ssh_root_check("rm -vf /etc/yum.repos.d/fedora*.repo\n") + self.ssh_root_check("echo '[fedora]' >> /etc/yum.repos.d/qemu.repo= \n") + self.ssh_root_check("echo 'baseurl=3D%s' >> /etc/yum.repos.d/qemu.= repo\n" % self.full) + self.ssh_root_check("echo 'gpgcheck=3D0' >> /etc/yum.repos.d/qemu.= repo\n") + self.ssh_root_check("dnf install -y %s\n" % " ".join(self.pkgs)) + + # shutdown + self.ssh_root(self.poweroff) + self.console_wait("sleep state S5") + self.wait() + + if os.path.exists(img): + os.remove(img) + os.rename(img_tmp, img) + os.remove(iso) + self.print_step("All done") + +if __name__ =3D=3D "__main__": + sys.exit(basevm.main(FedoraVM)) --=20 2.18.1 From nobody Mon May 6 08:18:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560746711; cv=none; d=zoho.com; s=zohoarc; b=Syt/urzEuc0hY9kuZUCre/w4YE24jCoAEtCzmdKdTHHUR0YEYthpudVaUWEzd2amCtHlJG/oZGz7xRt0zZ+vARgjxHRKps5BJp1l/WblVGNFpC99ULMHAtwN3XxyeReLZNpxjHnuz6s7awUkaGHiYhXClwBJEumtsAaPlkrALXE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560746711; 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:ARC-Authentication-Results; bh=qNfbsccUmaQPuFQyH+IHsVdo/VT9rbxVUn5z4K0BUlA=; b=aMlbe30LN8sz/OottS32Gy6Tcxbgb8FAZyotH68Q55+GJAS5PbXvd7UstI0YR/OBR2bxId157M2fGBjnasKwuxbtu9RhQlN5pI6ZrIVHrJoTLUJ/qtZsC4FPXJC7yPNsraW2gmVvmNz+uvNU3uEPm2k739XTgZMDkQ12hwEKuF0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1560746711114502.6118077309436; Sun, 16 Jun 2019 21:45:11 -0700 (PDT) Received: from localhost ([::1]:44226 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjW0-0006mA-5U for importer@patchew.org; Mon, 17 Jun 2019 00:45:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60164) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcjQE-0001P1-H1 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcjQC-0005sP-Kd for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58892) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcjQB-0005q8-Mp for qemu-devel@nongnu.org; Mon, 17 Jun 2019 00:39:07 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4DC4A31628FB; Mon, 17 Jun 2019 04:39:06 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05D242CFD6; Mon, 17 Jun 2019 04:39:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 42D7B1753A; Mon, 17 Jun 2019 06:38:59 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 06:38:58 +0200 Message-Id: <20190617043858.8290-12-kraxel@redhat.com> In-Reply-To: <20190617043858.8290-1-kraxel@redhat.com> References: <20190617043858.8290-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 17 Jun 2019 04:39:06 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 11/11] tests/vm: ubuntu.i386: apt proxy setup 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 , Ed Maste , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Kamil Rytarowski , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Li-Wen Hsu , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Configure apt proxy so package downloads can be cached and can pass firewalls. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/vm/ubuntu.i386 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/vm/ubuntu.i386 b/tests/vm/ubuntu.i386 index a22d137e76df..b869afd212fa 100755 --- a/tests/vm/ubuntu.i386 +++ b/tests/vm/ubuntu.i386 @@ -51,6 +51,10 @@ class UbuntuX86VM(basevm.BaseVM): " ssh-authorized-keys:\n", " - %s\n" % basevm.SSH_PUB_KEY, "locale: en_US.UTF-8\n"]) + proxy =3D os.environ.get("http_proxy") + if not proxy is None: + udata.writelines(["apt:\n", + " proxy: %s" % proxy]) udata.close() subprocess.check_call(["genisoimage", "-output", "cloud-init.iso", "-volid", "cidata", "-joliet", "-rock", --=20 2.18.1