5 # Copyright 2017-2019 Red Hat Inc.
8 # Fam Zheng <famz@redhat.com>
9 # Gerd Hoffmann <kraxel@redhat.com>
11 # This code is licensed under the GPL version 2 or later. See
12 # the COPYING file in the top-level directory.
21 class OpenBSDVM(basevm.BaseVM):
25 link = "https://cdn.openbsd.org/pub/OpenBSD/6.6/amd64/install66.iso"
26 csum = "b22e63df56e6266de6bbeed8e9be0fbe9ee2291551c5bc03f3cc2e4ab9436ee3"
58 rm -rf /home/qemu/qemu-test.*
59 cd $(mktemp -d /home/qemu/qemu-test.XXXXXX);
60 mkdir src build; cd src;
63 ../src/configure --cc=cc --python=python3 {configure_opts};
64 gmake --output-sync -j{jobs} {target} {verbose};
68 def build_image(self, img):
69 self.print_step("Downloading install iso")
70 cimg = self._download_with_cache(self.link, sha256sum=self.csum)
71 img_tmp = img + ".tmp"
72 iso = img + ".install.iso"
74 self.print_step("Preparing iso and disk image")
75 subprocess.check_call(["cp", "-f", cimg, iso])
76 self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
78 self.print_step("Booting installer")
79 self.boot(img_tmp, extra_args = [
80 "-bios", "pc-bios/bios-256k.bin",
81 "-machine", "graphics=off",
85 self.console_wait_send("boot>", "set tty com0\n")
86 self.console_wait_send("boot>", "\n")
88 # pre-install configuration
89 self.console_wait_send("(I)nstall", "i\n")
90 self.console_wait_send("Terminal type", "xterm\n")
91 self.console_wait_send("System hostname", "openbsd\n")
92 self.console_wait_send("Which network interface", "vio0\n")
93 self.console_wait_send("IPv4 address", "dhcp\n")
94 self.console_wait_send("IPv6 address", "none\n")
95 self.console_wait_send("Which network interface", "done\n")
96 self.console_wait_send("DNS domain name", "localnet\n")
97 self.console_wait("Password for root account")
98 self.console_send("%s\n" % self.ROOT_PASS)
99 self.console_wait("Password for root account")
100 self.console_send("%s\n" % self.ROOT_PASS)
101 self.console_wait_send("Start sshd(8)", "yes\n")
102 self.console_wait_send("X Window System", "\n")
103 self.console_wait_send("xenodm", "\n")
104 self.console_wait_send("console to com0", "\n")
105 self.console_wait_send("Which speed", "\n")
107 self.console_wait("Setup a user")
108 self.console_send("%s\n" % self.GUEST_USER)
109 self.console_wait("Full name")
110 self.console_send("%s\n" % self.GUEST_USER)
111 self.console_wait("Password")
112 self.console_send("%s\n" % self.GUEST_PASS)
113 self.console_wait("Password")
114 self.console_send("%s\n" % self.GUEST_PASS)
116 self.console_wait_send("Allow root ssh login", "yes\n")
117 self.console_wait_send("timezone", "UTC\n")
118 self.console_wait_send("root disk", "\n")
119 self.console_wait_send("(W)hole disk", "\n")
120 self.console_wait_send("(A)uto layout", "\n")
121 self.console_wait_send("Location of sets", "cd0\n")
122 self.console_wait_send("Pathname to the sets", "\n")
123 self.console_wait_send("Set name(s)", "\n")
124 self.console_wait_send("without verification", "yes\n")
126 self.print_step("Installation started now, this will take a while")
127 self.console_wait_send("Location of sets", "done\n")
129 self.console_wait("successfully completed")
130 self.print_step("Installation finished, rebooting")
131 self.console_wait_send("(R)eboot", "reboot\n")
135 self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS)
136 self.console_wait_send(prompt, "exit\n")
140 self.console_ssh_init(prompt, "root", self.ROOT_PASS)
141 self.console_sshd_config(prompt)
143 # setup virtio-blk #1 (tarfile)
144 self.console_wait(prompt)
145 self.console_send("echo 'chmod 666 /dev/rsd1c' >> /etc/rc.local\n")
147 # enable w+x for /home
148 self.console_wait(prompt)
149 self.console_send("sed -i -e '/home/s/rw,/rw,wxallowed,/' /etc/fstab\n")
151 # tweak datasize limit
152 self.console_wait(prompt)
153 self.console_send("sed -i -e 's/\\(datasize[^=]*\\)=[^:]*/\\1=infinity/' /etc/login.conf\n")
155 # use http (be proxy cache friendly)
156 self.console_wait(prompt)
157 self.console_send("sed -i -e 's/https/http/' /etc/installurl\n")
159 self.print_step("Configuration finished, rebooting")
160 self.console_wait_send(prompt, "reboot\n")
161 self.console_wait("login:")
164 self.print_step("Installing packages")
165 self.ssh_root_check("pkg_add %s\n" % " ".join(self.pkgs))
168 self.ssh_root(self.poweroff)
171 if os.path.exists(img):
173 os.rename(img_tmp, img)
175 self.print_step("All done")
177 if __name__ == "__main__":
178 sys.exit(basevm.main(OpenBSDVM))