]>
git.proxmox.com Git - mirror_qemu.git/blob - tests/vm/freebsd
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.
23 class FreeBSDVM(basevm
.BaseVM
):
27 link
= "https://download.freebsd.org/ftp/releases/ISO-IMAGES/12.1/FreeBSD-12.1-RELEASE-amd64-disc1.iso.xz"
28 csum
= "7394c3f60a1e236e7bd3a05809cf43ae39a3b8e5d42d782004cf2f26b1cfcd88"
65 rm -rf /home/qemu/qemu-test.*
66 cd $(mktemp -d /home/qemu/qemu-test.XXXXXX);
67 mkdir src build; cd src;
70 ../src/configure --python=python3.7 {configure_opts};
71 gmake --output-sync -j{jobs} {target} {verbose};
74 def console_boot_serial(self
):
75 self
.console_wait_send("Autoboot", "3")
76 self
.console_wait_send("OK", "set console=comconsole\n")
77 self
.console_wait_send("OK", "boot\n")
79 def build_image(self
, img
):
80 self
.print_step("Downloading install iso")
81 cimg
= self
._download
_with
_cache
(self
.link
, sha256sum
=self
.csum
)
82 img_tmp
= img
+ ".tmp"
83 iso
= img
+ ".install.iso"
86 self
.print_step("Preparing iso and disk image")
87 subprocess
.check_call(["cp", "-f", cimg
, iso_xz
])
88 subprocess
.check_call(["xz", "-dvf", iso_xz
])
89 self
.exec_qemu_img("create", "-f", "qcow2", img_tmp
, self
.size
)
91 self
.print_step("Booting installer")
92 self
.boot(img_tmp
, extra_args
= [
93 "-bios", "pc-bios/bios-256k.bin",
94 "-machine", "graphics=off",
99 self
.console_boot_serial()
100 self
.console_wait_send("Console type", "xterm\n")
102 # pre-install configuration
103 self
.console_wait_send("Welcome", "\n")
104 self
.console_wait_send("Keymap Selection", "\n")
105 self
.console_wait_send("Set Hostname", "freebsd\n")
106 self
.console_wait_send("Distribution Select", "\n")
107 self
.console_wait_send("Partitioning", "\n")
108 self
.console_wait_send("Partition", "\n")
109 self
.console_wait_send("Scheme", "\n")
110 self
.console_wait_send("Editor", "f")
111 self
.console_wait_send("Confirmation", "c")
113 self
.print_step("Installation started now, this will take a while")
115 # post-install configuration
116 self
.console_wait("New Password:")
117 self
.console_send("%s\n" % self
.ROOT_PASS
)
118 self
.console_wait("Retype New Password:")
119 self
.console_send("%s\n" % self
.ROOT_PASS
)
121 self
.console_wait_send("Network Configuration", "\n")
122 self
.console_wait_send("IPv4", "y")
123 self
.console_wait_send("DHCP", "y")
124 self
.console_wait_send("IPv6", "n")
125 self
.console_wait_send("Resolver", "\n")
127 self
.console_wait_send("Time Zone Selector", "a\n")
128 self
.console_wait_send("Confirmation", "y")
129 self
.console_wait_send("Time & Date", "\n")
130 self
.console_wait_send("Time & Date", "\n")
132 self
.console_wait_send("System Configuration", "\n")
133 self
.console_wait_send("System Hardening", "\n")
136 self
.console_wait_send("Add User Accounts", "y")
137 self
.console_wait("Username")
138 self
.console_send("%s\n" % self
.GUEST_USER
)
139 self
.console_wait("Full name")
140 self
.console_send("%s\n" % self
.GUEST_USER
)
141 self
.console_wait_send("Uid", "\n")
142 self
.console_wait_send("Login group", "\n")
143 self
.console_wait_send("Login group", "\n")
144 self
.console_wait_send("Login class", "\n")
145 self
.console_wait_send("Shell", "\n")
146 self
.console_wait_send("Home directory", "\n")
147 self
.console_wait_send("Home directory perm", "\n")
148 self
.console_wait_send("Use password", "\n")
149 self
.console_wait_send("Use an empty password", "\n")
150 self
.console_wait_send("Use a random password", "\n")
151 self
.console_wait("Enter password:")
152 self
.console_send("%s\n" % self
.GUEST_PASS
)
153 self
.console_wait("Enter password again:")
154 self
.console_send("%s\n" % self
.GUEST_PASS
)
155 self
.console_wait_send("Lock out", "\n")
156 self
.console_wait_send("OK", "yes\n")
157 self
.console_wait_send("Add another user", "no\n")
159 self
.console_wait_send("Final Configuration", "\n")
160 self
.console_wait_send("Manual Configuration", "\n")
161 self
.console_wait_send("Complete", "\n")
163 self
.print_step("Installation finished, rebooting")
164 self
.console_boot_serial()
168 self
.console_ssh_init(prompt
, self
.GUEST_USER
, self
.GUEST_PASS
)
169 self
.console_wait_send(prompt
, "exit\n")
172 prompt
= "root@freebsd:~ #"
173 self
.console_ssh_init(prompt
, "root", self
.ROOT_PASS
)
174 self
.console_sshd_config(prompt
)
176 # setup serial console
177 self
.console_wait(prompt
)
178 self
.console_send("echo 'console=comconsole' >> /boot/loader.conf\n")
181 self
.console_wait(prompt
)
182 self
.console_send("echo 'autoboot_delay=1' >> /boot/loader.conf\n")
184 # setup virtio-blk #1 (tarfile)
185 self
.console_wait(prompt
)
186 self
.console_send("echo 'chmod 666 /dev/vtbd1' >> /etc/rc.local\n")
188 self
.print_step("Configuration finished, rebooting")
189 self
.console_wait_send(prompt
, "reboot\n")
190 self
.console_wait("login:")
193 self
.print_step("Installing packages")
194 self
.ssh_root_check("pkg install -y %s\n" % " ".join(self
.pkgs
))
197 self
.ssh_root(self
.poweroff
)
198 self
.console_wait("Uptime:")
201 if os
.path
.exists(img
):
203 os
.rename(img_tmp
, img
)
205 self
.print_step("All done")
207 if __name__
== "__main__":
208 sys
.exit(basevm
.main(FreeBSDVM
))