Page MenuHomeFreeBSD

bhyvectl: Add device hotplugging options
Needs ReviewPublic

Authored by bnovkov on Jan 11 2026, 1:33 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 1, 9:03 PM
Unknown Object (File)
Fri, May 1, 9:43 AM
Unknown Object (File)
Tue, Apr 28, 5:31 AM
Unknown Object (File)
Mon, Apr 27, 1:25 PM
Unknown Object (File)
Thu, Apr 23, 11:20 PM
Unknown Object (File)
Sat, Apr 11, 12:16 AM
Unknown Object (File)
Mar 30 2026, 8:27 AM
Unknown Object (File)
Mar 12 2026, 11:43 PM

Details

Reviewers
None
Group Reviewers
bhyve
Summary

This change introduces the --pci-{add,remove} options which allow
users to add or remove emulated PCI devices to an active virtual machine.

--pci-add's argument follows the same format as bhyve's -s option,
with the only difference being that --pci-add does not take a
bus:slot:function string. When asked to hotplug a device,
bhyvectl creates a new nvlist and uses libbhyve's
pci_parse_config and pci_init_fds routines to populate it with the
appropriate key/value pairs and file descriptors. It will then
invoke the appropriate bhyve IPC command.

--pci-remove takes a bus:slot:function string as an argument.
The argument can also be specified in all of the same formats
used by bhyve's -s flag.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 69802
Build 66685: arc lint + arc unit

Event Timeline

Couple of comments/questions:

  1. I think we should not allow neither --pci-add nor --pci-remove to be combined with other options (such as --destroy) and also with each other.
  2. Is it possible to make --pci-add print the PCI address of the added device? That would be important for preserving consistent device addresses for the VM, and also just convenient for the consequent --pci-remove without having to use the guest to figure out that PCI address.