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.
24 'cpu' : "max,sse4.2=off",
27 class FreeBSDVM(basevm.BaseVM):
31 link = "https://download.freebsd.org/ftp/releases/ISO-IMAGES/12.3/FreeBSD-12.3-RELEASE-amd64-disc1.iso.xz"
32 csum = "36dd0de50f1fe5f0a88e181e94657656de26fb64254412f74e80e128e8b938b4"
73 rm -rf /home/qemu/qemu-test.*
74 cd $(mktemp -d /home/qemu/qemu-test.XXXXXX);
75 mkdir src build; cd src;
78 ../src/configure --python=python3.7 {configure_opts};
79 gmake --output-sync -j{jobs} {target} {verbose};
82 def console_boot_serial(self):
83 self.console_wait_send("Autoboot", "3")
84 self.console_wait_send("OK", "set console=comconsole\n")
85 self.console_wait_send("OK", "boot\n")
87 def build_image(self, img):
88 self.print_step("Downloading install iso")
89 cimg = self._download_with_cache(self.link, sha256sum=self.csum)
90 img_tmp = img + ".tmp"
91 iso = img + ".install.iso"
94 self.print_step("Preparing iso and disk image")
95 subprocess.check_call(["cp", "-f", cimg, iso_xz])
96 subprocess.check_call(["xz", "-dvf", iso_xz])
97 self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
99 self.print_step("Booting installer")
100 self.boot(img_tmp, extra_args = [
101 "-machine", "graphics=off",
106 self.console_boot_serial()
107 self.console_wait_send("Console type", "xterm\n")
109 # pre-install configuration
110 self.console_wait_send("Welcome", "\n")
111 self.console_wait_send("Keymap Selection", "\n")
112 self.console_wait_send("Set Hostname", "freebsd\n")
113 self.console_wait_send("Distribution Select", "\n")
114 self.console_wait_send("Partitioning", "\n")
115 self.console_wait_send("Partition", "\n")
116 self.console_wait_send("Scheme", "\n")
117 self.console_wait_send("Editor", "f")
118 self.console_wait_send("Confirmation", "c")
120 self.print_step("Installation started now, this will take a while")
122 # post-install configuration
123 self.console_wait("New Password:")
124 self.console_send("%s\n" % self._config["root_pass"])
125 self.console_wait("Retype New Password:")
126 self.console_send("%s\n" % self._config["root_pass"])
128 self.console_wait_send("Network Configuration", "\n")
129 self.console_wait_send("IPv4", "y")
130 self.console_wait_send("DHCP", "y")
131 self.console_wait_send("IPv6", "n")
132 self.console_wait_send("Resolver", "\n")
134 self.console_wait_send("Time Zone Selector", "0\n")
135 self.console_wait_send("Confirmation", "y")
136 self.console_wait_send("Time & Date", "\n")
137 self.console_wait_send("Time & Date", "\n")
139 self.console_wait_send("System Configuration", "\n")
140 self.console_wait_send("System Hardening", "\n")
143 self.console_wait_send("Add User Accounts", "y")
144 self.console_wait("Username")
145 self.console_send("%s\n" % self._config["guest_user"])
146 self.console_wait("Full name")
147 self.console_send("%s\n" % self._config["guest_user"])
148 self.console_wait_send("Uid", "\n")
149 self.console_wait_send("Login group", "\n")
150 self.console_wait_send("Login group", "\n")
151 self.console_wait_send("Login class", "\n")
152 self.console_wait_send("Shell", "\n")
153 self.console_wait_send("Home directory", "\n")
154 self.console_wait_send("Home directory perm", "\n")
155 self.console_wait_send("Use password", "\n")
156 self.console_wait_send("Use an empty password", "\n")
157 self.console_wait_send("Use a random password", "\n")
158 self.console_wait("Enter password:")
159 self.console_send("%s\n" % self._config["guest_pass"])
160 self.console_wait("Enter password again:")
161 self.console_send("%s\n" % self._config["guest_pass"])
162 self.console_wait_send("Lock out", "\n")
163 self.console_wait_send("OK", "yes\n")
164 self.console_wait_send("Add another user", "no\n")
166 self.console_wait_send("Final Configuration", "\n")
167 self.console_wait_send("Manual Configuration", "\n")
168 self.console_wait_send("Complete", "\n")
170 self.print_step("Installation finished, rebooting")
171 self.console_boot_serial()
175 self.console_ssh_init(prompt, self._config["guest_user"], self._config["guest_pass"])
176 self.console_wait_send(prompt, "exit\n")
179 prompt = "root@freebsd:~ #"
180 self.console_ssh_init(prompt, "root", self._config["root_pass"])
181 self.console_sshd_config(prompt)
183 # setup serial console
184 self.console_wait(prompt)
185 self.console_send("echo 'console=comconsole' >> /boot/loader.conf\n")
188 self.console_wait(prompt)
189 self.console_send("echo 'autoboot_delay=1' >> /boot/loader.conf\n")
191 # setup virtio-blk #1 (tarfile)
192 self.console_wait(prompt)
193 self.console_send("echo 'chmod 666 /dev/vtbd1' >> /etc/rc.local\n")
195 self.print_step("Configuration finished, rebooting")
196 self.console_wait_send(prompt, "reboot\n")
197 self.console_wait("login:")
200 self.print_step("Installing packages")
201 self.ssh_root_check("pkg install -y %s\n" % " ".join(self.pkgs))
204 self.ssh_root(self.poweroff)
205 self.console_wait("Uptime:")
208 if os.path.exists(img):
210 os.rename(img_tmp, img)
212 self.print_step("All done")
214 if __name__ == "__main__":
215 sys.exit(basevm.main(FreeBSDVM, config=FREEBSD_CONFIG))