Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a35c441
Add qemu-system for armv7-unknown-linux-gnueabihf
malbarbo Dec 1, 2017
4158251
Add qemu-{user,system} for i686-unknown-linux-gnu
malbarbo Dec 1, 2017
d15c941
Add qemu-system for {mips,mipsel}-unknown-linux-gnu
malbarbo Dec 1, 2017
7710561
Add qemu-system for mips64el-unknown-linux-gnuabi64
malbarbo Dec 1, 2017
f1c1a64
Add qemu-system for powerpc64le-unknown-linux-gnu
malbarbo Dec 2, 2017
e9d7298
Add qemu-system for s390x-unknown-linux-gnu
malbarbo Dec 2, 2017
de9c6e2
Add qemu-{user,system} for x86_64-unknown-linux-gnu
malbarbo Dec 2, 2017
8a45c95
Add qemu-system for powerpc64-unknown-linux-gnu
malbarbo Dec 2, 2017
bb540e0
Add qemu-system for sparc64-unknown-linux-gnu
malbarbo Dec 2, 2017
0c048e7
Add qemu-system for powerpc-unknown-linux-gnu
malbarbo Dec 2, 2017
6895fc0
Use 9p2000.u protocol in qemu-system
malbarbo Dec 2, 2017
c6e54a2
Print the boot time of qemu-system using $SECONDS
malbarbo Dec 2, 2017
4f98b4d
Fix qemu-system for armv7, powerpc and x86_64
malbarbo Dec 3, 2017
355d608
Create /tmp in qemu system linux images
malbarbo Dec 21, 2017
3aa6e6d
Update spach64 kernel version
malbarbo Jan 24, 2018
7cf59f3
Use qarch in QEMU_CMD
malbarbo Mar 20, 2018
c416c22
Update sparc64 and powerpc64 kernel
malbarbo Mar 20, 2018
cec4fd5
Only limit the cpu number for aarch64
malbarbo Mar 20, 2018
af3db9b
Fix typo
malbarbo Oct 16, 2018
d8c912b
Update qemu-system kernel of sparc64 and powerpc64 to 4.18.0-2
malbarbo Oct 16, 2018
0c486fd
Use correct arch for qemu-user runner
malbarbo Oct 16, 2018
6d112a2
Enable run tests for s390x-unknown-linux-gnu sparc64-unknown-linux-gnu
malbarbo Oct 16, 2018
b8aaa3c
Test sparc64-unknown-linux-gnu with openssl 0.7.17
malbarbo Oct 16, 2018
831f073
Update qemu-system kernel of powerpc to 4.9.0-0.bpo.6
malbarbo Oct 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ matrix:
# Linux
- env: TARGET=aarch64-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.5.5 RUN=1 RUNNERS="qemu-user qemu-system" CROSS_DEBUG=1
- env: TARGET=arm-unknown-linux-gnueabi CPP=1 DYLIB=1 STD=1 OPENSSL=0.5.5 RUN=1
- env: TARGET=armv7-unknown-linux-gnueabihf CPP=1 DYLIB=1 STD=1 OPENSSL=0.5.5 RUN=1
- env: TARGET=armv7-unknown-linux-gnueabihf CPP=1 DYLIB=1 STD=1 OPENSSL=0.5.5 RUN=1 RUNNERS="qemu-user qemu-system"
- env: TARGET=i586-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.5.5 RUN=1
- env: TARGET=i686-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.5.5 RUN=1
- env: TARGET=mips-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.5.5 RUN=1
- env: TARGET=i686-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.5.5 RUN=1 RUNNERS="native qemu-user qemu-system"
- env: TARGET=mips-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.5.5 RUN=1 RUNNERS="qemu-user qemu-system"
- env: TARGET=mipsel-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.5.5 RUN=1 RUNNERS="qemu-user qemu-system"
- env: TARGET=mips64-unknown-linux-gnuabi64 CPP=1 DYLIB=1 STD=1 OPENSSL=0.7.17 RUN=1
- env: TARGET=mips64el-unknown-linux-gnuabi64 CPP=1 DYLIB=1 STD=1 OPENSSL=0.7.17 RUN=1
- env: TARGET=mipsel-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.5.5 RUN=1
- env: TARGET=powerpc-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.5.5 RUN=1
- env: TARGET=powerpc64-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.7.17 RUN=1
- env: TARGET=powerpc64le-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.7.17 RUN=1
- env: TARGET=s390x-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.7.17
- env: TARGET=sparc64-unknown-linux-gnu CPP=1 DYLIB=1 OPENSSL=0.5.5 RUN=1
- env: TARGET=x86_64-unknown-linux-gnu CPP=1 DYLIB=1 OPENSSL=0.5.5 RUN=1 DEPLOY=1
- env: TARGET=mips64el-unknown-linux-gnuabi64 CPP=1 DYLIB=1 STD=1 OPENSSL=0.7.17 RUN=1 RUNNERS="qemu-user qemu-system"
- env: TARGET=powerpc-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.5.5 RUN=1 RUNNERS="qemu-user qemu-system"
- env: TARGET=powerpc64-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.7.17 RUN=1 RUNNERS="qemu-user qemu-system"
- env: TARGET=powerpc64le-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.7.17 RUN=1 RUNNERS="qemu-user qemu-system"
- env: TARGET=s390x-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.7.17 RUN=1 RUNNERS="qemu-system"
- env: TARGET=sparc64-unknown-linux-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.7.17 RUN=1 RUNNERS="qemu-system"
- env: TARGET=x86_64-unknown-linux-gnu CPP=1 DYLIB=1 OPENSSL=0.5.5 RUN=1 DEPLOY=1 RUNNERS="native qemu-user qemu-system"

# Linux musl
- env: TARGET=aarch64-unknown-linux-musl STD=1 OPENSSL=0.5.5 RUN=1
Expand Down
21 changes: 16 additions & 5 deletions docker/armv7-unknown-linux-gnueabihf/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,26 @@ COPY cmake.sh /
RUN apt-get purge --auto-remove -y cmake && \
bash /cmake.sh 3.5.1

COPY openssl.sh qemu.sh /
RUN apt-get install -y --no-install-recommends \
g++-arm-linux-gnueabihf \
libc6-dev-armhf-cross && \
bash /openssl.sh linux-armv4 arm-linux-gnueabihf- && \
bash /qemu.sh arm
libc6-dev-armhf-cross

COPY openssl.sh /
RUN bash /openssl.sh linux-armv4 arm-linux-gnueabihf-

COPY qemu.sh /
RUN bash /qemu.sh arm linux softmmu

COPY dropbear.sh /
RUN bash /dropbear.sh

COPY linux-image.sh /
RUN bash /linux-image.sh armv7

COPY linux-runner /

ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER=qemu-arm \
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER="/linux-runner armv7" \
CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \
CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ \
OPENSSL_DIR=/openssl \
Expand Down
21 changes: 17 additions & 4 deletions docker/i686-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,24 @@ COPY cmake.sh /
RUN apt-get purge --auto-remove -y cmake && \
bash /cmake.sh 3.5.1

COPY openssl.sh /
RUN apt-get install -y --no-install-recommends \
g++-multilib && \
bash /openssl.sh linux-elf "" -m32
g++-multilib

COPY openssl.sh /
RUN bash /openssl.sh linux-elf "" -m32

COPY qemu.sh /
RUN bash /qemu.sh i386 linux softmmu

COPY dropbear.sh /
RUN bash /dropbear.sh

COPY linux-image.sh /
RUN bash /linux-image.sh i686

COPY linux-runner /

