[PATCH 3/3] qemu: domain: Treat 'volume' disks as 'raw' if neiter user nor pool provided format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c                            | 5 +++++
 tests/qemuxml2argvdata/disk-source-pool-mode.args | 6 +++---
 tests/qemuxml2argvdata/disk-source-pool.args      | 4 ++--
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 20ce9330e5..7677b2d3c0 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -13688,6 +13688,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;
diff --git a/tests/qemuxml2argvdata/disk-source-pool-mode.args b/tests/qemuxml2argvdata/disk-source-pool-mode.args
index e8d9aacd77..930d360d16 100644
--- a/tests/qemuxml2argvdata/disk-source-pool-mode.args
+++ b/tests/qemuxml2argvdata/disk-source-pool-mode.args
@@ -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
diff --git a/tests/qemuxml2argvdata/disk-source-pool.args b/tests/qemuxml2argvdata/disk-source-pool.args
index 49dc853bcd..fe95aa2250 100644
--- a/tests/qemuxml2argvdata/disk-source-pool.args
+++ b/tests/qemuxml2argvdata/disk-source-pool.args
@@ -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 \
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux