Handle nil volumes when cd-rom attached (#1273)

When a cd-rom is attached as an additional storage, listing the volumes
can include a nil element. Make sure to check that the element is valid
before attempting to access the attribute.

Update the test to better match the observed behaviour.

Fixes: #1209, #1262
This commit is contained in:
Darragh Bailey
2021-05-08 17:27:04 +01:00
committed by GitHub
parent fbf32889d7
commit 86cf4e08a7
2 changed files with 2 additions and 2 deletions

View File

@@ -70,7 +70,7 @@ module VagrantPlugins
# remove root storage
root_disk = domain.volumes.select do |x|
x.name == libvirt_domain.name + '.img'
x.name == libvirt_domain.name + '.img' if x
end.first
root_disk.destroy if root_disk
end