Switch to drive snapshots

This commit is contained in:
Lauri Võsandi 2021-05-30 11:03:43 +00:00
parent 20f6f6eedb
commit 1d0da378fc
3 changed files with 5 additions and 16 deletions

View File

@ -2,8 +2,8 @@
Dockerized QEMU image for reproducibly testing stuff on Windows. Dockerized QEMU image for reproducibly testing stuff on Windows.
Prepare OS image as described below. Prepare OS image as described below.
If OS image is mounted to the Docker container as read-only Disk image is used as read-only using the QEMU disk snapshot option,
it is first copied during Docker container launch. all local changes are lost after Docker container restart.
Specify MAC address via environment variable `MAC`. Specify MAC address via environment variable `MAC`.
For more example see `docker-compose.yml` For more example see `docker-compose.yml`
You probably need the machines to come up with You probably need the machines to come up with

View File

@ -15,4 +15,4 @@ services:
tmpfs: tmpfs:
- /tmp - /tmp
environment: environment:
- MAC=52:54:00:5e:00:05 - MAC=52:54:00:12:34:56

View File

@ -2,16 +2,6 @@
set -x set -x
set -e set -e
# Source image path
IMAGE=/data/image.bin
# TODO: With QEMU snapshots instead
if [ ! -w $IMAGE ]; then
echo "Data volume is not writable, assuming discardable VM and copying to tmpfs"
cp $IMAGE /tmp/image.bin
IMAGE=/tmp/image.bin
fi
# Create macvlan interface on Docker's eth0 # Create macvlan interface on Docker's eth0
ip link add link eth0 name macvtap0 type macvtap mode bridge ip link add link eth0 name macvtap0 type macvtap mode bridge
ip link set dev macvtap0 address ${MAC:?} ip link set dev macvtap0 address ${MAC:?}
@ -26,11 +16,10 @@ mknod "/dev/tap$(cat /sys/class/net/macvtap0/ifindex)" c $major $minor
-machine pc-i440fx-4.2,accel=kvm \ -machine pc-i440fx-4.2,accel=kvm \
-m 8192 \ -m 8192 \
-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x6 \ -device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x6 \
-blockdev "{\"driver\":\"file\",\"filename\":\"$IMAGE\",\"node-name\":\"libvirt-1-storage\",\"auto-read-only\":true,\"discard\":\"unmap\"}" \
-blockdev "{\"node-name\":\"libvirt-1-format\",\"read-only\":false,\"driver\":\"raw\",\"file\":\"libvirt-1-storage\"}" \
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,device_id=drive-scsi0-0-0-0,drive=libvirt-1-format,id=scsi0-0-0-0,bootindex=2 \
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=$(cat /sys/class/net/macvtap0/address) \ -device virtio-net-pci,netdev=hostnet0,id=net0,mac=$(cat /sys/class/net/macvtap0/address) \
-device virtio-balloon-pci \ -device virtio-balloon-pci \
-drive if=none,id=hd,file=/data/image.bin,snapshot=on,format=raw \
-device scsi-hd,drive=hd \
-usb \ -usb \
-device usb-ehci,id=ehci \ -device usb-ehci,id=ehci \
-device usb-tablet,bus=usb-bus.0 \ -device usb-tablet,bus=usb-bus.0 \