Disk pool volumes should be always attached as "raw" disks

Usually, when storage volume is attached as a disk and disk xml is filled with
default values, the "<driver type=...>" value is copied from volume's
"<format type=...>".  This makes sense for volumes of storage pool of type
"dir", where format types include "raw, qcow2...".

However, the same approach cannot be used for the storage pool of type "disk".
In that case, format types include "none, linux, fat16, fat32...". Such formats
cannot be used for disk's "<driver type=...>".

Therefore, when generating disk XML for volume of storage pool type "disk",
driver type should always be "raw".
This commit is contained in:
Simon Kobyda 2021-10-08 11:43:49 +02:00 committed by Cole Robinson
parent 59e24f6bb9
commit 2676640979
2 changed files with 7 additions and 4 deletions

View File

@ -1,5 +1,5 @@
<disk type="volume" device="disk">
<driver name="qemu" type="none"/>
<driver name="qemu" type="raw"/>
<source volume="sdfg1" pool="pool-disk"/>
<target dev="vdag" bus="virtio"/>
</disk>

View File

@ -787,9 +787,12 @@ class StorageBackend(_StorageBase):
def get_driver_type(self):
if self._vol_object:
ret = self.get_vol_xml().format
if ret != "unknown":
return ret
if self.get_parent_pool_xml().type != "disk":
ret = self.get_vol_xml().format
if ret != "unknown":
return ret
else:
return "raw"
return None
def validate(self):