ENV OPENSSL_DIR=/openssl \
ENV CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_RUNNER="/linux-runner i686" \
OPENSSL_DIR=/openssl \
OPENSSL_INCLUDE_DIR=/openssl/include \
OPENSSL_LIB_DIR=/openssl/lib
89 changes: 79 additions & 10 deletions docker/linux-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,70 @@ main() {
local arch=$1 \
kversion=4.9.0-8

local debsource="deb http://http.debian.net/debian/ stretch main"
debsource="$debsource\ndeb http://security.debian.org/ stretch/updates main"

local dropbear="dropbear-bin"
local libssl="libssl1.0.2"

# select debian arch and kernel version
case $arch in
aarch64)
arch=arm64
kernel=$kversion-arm64
;;
armv7)
arch=armhf
kernel=$kversion-armmp
;;
i686)
arch=i386
kernel=$kversion-686
;;
mips|mipsel)
kernel=$kversion-4kc-malta
;;
mips64el)
kernel=$kversion-5kc-malta
;;
powerpc)
# there is no stretch powerpc port, so we use jessie
# use a more recent kernel from backports
kernel=4.9.0-0.bpo.6-powerpc
debsource="deb http://http.debian.net/debian/ jessie main"
debsource="$debsource\ndeb http://http.debian.net/debian/ jessie-backports main"
dropbear="dropbear"
libssl="libssl1.0.0"
;;
powerpc64)
# there is no stable port
arch=ppc64
kernel=4.18.0-2-powerpc64
debsource="deb http://ftp.ports.debian.org/debian-ports/ unreleased main"
debsource="$debsource\ndeb http://ftp.ports.debian.org/debian-ports/ unstable main"
# sid version of dropbear requeries this depencendies
deps="libtommath1:ppc64 libtomcrypt1:ppc64 libgmp10:ppc64"
;;
powerpc64le)
arch=ppc64el
kernel=$kversion-powerpc64le
;;
s390x)
arch=s390x
kernel=$kversion-s390x
;;
sparc64)
# there is no stable port
kernel=4.18.0-2-sparc64
debsource="deb http://ftp.ports.debian.org/debian-ports/ unreleased main"
debsource="$debsource\ndeb http://ftp.ports.debian.org/debian-ports/ unstable main"
# sid version of dropbear requeries this depencendies
deps="libtommath1:sparc64 libtomcrypt1:sparc64 libgmp10:sparc64"
;;
x86_64)
arch=amd64
kernel=$kversion-amd64
;;
*)
echo "Invalid arch: $arch"
exit 1
Expand All @@ -33,31 +91,33 @@ main() {

# Download packages
mv /etc/apt/sources.list /etc/apt/sources.list.bak
echo "deb http://http.debian.net/debian/ stretch main" > \
/etc/apt/sources.list
echo "deb http://security.debian.org/ stretch/updates main" >> \
/etc/apt/sources.list
echo -e "$debsource" > /etc/apt/sources.list

# Old ubuntu does not support --add-architecture, so we directly change multiarch file
if [ -f /etc/dpkg/dpkg.cfg.d/multiarch ]; then
cp /etc/dpkg/dpkg.cfg.d/multiarch /etc/dpkg/dpkg.cfg.d/multiarch.bak
fi
dpkg --add-architecture $arch || echo "foreign-architecture $arch" > /etc/dpkg/dpkg.cfg.d/multiarch

# Add debian keys
apt-key adv --recv-key --keyserver keyserver.ubuntu.com EF0F382A1A7B6500
apt-key adv --recv-key --keyserver keyserver.ubuntu.com 9D6D8F6BC857C906
apt-key adv --recv-key --keyserver keyserver.ubuntu.com 8B48AD6246925553
apt-key adv --recv-key --keyserver keyserver.ubuntu.com 7638D0442B90D010
apt-key adv --recv-key --keyserver keyserver.ubuntu.com 8BC3A7D46F930576 # ports
apt-key adv --recv-key --keyserver keyserver.ubuntu.com CBF8D6FD518E17E1
apt-key adv --recv-key --keyserver keyserver.ubuntu.com 06AED62430CB581C
apt-get update

mkdir -p -m 777 /qemu/$arch
cd /qemu/$arch
apt-get -t stretch -d --no-install-recommends download \
apt-get -d --no-install-recommends download \
$deps \
busybox:$arch \
dropbear-bin:$arch \
$dropbear:$arch \
libc6:$arch \
libgcc1:$arch \
libssl1*:$arch \
$libssl:$arch \
libstdc++6:$arch \
linux-image-$kernel:$arch \
ncurses-base \
Expand All @@ -66,23 +126,30 @@ main() {

# Install packages
root=root-$arch
mkdir -p $root/{bin,etc/dropbear,root,sys,dev,proc,sbin,usr/{bin,sbin},var/log}
mkdir -p $root/{bin,etc/dropbear,root,sys,dev,proc,sbin,tmp,usr/{bin,sbin},var/log}
for deb in $arch/*deb; do
dpkg -x $deb $root/
done

# kernel
cp $root/boot/vmlinu* kernel
if [ "$arch" = "sparc64" ]; then
# boot fails if the kernel is compressed
zcat $root/boot/vmlinu* > kernel
else
cp $root/boot/vmlinu* kernel
fi

# initrd
mkdir -p $root/modules
cp \
$root/lib/modules/*/kernel/drivers/net/net_failover.ko \
$root/lib/modules/*/kernel/drivers/net/virtio_net.ko \
$root/lib/modules/*/kernel/drivers/virtio/* \
$root/lib/modules/*/kernel/fs/9p/9p.ko \
$root/lib/modules/*/kernel/fs/fscache/fscache.ko \
$root/lib/modules/*/kernel/net/9p/9pnet.ko \
$root/lib/modules/*/kernel/net/9p/9pnet_virtio.ko \
$root/lib/modules/*/kernel/net/core/failover.ko \
$root/modules || true # some file may not exist
rm -rf $root/boot
rm -rf $root/lib/modules
Expand Down Expand Up @@ -140,6 +207,8 @@ mkdir /dev/pts
mount -t devpts none /dev/pts/

# some archs does not have virtio modules
insmod /modules/failover.ko || true
insmod /modules/net_failover.ko || true
insmod /modules/virtio.ko || true
insmod /modules/virtio_ring.ko || true
insmod /modules/virtio_mmio.ko || true
Expand All @@ -155,7 +224,7 @@ ifconfig eth0 10.0.2.15
route add default gw 10.0.2.2 eth0

mkdir /target
mount -t 9p -o trans=virtio target /target -oversion=9p2000.L || true
mount -t 9p -o trans=virtio target /target -oversion=9p2000.u || true

exec dropbear -F -E -B
EOF
Expand Down
83 changes: 70 additions & 13 deletions docker/linux-runner
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,36 @@ fi
arch=$1
shift

# select qemu arch
qarch=$arch
case "$arch" in
armv7)
qarch="arm"
;;
i686)
qarch="i386"
;;
powerpc)
qarch="ppc"
;;
powerpc64)
qarch="ppc64"
;;
powerpc64le)
if [ "$CROSS_RUNNER" = "qemu-user" ]; then
qarch="ppc64le"
else
qarch="ppc64"
fi
;;
esac

