Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk7 min

Virtio-mem: How Paravirtualized Memory Resizes KVM Guests

Virtio-mem dynamically adds and removes guest RAM in blocks, but successful hot-unplug depends on Linux memory policy, workload page mobility, NUMA placement, and device compatibility.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

How the architecture works

The device has three cooperating layers:

  1. Management: libvirt, QMP, or an orchestrator changes a device’s target.
  2. QEMU: a memory backend supplies the device’s maximum region and tracks requested-size versus actual size. A common implementation is virtio-mem-pci.
  3. Guest: the virtio_mem driver 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prepare 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):

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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=20G sets initial RAM and the VM’s overall envelope.
  • size=16G gives this device its maximum capacity.
  • id=vm0 identifies it for monitoring and QMP changes.
  • block-size=2M requests 2 MiB device granularity where supported.
  • reserve=off follows 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:

<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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When 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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.