Skip to content

Commit

Permalink
Merge pull request #208 from simondeziel/long-names-older-releases
Browse files Browse the repository at this point in the history
Use shorter dev names on older LXD releases
  • Loading branch information
tomponline authored Jun 26, 2024
2 parents 480d659 + 8083d6a commit 28aafc1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
31 changes: 23 additions & 8 deletions tests/storage-disks-vm
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,35 @@ lxc stop -f v1

# Check adding a disk to a vm with a long name (max 63) and slash to test possible problems with long socket paths or long qemu device tags
LONG_DEVICE_NAME="device-with-very-long-name-and-/-4-qemu-property-handling-test_"
# XXX: LXD releases 5.21 and earlier don't support long names (yet)
if echo "${LXD_SNAP_CHANNEL}" | grep -E '^([45]\.0|5\.21)/'; then
echo "::warning::${LXD_SNAP_CHANNEL} detected, using a shorter name"
LONG_DEVICE_NAME="notSoLongName"
fi

lxc init "${IMAGE}" v2 --vm
lxc config device add v2 "${LONG_DEVICE_NAME}" disk source="${testRoot}/allowed1" path="/mnt/bar1"
lxc start v2
waitInstanceReady v2
lxc exec v2 -- mountpoint /mnt/bar1
lxc config device remove v2 "${LONG_DEVICE_NAME}"
sleep 1
! lxc exec v2 -- mountpoint /mnt/bar1 || false # Just tests for mountpoint disconnected, not unmount.
lxc config device add v2 "${LONG_DEVICE_NAME}" disk source="${testRoot}/allowed1" path="/mnt/bar2" # Test hotplugging as well
lxc exec v2 -- mountpoint /mnt/bar2
lxc config device remove v2 "${LONG_DEVICE_NAME}"
sleep 1
! lxc exec v2 -- mountpoint /mnt/bar2 || false # Just tests for mountpoint disconnected, not unmount.
if [ "${LONG_DEVICE_NAME}" = "notSoLongName" ]; then
lxc stop -f v2
lxc config device remove v2 "${LONG_DEVICE_NAME}"
lxc start v2
waitInstanceReady v2
! lxc exec v2 -- mountpoint /mnt/bar2 || false # Make sure nothing is mounted
lxc config device add v2 "${LONG_DEVICE_NAME}" disk source="${testRoot}/allowed1" path="/mnt/bar2" # Test hotplugging as well
lxc exec v2 -- mountpoint /mnt/bar2
else
lxc config device remove v2 "${LONG_DEVICE_NAME}"
sleep 1
! lxc exec v2 -- mountpoint /mnt/bar1 || false # Just tests for mountpoint disconnected, not unmount.
lxc config device add v2 "${LONG_DEVICE_NAME}" disk source="${testRoot}/allowed1" path="/mnt/bar2" # Test hotplugging as well
lxc exec v2 -- mountpoint /mnt/bar2
lxc config device remove v2 "${LONG_DEVICE_NAME}"
sleep 1
! lxc exec v2 -- mountpoint /mnt/bar2 || false # Just tests for mountpoint disconnected, not unmount.
fi
lxc delete -f v2

# Check adding a disk with a source path that is allowed that symlinks to another allowed source path isn't
Expand Down
5 changes: 5 additions & 0 deletions tests/tpm-vm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ lxc stop "${vmName}" --force
# TPM names are included on the swtpm socket path and long socket paths can cause problems if not handled correctly.
echo "==> Test handling TPMs with long names"
longName="tpm-device-with-long-name-for-testing"
# XXX: LXD releases 5.21 and earlier don't support long names (yet)
if echo "${LXD_SNAP_CHANNEL}" | grep -E '^([45]\.0|5\.21)/'; then
echo "::warning::${LXD_SNAP_CHANNEL} detected, using a shorter name"
longName="notSoLongName"
fi
lxc config device add "${vmName}" "${longName}" tpm
lxc start "${vmName}"
waitInstanceReady "${vmName}"
Expand Down

0 comments on commit 28aafc1

Please sign in to comment.