Skip to content

Commit

Permalink
test/storage: VM root volume attachments
Browse files Browse the repository at this point in the history
This just validates the attachment logic and the config keys that protect
VM root volumes from concurrent access. I will add more tests in lxd-ci
to test that the volumes actually attach and are usable in the VMs.

Signed-off-by: Wesley Hershberger <[email protected]>
  • Loading branch information
MggMuggins committed Nov 27, 2024
1 parent 13a1fc1 commit 9c291a0
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/suites/storage_volume_attach.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,48 @@ EOF
lxc delete -f c1
lxc delete -f c2
lxc storage volume delete "${pool}" testvolume

# attach VM root volumes
lxc init --empty --vm vm1
lxc init --empty --vm vm2
lxc init --empty --vm vm3

# Requires either security.shared or security.protection.start
! lxc storage volume attach "${pool}" virtual-machine/vm1 vm2 || false

lxc config set vm1 security.protection.start=true

# security.protection.start on the VM allows exactly one other attachment
lxc storage volume attach "${pool}" virtual-machine/vm1 vm2
! lxc storage volume attach "${pool}" virtual-machine/vm1 vm3 || false

# Deleting the instance will fail while it's root volume is in use
! lxc delete vm1 || false

# Make sure used_by is calculated correctly
lxc storage volume show "${pool}" virtual-machine/vm1 | grep -q '/1.0/instances/vm2'

# Can't unset security.protection.start when vm1's root volume is attached elsewhere
! lxc config unset vm1 security.protection.start || false

lxc storage volume set "${pool}" virtual-machine/vm1 security.shared=true

# security.shared allows many attachments
lxc storage volume attach "${pool}" virtual-machine/vm1 vm3

lxc storage volume show "${pool}" virtual-machine/vm1 | grep -q '/1.0/instances/vm2'
lxc storage volume show "${pool}" virtual-machine/vm1 | grep -q '/1.0/instances/vm3'

lxc config unset vm1 security.protection.start

# Can't unset security.shared when vm1's root volume is attached elsewhere
! lxc storage volume unset "${pool}" virtual-machine/vm1 security.shared

lxc storage volume detach "${pool}" virtual-machine/vm1 vm2
lxc storage volume detach "${pool}" virtual-machine/vm1 vm3

lxc storage volume unset "${pool}" virtual-machine/vm1 security.shared

lxc delete -f vm1
lxc delete -f vm2
}

0 comments on commit 9c291a0

Please sign in to comment.