Add a traditional virtio-balloon device for amd64 and arm64, using the
shared vm_discard_pages() interface to reclaim disposable guest RAM.
Process inflation synchronously, finishing all discard attempts before
acknowledging each request. Retain no PFNs for later retries, so
deflation needs no host work. Accept up to 1024 PFNs per request, as
sent by the Windows driver; the FreeBSD, Linux, and NetBSD drivers send
- Complete larger requests without discarding anything, which bounds
the work that one notification can cause while the device lock is held.
Reclamation is best-effort; the guest-reported actual size is not a
freed-byte count.
Honor legacy initialization ordering by completing initialized inflate
and deflate queues before DRIVER_OK. Keep the statistics handshake gated
on readiness and feature negotiation.
Support on-demand guest statistics by returning a held queue buffer to
request a sample. Cache reported values with a receipt timestamp and
reset the handshake on device reset. Accept up to 256 statistics
records per sample; drivers send one per tag they support, currently at
most 16.
Offer VIRTIO_BALLOON_F_DEFLATE_ON_OOM when the deflate_on_oom device
setting is enabled, like QEMU's deflate-on-oom property, so that the
guest can take pages back under memory pressure. Leave it disabled by
default so that the balloon holds the requested target. Register the
setting so that bhyve -o help lists it.
Add bhyvectl commands to set the balloon target, using the size syntax
of bhyve -m, and to read statistics and diagnostic counters through
bhyve's IPC socket. Return an errno value with IPC errors so that
bhyvectl reports why bhyve rejected a request. Keep target policy in the
management layer and document the commands and device.
Support one balloon per VM with unwired RAM and no PCI passthrough.
Balloon checkpoint support is deferred in this commit.
Sponsored by: The FreeBSD Foundation