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>
---
 PVE/QemuServer.pm | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 90d07cee..e5f8a607 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1322,7 +1322,13 @@ 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, 
$machine_type);
-       $device = 
"virtio-blk-pci,drive=drive-$drive_id,id=${drive_id}${pciaddr}";
+       $device = 'virtio-blk-pci';
+       if (min_version($machine_version, 10, 0)) { # there is no blockdev for 
'none'
+           $device .= ",drive=drive-$drive_id" if $drive->{file} ne 'none';
+           $device .= ",id=${drive_id}${pciaddr}";
+       } else {
+           $device .= ",drive=drive-$drive_id,id=${drive_id}${pciaddr}";
+       }
        $device .= ",iothread=iothread-$drive_id" if $drive->{iothread};
     } elsif ($drive->{interface} eq 'scsi') {
 
@@ -1338,7 +1344,12 @@ 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";
+       if (min_version($machine_version, 10, 0)) { # there is no blockdev for 
'none'
+           $device .= ",drive=drive-$drive_id" if $drive->{file} ne 'none';
+           $device .= ",id=$drive_id";
+       } else {
+           $device .= ",drive=drive-$drive_id,id=$drive_id";
+       }
 
        if ($drive->{ssd} && ($device_type eq 'block' || $device_type eq 'hd')) 
{
            $device .= ",rotation_rate=1";
@@ -1378,7 +1389,12 @@ 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)) { # there is no blockdev for 
'none'
+           $device .= ",drive=drive-$drive_id" if $drive->{file} ne 'none';
+           $device .= ",id=$drive_id";
+       } else {
+           $device .= ",drive=drive-$drive_id,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

Reply via email to