What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
virtio-mem is a paravirtualized KVM/QEMU memory device that lets a running virtual machine add or remove usable RAM in fixed-size blocks. QEMU sets a target, while the guest’s virtio_mem driver plugs, onlines, migrates, and unplugs blocks. It is especially mature for Linux, but a resize is a request rather than a guarantee: the guest may complete it partially or not at all.
That makes virtio-mem useful for elastic VM capacity, not a substitute for deterministic fixed memory, conventional DIMM hotplug, or every form of ballooning.
As an Amazon Associate I earn from qualifying purchases.
What problem does virtio-mem solve?
VM memory demand changes. A database, build worker, or cloud service may need more RAM during a burst and return it later. Fixed boot memory cannot change without disruptive procedures; DIMM hotplug usually uses larger units and requires DIMM-count, address-space, alignment, and migration planning.
| Mechanism | Purpose | Guest-visible effect | Main limitation |
|---|---|---|---|
| Fixed VM RAM | Predictable capacity | RAM available from boot | Cannot normally resize while running |
| DIMM hotplug | Add or remove large virtual DIMMs | Ordinary system RAM | Coarser units and topology planning |
virtio-balloon |
Reclaim unused pages | Balloon pressure reduces available memory | Not a general way to add arbitrary RAM |
virtio-mem |
Resize VM capacity | System RAM plugged or unplugged in blocks | Needs a guest driver and reliable hot-unplug |
virtio-pmem |
Persistent-memory-like storage | Persistent memory semantics | Not ordinary dynamically resized RAM |
See the virtio-mem project guide and QEMU’s virtio-pmem documentation for the device distinction.
#1 Best Overall
How the architecture works
The device has three cooperating layers:
- Management: libvirt, QMP, or an orchestrator changes a device’s target.
- QEMU: a memory backend supplies the device’s maximum region and tracks
requested-sizeversus actualsize. A common implementation isvirtio-mem-pci. - Guest: the
virtio_memdriver discovers the device-managed region, plugs blocks, onlines Linux memory, and migrates or frees pages during removal.
The region is not simply ordinary boot RAM in the firmware map. The guest driver must expose it to the operating system. QEMU’s model and properties are documented in the QEMU user guide.
Capacity, block size, and NUMA
The backend’s size is the device’s maximum capacity; the device’s actual size is what the guest has successfully plugged. In typical x86-64 and AArch64 Linux configurations, blocks are commonly 2 MiB. QEMU requires block-size to be greater than 1 MiB, a power of two, and at least the backing page size. Huge-page backing, architecture, kernel behavior, and management constraints can produce larger effective units.
Smaller blocks provide finer control but increase mapping and metadata overhead. Larger blocks can make unplug harder because the guest must evacuate larger units. Each virtio-mem device belongs to one vNUMA node and one memory backend; use multiple devices when modeling per-node capacity. Check placement with QEMU’s info numa. A successful resize on the wrong node can still create remote-memory latency.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minutePrepare a Linux guest
The kernel needs the virtio_mem driver (the upstream project lists Linux 5.8 as its baseline; distribution backports matter). Newly added memory must be onlined, automatically or manually. Unplug requires Linux to migrate pages out of blocks before removing them.
For reliable shrinking, movable memory is important. ZONE_MOVABLE generally improves evacuation, while online_kernel gives the normal kernel zone more flexibility for ordinary allocations. The newer auto-movable policy balances both. The virtio-mem guide warns against blindly placing memory in ZONE_MOVABLE when hotplugging several times the initial memory (roughly beyond three to four times boot RAM); workload, kernel, and NUMA policy decide the right choice.
RHEL 10 documents these kernel-command-line examples (reboot after changing them):
Rank #3
grubby --update-kernel=ALL --remove-args=memhp_default_state --args=memhp_default_state=online_movable
grubby --update-kernel=ALL --remove-args=memhp_default_state --args=memhp_default_state=online_kernel
grubby --update-kernel=ALL --remove-args=memhp_default_state --args=memhp_default_state=online
grubby --update-kernel=ALL --remove-args=memory_hotplug.online_policy --args=memory_hotplug.online_policy=auto-movable
RHEL also exposes optional movable-ratio and NUMA-aware settings. These commands are RHEL-specific; Debian, Ubuntu, SUSE, and custom kernels use their own bootloader or udev configuration. Establish the policy before resizing. Hibernation is not supported by the upstream project, and the driver should not be unloaded during normal operation. The Linux hotplug phases are described in the kernel memory-hotplug documentation.
Representative QEMU configuration
-object memory-backend-ram,id=mem0,size=16G,reserve=off
-device virtio-mem-pci,id=vm0,memdev=mem0,node=0,block-size=2M
-m 4G,maxmem=20G
-m 4G,maxmem=20Gsets initial RAM and the VM’s overall envelope.size=16Ggives this device its maximum capacity.id=vm0identifies it for monitoring and QMP changes.block-size=2Mrequests 2 MiB device granularity where supported.reserve=offfollows the virtio-mem guide’s recommendation for assigned backends.
This is a conceptual example, not a universal production command. Machine type, firmware, PCI layout, NUMA topology, backend type, QEMU version, and migration policy may require additional options.
libvirt definition
Give the domain enough maxMemory headroom, then define a virtio-mem device. For example:
Rank #4
<maxMemory unit='GiB'>128</maxMemory>
<memory model='virtio-mem'>
<target>
<size unit='GiB'>48</size>
<node>0</node>
<block unit='MiB'>2</block>
<requested unit='GiB'>16</requested>
<current unit='GiB'>16</current>
</target>
<alias name='ua-virtiomem0'/>
</memory>
User-defined aliases must use libvirt’s ua- convention. requested is the target and current is currently available memory; capacity is separate. Enable dynamic-memslots where compatible. Consult the libvirt guide and your installed libvirt schema. virsh setmem and balloon inflation are not substitutes for changing a virtio-mem device.
Resize and monitor at runtime
In the QEMU monitor, use the device ID:
(qemu) qom-get vm0 requested-size
(qemu) qom-get vm0 size
(qemu) qom-set vm0 requested-size 1G
(qemu) info memory_size_summary
(qemu) info numa
The set operation is asynchronous. If requested-size exceeds size, the guest has not completed the operation. QEMU emits a rate-limited MEMORY_DEVICE_SIZE_CHANGE event when actual size changes. Verify the guest with free -h, /proc/meminfo, and its memory-block sysfs entries.
Free tools Windows power users keep installed
One-click scans. No signup required.
Why shrinking fails or stops part-way
- Pages in the target blocks remain allocated.
- Memory was onlined into
ZONE_NORMAL, making evacuation harder. - Pinned pages, huge-page or contiguous allocations, VFIO mappings, or an aggressively active workload block migration.
- The driver is absent, malfunctioning, or the requested target is below what the guest can release.
- Onlining policy was configured too late, or the backend/device combination is incompatible.
Partial completion is normal behavior, not proof that QEMU ignored the request. Treat actual size as authoritative; reduce workload pressure, inspect page-migration and device-assignment constraints, then retry.
Diagnostics when added RAM is missing
lsmod | grep virtio_mem
dmesg | grep -i virtio
dmesg | grep -i memory
ls /sys/devices/system/memory/
cat /sys/devices/system/memory/auto_online_blocks
Separate the chain of events: QEMU changed the target, the driver accepted it, Linux created blocks, blocks were onlined, and the page allocator can use them. A break at any stage explains why host-side monitoring shows a request but the guest’s usable RAM does not increase.
Compatibility and operational limits
| Area | Practical status |
|---|---|
| Linux | Mature upstream environment; validate kernel and distribution packaging. |
| Windows | virtio-win support exists, but maturity and certification vary by edition, driver, and vendor. |
| AArch64 | Upstream support milestone was Linux 5.18; confirm package versions. |
| s390x | Project notes Linux 6.13, QEMU 10.0, and libvirt 11.1 milestones; check exact distributions. |
| Ballooning | Use virtio-mem for capacity and balloon/free-page reporting for reclamation; do not control the same resize goal with both. |
| VFIO | Possible, but small blocks and large capacities can hit mapping limits. |
| vhost-user | Some DPDK/SPDK configurations are incompatible; virtiofs is treated differently. Test dynamic slots. |
| Huge pages | Change effective granularity and reservation requirements; test fragmentation and migration. |
| Secure virtualization and memory locking | Not supported in the documented libvirt integration; fixed memory may be required. |
| Migration, dumps, snapshots | Documented in several configurations, but backend, huge pages, vhost devices, destination capacity, and QEMU version determine success. |
Project documentation records QEMU 5.1 as the approximate upstream introduction, QEMU 8.2 for dynamic memory slots, QEMU 8.1 for constrained device unplug, and Linux milestones including 5.19 pageblock improvements. These are compatibility markers, not guarantees for every vendor package. See the migration notes.
Host memory, preallocation, and migration planning
A maximum backend region is not automatically equivalent to currently plugged guest RAM. Sparse file-backed memory, preallocation, huge pages, cgroup limits, and concurrent VMs determine host consumption. The guide recommends reserve=off; prealloc=on may be appropriate for a deliberately reserved design but changes startup, capacity, and migration behavior. File-backed backends need a filesystem supporting sparse files. Monitor requested size, actual size, QEMU resident memory, host free memory and swap, huge-page availability, and service limits. Frequent host overcommit can lead to instability or OOM conditions.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallWhen to choose virtio-mem
- Choose it when Linux VM demand changes materially, fine-grained capacity matters, asynchronous resizing is acceptable, and guest onlining and hot-unplug behavior have been tested.
- Prefer fixed RAM for deterministic reservation, secure/encrypted virtualization, real-time locking, strict huge-page allocation, or platforms that cannot control the guest kernel.
- Prefer ballooning when the goal is reclaiming unused pages or free-page reporting, not adding arbitrary system RAM.
- Prefer DIMM hotplug when conventional guest compatibility and coarse, mature workflows outweigh finer granularity.
Validate resize latency, NUMA locality, migration, snapshots, device passthrough, and rollback under realistic workload pressure. Deploy virtio-mem because elastic capacity is an operational requirement—not merely because its nominal block size is small.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




