|
| 1 | +#!/bin/bash -xe |
| 2 | + |
| 3 | +cd $(dirname "$0") |
| 4 | + |
| 5 | +libvirtd --daemon |
| 6 | +virtlogd --daemon |
| 7 | +export LIBGUESTFS_BACKEND=direct |
| 8 | + |
| 9 | +mkdir -p test-data/ |
| 10 | +pushd test-data |
| 11 | + IMAGE=Fedora-Cloud-Base-38-1.6.x86_64.qcow2 |
| 12 | + test -e "$IMAGE" || wget --quiet "https://download.fedoraproject.org/pub/fedora/linux/releases/38/Cloud/x86_64/images/$IMAGE" -O "$IMAGE" |
| 13 | + qemu-img create -f qcow2 -F qcow2 -b "$PWD/$IMAGE" fedora-overlay.qcow2 |
| 14 | + |
| 15 | + test -e test-key-id_rsa || ssh-keygen -N "" -f test-key-id_rsa |
| 16 | + |
| 17 | + virt-sysprep -a fedora-overlay.qcow2 \ |
| 18 | + --ssh-inject root:file:test-key-id_rsa.pub |
| 19 | + |
| 20 | + fallocate -l 5GiB big-image.img |
| 21 | +popd |
| 22 | + |
| 23 | +SSH_OPTS="-i test-data/test-key-id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o User=root -o Port=2222" |
| 24 | + |
| 25 | +vhost-device-scsi --socket-path /tmp/vhost-user-scsi.sock test-data/big-image.img & |
| 26 | + |
| 27 | +sleep 1 |
| 28 | + |
| 29 | +qemu-system-x86_64 \ |
| 30 | + -enable-kvm -cpu host \ |
| 31 | + -device virtio-net-pci,netdev=net0,mac=52:54:00:12:35:02\ |
| 32 | + -netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::2323-:23 \ |
| 33 | + -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 \ |
| 34 | + -hda test-data/fedora-overlay.qcow2 \ |
| 35 | + -object memory-backend-memfd,id=mem,size=8192M,share=on \ |
| 36 | + -numa node,memdev=mem \ |
| 37 | + -device vhost-user-scsi-pci,num_queues=1,param_change=off,chardev=vus \ |
| 38 | + -chardev socket,id=vus,path=/tmp/vhost-user-scsi.sock \ |
| 39 | + -smp 4 -m 8192 \ |
| 40 | + -serial mon:stdio \ |
| 41 | + -display none & |
| 42 | + |
| 43 | + |
| 44 | +while ! ssh $SSH_OPTS localhost echo waiting for guest to come online |
| 45 | +do |
| 46 | + sleep 1 |
| 47 | +done |
| 48 | + |
| 49 | + |
| 50 | +scp $SSH_OPTS test-script.sh localhost:~/ |
| 51 | +ssh $SSH_OPTS localhost /root/test-script.sh || echo "tests failed" |
| 52 | + |
| 53 | +export RESULT_DIR="$PWD/results/$(date --rfc-3339=s)" |
| 54 | +mkdir -p "$RESULT_DIR" |
| 55 | + |
| 56 | +scp $SSH_OPTS -r localhost:/root/blktests/results/ "$RESULT_DIR/" |
| 57 | +ssh $SSH_OPTS localhost poweroff |
| 58 | + |
| 59 | +wait # wait for qemu to terminate |
| 60 | + |
0 commit comments