]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: domain: Use 'raw' for 'volume' disks without format
authorPeter Krempa <pkrempa@redhat.com>
Thu, 31 Jan 2019 14:37:53 +0000 (15:37 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 4 Feb 2019 12:42:11 +0000 (13:42 +0100)
Storage pools might want to specify format of the image when translating
the volume thus we can't add any default format when parsing the XML.

Add a explicit format when starting the VM and format is not present
neither by user specifying it nor by the storage pool translation
function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain.c
tests/qemuxml2argvdata/disk-source-pool-mode.args
tests/qemuxml2argvdata/disk-source-pool.args

index 25dc4412c0efb2b74272b3cc8b70db02d013e537..e2b0bd87b46ee3c6dd14fe169155f165fe7ad998 100644 (file)
@@ -13714,6 +13714,11 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
 {
     qemuDomainPrepareDiskCachemode(disk);
 
+    /* add raw file format if the storage pool did not fill it in */
+    if (disk->src->type == VIR_STORAGE_TYPE_VOLUME &&
+        disk->src->format <= VIR_STORAGE_FILE_NONE)
+        disk->src->format = VIR_STORAGE_FILE_RAW;
+
     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
         if (qemuDomainPrepareDiskSourceBlockdev(disk, priv, cfg) < 0)
             return -1;
index e8d9aacd7757cda883b9236035848c2b38a2b927..930d360d16ef17458ccb9e262805e16b4678a074 100644 (file)
@@ -21,16 +21,16 @@ server,nowait \
 -no-shutdown \
 -no-acpi \
 -usb \
--drive file=/some/block/device/unit:0:0:1,if=none,id=drive-ide0-0-1,\
+-drive file=/some/block/device/unit:0:0:1,format=raw,if=none,id=drive-ide0-0-1,\
 media=cdrom,readonly=on \
 -device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
--drive file=iscsi://iscsi.example.com:3260/demo-target/2,if=none,\
+-drive file=iscsi://iscsi.example.com:3260/demo-target/2,format=raw,if=none,\
 id=drive-ide0-0-2,media=cdrom,readonly=on \
 -device ide-drive,bus=ide.0,unit=2,drive=drive-ide0-0-2,id=ide0-0-2 \
 -drive file=/tmp/idedisk.img,format=raw,if=none,id=drive-ide0-0-3 \
 -device ide-drive,bus=ide.0,unit=3,drive=drive-ide0-0-3,id=ide0-0-3,\
 bootindex=1 \
--drive file=iscsi://iscsi.example.com:3260/demo-target/3,if=none,\
+-drive file=iscsi://iscsi.example.com:3260/demo-target/3,format=raw,if=none,\
 id=drive-ide0-0-4,media=cdrom,readonly=on \
 -device ide-drive,bus=ide.0,unit=4,drive=drive-ide0-0-4,id=ide0-0-4 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
index 49dc853bcd5affca5d454b4ffb6603795d7c8d38..fe95aa2250c918f534aa0d10ddd2b6608ff5dc6b 100644 (file)
@@ -21,8 +21,8 @@ server,nowait \
 -no-shutdown \
 -no-acpi \
 -usb \
--drive file=/some/block/device/cdrom,if=none,id=drive-ide0-0-1,media=cdrom,\
-readonly=on \
+-drive file=/some/block/device/cdrom,format=raw,if=none,id=drive-ide0-0-1,\
+media=cdrom,readonly=on \
 -device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
 -drive if=none,id=drive-ide0-1-0,media=cdrom,readonly=on \
 -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \