]> Git Repo - qemu.git/blame - tests/vm/netbsd
tests/vm: Allow to set qemu-img path
[qemu.git] / tests / vm / netbsd
CommitLineData
5cd2b138
FZ
1#!/usr/bin/env python
2#
3# NetBSD VM image
4#
af093bc9 5# Copyright 2017-2019 Red Hat Inc.
5cd2b138
FZ
6#
7# Authors:
8# Fam Zheng <[email protected]>
af093bc9 9# Gerd Hoffmann <[email protected]>
5cd2b138
FZ
10#
11# This code is licensed under the GPL version 2 or later. See
12# the COPYING file in the top-level directory.
13#
14
15import os
16import sys
af093bc9 17import time
5cd2b138
FZ
18import subprocess
19import basevm
20
21class NetBSDVM(basevm.BaseVM):
22 name = "netbsd"
31719c37 23 arch = "x86_64"
af093bc9 24
2548b4a7 25 link = "https://cdn.netbsd.org/pub/NetBSD/NetBSD-8.1/images/NetBSD-8.1-amd64.iso"
5b4b4865 26 csum = "718f275b7e0879599bdac95630c5e3f2184700032fdb6cdebf3bdd63687898c48ff3f08f57b89f4437a86cdd8ea07c01a39d432dbb37e1e4b008f4985f98da3f"
af093bc9
GH
27 size = "20G"
28 pkgs = [
29 # tools
30 "git-base",
31 "pkgconf",
32 "xz",
33 "python37",
34
35 # gnu tools
36 "bash",
37 "gmake",
38 "gsed",
39 "flex", "bison",
40
41 # libs: crypto
42 "gnutls",
43
44 # libs: images
45 "jpeg",
46 "png",
47
48 # libs: ui
49 "SDL2",
50 "gtk3+",
51 "libxkbcommon",
52 ]
53
5cd2b138
FZ
54 BUILD_SCRIPT = """
55 set -e;
af093bc9
GH
56 rm -rf /home/qemu/qemu-test.*
57 cd $(mktemp -d /home/qemu/qemu-test.XXXXXX);
58 mkdir src build; cd src;
5cd2b138 59 tar -xf /dev/rld1a;
af093bc9
GH
60 cd ../build
61 ../src/configure --python=python3.7 --disable-opengl {configure_opts};
5c2ec9b6 62 gmake --output-sync -j{jobs} {target} {verbose};
5cd2b138 63 """
af093bc9 64 poweroff = "/sbin/poweroff"
5cd2b138 65
6d46e602
EH
66 # Workaround for NetBSD + IPv6 + slirp issues.
67 # NetBSD seems to ignore the ICMPv6 Destination Unreachable
68 # messages generated by slirp. When the host has no IPv6
69 # connectivity, this causes every connection to ftp.NetBSD.org
70 # take more than a minute to be established.
71 ipv6 = False
72
5cd2b138 73 def build_image(self, img):
5b4b4865 74 cimg = self._download_with_cache(self.link, sha512sum=self.csum)
5cd2b138 75 img_tmp = img + ".tmp"
af093bc9
GH
76 iso = img + ".install.iso"
77
78 self.print_step("Preparing iso and disk image")
79 subprocess.check_call(["ln", "-f", cimg, iso])
1e48931c 80 self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
af093bc9
GH
81
82 self.print_step("Booting installer")
83 self.boot(img_tmp, extra_args = [
84 "-bios", "pc-bios/bios-256k.bin",
85 "-machine", "graphics=off",
86 "-cdrom", iso
87 ])
88 self.console_init()
89 self.console_wait("Primary Bootstrap")
90
91 # serial console boot menu output doesn't work for some
92 # reason, so we have to fly blind ...
93 for char in list("5consdev com0\n"):
94 time.sleep(0.2)
95 self.console_send(char)
00963aca 96 self.console_consume()
af093bc9
GH
97 self.console_wait_send("> ", "boot\n")
98
99 self.console_wait_send("Terminal type", "xterm\n")
100 self.console_wait_send("a: Installation messages", "a\n")
101 self.console_wait_send("b: US-English", "b\n")
102 self.console_wait_send("a: Install NetBSD", "a\n")
103 self.console_wait("Shall we continue?")
104 self.console_wait_send("b: Yes", "b\n")
105
106 self.console_wait_send("a: ld0", "a\n")
107 self.console_wait_send("a: This is the correct", "a\n")
108 self.console_wait_send("b: Use the entire disk", "b\n")
109 self.console_wait("NetBSD bootcode")
110 self.console_wait_send("a: Yes", "a\n")
111 self.console_wait_send("b: Use existing part", "b\n")
112 self.console_wait_send("x: Partition sizes ok", "x\n")
113 self.console_wait_send("for your NetBSD disk", "\n")
114 self.console_wait("Shall we continue?")
115 self.console_wait_send("b: Yes", "b\n")
116
117 self.console_wait_send("b: Use serial port com0", "b\n")
118 self.console_wait_send("f: Set serial baud rate", "f\n")
119 self.console_wait_send("a: 9600", "a\n")
120 self.console_wait_send("x: Exit", "x\n")
121
122 self.console_wait_send("a: Full installation", "a\n")
123 self.console_wait_send("a: CD-ROM", "a\n")
124
125 self.print_step("Installation started now, this will take a while")
126 self.console_wait_send("Hit enter to continue", "\n")
127
128 self.console_wait_send("d: Change root password", "d\n")
129 self.console_wait_send("a: Yes", "a\n")
130 self.console_wait("New password:")
131 self.console_send("%s\n" % self.ROOT_PASS)
132 self.console_wait("New password:")
133 self.console_send("%s\n" % self.ROOT_PASS)
134 self.console_wait("Retype new password:")
135 self.console_send("%s\n" % self.ROOT_PASS)
136
137 self.console_wait_send("o: Add a user", "o\n")
138 self.console_wait("username")
139 self.console_send("%s\n" % self.GUEST_USER)
140 self.console_wait("to group wheel")
141 self.console_wait_send("a: Yes", "a\n")
142 self.console_wait_send("a: /bin/sh", "a\n")
143 self.console_wait("New password:")
144 self.console_send("%s\n" % self.GUEST_PASS)
145 self.console_wait("New password:")
146 self.console_send("%s\n" % self.GUEST_PASS)
147 self.console_wait("Retype new password:")
148 self.console_send("%s\n" % self.GUEST_PASS)
149
150 self.console_wait_send("a: Configure network", "a\n")
151 self.console_wait_send("a: vioif0", "a\n")
152 self.console_wait_send("Network media type", "\n")
153 self.console_wait("autoconfiguration")
154 self.console_wait_send("a: Yes", "a\n")
155 self.console_wait_send("DNS domain", "localnet\n")
156 self.console_wait("Are they OK?")
157 self.console_wait_send("a: Yes", "a\n")
158 self.console_wait("installed in /etc")
159 self.console_wait_send("a: Yes", "a\n")
160
161 self.console_wait_send("e: Enable install", "e\n")
162 proxy = os.environ.get("http_proxy")
163 if not proxy is None:
164 self.console_wait_send("f: Proxy", "f\n")
165 self.console_wait("Proxy")
166 self.console_send("%s\n" % proxy)
167 self.console_wait_send("x: Install pkgin", "x\n")
168 self.console_init(1200)
169 self.console_wait_send("Hit enter to continue", "\n")
170 self.console_init()
171
172 self.console_wait_send("g: Enable sshd", "g\n")
173 self.console_wait_send("x: Finished conf", "x\n")
174 self.console_wait_send("Hit enter to continue", "\n")
175
176 self.print_step("Installation finished, rebooting")
177 self.console_wait_send("d: Reboot the computer", "d\n")
178
179 # setup qemu user
180 prompt = "localhost$"
181 self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS)
182 self.console_wait_send(prompt, "exit\n")
183
184 # setup root user
185 prompt = "localhost#"
186 self.console_ssh_init(prompt, "root", self.ROOT_PASS)
187 self.console_sshd_config(prompt)
188
189 # setup virtio-blk #1 (tarfile)
190 self.console_wait(prompt)
191 self.console_send("echo 'chmod 666 /dev/rld1a' >> /etc/rc.local\n")
192
193 # turn off mprotect (conflicts with tcg)
194 self.console_wait(prompt)
195 self.console_send("echo security.pax.mprotect.enabled=0 >> /etc/sysctl.conf\n")
196
197 self.print_step("Configuration finished, rebooting")
198 self.console_wait_send(prompt, "reboot\n")
199 self.console_wait("login:")
200 self.wait_ssh()
201
202 self.print_step("Installing packages")
203 self.ssh_root_check("pkgin update\n")
204 self.ssh_root_check("pkgin -y install %s\n" % " ".join(self.pkgs))
205
206 # shutdown
207 self.ssh_root(self.poweroff)
208 self.console_wait("entering state S5")
209 self.wait()
210
5cd2b138 211 os.rename(img_tmp, img)
af093bc9
GH
212 os.remove(iso)
213 self.print_step("All done")
5cd2b138
FZ
214
215if __name__ == "__main__":
216 sys.exit(basevm.main(NetBSDVM))
This page took 0.160255 seconds and 4 git commands to generate.