public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server 1/2] fix #6680: avoid setting nonexistent 'write-cache' option for scsi-{block, generic}
Date: Wed, 13 Aug 2025 10:58:36 +0200	[thread overview]
Message-ID: <20250813085845.25516-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250813085845.25516-1-f.ebner@proxmox.com>

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 <f.ebner@proxmox.com>
---
 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;
+        } else {
+            $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


  reply	other threads:[~2025-08-13  8:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13  8:58 [pve-devel] [PATCH-SERIES qemu-server 0/2] fix scsi-{block, generic} with blockdev regressions Fiona Ebner
2025-08-13  8:58 ` Fiona Ebner [this message]
2025-08-13 10:08   ` [pve-devel] [PATCH qemu-server 1/2] fix #6680: avoid setting nonexistent 'write-cache' option for scsi-{block, generic} Fabian Grünbichler
2025-08-13 10:35     ` Fiona Ebner
2025-08-13  8:58 ` [pve-devel] [PATCH qemu-server 2/2] drive device: scsi: avoid setting nonexistent 'device_id' " Fiona Ebner
2025-08-13 14:14 ` [pve-devel] applied: [PATCH-SERIES qemu-server 0/2] fix scsi-{block, generic} with blockdev regressions Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250813085845.25516-2-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal