From 319e1126fc09b4b1d1a8dbc0e6911e5122a2cd18 Mon Sep 17 00:00:00 2001 From: Simon Deziel Date: Thu, 26 Sep 2024 17:01:10 -0400 Subject: [PATCH] tests/storage-vm: test config disk when ZFS is in block mode Signed-off-by: Simon Deziel --- tests/storage-vm | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/tests/storage-vm b/tests/storage-vm index 5549de50..66151f02 100755 --- a/tests/storage-vm +++ b/tests/storage-vm @@ -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}" @@ -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"