From 0a918d0d20d0f2fea05fc94a0a59d7af3ebf6b67 Mon Sep 17 00:00:00 2001 From: Jeremi Piotrowski Date: Wed, 30 Aug 2023 15:32:14 +0200 Subject: [PATCH] runtime: Check config for supported CLH (cold|hot)_plug_vfio values The only supported options are hot_plug_vfio=root-port or no-port. cold_plug_vfio not supported yet. Signed-off-by: Jeremi Piotrowski (cherry picked from commit fc51e4b9eb2d0d99aa224e2cb6805be7af3e9d67) --- src/runtime/pkg/katautils/config.go | 12 ++++++++++-- src/runtime/virtcontainers/clh_test.go | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/runtime/pkg/katautils/config.go b/src/runtime/pkg/katautils/config.go index f577df5263..0a2c8022c0 100644 --- a/src/runtime/pkg/katautils/config.go +++ b/src/runtime/pkg/katautils/config.go @@ -1680,8 +1680,8 @@ func checkConfig(config oci.RuntimeConfig) error { // Only allow one of the following settings for cold-plug: // no-port, root-port, switch-port func checkPCIeConfig(coldPlug config.PCIePort, hotPlug config.PCIePort, machineType string, hypervisorType virtcontainers.HypervisorType) error { - if hypervisorType != virtcontainers.QemuHypervisor { - kataUtilsLogger.Warn("Advanced PCIe Topology only available for QEMU hypervisor, ignoring hot(cold)_vfio_port setting") + if hypervisorType != virtcontainers.QemuHypervisor && hypervisorType != virtcontainers.ClhHypervisor { + kataUtilsLogger.Warn("Advanced PCIe Topology only available for QEMU/CLH hypervisor, ignoring hot(cold)_vfio_port setting") return nil } @@ -1696,6 +1696,14 @@ func checkPCIeConfig(coldPlug config.PCIePort, hotPlug config.PCIePort, machineT if machineType != "q35" && machineType != "virt" { return nil } + if hypervisorType == virtcontainers.ClhHypervisor { + if coldPlug != config.NoPort { + return fmt.Errorf("cold-plug not supported on CLH") + } + if hotPlug != config.RootPort { + return fmt.Errorf("only hot-plug=%s supported on CLH", config.RootPort) + } + } var port config.PCIePort if coldPlug != config.NoPort { diff --git a/src/runtime/virtcontainers/clh_test.go b/src/runtime/virtcontainers/clh_test.go index d617ab4e1c..c141adfd91 100644 --- a/src/runtime/virtcontainers/clh_test.go +++ b/src/runtime/virtcontainers/clh_test.go @@ -68,6 +68,7 @@ func newClhConfig() (HypervisorConfig, error) { NetRateLimiterBwOneTimeBurst: int64(0), NetRateLimiterOpsMaxRate: int64(0), NetRateLimiterOpsOneTimeBurst: int64(0), + HotPlugVFIO: config.NoPort, }, nil }