public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC PATCH qemu-server] pci: add 'keep-driver' option
Date: Tue, 12 Aug 2025 12:00:09 +0200	[thread overview]
Message-ID: <20250812100009.1613204-1-d.csapak@proxmox.com> (raw)

by default, pci devices will be bound to 'vfio-pci' driver and reset.
For most devices this is necessary, but there are a few exceptions,
e.g.:

* some mellanox nics have support for the driver 'mlx5_vfio_pci'
* intel flex gpus have support for 'i915_vfio_pci'
* (maybe some more i don't know about)

both of these drivers play the role of the vfio-pci drivers themselves,
so no rebinding or resetting necessary. Those drivers usually have more
functionality than the default vfio driver, like support for
live-migration.

To be able to configure that on our side, introduce the 'keep-driver'
option for 'hostpciX', which will not rebind/reset the device.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
sending as RFC, since i'm not sure if we want to go this (generic)
approach, or if we e.g. want to make special configs/cases for driver we
know. Pro of this approach is that we don't have to add more drivers in
the future, but con is that it has some potential to confuse users when
it does not work the way they though it would.

 src/PVE/QemuServer/PCI.pm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/PVE/QemuServer/PCI.pm b/src/PVE/QemuServer/PCI.pm
index e7a9a610..84a56998 100644
--- a/src/PVE/QemuServer/PCI.pm
+++ b/src/PVE/QemuServer/PCI.pm
@@ -124,6 +124,13 @@ EODESCR
         optional => 1,
         description => "Override PCI subsystem device ID visible to guest",
     },
+    'keep-driver' => {
+        type => 'boolean',
+        optional => 1,
+        default => 0,
+        description => "If this is set, does not bind the device to vfio-pci and does not reset"
+            . "the device. Useful for VF that already have the correct driver loaded.",
+    },
 };
 PVE::JSONSchema::register_format('pve-qm-hostpci', $hostpci_fmt);
 
@@ -736,7 +743,7 @@ sub prepare_pci_device {
         if !PVE::SysFSTools::check_iommu_support();
     die "no pci device info for device '$pciid'\n" if !$info;
 
-    if ($device->{nvidia}) {
+    if ($device->{nvidia} || $device->{'keep-driver'}) {
         # nothing to do
     } elsif (my $mdev = $device->{mdev}) {
         my $uuid = generate_mdev_uuid($vmid, $index);
-- 
2.39.5



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


             reply	other threads:[~2025-08-12  9:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-12 10:00 Dominik Csapak [this message]
2025-08-26 10:11 ` Thomas Lamprecht
2025-08-26 10:14   ` Dominik Csapak
2025-08-26 10:24     ` Thomas Lamprecht

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=20250812100009.1613204-1-d.csapak@proxmox.com \
    --to=d.csapak@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