public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Friedrich Weber <f.weber@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server 2/2] vm start: warn if using ballooning and PCI(e) passthrough
Date: Mon, 13 Nov 2023 18:09:16 +0100	[thread overview]
Message-ID: <20231113170916.184994-3-f.weber@proxmox.com> (raw)
In-Reply-To: <20231113170916.184994-1-f.weber@proxmox.com>

If a VM uses PCI(e) passthrough, ballooning does not work as expected:
The QEMU process will always consume the full memory amount given in
`memory`, even if `balloon` is set to a smaller (non-zero) amount. The
reason is that the PCI device might use DMA, so QEMU needs to map the
complete guest memory on startup. However, users may not be aware of
that (see e.g. [0]).

To make users aware of the limitation, warn on VM start if at least
one PCI device is passed through and ballooning is enabled (and
`balloon` != `memory`).

[0] https://forum.proxmox.com/threads/134202/

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
---

Notes:
    I did not test this on a "real" PCI passthrough setup as I don't have
    one at hand, but Markus tested (an earlier version) of this patch on
    his machine.

 PVE/QemuServer.pm | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index dbcd568..70983a4 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5789,6 +5789,16 @@ sub vm_start_nolock {
 	die $err;
     }
 
+    if (
+	scalar(%$pci_devices)
+	&& defined($conf->{balloon})
+	&& $conf->{balloon} != 0
+	&& $conf->{balloon} != $memory
+    ) {
+	log_warn("Ballooning is not possible when using PCI(e) passthrough, "
+		."VM will use maximum configured memory ($memory MiB).\n");
+    }
+
     PVE::Storage::activate_volumes($storecfg, $vollist);
 
 
-- 
2.39.2





  parent reply	other threads:[~2023-11-13 17:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-13 17:09 [pve-devel] [PATCH docs/qemu-server 0/2] Ballooning/PCI passthrough incompatibility: add warning and docs Friedrich Weber
2023-11-13 17:09 ` [pve-devel] [PATCH docs 1/2] pci passthrough: mention incompatibility with ballooning Friedrich Weber
2023-11-14  8:30   ` Fiona Ebner
2023-11-14 10:20     ` Friedrich Weber
2023-11-17 12:37       ` Friedrich Weber
2023-11-13 17:09 ` Friedrich Weber [this message]
2023-11-14  9:13   ` [pve-devel] [PATCH qemu-server 2/2] vm start: warn if using ballooning and PCI(e) passthrough Fiona Ebner
2023-11-14 10:20     ` Friedrich Weber

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=20231113170916.184994-3-f.weber@proxmox.com \
    --to=f.weber@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