From d073cf3c16297bbf86d9e49f57f9c7b78023ad26 Mon Sep 17 00:00:00 2001 From: Tim Serong Date: Wed, 20 Mar 2024 18:12:47 +1100 Subject: [PATCH] Set bus and disk type correctly when creating VMs from ISO images The onImageChange() function in edit/kubevirt.io.virtualmachine/VirtualMachineVolume/type/vmImage.vue includes logic to set type="cd-rom" and bus="sata" when you select an ISO image as the source for a volume. This commit applies the same logic when initially creating a VM from a given image. Signed-off-by: Tim Serong (cherry picked from commit db0a588b9498fd337b424525df05010d9729be80) --- pkg/harvester/mixins/harvester-vm/index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/harvester/mixins/harvester-vm/index.js b/pkg/harvester/mixins/harvester-vm/index.js index ea31a5a3213..380ca00d767 100644 --- a/pkg/harvester/mixins/harvester-vm/index.js +++ b/pkg/harvester/mixins/harvester-vm/index.js @@ -412,15 +412,25 @@ export default { let out = []; if (_disks.length === 0) { + let bus = 'virtio'; + let type = HARD_DISK; + + const imageResource = this.images.find( I => this.imageId === I.id); + + if (/iso$/i.test(imageResource?.imageSuffix)) { + bus = 'sata'; + type = CD_ROM; + } + out.push({ id: randomStr(5), source: SOURCE_TYPE.IMAGE, name: 'disk-0', accessMode: 'ReadWriteMany', - bus: 'virtio', + bus, volumeName: '', size: '10Gi', - type: HARD_DISK, + type, storageClassName: '', image: this.imageId, volumeMode: 'Block',