From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id BD68E990C3 for ; Mon, 13 Nov 2023 18:11:16 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9566816489 for ; Mon, 13 Nov 2023 18:10:46 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 13 Nov 2023 18:10:45 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id BB4DD4104A for ; Mon, 13 Nov 2023 18:10:44 +0100 (CET) From: Friedrich Weber To: pve-devel@lists.proxmox.com Date: Mon, 13 Nov 2023 18:09:16 +0100 Message-Id: <20231113170916.184994-3-f.weber@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231113170916.184994-1-f.weber@proxmox.com> References: <20231113170916.184994-1-f.weber@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.128 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH qemu-server 2/2] vm start: warn if using ballooning and PCI(e) passthrough 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: , X-List-Received-Date: Mon, 13 Nov 2023 17:11:16 -0000 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 --- 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