Repository navigation
Use PCI and support Firecracker device hotplugging #1155
richardcase
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
Firecracker now supports PCI transport for virtio devices and Developer Preview hotplugging of virtio block, pmem, and network devices. Flintlock currently starts Firecracker without its API socket, explicitly boots guests with
pci=off, and has no API for changing devices on a running microVM.This proposal makes PCI the default transport for new Firecracker microVMs and adds asynchronous hot-attach and hot-detach operations for block volumes and network interfaces. Guest coordination is performed through the Flintlock guest agent because Firecracker does not currently notify the guest when the PCI topology changes.
This revisits the conclusion of Firecracker Patch Limitations & The Flintlock Update API, but only for explicitly supported device operations. It does not restore a generic microVM update operation.
Goals
Non-goals
UpdateMicroVMAPI.Firecracker and guest requirements
Flintlock would:
--enable-pci.pci=offfrom the kernel command line.PUTandDELETErequests can be made after boot.CONFIG_PCI,CONFIG_PCI_MSI,CONFIG_PCIEPORTBUS,CONFIG_VIRTIO_PCI,CONFIG_PCI_HOST_COMMON, andCONFIG_PCI_HOST_GENERIC.Firecracker currently describes device hotplugging as Developer Preview. Production adoption should use a tagged release containing the attach and unplug deadlock fixes that landed after v1.16.1 if no such release is available when implementation begins.
Existing MMIO microVMs would continue running unchanged but must be recreated before they can use these APIs.
References:
Flintlock API
Rather than restoring a generic update RPC, add four narrowly scoped RPCs:
Each RPC returns a
DeviceMutationResponsecontaining the currentMicroVM. Acceptance is asynchronous: the response confirms that Flintlock persisted the requested operation, not that the guest can already use the device.expected_versionprovides optimistic concurrency. An exact retry is idempotent. Only one device mutation may be pending for a microVM; a different concurrent request returnsFailedPrecondition.Requests are rejected when:
allow_guest_agent.Both initially configured and hot-added non-root devices may be detached.
Status model
Extend
MicroVMStatuswith device-operation status containing:Pending,Succeeded, orFailed.A failed device operation does not change an otherwise healthy running microVM from
Created. The operation status records the failure and the reconciler retains enough information to retry or clean up safely.Guest-agent protocol
The guest agent would expose an additive
pci-hotplug-v1capability and three operations:pci-list: enumerate supported PCI devices and return their BDF, kind, Linux device name, block serial, and MAC address.pci-rescan: write to/sys/bus/pci/rescanand return the resulting supported-device inventory.pci-remove: validate and remove a specific BDF through sysfs.The implementation should inspect sysfs directly and not depend on
lspciorip. Block removal must reject a device when it or any partition is mounted, based on mountinfo. Network removal must lower the interface before removing its PCI device.Flintlock should consume the protocol through a reusable guest-agent host client rather than duplicating the vsock framing logic.
The guest agent only discovers and safely releases devices. The caller remains responsible for mounting volumes and configuring guest networking.
Reconciliation
Attach volume
PUT /drives/{id}.Attach network interface
PUT /network-interfaces/{id}.Detach
DELETErequest.Ambiguous guest-device matches fail safely. Reconciliation must preserve the last completed step so retries do not create duplicate Firecracker, TAP, or containerd resources. Flintlock also needs per-volume snapshot and lease cleanup rather than releasing all containerd resources only when the microVM is deleted.
Alternatives considered
Restore a generic UpdateMicroVM RPC
Rejected because Firecracker still supports only a constrained set of post-boot mutations. Dedicated RPCs provide clearer validation, authorization, status, and compatibility semantics.
Make PCI opt-in
Rejected for new Firecracker microVMs. Maintaining both MMIO and PCI paths would increase test and compatibility complexity, while hotplug necessarily requires PCI.
Require callers to rescan and remove PCI devices
Rejected because the host cannot know that guest filesystems and interfaces are safe to release. The guest agent provides a controlled protocol and consistent failure handling.
Perform host-side hotplug only
Rejected because Firecracker provides no automatic guest notification. Unplugging before the guest releases the device can leave stale guest state and unsafe memory access.
Only detach devices that were hot-added
Rejected because Firecracker can detach initially configured non-root devices too, and callers should not need to track how a detachable device was introduced.
Consequences and limitations
Validation
Implementation should include:
Suggested delivery order
Feedback is especially welcome on the dedicated RPC shape, mandatory PCI rollout, status representation, and whether the one-operation-per-microVM constraint is appropriate.
All reactions