hw/arm: versal-virt: Add support for SD
[qemu/ar7.git] / tests / vm / ubuntu.i386
blob157077533532f1c5f49d2b6accb9429cc05f66ac
1 #!/usr/bin/env python3
3 # Ubuntu i386 image
5 # Copyright 2017 Red Hat Inc.
7 # Authors:
8 #  Fam Zheng <famz@redhat.com>
10 # This code is licensed under the GPL version 2 or later.  See
11 # the COPYING file in the top-level directory.
14 import os
15 import sys
16 import subprocess
17 import basevm
18 import time
20 class UbuntuX86VM(basevm.BaseVM):
21     name = "ubuntu.i386"
22     arch = "i386"
23     BUILD_SCRIPT = """
24         set -e;
25         cd $(mktemp -d);
26         sudo chmod a+r /dev/vdb;
27         tar -xf /dev/vdb;
28         ./configure {configure_opts};
29         make --output-sync {target} -j{jobs} {verbose};
30     """
32     def build_image(self, img):
33         cimg = self._download_with_cache(
34             "https://cloud-images.ubuntu.com/releases/bionic/release-20191114/ubuntu-18.04-server-cloudimg-i386.img",
35             sha256sum="28969840626d1ea80bb249c08eef1a4533e8904aa51a327b40f37ac4b4ff04ef")
36         img_tmp = img + ".tmp"
37         subprocess.check_call(["cp", "-f", cimg, img_tmp])
38         self.exec_qemu_img("resize", img_tmp, "50G")
39         self.boot(img_tmp, extra_args = [
40             "-device", "VGA",
41             "-cdrom", self.gen_cloud_init_iso()
42         ])
43         self.wait_ssh()
44         self.ssh_root_check("touch /etc/cloud/cloud-init.disabled")
45         self.ssh_root_check("apt-get update")
46         self.ssh_root_check("apt-get install -y cloud-initramfs-growroot")
47         # Don't check the status in case the guest hang up too quickly
48         self.ssh_root("sync && reboot")
49         time.sleep(5)
50         self.wait_ssh()
51         # The previous update sometimes doesn't survive a reboot, so do it again
52         self.ssh_root_check("sed -ie s/^#\ deb-src/deb-src/g /etc/apt/sources.list")
53         self.ssh_root_check("apt-get update")
54         self.ssh_root_check("apt-get build-dep -y qemu")
55         self.ssh_root_check("apt-get install -y libfdt-dev flex bison language-pack-en")
56         self.ssh_root("poweroff")
57         self.wait()
58         os.rename(img_tmp, img)
59         return 0
61 if __name__ == "__main__":
62     sys.exit(basevm.main(UbuntuX86VM))