From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 95FE61FF170
	for <inbox@lore.proxmox.com>; Thu, 12 Jun 2025 16:05:32 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 685911F8F0;
	Thu, 12 Jun 2025 16:03:39 +0200 (CEST)
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Thu, 12 Jun 2025 16:02:49 +0200
Message-Id: <20250612140253.106555-19-f.ebner@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250612140253.106555-1-f.ebner@proxmox.com>
References: <20250612140253.106555-1-f.ebner@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.032 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [PATCH qemu-server 18/22] print drive device: don't
 reference any drive for 'none' starting with machine version 10.0
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

There will be no block node for 'none' after switching to '-blockdev'.

Co-developed-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
[FE: split out from larger patch
     do it also for non-SCSI cases]
Signed-off-by: Fiona Ebner <f.ebner@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