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 v2 11/32] drive: introduce aio_cmdline_option() helper
Date: Wed, 18 Jun 2025 15:01:48 +0200	[thread overview]
Message-ID: <20250618130209.90649-12-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250618130209.90649-1-f.ebner@proxmox.com>

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

No changes in v2.

 src/PVE/QemuServer.pm         | 17 +++--------------
 src/PVE/QemuServer/Drive.pm   | 18 ++++++++++++++++++
 src/test/cfg2cmd/aio.conf.cmd | 16 ++++++++--------
 3 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index a3c37707..7bcc36db 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -1520,7 +1520,7 @@ sub print_drive_commandline_full {
     my $is_rbd = $path =~ m/^rbd:/;
 
     my $opts = '';
-    my @qemu_drive_options = qw(media cache rerror werror aio discard);
+    my @qemu_drive_options = qw(media cache rerror werror discard);
     foreach my $o (@qemu_drive_options) {
         $opts .= ",$o=$drive->{$o}" if defined($drive->{$o});
     }
@@ -1570,19 +1570,8 @@ sub print_drive_commandline_full {
 
     $opts .= ",cache=none" if !$drive->{cache} && $cache_direct;
 
-    if (!$drive->{aio}) {
-        if (storage_allows_io_uring_default($scfg, $cache_direct)) {
-            # io_uring supports all cache modes
-            $opts .= ",aio=io_uring";
-        } else {
-            # aio native works only with O_DIRECT
-            if ($cache_direct) {
-                $opts .= ",aio=native";
-            } else {
-                $opts .= ",aio=threads";
-            }
-        }
-    }
+    my $aio = PVE::QemuServer::Drive::aio_cmdline_option($scfg, $drive, $cache_direct);
+    $opts .= ",aio=$aio";
 
     die "$drive_id: explicit media parameter is required for iso images\n"
         if !defined($drive->{media}) && defined($vtype) && $vtype eq 'iso';
diff --git a/src/PVE/QemuServer/Drive.pm b/src/PVE/QemuServer/Drive.pm
index 377cf54e..73678ae2 100644
--- a/src/PVE/QemuServer/Drive.pm
+++ b/src/PVE/QemuServer/Drive.pm
@@ -1093,4 +1093,22 @@ sub drive_uses_cache_direct {
     return $cache_direct;
 }
 
+sub aio_cmdline_option {
+    my ($scfg, $drive, $cache_direct) = @_;
+
+    return $drive->{aio} if $drive->{aio};
+
+    if (storage_allows_io_uring_default($scfg, $cache_direct)) {
+        # io_uring supports all cache modes
+        return 'io_uring';
+    } else {
+        # aio native works only with O_DIRECT
+        if ($cache_direct) {
+            return 'native';
+        } else {
+            return 'threads';
+        }
+    }
+}
+
 1;
diff --git a/src/test/cfg2cmd/aio.conf.cmd b/src/test/cfg2cmd/aio.conf.cmd
index 851cb90b..9d29a34f 100644
--- a/src/test/cfg2cmd/aio.conf.cmd
+++ b/src/test/cfg2cmd/aio.conf.cmd
@@ -24,33 +24,33 @@
   -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3,free-page-reporting=on' \
   -iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \
   -device 'lsi,id=scsihw0,bus=pci.0,addr=0x5' \
-  -drive 'file=/var/lib/vz/images/8006/vm-8006-disk-0.raw,if=none,id=drive-scsi0,aio=threads,discard=on,format=raw,cache=none,detect-zeroes=unmap' \
+  -drive 'file=/var/lib/vz/images/8006/vm-8006-disk-0.raw,if=none,id=drive-scsi0,discard=on,format=raw,cache=none,aio=threads,detect-zeroes=unmap' \
   -device 'scsi-hd,bus=scsihw0.0,scsi-id=0,drive=drive-scsi0,id=scsi0' \
-  -drive 'file=/var/lib/vz/images/8006/vm-8006-disk-1.raw,if=none,id=drive-scsi1,aio=native,discard=on,format=raw,cache=none,detect-zeroes=unmap' \
+  -drive 'file=/var/lib/vz/images/8006/vm-8006-disk-1.raw,if=none,id=drive-scsi1,discard=on,format=raw,cache=none,aio=native,detect-zeroes=unmap' \
   -device 'scsi-hd,bus=scsihw0.0,scsi-id=1,drive=drive-scsi1,id=scsi1' \
-  -drive 'file=/var/lib/vz/images/8006/vm-8006-disk-2.raw,if=none,id=drive-scsi2,aio=io_uring,discard=on,format=raw,cache=none,detect-zeroes=unmap' \
+  -drive 'file=/var/lib/vz/images/8006/vm-8006-disk-2.raw,if=none,id=drive-scsi2,discard=on,format=raw,cache=none,aio=io_uring,detect-zeroes=unmap' \
   -device 'scsi-hd,bus=scsihw0.0,scsi-id=2,drive=drive-scsi2,id=scsi2' \
   -drive 'file=/var/lib/vz/images/8006/vm-8006-disk-3.raw,if=none,id=drive-scsi3,discard=on,format=raw,cache=none,aio=io_uring,detect-zeroes=unmap' \
   -device 'scsi-hd,bus=scsihw0.0,scsi-id=3,drive=drive-scsi3,id=scsi3' \
   -drive 'file=/mnt/pve/cifs-store/images/8006/vm-8006-disk-4.raw,if=none,id=drive-scsi4,discard=on,format=raw,cache=none,aio=native,detect-zeroes=unmap' \
   -device 'scsi-hd,bus=scsihw0.0,scsi-id=4,drive=drive-scsi4,id=scsi4' \
-  -drive 'file=/mnt/pve/cifs-store/images/8006/vm-8006-disk-5.raw,if=none,id=drive-scsi5,aio=io_uring,discard=on,format=raw,cache=none,detect-zeroes=unmap' \
+  -drive 'file=/mnt/pve/cifs-store/images/8006/vm-8006-disk-5.raw,if=none,id=drive-scsi5,discard=on,format=raw,cache=none,aio=io_uring,detect-zeroes=unmap' \
   -device 'scsi-hd,bus=scsihw0.0,scsi-id=5,drive=drive-scsi5,id=scsi5' \
   -drive 'file=/dev/rbd-pve/fc4181a6-56eb-4f68-b452-8ba1f381ca2a/cpool/vm-8006-disk-6,if=none,id=drive-scsi6,discard=on,format=raw,cache=none,aio=io_uring,detect-zeroes=unmap' \
   -device 'scsi-hd,bus=scsihw0.0,scsi-id=6,drive=drive-scsi6,id=scsi6' \
   -device 'lsi,id=scsihw1,bus=pci.0,addr=0x6' \
-  -drive 'file=/dev/rbd-pve/fc4181a6-56eb-4f68-b452-8ba1f381ca2a/cpool/vm-8006-disk-7,if=none,id=drive-scsi7,aio=io_uring,discard=on,format=raw,cache=none,detect-zeroes=unmap' \
+  -drive 'file=/dev/rbd-pve/fc4181a6-56eb-4f68-b452-8ba1f381ca2a/cpool/vm-8006-disk-7,if=none,id=drive-scsi7,discard=on,format=raw,cache=none,aio=io_uring,detect-zeroes=unmap' \
   -device 'scsi-hd,bus=scsihw1.0,scsi-id=0,drive=drive-scsi7,id=scsi7' \
   -drive 'file=/dev/rbd-pve/fc4181a6-56eb-4f68-b452-8ba1f381ca2a/cpool/vm-8006-disk-8,if=none,id=drive-scsi8,cache=writeback,discard=on,format=raw,aio=threads,detect-zeroes=unmap' \
   -device 'scsi-hd,bus=scsihw1.0,scsi-id=1,drive=drive-scsi8,id=scsi8' \
-  -drive 'file=/dev/rbd-pve/fc4181a6-56eb-4f68-b452-8ba1f381ca2a/cpool/vm-8006-disk-9,if=none,id=drive-scsi9,cache=writeback,aio=io_uring,discard=on,format=raw,detect-zeroes=unmap' \
+  -drive 'file=/dev/rbd-pve/fc4181a6-56eb-4f68-b452-8ba1f381ca2a/cpool/vm-8006-disk-9,if=none,id=drive-scsi9,cache=writeback,discard=on,format=raw,aio=io_uring,detect-zeroes=unmap' \
   -device 'scsi-hd,bus=scsihw1.0,scsi-id=2,drive=drive-scsi9,id=scsi9' \
   -drive 'file=rbd:cpool/vm-8006-disk-8:mon_host=127.0.0.42;127.0.0.21;[\:\:1]:auth_supported=none,if=none,id=drive-scsi10,discard=on,format=raw,cache=none,aio=io_uring,detect-zeroes=unmap' \
   -device 'scsi-hd,bus=scsihw1.0,scsi-id=3,drive=drive-scsi10,id=scsi10' \
-  -drive 'file=rbd:cpool/vm-8006-disk-8:mon_host=127.0.0.42;127.0.0.21;[\:\:1]:auth_supported=none,if=none,id=drive-scsi11,aio=io_uring,discard=on,format=raw,cache=none,detect-zeroes=unmap' \
+  -drive 'file=rbd:cpool/vm-8006-disk-8:mon_host=127.0.0.42;127.0.0.21;[\:\:1]:auth_supported=none,if=none,id=drive-scsi11,discard=on,format=raw,cache=none,aio=io_uring,detect-zeroes=unmap' \
   -device 'scsi-hd,bus=scsihw1.0,scsi-id=4,drive=drive-scsi11,id=scsi11' \
   -drive 'file=/dev/veegee/vm-8006-disk-9,if=none,id=drive-scsi12,discard=on,format=raw,cache=none,aio=native,detect-zeroes=unmap' \
   -device 'scsi-hd,bus=scsihw1.0,scsi-id=5,drive=drive-scsi12,id=scsi12' \
-  -drive 'file=/dev/veegee/vm-8006-disk-9,if=none,id=drive-scsi13,aio=io_uring,discard=on,format=raw,cache=none,detect-zeroes=unmap' \
+  -drive 'file=/dev/veegee/vm-8006-disk-9,if=none,id=drive-scsi13,discard=on,format=raw,cache=none,aio=io_uring,detect-zeroes=unmap' \
   -device 'scsi-hd,bus=scsihw1.0,scsi-id=6,drive=drive-scsi13,id=scsi13' \
   -machine 'type=pc+pve1'
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-06-18 13:05 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-18 13:01 [pve-devel] [PATCH-SERIES common/qemu-server v2 00/32] preparation for switch to blockdev Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH common v2 01/32] schema: parse property string: support skipping keys Fiona Ebner
2025-06-20 11:00   ` Fabian Grünbichler
2025-06-18 13:01 ` [pve-devel] [PATCH common v2 02/32] json schema: add helper to convert to JSON boolean Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 03/32] buildsys: order Perl source files in QemuServer/Makefile Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 04/32] drive: code cleanup: drop unused $vmid parameter from get_path_and_format() Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 05/32] cfg2cmd: require at least QEMU binary version 6.0 Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 06/32] drive: parse: use hash argument for optional parameters Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 07/32] drive: parse: properly handle dropped properties for restore Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 08/32] drive: remove geometry options gone since QEMU 3.1 Fiona Ebner
2025-06-20 11:03   ` Fabian Grünbichler
2025-06-20 11:20     ` Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 09/32] clone disk: io uring check: fix call to determine cache direct Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 10/32] drive: move storage_allows_io_uring_default() and drive_uses_cache_direct() helpers to drive module Fiona Ebner
2025-06-18 13:01 ` Fiona Ebner [this message]
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 12/32] drive: introduce detect_zeroes_cmdline_option() helper Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 13/32] vm start: assert that migration type is set for 'tcp' migration Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 14/32] introduce StateFile module for state file related helpers Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 15/32] vm start: move state file handling to dedicated module Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 16/32] vm start: move config_to_command() call further down Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 17/32] vm start/commandline: also clean up pci reservation when config_to_command() fails Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 18/32] vm start/commandline: activate volumes before config_to_command() Fiona Ebner
2025-06-20 11:33   ` Fabian Grünbichler
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 19/32] pci: add missing includes Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 20/32] test: add tests for PCI reservations Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 21/32] cfg2cmd: print vga: fix call to print_pcie_addr() Fiona Ebner
2025-06-18 13:01 ` [pve-devel] [PATCH qemu-server v2 22/32] pci: code cleanup: remove superfluous machine type paramater from print_pci_addr Fiona Ebner
2025-06-18 15:19   ` Fiona Ebner
2025-06-18 13:02 ` [pve-devel] [PATCH qemu-server v2 23/32] cfg2cmd: collect optional parameters as a hash Fiona Ebner
2025-06-18 13:02 ` [pve-devel] [PATCH qemu-server v2 24/32] qm: showcmd: never reserve PCI devices Fiona Ebner
2025-06-18 13:02 ` [pve-devel] [PATCH qemu-server v2 25/32] vm devices list: prepare querying block device names for -blockdev Fiona Ebner
2025-06-18 13:02 ` [pve-devel] [PATCH qemu-server v2 26/32] print drive device: explicitly set write-cache starting with machine version 10.0 Fiona Ebner
2025-06-18 13:02 ` [pve-devel] [PATCH qemu-server v2 27/32] print drive device: set {r, w}error front-end properties " Fiona Ebner
2025-06-18 13:02 ` [pve-devel] [PATCH qemu-server v2 28/32] print drive device: don't reference any drive for 'none' " Fiona Ebner
2025-06-18 13:02 ` [pve-devel] [PATCH qemu-server v2 29/32] drive: create a throttle group for each drive " Fiona Ebner
2025-06-18 13:02 ` [pve-devel] [PATCH qemu-server v2 30/32] blockdev: add helpers to generate blockdev commandline Fiona Ebner
2025-06-18 13:02 ` [pve-devel] [RFC qemu-server v2 31/32] blockdev: add support for NBD paths Fiona Ebner
2025-06-18 13:02 ` [pve-devel] [RFC qemu-server v2 32/32] command line: switch to blockdev starting with machine version 10.0 Fiona Ebner
2025-06-23  9:12   ` DERUMIER, Alexandre via pve-devel
2025-06-23  9:31     ` Fiona Ebner
2025-06-23 13:06       ` DERUMIER, Alexandre via pve-devel
2025-06-20 13:03 ` [pve-devel] partially-applied: [PATCH-SERIES common/qemu-server v2 00/32] preparation for switch to blockdev 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=20250618130209.90649-12-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