107. Proxmox QEMU boxes enable the virtio balloon device
Status: Accepted
Date: 2026-11-27
Context
setup/proxmox-qemu/build.sh and setup/proxmox-qemu/build-linux.sh created QEMU templates with --balloon 0, and clones inherited balloon: 0. Without a virtio balloon device, a running VM cannot return unused RAM to the host. Windows touches all of its configured RAM during boot, so an idle 32GiB Windows box held gigabytes of resident host memory and host swap even while Windows itself used only a few gigabytes.
Proxmox VE’s qemu-server (since 7.2-1, commit c70e4ec397, across all Proxmox VE 7.2, 8.x and 9.x releases) attaches virtio-balloon-pci,id=balloon0,...,free-page-reporting=on whenever balloon is unset or non-zero and the QEMU machine version is at least 6.2 (--machine q35 resolves to the host’s QEMU version).
How Proxmox drives a configured balloon floor differs sharply from free page reporting:
- Cold start at the floor: on every start without a saved state (
QemuServer.pmlines 5919 to 5920:mon_cmd($vmid, "balloon", value => $conf->{balloon} * 1024 * 1024) if !$statefile && $conf->{balloon}), Proxmox immediately sets the VM’s balloon target to the configuredballoonvalue. A box configured with a 50% floor cold-boots at half its memory (for example 16GiB usable on a 32GiB box, or 4GiB on an 8GiB box), and a warm VM that hibernates soon after boot is claimed still near the floor. - Slow ramp-up only under 80% host use:
pvestatd(PVE/Service/pvestatd.pm,PVE::AutoBalloon::compute_alg1) computes host memory use as total minusMemAvailable(which on a ZFS host can stay high with ARC). Only while host use is underballooning-target(80% by default) doespvestatdgrow a VM’s balloon back towardmaxmem, at most 100MiB per VM per 10-second cycle (about 27 minutes to restore 16GiB). On a host sitting above 80%, a cold-booted box stays at its floor. - Shrinking above 80% includes busy boxes: when host memory use exceeds 80%,
compute_alg1shrinks VMs withfreemem > balloon_min * 0.25first, and if that does not meet the goal, falls through to every ballooned VM. Even a busy Windows box can therefore be shrunk by 100MiB per cycle down to its floor, andballoon.sysdoes not deflate on guest memory pressure. - Monitor API privilege for resetting after cold start: resetting a cold-booted VM’s balloon target back to full memory via
POST /nodes/{node}/qemu/{vmid}/monitor(balloon <MiB>) requiresSys.Modifyon/(PVE/API2/Qemu/HMPPerms.pm:balloon => 'Sys.Modify'). BB Box’s pool-scoped API token (setup-token.sh:VM.*andPool.Auditon the pool, plusSys.Auditon the node) deliberately does not holdSys.Modifyon/. Doing that in a later change would require either grantingSys.Modifyon/or a root host helper.
Guest support also differs between Linux and Windows:
- Linux VMs (Ubuntu 24.04): the pinned Ubuntu 24.04 cloud image (
linux-image-6.8.0-139-generic,linux-image-virtual) buildsCONFIG_VIRTIO_BALLOON=y,CONFIG_MEMORY_BALLOON=yandCONFIG_PAGE_REPORTING=yinto the kernel. Linux kernels 5.7 and later implementVIRTIO_BALLOON_F_REPORTING, so a Linux VM withballoonequal tomemoryreturns large free page blocks to the host through free page reporting without auto-ballooning (page cache stays in the guest until reclaimed). - Windows VMs:
setup/proxmox-qemu/answer/bb-box/firstlogon.ps1runsvirtio-win-gt-x64.msi /qn /norestart, which installsFE_balloon_driver(balloon.inf,balloon.cat,balloon.sysstaged into the Windows Driver Store viaSetupCopyOEMInf) andBalloonService(blnsvr.exe, automatic start). Existing Windows templates built with--balloon 0therefore bindballoon.sysat boot with no rebuild. However, upstreamvirtio-win/kvm-guest-drivers-windows(masteras of November 2026) negotiates onlyVIRTIO_BALLOON_F_STATS_VQand classic balloon inflate and deflate (BalloonFillandBalloonLeak), and does not yet implementVIRTIO_BALLOON_F_REPORTING(upstream issue 899; PR 1657 remains open). Windows therefore does not give unused memory back on its own today.
Decision
- Linux VMs (
linuxandlinux-desktop-cpu): BB Box setsballoonequal tomemory(in MiB) whenever it configures a Linux VM’s size: on acquire, resize (taking the kind from the method’skindargument, including rollbacks), fork, image build or trial boxes, and template capture.setup/proxmox-qemu/build-linux.shcreates newlinuxandlinux-desktoptemplates with--balloonequal to--memory(16384MiB during build, then 4096MiB forlinuxand 8192MiB forlinux-desktopbefore templating). Auto-ballooning never shrinks Linux VMs; free page reporting returns large free page blocks to the host. - Windows VMs (
windows-desktop): Proxmox QEMU adds an advanced settingwindows-balloon-min-percentwith default100(whole numbers from25to100). At the default of100,balloonequalsmemory: every Windows box cold-boots at full memory with auto-ballooning off,virtio-balloon-pciandfree-page-reporting=onready, andBalloonServicereporting real guest memory to Proxmox. Operators who accept the cold-boot-at-floor and busy-shrink trade-offs can lower the setting (25 to 99); BB Box then setsballoontoround(memory * windows-balloon-min-percent / 100)MiB (clamped between 1 andmemory) on acquire, warm pool fill, resize (including rollbacks) and image boxes.setup/proxmox-qemu/build.shand template capture (#capture) always write templates withballoonequal tomemory. - Android VMs (
android): unchanged (balloon: 0inbuild-linux.shand omitted by BB Box). - Start gate (
src/backends/proxmox/start-gate.ts): extends decision 106 with no code changes. Ballooned Linux VMs no longer haveballoonoff, so they do not count as heavy (they allocate memory lazily and do not zero all RAM at boot). Windows VMs remain heavy by OS (windows), kind (windows-desktop) andostype(win*), and Android remains heavy by kind. Admission continues to check each guest’s full configuredmemory, never a lower balloon floor. - Existing guests and hibernated warm VMs: boxes and warm VMs made before this change keep
balloon: 0until they are made again. Claiming a hibernated warm VM resumes it first and never changes its hardware configuration before resume.
Consequences
- Linux VMs on Proxmox QEMU return large free page blocks to the host through
free-page-reporting=onwith no change to guest-visible memory and no heavy start settle delay, while page cache stays until reclaimed. - At the default
windows-balloon-min-percentof100, Windows boxes cold-boot at full memory and report guest memory usage to Proxmox throughBalloonService, but do not return idle RAM to the host on their own until upstreamvirtio-winships free page reporting (PR 1657). - When an operator lowers
windows-balloon-min-percentbelow100, cold-booted Windows boxes start at that floor and grow back toward full memory only while host memory use is under 80% (at most 100MiB per 10-second cycle); above 80%, Proxmox can shrink even a busy Windows box to its floor. Inside Windows,balloon.syslocks inflated pages viaMmAllocatePagesForMdlEx, so Task Manager still shows full installed RAM while “In use” rises and “Available” RAM falls by the inflated amount. - Proxmox rejects a VM config where non-zero
balloonexceedsmemory, so resize and capture always updatememoryandballoontogether. - A later change to start lower-floor Windows boxes at full memory would need to reset the balloon target after each cold start (which requires
Sys.Modifyon/for Proxmox’s monitor endpoint, or a host helper), or wait for upstreamvirtio-winPR 1657.