diff --git a/ci/docker/x86_64-unknown-freebsd/Dockerfile b/ci/docker/x86_64-unknown-freebsd/Dockerfile
index bffcaa0ced30bc232ebd1809d4b7958ff10577e9..23135e8d86802535fabde897a4b5ec73c952ab88 100644
--- a/ci/docker/x86_64-unknown-freebsd/Dockerfile
+++ b/ci/docker/x86_64-unknown-freebsd/Dockerfile
@@ -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
diff --git a/ci/run.sh b/ci/run.sh
index 4e04ddddce210ff0d7b33a104c79c561e3def62f..a4e7117765dc1a314bef4b4d6247cd50dbb0672b 100755
--- a/ci/run.sh
+++ b/ci/run.sh
@@ -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 \