[pbs-devel] [PATCH proxmox-backup 3/9] file-restore: add more RAM for VMs with many drives or debug

Stefan Reiter s.reiter at proxmox.com
Thu May 6 17:26:18 CEST 2021


The guest kernel requires more memory depending on how many disks are
attached. 256 seems to be enough for basically any reasonable and
unreasonable amount of disks though.

For debug instance, make it 1G, as these are never started automatically
anyway, and need at least 512MB since the initramfs (especially when
including a debug build of the daemon) is substantially bigger.

Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---
 src/bin/proxmox_file_restore/qemu_helper.rs | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/bin/proxmox_file_restore/qemu_helper.rs b/src/bin/proxmox_file_restore/qemu_helper.rs
index a2b5b09d..9b44b55d 100644
--- a/src/bin/proxmox_file_restore/qemu_helper.rs
+++ b/src/bin/proxmox_file_restore/qemu_helper.rs
@@ -183,8 +183,6 @@ pub async fn start_vm(
         "-vnc",
         "none",
         "-enable-kvm",
-        "-m",
-        "128",
         "-kernel",
         buildcfg::PROXMOX_BACKUP_KERNEL_FN,
         "-initrd",
@@ -226,11 +224,24 @@ pub async fn start_vm(
         id += 1;
     }
 
+    let ram = if debug {
+        1024
+    } else {
+        // add more RAM if many drives are given
+        match id {
+            f if f < 10 => 128,
+            f if f < 20 => 192,
+            _ => 256,
+        }
+    };
+
     // Try starting QEMU in a loop to retry if we fail because of a bad 'cid' value
     let mut attempts = 0;
     loop {
         let mut qemu_cmd = std::process::Command::new("qemu-system-x86_64");
         qemu_cmd.args(base_args.iter());
+        qemu_cmd.arg("-m");
+        qemu_cmd.arg(ram.to_string());
         qemu_cmd.args(&drives);
         qemu_cmd.arg("-device");
         qemu_cmd.arg(format!(
-- 
2.20.1






More information about the pbs-devel mailing list