From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 163291FF183 for ; Wed, 13 Aug 2025 12:07:31 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EDCA6307BD; Wed, 13 Aug 2025 12:09:08 +0200 (CEST) Date: Wed, 13 Aug 2025 12:08:31 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20250813085845.25516-1-f.ebner@proxmox.com> <20250813085845.25516-2-f.ebner@proxmox.com> In-Reply-To: <20250813085845.25516-2-f.ebner@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.17.0 (https://github.com/astroidmail/astroid) Message-Id: <1755079639.qwkpi5tsex.astroid@yuna.none> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1755079683222 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.049 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: Re: [pve-devel] [PATCH qemu-server 1/2] fix #6680: avoid setting nonexistent 'write-cache' option for scsi-{block, generic} X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" On August 13, 2025 10:58 am, Fiona Ebner wrote: > Only scsi-cd and scsi-hd have a 'write-cache' option, scsi-block and > scsi-generic do not. > > Setting the 'cache' setting on such a drive in the VM configuration is > still valid and should not be prohibited, because it affects the > blockdev settings. > > Signed-off-by: Fiona Ebner > --- > src/PVE/QemuServer.pm | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm > index d40b14de..99d4da4f 100644 > --- a/src/PVE/QemuServer.pm > +++ b/src/PVE/QemuServer.pm > @@ -1203,6 +1203,7 @@ sub print_drivedevice_full { > my $maxdev = 0; > > my $machine_version = extract_version($machine_type, kvm_user_version()); > + my $has_write_cache = 1; # whether the device has a 'write-cache' option > > my $drive_id = PVE::QemuServer::Drive::get_drive_id($drive); > if ($drive->{interface} eq 'virtio') { > @@ -1244,7 +1245,8 @@ sub print_drivedevice_full { > } > $device .= ",wwn=$drive->{wwn}" if $drive->{wwn}; > > - # only scsi-hd and scsi-cd support passing vendor and product information > + # only scsi-hd and scsi-cd support passing vendor and product information and have a > + # 'write-cache' option > if ($device_type eq 'hd' || $device_type eq 'cd') { > if (my $vendor = $drive->{vendor}) { > $device .= ",vendor=$vendor"; > @@ -1252,6 +1254,10 @@ sub print_drivedevice_full { > if (my $product = $drive->{product}) { > $device .= ",product=$product"; > } > + > + $has_write_cache = 1; nit: this already is the default initial value above, and we don't loop over devices here? so we could drop this and the comment above > + } else { and instead add a comment here that -block and -generic don't support this? > + $has_write_cache = 0; > } > > } elsif ($drive->{interface} eq 'ide' || $drive->{interface} eq 'sata') { > @@ -1316,7 +1322,7 @@ sub print_drivedevice_full { > } > > if (min_version($machine_version, 10, 0)) { # for the switch to -blockdev > - if (!drive_is_cdrom($drive)) { > + if (!drive_is_cdrom($drive) && $has_write_cache) { > my $write_cache = 'on'; > if (my $cache = $drive->{cache}) { > $write_cache = 'off' if $cache eq 'writethrough' || $cache eq 'directsync'; > -- > 2.47.2 > > > > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel > > > _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel