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 15, 1:14 AM
Unknown Object (File)
Thu, May 14, 2:07 PM
Unknown Object (File)
Thu, May 14, 2:07 PM
Unknown Object (File)
Thu, May 14, 12:36 PM
Unknown Object (File)
Wed, May 13, 5:23 PM
Unknown Object (File)
Tue, May 12, 11:43 PM
Unknown Object (File)
Mon, May 11, 12:40 PM
Unknown Object (File)
Mon, May 11, 7:28 AM

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.