Files
cyborg/devstack/plugin.sh
T
Sean Mooney 7b1fc570bd devstack: add pci-sim fake SR-IOV PCI passthrough test fixture
Testing Cyborg's pci_driver and Nova PCI passthrough normally requires
physical SR-IOV hardware. This change introduces pci-sim, an out-of-tree
Linux kernel module (fake_pci_sriov) that creates fake SR-IOV PCI devices
whose virtual functions can be bound to VFIO and assigned to QEMU guests.
This makes it possible to exercise the full Nova and Cyborg PCI passthrough
control plane, including device enumeration, VF assignment, and VFIO
passthrough to CirrOS guests, in a standard devstack VM with no physical
SR-IOV hardware present.

pci-sim/
  Source for the fake_pci_sriov out-of-tree kernel module. The module
  creates one fake PCI host bridge per PF, each with software-emulated
  VFs backed by a 16550-style UART loopback payload. Build artifacts are
  excluded via .gitignore. The directory is excluded from Python wheels
  and sdists via [tool.setuptools.packages.find].

devstack/
  lib/pci_sim provides functions to build, load, configure, and unload
  the module. All paths are expressed relative to CYBORG_DIR so they
  resolve correctly within the cyborg checkout.

  devstack/settings gains a new ENABLE_PCI_SIM master toggle
  (default False) and the full set of PCI_SIM_* variables to control
  the fake PCI topology and service integration.
  PCI_SIM_CONFIGURE_NOVA_PCI and PCI_SIM_CONFIGURE_CYBORG_PCI are both
  defaulted to ENABLE_PCI_SIM but provide a explicy opt out if required.

  plugin.sh drives the pci-sim lifecycle alongside cyborg's own phases.
  The pci-sim cyborg service configuration is applied before start_cyborg
  in the extra phase so the agent picks up pci_driver and
  passthrough_whitelist on first start.

  devstack/local-conf.pci-sim.sample provides a ready-to-use local.conf
  for a two-PF, four-VF-per-PF topology with both Nova and Cyborg
  integrations enabled.

tools/
  check-kernel-config.sh validates the running kernel's config against
  the requirements for fake_pci_sriov before attempting a build.
  run-devstack-serial-echo-test.sh creates test VMs using the pci-sim
  flavors and validates the UART echo path inside a CirrOS guest.

doc/source/contributor/pci-sim/
  New contributor documentation covering build instructions, devstack
  setup, plugin settings, testing procedures, and kernel config
  requirements. Linked from the contributor index.

Assisted-By: pi gpt-5.5
Assisted-By: pi sonnet-4.6
Change-Id: I14dba5d0de833c9f2df28478daacbf8250de2127
Signed-off-by: Sean Mooney <work@seanmooney.info>
2026-06-15 10:49:23 +01:00

89 lines
3.3 KiB
Bash

# plugin.sh - devstack plugin for cyborg
# devstack plugin contract defined at:
# https://docs.openstack.org/devstack/latest/plugins.html
echo_summary "cyborg devstack plugin.sh called: $1/$2"
CYBORG_DEVSTACK_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
source $CYBORG_DEVSTACK_DIR/lib/cyborg
source $CYBORG_DEVSTACK_DIR/lib/pci_sim
case $1 in
"stack")
case $2 in
"pre-install")
clone_cyborg_client
;;
"install")
echo_summary "Installing Cyborg"
install_cyborg
install_cyborg_client
if [[ "$ENABLE_PCI_SIM" == True ]]; then
install_package pciutils
if [[ "$PCI_SIM_BUILD" == True ]]; then
async_runfunc build_pci_sim
fi
fi
;;
"post-config")
# stack/post-config - Called after the layer 0 and 2 services
# have been configured. All configuration files for enabled
# services should exist at this point.
echo_summary "Configuring Cyborg"
configure_cyborg
create_cyborg_accounts
if [[ "$ENABLE_PCI_SIM" == True ]]; then
if [[ "$PCI_SIM_BUILD" == True ]]; then
async_wait build_pci_sim
fi
if [[ "$PCI_SIM_LOAD" == True ]]; then
load_pci_sim
configure_pci_sim_vfs
configure_pci_sim_nova_service_config
fi
fi
;;
"extra")
# stack/extra - Called near the end after layer 1 and 2
# services have been started.
# Configure pci-sim Cyborg service settings before starting
# the agent so it picks up pci_driver and passthrough_whitelist.
if [[ "$ENABLE_PCI_SIM" == True && "$PCI_SIM_LOAD" == True ]]; then
configure_pci_sim_cyborg_service_config
fi
# Initialize cyborg
init_cyborg
# Start the cyborg API and cyborg taskmgr components
echo_summary "Starting Cyborg"
start_cyborg
;;
"test-config")
# stack/test-config - Called at the end of devstack used to configure tempest
# or any other test environments
if is_service_enabled tempest; then
echo_summary "Configuring Tempest for Cyborg needs"
cyborg_configure_tempest
fi
if [[ "$ENABLE_PCI_SIM" == True ]]; then
create_pci_sim_test_resources
fi
;;
esac
;;
"unstack")
# unstack - Called by unstack.sh before other services are shut down.
stop_cyborg
if [[ "$ENABLE_PCI_SIM" == True ]]; then
unload_pci_sim || true
fi
;;
"clean")
# clean - Called by clean.sh before other services are cleaned, but after
# unstack.sh has been called.
cleanup_cyborg
if [[ "$ENABLE_PCI_SIM" == True ]]; then
unload_pci_sim || true
fi
;;
esac