#!/bin/bash set -e proc die { echo >&2 @ARGV>&2 "$@" exit 1 } setvar img = '/usr/share/clear-containers/clear-containers.img' setvar img = $(readlink -f "$img") setvar img_size = $(du -b "${img}" | awk '{print $1}') setvar kernel = ""$(pwd)/clear-containers-vmlinux"" setvar kernel_cmdline_file = ""$(pwd)/clear-containers-cmdline"" test -f ${img} || die "Image s required" test -f ${kernel} || die "Kernel is required" test -f ${kernel_cmdline_file} || \ die "Kernel cmdline file is required" setvar kernel_cmdline = $(cat "$kernel_cmdline_file") setvar cmd = ""/usr/bin/qemu-lite-system-x86_64"" setvar cmd = ""$cmd -machine pc-lite,accel=kvm,kernel_irqchip,nvdimm"" setvar cmd = ""$cmd -device nvdimm,memdev=mem0,id=nv0"" #image setvar cmd = ""$cmd -object memory-backend-file,id=mem0,mem-path=${img},size=${img_size}"" #memory setvar cmd = ""$cmd -m 2G,slots=2,maxmem=3G"" #kernel setvar cmd = ""$cmd -kernel ${kernel}"" setvar cmd = ""$cmd -append '${kernel_cmdline}'"" #cpu setvar cmd = ""$cmd -smp 2,sockets=1,cores=2,threads=1"" setvar cmd = ""$cmd -cpu host"" #clock setvar cmd = ""$cmd -rtc base=utc,driftfix=slew"" setvar cmd = ""$cmd -no-user-config"" setvar cmd = ""$cmd -nodefaults"" setvar cmd = ""$cmd -global"" setvar cmd = ""$cmd kvm-pit.lost_tick_policy=discard"" #console setvar cmd = ""$cmd -device virtio-serial-pci,id=virtio-serial0"" setvar cmd = ""$cmd -chardev stdio,id=charconsole0,signal=off"" setvar cmd = ""$cmd -device virtconsole,chardev=charconsole0,id=console0"" setvar cmd = ""$cmd -nographic"" setvar cmd = ""$cmd -vga none"" eval $cmd