[BUG] 3006: virt: Externally managed LVM volumes no longer work (libvirt 8+, qemu 6.2+) #67950
Open
1 of 9 tasks
Labels
Bug
broken, incorrect, or confusing behavior
Description
For manually maintained
virt
VM disks (ie, not in apool
), ifsource_file
is given to define the disk storage, thensalt/modules/virt.py
_gen_xml
forces the libvirt disk type to befile
.Before
libvirt
8 /qemu
6.2 (eg, as present on Ubuntu 20.04 LTS and earlier), having a LVM logical volume that was referred to as typefile
was supported, and worked with saltstack before 3002, and since saltstack 3004 (saltstack 3002 introduced an attempt to turn thesource_file
into a file if it was not a file, which was fixed in 3003 -- backstory in #53081 (comment) and an example in #60296).Since
libvirt
8 /qemu
6.2 (eg as present on Ubuntu 22.04 LTS and later), referring to a LVM logical volume disk as typefile
is rejected:which means the VM fails to define/start.
That
libvirt
8 /qemu
6.2 issue can be avoided by changing the type toblock
(and thesource file=
tosource dev=
).Salt 3006 has the necessary XML templating code to support this generating the right XML when
type = 'block'
is set:salt/salt/templates/virt/libvirt_domain.jinja
Lines 244 to 263 in 21e99f6
but
salt/modules/virt.py
_gen_xml()
forcestype = 'file'
any timesource_file
is defined, no matter what the filename is:salt/salt/modules/virt.py
Lines 1063 to 1067 in 21e99f6
which means there is no way to pass in the required
type = 'block'
from the disk defintion.And even if the disk type is manually changed in the libvirt definition (eg, via
virsh
the saltvirt.py
is overriding it back totype = 'file'
, which rewrites the libvirl XML and breaks the VM definition.Setup
The salt master is a VM. The relevant salt miniion is an Ubuntu 22.04 LTS VM (upgraded from Ubuntu 20.04 LTS earlier this month, due to the end of support of Ubuntu 20.04 LTS approaching very soon). The salt minion is a VM host, with libvirt / qemu, managed by salt.
Steps to Reproduce the behavior
Define a LVM volume group (perhaps backed by a temporarily created file as the physical volume). Define a logical volume on that volume group. Make sure libvirt / qemu are installed on the target. (See, eg, #60296 for a simple example of that.)
Define a
hardcoded
disk type (to avoid the deafultqcow2
disk being injected into the VM with manually managed storage (eg in a pillar):Then use
virt.running
to define a VM disk a disk that refers to the LVM logical volume created above, eg:Attempt to get salt to define that VM (eg,
highstate
), and observe that the type will be set tofile
, which will not work.Expected behavior
It should be possible to override the default
type = 'file'
by specifying thetype: block
in the salt disk definition, so the user can override the defaulttype: file
that is being set (whensource_file
is set, or by default). Eg,and that should override the default
salt/modules/virt.py
type = 'file'
setting.This can be achieved with a trivial code change in
salt/modules/virt.py
in_gen_xml()
to look for a user suppliedtype
override:Alternatively if the
source_file
starts with/dev
then it could be automatically treated as ablock
type.(For now I'm not attempting to make this a PR, as I'm unsure if y'all want it to be a documented disk parameter, just an "if you know, it works" parameter, or magically autodetect based on
disk['source_file'].startswith('/dev')
.Screenshots
N/A.
Versions Report
salt --versions-report
salt-master:
The relevant minion is the same, but on Ubuntu 22.04 LTS.
Additional context
N/A.
The text was updated successfully, but these errors were encountered: