Commit 3ca510c0 authored by Mathew McBride's avatar Mathew McBride
Browse files

test: add test vm start script

parent e8f31380
Pipeline #292142264 passed with stage
in 2 minutes and 25 seconds
#!/bin/sh
set -e
BUILD_ARTIFACTS_DIR="muvirt-imagebuilder-SNAPSHOT-layerscape-armv8_64b.Linux-x86_64/build_dir/target-aarch64_generic_musl/linux-layerscape_armv8_64b/"
RECOVERY_KERNEL=${RECOVERY_KERNEL:-"${BUILD_ARTIFACTS_DIR}/Image"}
RECOVERY_ROOTFS="${BUILD_ARTIFACTS_DIR}/root.ext4"
RECOVERY_ROOTFS_COMPRESSED=${RECOVERY_ROOTFS_COMPRESSED:-"${BUILD_ARTIFACTS_DIR}/root.ext4.gz"}
[ ! -f "${RECOVERY_KERNEL}" ] && echo "ERROR: No kernel file present at ${RECOVERY_KERNEL}" && exit 1
[ ! -f "${RECOVERY_ROOTFS}" ] && [ ! -f "${RECOVERY_ROOTFS_COMPRESSED}" ] && echo "ERROR: No rootfs file present at ${RECOVERY_ROOTFS}" && exit 1
if [ -f "${RECOVERY_ROOTFS}" ]; then
gzip -c "${RECOVERY_ROOTFS}" > "${RECOVERY_ROOTFS_COMPRESSED}"
fi
KVM_OPTIONS=""
CPU_OPTIONS="cortex-a53"
if [ $(uname -m) = "aarch64" ]; then
echo "Native aarch64 host, using KVM"
KVM_OPTIONS="--enable-kvm"
CPU_OPTIONS="host"
else
echo "WARNING: It is strongly recommended to use a native aarch64 host as"
echo "some operations do not work well under emulation"
fi
QEMU_COMMAND_LINE="qemu-system-aarch64 ${KVM_OPTIONS} -m 2084 -cpu ${CPU_OPTIONS} -M virt -nographic"
QEMU_COMMAND_LINE="${QEMU_COMMAND_LINE} -netdev tap,id=recoverylan,script=no -net nic,netdev=recoverylan"
QEMU_COMMAND_LINE="${QEMU_COMMAND_LINE} -netdev user,id=recoverywan -net nic,netdev=recoverywan"
QEMU_COMMAND_LINE="${QEMU_COMMAND_LINE} -kernel ${RECOVERY_KERNEL} -initrd ${RECOVERY_ROOTFS_COMPRESSED}"
QEMU_COMMAND_LINE="${QEMU_COMMAND_LINE} -append \"console=ttyAMA0 root=/dev/ram0 ramdisk_size=131072\""
QEMU_COMMAND_LINE="${QEMU_COMMAND_LINE} -drive file=test.qcow2,if=none,id=drivetest -device virtio-blk,drive=drivetest,serial=testdrive123"
QEMU_COMMAND_LINE="${QEMU_COMMAND_LINE} -drive file=cache.qcow2,if=none,id=dlcache -device virtio-blk,drive=dlcache,serial=dlcache1"
if [ -d "${HUGETLB_MOUNT}" ]; then
QEMU_COMMAND_LINE="${QEMU_COMMAND_LINE} -mem-path ${HUGETLB_MOUNT}"
fi
rm -f test.qcow2
qemu-img create test.qcow2 16G
rm -f cache.qcow2
qemu-img create cache.qcow2 4G
echo "${QEMU_COMMAND_LINE}" | xargs sudo
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment