From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Fam Zheng" <fam@euphon.net>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Thomas Huth" <thuth@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH v1 25/26] tests/vm: fedora autoinstall, using serial console
Date: Thu, 30 May 2019 11:16:02 +0100 [thread overview]
Message-ID: <20190530101603.22254-26-alex.bennee@linaro.org> (raw)
In-Reply-To: <20190530101603.22254-1-alex.bennee@linaro.org>
From: Gerd Hoffmann <kraxel@redhat.com>
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 <kraxel@redhat.com>
Tested-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190520124716.30472-14-kraxel@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
tests/vm/Makefile.include | 3 +-
tests/vm/basevm.py | 9 +-
tests/vm/fedora | 187 ++++++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+), 2 deletions(-)
create mode 100755 tests/vm/fedora
diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
index 628eecade78..5e37063d32d 100644
--- a/tests/vm/Makefile.include
+++ b/tests/vm/Makefile.include
@@ -2,7 +2,7 @@
.PHONY: vm-build-all vm-clean-all
-IMAGES := ubuntu.i386 freebsd netbsd openbsd centos
+IMAGES := ubuntu.i386 freebsd netbsd openbsd centos fedora
IMAGES_DIR := $(HOME)/.cache/qemu-vm/images
IMAGE_FILES := $(patsubst %, $(IMAGES_DIR)/%.img, $(IMAGES))
@@ -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/basevm.py b/tests/vm/basevm.py
index 8894267f078..d4b816be14d 100755
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -205,7 +205,7 @@ class BaseVM(object):
# log console line
sys.stderr.write("con recv: %s\n" % line)
- def console_wait(self, expect):
+ def console_wait(self, expect, expectalt = None):
vm = self._guest
output = ""
while True:
@@ -214,6 +214,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())
@@ -222,6 +224,8 @@ class BaseVM(object):
output += 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 = re.split("[\r\n]", output)
output = lines.pop()
@@ -229,6 +233,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
def console_send(self, command):
vm = self._guest
diff --git a/tests/vm/fedora b/tests/vm/fedora
new file mode 100755
index 00000000000..c5621d08322
--- /dev/null
+++ b/tests/vm/fedora
@@ -0,0 +1,187 @@
+#!/usr/bin/env python
+#
+# Fedora VM image
+#
+# Copyright 2019 Red Hat Inc.
+#
+# Authors:
+# Gerd Hoffmann <kraxel@redhat.com>
+#
+# This code is licensed under the GPL version 2 or later. See
+# the COPYING file in the top-level directory.
+#
+
+import os
+import re
+import sys
+import time
+import socket
+import subprocess
+import basevm
+
+class FedoraVM(basevm.BaseVM):
+ name = "fedora"
+ arch = "x86_64"
+
+ base = "http://dl.fedoraproject.org/pub/fedora/linux/releases/30/"
+ link = base + "Server/x86_64/iso/Fedora-Server-netinst-x86_64-30-1.2.iso"
+ repo = base + "Server/x86_64/os/"
+ full = base + "Everything/x86_64/os/"
+ csum = "5e4eac4566d8c572bfb3bcf54b7d6c82006ec3c6c882a2c9235c6d3494d7b100"
+ size = "20G"
+ pkgs = [
+ # 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 = """
+ 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=python3 {configure_opts};
+ gmake --output-sync -j{jobs} {target} {verbose};
+ """
+
+ def build_image(self, img):
+ self.print_step("Downloading install iso")
+ cimg = self._download_with_cache(self.link, sha256sum=self.csum)
+ img_tmp = img + ".tmp"
+ 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 = [
+ "-machine", "graphics=off",
+ "-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=ttyS0")
+ proxy = os.environ.get("http_proxy")
+ if not proxy is None:
+ self.console_send(" proxy=%s" % proxy)
+ self.console_send(" inst.repo=%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 = self.console_wait("3) [x] Installation",
+ "3) [!] Installation")
+ self.console_send("r\n")
+ if good:
+ break
+ time.sleep(10)
+
+ while True:
+ good = 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 = " ~]$"
+ self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS)
+ self.console_wait_send(prompt, "exit\n")
+
+ # setup root user
+ prompt = " ~]#"
+ 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==\"vdb\" MODE=\"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=%s' >> /etc/yum.repos.d/qemu.repo\n" % self.full)
+ self.ssh_root_check("echo 'gpgcheck=0' >> /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__ == "__main__":
+ sys.exit(basevm.main(FedoraVM))
--
2.20.1
next prev parent reply other threads:[~2019-05-30 10:24 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-30 10:15 [Qemu-devel] [PATCH v1 00/26] testing/next queue (iotests, docker, tests/vm) Alex Bennée
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 01/26] editorconfig: add setting for shell scripts Alex Bennée
2019-05-30 18:15 ` Richard Henderson
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 02/26] qemu-io-cmds: use clock_gettime for benchmarking Alex Bennée
2019-05-30 18:41 ` Richard Henderson
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 03/26] tests: Run the iotests during "make check" again Alex Bennée
2019-06-07 9:33 ` Alex Bennée
2019-07-15 11:06 ` Thomas Huth
2019-07-15 11:58 ` Alex Bennée
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 04/26] tests/docker: Update the Fedora image to Fedora 30 Alex Bennée
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 05/26] tests/docker: Update the Fedora cross compile images to 30 Alex Bennée
2019-05-30 18:43 ` Richard Henderson
2019-05-31 6:54 ` Philippe Mathieu-Daudé
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 06/26] tests/docker: Update the Ubuntu image to 19.04 Alex Bennée
2019-05-30 18:44 ` Richard Henderson
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 07/26] .travis.yml: bump gcc sanitiser job to gcc-9 Alex Bennée
2019-05-31 7:56 ` Stefano Garzarella
2019-05-31 8:16 ` Alex Bennée
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 08/26] .travis.yml: add clang ubsan job Alex Bennée
2019-05-31 6:21 ` Philippe Mathieu-Daudé
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 09/26] tests/vm: Use python configured on build Alex Bennée
2019-05-31 6:22 ` Philippe Mathieu-Daudé
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 10/26] tests/vm: Port basevm to Python 3 Alex Bennée
2019-05-31 6:22 ` Philippe Mathieu-Daudé
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 11/26] tests/vm: Fix build-centos docker-based tests run Alex Bennée
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 12/26] tests/vm: Add missing variables on help Alex Bennée
2019-05-31 6:45 ` Philippe Mathieu-Daudé
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 13/26] scripts: use git archive in archive-source Alex Bennée
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 14/26] tests/vm: python3 fixes Alex Bennée
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 15/26] tests/vm: send proxy environment variables over ssh Alex Bennée
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 16/26] tests/vm: use ssh with pty unconditionally Alex Bennée
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 17/26] tests/vm: run test builds on snapshot Alex Bennée
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 18/26] tests/vm: proper guest shutdown Alex Bennée
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 19/26] tests/vm: add vm-boot-{ssh, serial}-<guest> targets Alex Bennée
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 20/26] tests/vm: add DEBUG=1 to help text Alex Bennée
2019-05-31 6:49 ` Philippe Mathieu-Daudé
2019-05-31 8:15 ` Alex Bennée
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 21/26] tests/vm: serial console support helpers Alex Bennée
2019-05-30 10:15 ` [Qemu-devel] [PATCH v1 22/26] tests/vm: openbsd autoinstall, using serial console Alex Bennée
2019-05-30 10:16 ` [Qemu-devel] [PATCH v1 23/26] tests/vm: freebsd " Alex Bennée
2019-05-30 10:16 ` [Qemu-devel] [PATCH v1 24/26] tests/vm: netbsd " Alex Bennée
2019-05-30 10:16 ` Alex Bennée [this message]
2019-05-30 10:16 ` [Qemu-devel] [PATCH v1 26/26] tests/vm: ubuntu.i386: apt proxy setup Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190530101603.22254-26-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=fam@euphon.net \
--cc=kraxel@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).