case "$CROSS_RUNNER" in
native)
exec "${@}"
;;
qemu-user | "")
exec qemu-$arch "${@}"
exec qemu-$qarch "${@}"
;;
qemu-system)
true
Expand All @@ -30,26 +54,64 @@ case "$CROSS_RUNNER" in
;;
esac

# 8 is the max number of cpu supported by qemu-aarch64
n=$(nproc)
n=$(( n > 8 ? 8 : n ))
memory=1G
driver9p="virtio-9p-device"
drivernet="virtio-net-device"
driver9p="virtio-9p-pci"
drivernet="virtio-net-pci"

# select qemu parameters
case "$arch" in
aarch64)
# 8 is the max number of cpu supported by qemu-aarch64
n=$(( n > 8 ? 8 : n ))
opt="-machine virt -cpu cortex-a57"
;;
armv7)
opt="-machine virt"
driver9p="virtio-9p-device"
drivernet="virtio-net-device"
;;
i686)
opt="-append console=ttyS0"
;;
mips|mipsel)
# avoid kernel error
# https://blahcat.github.io/2017/07/14/building-a-debian-stretch-qemu-image-for-mipsel/
opt="-append nokaslr"
n=1
;;
mips64el)
# avoid kernel error
# https://blahcat.github.io/2017/07/14/building-a-debian-stretch-qemu-image-for-mipsel/
opt="-append nokaslr -cpu MIPS64R2-generic"
n=1
;;
powerpc)
opt="-append console=ttyPZ0"
n=1
;;
powerpc64|powerpc64le)
opt="-append console=hvc0 --nodefaults -serial stdio"
;;
s390x)
n=1
driver9p="virtio-9p-ccw"
drivernet="virtio-net-ccw"
;;
sparc64)
n=1
;;
x86_64)
opt="-append console=ttyS0"
;;
esac

(
flock -n 200 || exit 0

echo Booting QEMU virtual machine with $n cpus...

QEMU_CMD="qemu-system-$arch \
QEMU_CMD="qemu-system-$qarch \
-m $memory \
-smp $n \
-nographic \
Expand Down Expand Up @@ -88,13 +150,8 @@ esac
fi
fi

echo Booted in $(dbclient -K 1 -p 10022 -y -y root@localhost "cut -d' ' -f1 /proc/uptime") seconds
echo Booted in $SECONDS seconds

) 200>$LOCK

dbclient \
-t \
-p 10022 \
-y -y \
root@localhost \
"${@}"
exec dbclient -t -p 10022 -y -y root@localhost "${@}"
Loading