From 7d5b283065e484645b6116397ac55b068396c430 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 25 Jun 2019 15:23:56 +0200 Subject: [PATCH] qemu: Supply correct default type for 'dir' based VIR_STORAGE_TYPE_VOLUME MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Our code would skip adding the default type in this cases, but since we know that the only reasonable option here is 'fat' we can add it while starting the VM. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_domain.c | 12 +++++++++--- tests/qemuxml2argvdata/disk-source-pool.args | 4 ++++ tests/qemuxml2argvdata/disk-source-pool.xml | 6 ++++++ tests/qemuxml2xmloutdata/disk-source-pool.xml | 7 +++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5b72b7f7bf..d71d9b3273 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -14217,10 +14217,16 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk, { qemuDomainPrepareDiskCachemode(disk); - /* add raw file format if the storage pool did not fill it in */ + /* set default format for storage pool based disks */ if (disk->src->type == VIR_STORAGE_TYPE_VOLUME && - disk->src->format <= VIR_STORAGE_FILE_NONE) - disk->src->format = VIR_STORAGE_FILE_RAW; + disk->src->format <= VIR_STORAGE_FILE_NONE) { + int actualType = virStorageSourceGetActualType(disk->src); + + if (actualType == VIR_STORAGE_TYPE_DIR) + disk->src->format = VIR_STORAGE_FILE_FAT; + else + disk->src->format = VIR_STORAGE_FILE_RAW; + } if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) { if (qemuDomainPrepareDiskSourceBlockdev(disk, priv, cfg) < 0) diff --git a/tests/qemuxml2argvdata/disk-source-pool.args b/tests/qemuxml2argvdata/disk-source-pool.args index 65565fe49e..7c05599822 100644 --- a/tests/qemuxml2argvdata/disk-source-pool.args +++ b/tests/qemuxml2argvdata/disk-source-pool.args @@ -36,4 +36,8 @@ readonly=on \ readonly=on \ -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\ id=virtio-disk0 \ +-drive file=fat:/some/dir/device/vol2,if=none,id=drive-virtio-disk1,\ +readonly=on \ +-device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk1,\ +id=virtio-disk1 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/disk-source-pool.xml b/tests/qemuxml2argvdata/disk-source-pool.xml index 96bcae9a57..31b148b4bb 100644 --- a/tests/qemuxml2argvdata/disk-source-pool.xml +++ b/tests/qemuxml2argvdata/disk-source-pool.xml @@ -43,6 +43,12 @@ + + + + + + diff --git a/tests/qemuxml2xmloutdata/disk-source-pool.xml b/tests/qemuxml2xmloutdata/disk-source-pool.xml index 7e3961381e..78e0449dfd 100644 --- a/tests/qemuxml2xmloutdata/disk-source-pool.xml +++ b/tests/qemuxml2xmloutdata/disk-source-pool.xml @@ -44,6 +44,13 @@
+ + + + + +
+
-- 2.47.2