From 9411f7ecd879056cdb12d05f1f445f3087d5f1c3 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 30 Apr 2026 15:21:20 +0100 Subject: [PATCH] vmm: Validate balloon size against total RAM The total RAM in the system needs to consider any hotpluggable RAM that is hotplugged in as well as the initial static "base" RAM. Signed-off-by: Rob Bradford --- vmm/src/config.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 3faa7ff75..3d37420b4 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -316,7 +316,7 @@ pub enum ValidationError { )] InvalidIommuAddressWidthBits(u8), /// Balloon too big - #[error("Ballon size ({0}) greater than RAM ({1})")] + #[error("Balloon size ({0}) greater than RAM ({1})")] BalloonLargerThanRam(u64, u64), /// On a IOMMU segment but not behind IOMMU #[error("Device is on an IOMMU PCI segment ({0}) but not placed behind IOMMU")] @@ -3044,14 +3044,7 @@ impl VmConfig { } if let Some(balloon) = &self.balloon { - let mut ram_size = self.memory.size; - - if let Some(zones) = &self.memory.zones { - for zone in zones { - ram_size += zone.size; - } - } - + let ram_size = self.memory.total_size(); if balloon.size >= ram_size { return Err(ValidationError::BalloonLargerThanRam( balloon.size,