From patchwork Mon Jun 24 13:43:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 167580 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4259720ilk; Mon, 24 Jun 2019 06:53:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqylJ/LMtgiZpGJ3j46aN9kM+2skgeAXKK7knL3X+XzHshEcHfl48Co7LQVK8y3Z+RW8D8Lm X-Received: by 2002:a50:90fa:: with SMTP id d55mr116465671eda.210.1561384399232; Mon, 24 Jun 2019 06:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561384399; cv=none; d=google.com; s=arc-20160816; b=ZhFemDadspnUzEhAt4qEiTxU3UZeYPP0e6iUO1ddX8bwScsBtR/VHnidDHwP8CS3hh tjcEQJFRuDe7e9/4Bp2mMCeor7ZKwMh5baqezqEzLEQhhtCc/0ZuIoMz7ka6jlJPTd4F +vu1wz0tHbPpIjoUlxC262Ki4WhcviqFd3Yaw3lsXQ2dEod9cdNYpyvpR1pG6J/Z2Ne5 6P+brxrC/lHtDLoWoB5361sucgfNGOrXVVveHc7Cuo290mhT9yQaAM0WjrbgGSQ5SxVW vYzrXy9ldfKOpGvHJ8z38rJgdvzbONtdALhtJPyTFiE593JAmHg95+W5bHifA5CZHFNA 9l0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=/RSieZJAcswfuzrWAl67uAJKjsybJgY5oC9aZNMPdU0=; b=xg6cOq8fyku8Kw2H1HD2OexhVmc6YCaFmWP1cCDnG7e/8UHD7ioFhyuMdPNP0pR7Xm VQ3owPM08SUQKGIZxG6VYCvfcR96JvXOYaTe4cpRW0w7Fd0RgdEIrI9FDf4ctn0Egthw gx26vyYDxB8tKMn8bJjarbLKB+7GInIUmV5bR/pDE0wzOKRxJHm8ujfPj8J5QGho8Tbk i59vf+eixs+4lT51TP74xl4kb8VH77pCtFTQxasB9wQcjit8nifLLfdZYrASeklnSOlY yr+8nxDhZueWSEi16KiRHznz6JWStPm01hn+uY8Cx9fnuy47uyvFR8BVyz8R+FthDsZD jOfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="YPViegu/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id op8si6661921ejb.193.2019.06.24.06.53.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2019 06:53:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="YPViegu/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfPPK-0006D7-7W for patch@linaro.org; Mon, 24 Jun 2019 09:53:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41585) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfPGJ-0006jB-4N for qemu-devel@nongnu.org; Mon, 24 Jun 2019 09:44:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfPGG-0007fY-CG for qemu-devel@nongnu.org; Mon, 24 Jun 2019 09:43:58 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:55061) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfPGE-0007T2-EH for qemu-devel@nongnu.org; Mon, 24 Jun 2019 09:43:55 -0400 Received: by mail-wm1-x32c.google.com with SMTP id g135so12844284wme.4 for ; Mon, 24 Jun 2019 06:43:47 -0700 (PDT) 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=/RSieZJAcswfuzrWAl67uAJKjsybJgY5oC9aZNMPdU0=; b=YPViegu/fLJeDmKBD8VgBppTY8qR1rNFe5QFgb9d19kNTOXc8dHHEwEmT/HdDZ/jTs ey7tWL//ccAfbXDhBKow22Qshewnf1lhuDYhfNF5u0yLB9Z5IXzSCJlt8uyOhjdWuWJr DYhpJ+SQbmm//n2yDib9OBeGGLuChTCZDlpDgpfz0mn8RLB9Psz5qbvjmhDraYRXH0Py zgSkKM+MdaOy+JOwIl/M2FQeA8aVFA9oS3hawsXEgNY8t6M6I00QwUs5N6JDBBa92dv4 I6tuLdH/mHjuXNZqGzGMAGAqVoXsC+k6Mp1zsPj88C6fZp0VP3GOPWh5urrXcGXBpJON zIKA== 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=/RSieZJAcswfuzrWAl67uAJKjsybJgY5oC9aZNMPdU0=; b=a+CXcNt8almTKbJ5Km74CO77oFB1uXqLO8beOrWTHeJqZGANwpx++wINxmQ4nAlD95 ChJKCHMOuUOAdw61loo1K7/X2yEwK8xB1MazB6GKKr4lY4WEpM/TjyM3HhSA1eYWgFsM 9SNqP82a0dNGl4lri3Z9NWLNtMPh/tlNdgpTmOALne7y2fTmqifLj8D4ASk4HB29FKsg hF5nUAo5W3KspThySsvqDw/e6pYuvJyD/bH1tGMV0XGyC2oLqj+Od51kmQsPztqJOTn1 iDK8hMaV2QUW9dErxTq3TdQWTKHfjCqAqu01I424lRCo9aeOB172kFK5NnzUgNHB2f76 1vPA== X-Gm-Message-State: APjAAAU3HhR5iFXXBit2WPwR6eJJNDO1f65o5ytIHmccMrx8pGFT8692 KgtPKIPFuIj7IZVdqdm8HewN+uHyNrM= X-Received: by 2002:a7b:cc04:: with SMTP id f4mr7267902wmh.125.1561383826654; Mon, 24 Jun 2019 06:43:46 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y12sm8423706wrr.3.2019.06.24.06.43.41 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 24 Jun 2019 06:43:42 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7028C1FF9B; Mon, 24 Jun 2019 14:43:38 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 24 Jun 2019 14:43:29 +0100 Message-Id: <20190624134337.10532-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624134337.10532-1-alex.bennee@linaro.org> References: <20190624134337.10532-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32c Subject: [Qemu-devel] [PULL 11/19] 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 , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann , =?utf-8?q?Alex_Benn=C3=A9e?= , Brad Smith Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Gerd Hoffmann 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é Tested-by: Philippe Mathieu-Daudé Message-Id: <20190617043858.8290-8-kraxel@redhat.com> [AJB: added tags] Signed-off-by: Alex Bennée -- 2.20.1 diff --git a/tests/vm/openbsd b/tests/vm/openbsd index 28c7d25e29..b92c39f89a 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,32 +14,166 @@ import os import sys +import socket import subprocess import basevm class OpenBSDVM(basevm.BaseVM): name = "openbsd" arch = "x86_64" + + link = "https://cdn.openbsd.org/pub/OpenBSD/6.5/amd64/install65.iso" + csum = "38d1f8cadd502f1c27bf05c5abde6cc505dd28f3f34f8a941048ff9a54f9f608" + size = "20G" + pkgs = [ + # 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 = """ 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=x86_64-unknown-openbsd6.1-gcc-4.9.4 --python=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=cc --python=python3 {configure_opts}; + gmake --output-sync -j{jobs} {target} {verbose}; """ + poweroff = "halt -p" def build_image(self, img): - cimg = self._download_with_cache("http://download.patchew.org/openbsd-6.1-amd64.img.xz", - sha256sum='8c6cedc483e602cfee5e04f0406c64eb99138495e8ca580bc0293bcf0640c1bf') - img_tmp_xz = img + ".tmp.xz" + self.print_step("Downloading install iso") + cimg = self._download_with_cache(self.link, sha256sum=self.csum) img_tmp = img + ".tmp" - sys.stderr.write("Extracting the image...\n") - subprocess.check_call(["ln", "-f", cimg, img_tmp_xz]) - subprocess.check_call(["xz", "--keep", "-dvf", img_tmp_xz]) + iso = 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 = [ + "-bios", "pc-bios/bios-256k.bin", + "-machine", "graphics=off", + "-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 = "$" + self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS) + self.console_wait_send(prompt, "exit\n") + + # setup root user + prompt = "openbsd#" + self.console_ssh_init(prompt, "root", self.ROOT_PASS) + self.console_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/fstab\n") + + # tweak datasize limit + self.console_wait(prompt) + self.console_send("sed -i -e 's/\\(datasize[^=]*\\)=[^:]*/\\1=infinity/' /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") if __name__ == "__main__": sys.exit(basevm.main(OpenBSDVM))