bhyve: support NUMA configuration for domains

Bhyve supports NUMA domains configuration using the '-n'
command line argument:

  -n id,size,cpus[,domain_policy]

Here, "id" is a numeric NUMA domain id, "size" is the total VM
memory size with units format similar to the "-m" switch,
"cpus" is a cpuset, and "domain_policy" is an optional
domainset(9) memory allocation policy. The "domain_policy"
is currently not used by the libvirt driver.

This argument is repeated for every NUMA domain to be configured, e.g.:

  bhyve \
  ...
  -n id=0,size=107,cpus=0-3
  -n id=1,size=107,cpus=4-7

To support that:

 * Add a corresponding capability; it is considered supported
   if the bhyve binary has the '-n' command line switch.

 * Generate command line arguments for NUMA from
   <cpu><numa>..</numa></cpu> domain configuration.

Additionally, validate that:

 * NUMA domains can be only configured with the UEFI loaders.
 * No more than 8 domains configured per VM as limited by bhyve.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Roman Bogorodskiy
2026-03-06 18:43:28 +01:00
parent e4b0fdb72f
commit 82b09f105a
12 changed files with 210 additions and 1 deletions
@@ -0,0 +1,42 @@
<domain type='bhyve'>
<name>bhyve</name>
<uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
<memory unit='KiB'>219136</memory>
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>8</vcpu>
<os firmware='efi'>
<type arch='x86_64'>hvm</type>
<boot dev='hd'/>
</os>
<cpu>
<numa>
<cell id='0' cpus='0-3' memory='109568' unit='KiB'/>
<cell id='1' cpus='4-7' memory='109568' unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='file' type='raw'/>
<source file='/tmp/freebsd.img'/>
<target dev='hda' bus='sata'/>
<address type='drive' controller='0' bus='0' target='2' unit='0'/>
</disk>
<controller type='pci' index='0' model='pci-root'/>
<controller type='isa' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
</controller>
<controller type='sata' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:b9:94:02'/>
<source bridge='virbr0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
</devices>
</domain>