Skip to content

Commit

Permalink
tests/storage-vm: test config disk when ZFS is in block mode
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Deziel <[email protected]>
  • Loading branch information
simondeziel committed Sep 27, 2024
1 parent fb1f9ac commit 319e112
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions tests/storage-vm
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,13 @@ for poolDriver in $poolDriverList; do
lxc storage set "${poolName}" volume.size 16GiB
fi

if [ "${poolDriver}" = "lvm" ] || [ "${poolDriver}" = "lvm-thin" ] || [ "${poolDriver}" = "ceph" ] || [ "${poolDriver}" = "powerflex" ]; then
if [ "${poolDriver}" = "lvm" ] || [ "${poolDriver}" = "lvm-thin" ] || [ "${poolDriver}" = "ceph" ] || [ "${poolDriver}" = "powerflex" ] || [ "${poolDriver}" = "zfs" ]; then
echo "==> Change volume.block.filesystem on pool and create VM"
lxc storage set "${poolName}" volume.block.filesystem xfs

if [ "${poolDriver}" = "zfs" ]; then
lxc storage set "${poolName}" volume.zfs.block_mode=true
fi
fi

lxc init "${IMAGE}" v1 --vm -s "${poolName}"
Expand All @@ -359,15 +363,30 @@ for poolDriver in $poolDriverList; do
[ "$(($(lxc exec v1 -- blockdev --getsize64 /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_lxd_root) / GiB))" -eq "16" ]
fi

if [ "${poolDriver}" = "lvm" ] || [ "${poolDriver}" = "lvm-thin" ] || [ "${poolDriver}" = "ceph" ] || [ "${poolDriver}" = "powerflex" ]; then
if [ "${poolDriver}" = "lvm" ] || [ "${poolDriver}" = "lvm-thin" ] || [ "${poolDriver}" = "ceph" ] || [ "${poolDriver}" = "powerflex" ] || [ "${poolDriver}" = "zfs" ]; then
echo "==> Ensure the VM volume ignores volume.block.filesystem"
[ "$(lxc storage volume get "${poolName}" virtual-machine/v1 block.filesystem)" = "ext4" ]
if [ "${poolDriver}" = "zfs" ]; then
# The VM config disk is not a zvol with ext4 on top but just a plain ZFS dataset so no block.filesystem is used
[ "$(lxc storage volume get "${poolName}" virtual-machine/v1 block.filesystem)" = "" ]
else
[ "$(lxc storage volume get "${poolName}" virtual-machine/v1 block.filesystem)" = "ext4" ]
fi

echo "==> Checking VM config disk filesystem is not XFS"
serverPID="$(lxc query /1.0 | jq .environment.server_pid)"
[ "$(nsenter -m -t "${serverPID}" findmnt --noheadings --output=FSTYPE --mountpoint /var/snap/lxd/common/lxd/devices/v1/config.mount)" = "ext4" ]
if [ "${poolDriver}" = "zfs" ]; then
# The VM config disk is not a zvol with ext4 on top but just a plain ZFS dataset
CONFIG_MOUNT_FS="zfs"
else
CONFIG_MOUNT_FS="ext4"
fi
[ "$(nsenter -m -t "${serverPID}" findmnt --noheadings --output=FSTYPE --mountpoint /var/snap/lxd/common/lxd/devices/v1/config.mount)" = "${CONFIG_MOUNT_FS}" ]

lxc storage unset "${poolName}" volume.block.filesystem

if [ "${poolDriver}" = "zfs" ]; then
lxc storage unset "${poolName}" volume.zfs.block_mode
fi
fi

echo "==> Deleting VM and reset pool volume.size"
Expand Down

0 comments on commit 319e112

Please sign in to comment.