There will be no block node for 'none' after switching to '-blockdev'. Co-developed-by: Alexandre Derumier <alexandre.derum...@groupe-cyllene.com> [FE: split out from larger patch do it also for non-SCSI cases] Signed-off-by: Fiona Ebner <f.eb...@proxmox.com> ---
Changes in v2: * Shorten code using better conditional. * Comment that the version guard is for the switch to -blockdev. src/PVE/QemuServer.pm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm index b9bc6b53..4eccfb62 100644 --- a/src/PVE/QemuServer.pm +++ b/src/PVE/QemuServer.pm @@ -1408,7 +1408,12 @@ sub print_drivedevice_full { my $drive_id = PVE::QemuServer::Drive::get_drive_id($drive); if ($drive->{interface} eq 'virtio') { my $pciaddr = print_pci_addr("$drive_id", $bridges, $arch); - $device = "virtio-blk-pci,drive=drive-$drive_id,id=${drive_id}${pciaddr}"; + $device = 'virtio-blk-pci'; + # for the switch to -blockdev, there is no blockdev for 'none' + if (!min_version($machine_version, 10, 0) || $drive->{file} ne 'none') { + $device .= ",drive=drive-$drive_id"; + } + $device .= ",id=${drive_id}${pciaddr}"; $device .= ",iothread=iothread-$drive_id" if $drive->{iothread}; } elsif ($drive->{interface} eq 'scsi') { @@ -1424,7 +1429,11 @@ sub print_drivedevice_full { $device = "scsi-$device_type,bus=$controller_prefix$controller.0,channel=0,scsi-id=0" . ",lun=$drive->{index}"; } - $device .= ",drive=drive-$drive_id,id=$drive_id"; + # for the switch to -blockdev, there is no blockdev for 'none' + if (!min_version($machine_version, 10, 0) || $drive->{file} ne 'none') { + $device .= ",drive=drive-$drive_id"; + } + $device .= ",id=$drive_id"; if ($drive->{ssd} && ($device_type eq 'block' || $device_type eq 'hd')) { $device .= ",rotation_rate=1"; @@ -1464,7 +1473,10 @@ sub print_drivedevice_full { } else { $device .= ",bus=ahci$controller.$unit"; } - $device .= ",drive=drive-$drive_id,id=$drive_id"; + if (!min_version($machine_version, 10, 0) || $drive->{file} ne 'none') { + $device .= ",drive=drive-$drive_id"; + } + $device .= ",id=$drive_id"; if ($device_type eq 'hd') { if (my $model = $drive->{model}) { -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel