sample_app: Add scripts to create RT and HMI VM images

Creating VM images is always a pain to users, and it is especially the case
for those who want to set up the ACRN sample application which needs two
different VM images, one with graphical desktop and the other optimized for
real-time.

This patch introduces the so-called "image builder" utility which is a set
of scripts that can automate the creation of those VM images. The scripts
will take care of:

  - Forking image files based on Ubuntu cloud images and enlarge the root
    file system per needs.

  - Setting up users and passwords.

  - Installing necessary packages to run either the graphical desktop or
    real-time applications.

  - Specific to the RT VM image, disabling services and tweaking kernel
    command line for optimized real-time performance.

  - Copying the sample applications into the images so that users can
    start them directly, after they launch the VMs.

Tracked-On: #7820
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Junjie Mao
2022-08-04 17:57:20 +08:00
committed by acrnsi-robot
parent 88ed588711
commit 3f0eb96d85
6 changed files with 438 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
#!/bin/bash
# Copyright (C) 2020-2022 Intel Corporation.
# SPDX-License-Identifier: BSD-3-Clause
logger_prefix="(rt-vm-rootfs) "
source logger.sh
function umount_directory() {
target_dir=$1
umount -q ${target_dir} || true
}
function disable_os_prober() {
if [[ -f /etc/grub.d/30_os-prober ]]; then
mv /etc/grub.d/30_os-prober /etc/grub.d/.30_os-prober
fi
}
function update_package_info() {
apt update
}
function install_tools() {
apt install rt-tests
}
function update_kernel_cmdline() {
cat <<EOF >> /etc/default/grub
GRUB_CMDLINE_LINUX="rootwait rootfstype=ext4 console=ttyS0,115200 console=tty0 rw nohpet console=hvc0 no_timer_check ignore_loglevel log_buf_len=16M consoleblank=0 tsc=reliable clocksource=tsc tsc=reliable x2apic_phys processor.max_cstate=0 intel_idle.max_cstate=0 intel_pstate=disable mce=ignore_ce audit=0 isolcpus=nohz,domain,1 nohz_full=1 rcu_nocbs=1 nosoftlockup idle=poll irqaffinity=0 no_ipi_broadcast=1"
EOF
}
function install_rt_kernel() {
search_dir=$1
for file in $(ls -r ${search_dir}/*acrn-kernel-*.deb)
do
apt install ${file}
done
}
function change_root_password() {
passwd root
}
function disable_services() {
services=(systemd-timesyncd.service \
systemd-journald.service \
systemd-journal-flush.service \
serial-getty@ttyS2.service \
apt-daily.service \
apt-daily-upgrade.service)
for service in ${services[*]}
do
systemctl disable ${service}
systemctl mask ${service}
done
for timer in $(systemctl list-unit-files | grep -o "^.*\.timer"); do
systemctl disable ${timer}
done
apt-get remove unattended-upgrades
}
# Change current working directory to the root to avoid "target is busy" errors
# on unmounting.
cd /
try_step "Unmounting /root" umount_directory /root
try_step "Unmounting /home" umount_directory /home
try_step "Disabling GRUB OS prober" disable_os_prober
try_step "Updating package information" update_package_info
try_step "Installing tools" install_tools
try_step "Updating kernel command line" update_kernel_cmdline
try_step "Installing RT kernel" install_rt_kernel /root
try_step "Changing the password of the root user" change_root_password
try_step "Disabling services that impact real-time performance" disable_services