From: Peter Krempa Date: Thu, 31 Jan 2019 14:37:53 +0000 (+0100) Subject: qemu: domain: Use 'raw' for 'volume' disks without format X-Git-Tag: v5.1.0-rc1~256 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bc3cca7bb43101730c94bc82762e5744420215a;p=thirdparty%2Flibvirt.git qemu: domain: Use 'raw' for 'volume' disks without format 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 Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 25dc4412c0..e2b0bd87b4 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -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; 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 \