mirror of
https://github.com/rancher/os.git
synced 2025-08-11 03:22:49 +00:00
Merge pull request #812 from imikushin/qemu-arm64
Run qemu and tests on different architectures
This commit is contained in:
commit
96c3f3958b
@ -2,7 +2,7 @@ FROM rancher/os-dapper-base
|
|||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get -y install locales sudo vim less curl wget git rsync build-essential isolinux xorriso gccgo \
|
apt-get -y install locales sudo vim less curl wget git rsync build-essential isolinux xorriso gccgo \
|
||||||
libblkid-dev libmount-dev libselinux1-dev cpio genisoimage qemu-kvm python-pip ca-certificates pkg-config tox
|
libblkid-dev libmount-dev libselinux1-dev cpio genisoimage qemu-kvm qemu python-pip ca-certificates pkg-config tox
|
||||||
|
|
||||||
ARG HOST_ARCH
|
ARG HOST_ARCH
|
||||||
ENV HOST_ARCH ${HOST_ARCH}
|
ENV HOST_ARCH ${HOST_ARCH}
|
||||||
|
2
Makefile
2
Makefile
@ -62,7 +62,7 @@ minimal: initrd dist/artifacts/vmlinuz
|
|||||||
iso: dist/artifacts/rancheros.iso dist/artifacts/iso-checksums.txt
|
iso: dist/artifacts/rancheros.iso dist/artifacts/iso-checksums.txt
|
||||||
|
|
||||||
test: minimal
|
test: minimal
|
||||||
cd tests/integration && tox
|
cd tests/integration && HOST_ARCH=$(HOST_ARCH) ARCH=$(ARCH) tox
|
||||||
|
|
||||||
.PHONY: all minimal initrd iso installer test
|
.PHONY: all minimal initrd iso installer test
|
||||||
|
|
||||||
|
47
scripts/run
47
scripts/run
@ -6,10 +6,28 @@ cd $(dirname $0)/..
|
|||||||
|
|
||||||
source scripts/build-common
|
source scripts/build-common
|
||||||
|
|
||||||
|
HOST_ARCH=${HOST_ARCH:-amd64}
|
||||||
|
ARCH=${ARCH:-amd64}
|
||||||
|
|
||||||
|
declare -A qemuarch=( ["amd64"]="x86_64" ["arm"]="arm" ["arm64"]="aarch64" )
|
||||||
|
declare -A ttycons=( ["amd64"]="ttyS0" ["arm"]="ttyAMA0" ["arm64"]="ttyAMA0" )
|
||||||
|
declare -A machine=( ["amd64"]="" ["arm"]="-M virt -cpu cortex-a8" ["arm64"]="-M virt -cpu cortex-a57" )
|
||||||
|
declare -A network=(
|
||||||
|
["amd64"]="-net nic,vlan=0,model=virtio -net user,vlan=0,hostfwd=tcp::2222-:22,hostname=rancher-dev"
|
||||||
|
["arm"]="-netdev user,id=unet,hostfwd=tcp::2222-:22,hostname=rancher-dev -device virtio-net-device,netdev=unet"
|
||||||
|
)
|
||||||
|
network["arm64"]=${network["arm"]}
|
||||||
|
|
||||||
|
hd_amd64() {
|
||||||
|
echo "-drive if=virtio,file=$1"
|
||||||
|
}
|
||||||
|
hd_arm() {
|
||||||
|
echo "-drive if=none,file=$1,id=hd0 -device virtio-blk-device,drive=hd0"
|
||||||
|
}
|
||||||
|
declare -A hd=( ["amd64"]="hd_amd64" ["arm"]="hd_arm" ["arm64"]="hd_arm" )
|
||||||
|
|
||||||
BASE=$(pwd)
|
BASE=$(pwd)
|
||||||
UNAME=$(uname)
|
UNAME=$(uname)
|
||||||
QEMUARCH=$(uname -m)
|
|
||||||
[ "${UNAME}" == "Darwin" ] && QEMUARCH=x86_64
|
|
||||||
|
|
||||||
KERNEL=${BASE}/dist/artifacts/vmlinuz
|
KERNEL=${BASE}/dist/artifacts/vmlinuz
|
||||||
INITRD=${BASE}/dist/artifacts/initrd
|
INITRD=${BASE}/dist/artifacts/initrd
|
||||||
@ -43,10 +61,12 @@ while [ "$#" -gt 0 ]; do
|
|||||||
QEMU=0
|
QEMU=0
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
--arch)
|
||||||
|
shift 1
|
||||||
|
ARCH="$1"
|
||||||
|
;;
|
||||||
--qemu)
|
--qemu)
|
||||||
if [ -x $(which qemu-system-${QEMUARCH}) ]; then
|
QEMU=1
|
||||||
QEMU=1
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
--qind)
|
--qind)
|
||||||
QIND=1
|
QIND=1
|
||||||
@ -74,6 +94,13 @@ while [ "$#" -gt 0 ]; do
|
|||||||
shift 1
|
shift 1
|
||||||
done
|
done
|
||||||
|
|
||||||
|
QEMUARCH=${qemuarch["${ARCH}"]}
|
||||||
|
TTYCONS=${ttycons["${ARCH}"]}
|
||||||
|
|
||||||
|
if [ "$QEMU" == "1" ] && ! which qemu-system-${QEMUARCH}; then
|
||||||
|
QEMU=0
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ ! -e ${KERNEL} || ! -e ${INITRD} ]]; then
|
if [[ ! -e ${KERNEL} || ! -e ${INITRD} ]]; then
|
||||||
echo "Failed to find ${KERNEL} or ${INITRD}" 1>&2
|
echo "Failed to find ${KERNEL} or ${INITRD}" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -112,7 +139,7 @@ if [ "$REBUILD" == "1" ]; then
|
|||||||
INITRD=${INITRD_TEST}
|
INITRD=${INITRD_TEST}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
KERNEL_ARGS="quiet rancher.password=rancher console=ttyS0 ${QEMU_APPEND}"
|
KERNEL_ARGS="quiet rancher.password=rancher console=${TTYCONS} ${QEMU_APPEND}"
|
||||||
if [ "$FORMAT" == "1" ]; then
|
if [ "$FORMAT" == "1" ]; then
|
||||||
KERNEL_ARGS="${KERNEL_ARGS} rancher.state.formatzero=true rancher.state.autoformat=[/dev/sda,/dev/vda]"
|
KERNEL_ARGS="${KERNEL_ARGS} rancher.state.formatzero=true rancher.state.autoformat=[/dev/sda,/dev/vda]"
|
||||||
fi
|
fi
|
||||||
@ -165,16 +192,16 @@ if [ "$XHYVE" == "1" ] || [ "$QEMU" == "1" ]; then
|
|||||||
|
|
||||||
elif [ "$QEMU" == "1" ]; then
|
elif [ "$QEMU" == "1" ]; then
|
||||||
|
|
||||||
if [ "$KVM" == "1" ]; then
|
if [ "$KVM" == "1" ] && [ "$ARCH" == "$HOST_ARCH" ]; then
|
||||||
KVM_ENABLE="-machine accel=kvm -cpu host"
|
KVM_ENABLE="-machine accel=kvm -cpu host"
|
||||||
fi
|
fi
|
||||||
exec qemu-system-${QEMUARCH} -serial stdio \
|
exec qemu-system-${QEMUARCH} -serial stdio \
|
||||||
|
${machine["$ARCH"]} \
|
||||||
-kernel ${KERNEL} \
|
-kernel ${KERNEL} \
|
||||||
-initrd ${INITRD} \
|
-initrd ${INITRD} \
|
||||||
-m 1024 \
|
-m 1024 \
|
||||||
-net nic,vlan=0,model=virtio \
|
${network["$ARCH"]} \
|
||||||
-net user,vlan=0,hostfwd=tcp::2222-:22,hostname=rancher-dev \
|
$(eval "${hd["$ARCH"]} ${HD}") \
|
||||||
-drive if=virtio,file=${HD} \
|
|
||||||
${KVM_ENABLE} \
|
${KVM_ENABLE} \
|
||||||
-smp 1 \
|
-smp 1 \
|
||||||
-cdrom ${CLOUD_CONFIG_ISO} \
|
-cdrom ${CLOUD_CONFIG_ISO} \
|
||||||
|
@ -4,6 +4,7 @@ skipsdist=True
|
|||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps=-rrequirements.txt
|
deps=-rrequirements.txt
|
||||||
|
passenv=HOST_ARCH ARCH
|
||||||
commands=py.test -s --durations=20 rostest {posargs}
|
commands=py.test -s --durations=20 rostest {posargs}
|
||||||
|
|
||||||
[testenv:flake8]
|
[testenv:flake8]
|
||||||
|
Loading…
Reference in New Issue
Block a user