How to implement automatic memory allocation with pure QEMU commands?

sacarias

Active Member
Oct 2, 2019
64
1
26
At office we use Proxmox for production use. But for particular desktop user I wanted to give pure qemu-system-<arch> a try.

After a big while of studying I think I got almost everything needed, except the detail of "automatic ballooning"; i.e., automatic memory allocation:
https://pve.proxmox.com/pve-docs/pve-admin-guide.html#qm_memory

But as far as I could read in QEMU's docs and manuals, there's no info at all regarding how to do this; only manually with the monitor.

Is it possible to do this with pure QEMU/KVM? Or is this actually a Proxmox-only thing?

Thanks beforehand.
 
you can check how PVE configures a particular VM with qm showcmd XXX --pretty (where XXX is the VMID).
 
  • Like
Reactions: Stoiko Ivanov
Thanks very much sir.

I set up a VM with RAM ballooning via the web GUI, with total RAM 8 Gb and minimum RAM 4 Gb.
However, even with "qm showcmd" the *only* balloon thing I could see was the virtio-balloon-pci device, with options "addr" and "free-page-reporting", which are not documented in the QEMU docs by the way...

Not even with "qm config" I was able to see anything related to this "minimum 4 Gb RAM" thing I tried setting up.

Is this "minimum" ballooning thing really working? Or am I failing to understand how ballooning works?

Thanks again.
 
Not even with "qm config" I was able to see anything related to this "minimum 4 Gb RAM" thing I tried setting up.

In a VM-config the minimum memory is defined with e.g.: balloon: 4096 for 4 GiB and the maximum memory is defined with e.g.: memory: 8192 for 8 GiB.

If it is not there, double check your VM-config over the GUI. There it will also show it as: 4.00 GiB/8.00 GiB in the "Hardware"-tab.
 
Last edited:
virtio-ballon-pci is (sparsely ;)) documented in qemu's help output:

Code:
$ kvm -device virtio-pci-balloon,help
virtio-balloon-pci options:
  acpi-index=<uint32>    -  (default: 0)
  addr=<int32>           - Slot and optional function number, example: 06.0 or 06 (default: -1)
  aer=<bool>             - on/off (default: false)
  any_layout=<bool>      - on/off (default: true)
  ats=<bool>             - on/off (default: false)
  deflate-on-oom=<bool>  - on/off (default: false)
  disable-legacy=<OnOffAuto> - on/off/auto (default: "auto")
  disable-modern=<bool>  -  (default: false)
  event_idx=<bool>       - on/off (default: true)
  failover_pair_id=<str>
  free-page-hint=<bool>  - on/off (default: false)
  free-page-reporting=<bool> - on/off (default: false)
  guest-stats-polling-interval=<int>
  guest-stats=<guest statistics>
  indirect_desc=<bool>   - on/off (default: true)
  iommu_platform=<bool>  - on/off (default: false)
  iothread=<link<iothread>>
  migrate-extra=<bool>   - on/off (default: true)
  modern-pio-notify=<bool> - on/off (default: false)
  multifunction=<bool>   - on/off (default: false)
  notify_on_empty=<bool> - on/off (default: true)
  packed=<bool>          - on/off (default: false)
  page-per-vq=<bool>     - on/off (default: false)
  page-poison=<bool>     - on/off (default: true)
  qemu-4-0-config-size=<bool> -  (default: false)
  rombar=<uint32>        -  (default: 1)
  romfile=<str>
  romsize=<uint32>       -  (default: 4294967295)
  use-disabled-flag=<bool> -  (default: true)
  use-started=<bool>     -  (default: true)
  virtio-backend=<child<virtio-balloon-device>>
  virtio-pci-bus-master-bug-migration=<bool> - on/off (default: false)
  x-ats-page-aligned=<bool> - on/off (default: true)
  x-disable-legacy-check=<bool> -  (default: false)
  x-disable-pcie=<bool>  - on/off (default: false)
  x-ignore-backend-features=<bool> -  (default: false)
  x-pcie-deverr-init=<bool> - on/off (default: true)
  x-pcie-extcap-init=<bool> - on/off (default: true)
  x-pcie-flr-init=<bool> - on/off (default: true)
  x-pcie-lnkctl-init=<bool> - on/off (default: true)
  x-pcie-lnksta-dllla=<bool> - on/off (default: true)
  x-pcie-pm-init=<bool>  - on/off (default: true)

when starting the VM, PVE will set 'guest-stats-polling-interval' to '2', the actual ballooning is then done by pvestatd:
https://git.proxmox.com/?p=pve-mana...2d153a07f557af2881c;hb=refs/heads/master#l180
https://git.proxmox.com/?p=pve-mana...2bb70c8f2b1a3e234e895558;hb=refs/heads/master
 
  • Like
Reactions: leesteken
Oohhh, so straight answer to OP is indeed a Proxmox original thing. Yes, I think I meant "auto-ballooning" since the beginning.

As much as I initially read, this was not possible with pure QEMU/KVM:
https://www.linux-kvm.org/page/Projects/auto-ballooning
And only possible manually by setting "balloon" value in QEMU monitor.

I expected to be able to find a way to set the "balloon" value directly with qemu-system-<arch>, i.e., right at VM start; but probably this is not possible...

Thanks for everything sir.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!