extend QEMU image management

- allow QEMU name to have subdirectory inside (replace `/` by `__` in
  the filename)
- add a new code path for plain qcow2 image (for efficient bandwidth
  usage, the qcow2 is expected to use compressed qcow2 format)
- move freebsd image to explicitly download the gzipped QEMU
This commit is contained in:
Sébastien Marie 2016-09-08 06:36:05 +02:00
parent 958a3d02c9
commit 919939451f
2 changed files with 17 additions and 5 deletions

View File

@ -8,6 +8,6 @@ RUN apt-get install -y --no-install-recommends \
ENTRYPOINT ["sh"]
ENV PATH=$PATH:/rust/bin \
QEMU=freebsd.qcow2 \
QEMU=freebsd.qcow2.gz \
CAN_CROSS=1 \
CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd10-gcc

View File

@ -16,9 +16,21 @@ TARGET=$1
if [ "$QEMU" != "" ]; then
tmpdir=/tmp/qemu-img-creation
mkdir -p $tmpdir
if [ ! -f $tmpdir/$QEMU ]; then
curl https://people.mozilla.org/~acrichton/libc-test/qemu/$QEMU.gz | \
gunzip -d > $tmpdir/$QEMU
if [ -z "${QEMU#*.gz}" ]; then
# image is .gz : download and uncompress it
qemufile=$(echo ${QEMU%.gz} | sed 's/\//__/g')
if [ ! -f $tmpdir/$qemufile ]; then
curl https://people.mozilla.org/~acrichton/libc-test/qemu/$QEMU | \
gunzip -d > $tmpdir/$qemufile
fi
else
# plain qcow2 image: just download it
qemufile=$(echo ${QEMU} | sed 's/\//__/g')
if [ ! -f $tmpdir/$qemufile ]; then
curl https://people.mozilla.org/~acrichton/libc-test/qemu/$QEMU \
> $tmpdir/$qemufile
fi
fi
# Create a mount a fresh new filesystem image that we'll later pass to QEMU.
@ -80,7 +92,7 @@ if [ "$QEMU" != "" ]; then
$program \
-m 1024 \
-snapshot \
-drive if=virtio,file=$tmpdir/$QEMU \
-drive if=virtio,file=$tmpdir/$qemufile \
-drive if=virtio,file=$tmpdir/libc-test.img \
-net nic,model=virtio \
-net user \