diff --git a/src/runtime/cmd/kata-runtime/kata-env.go b/src/runtime/cmd/kata-runtime/kata-env.go index d87e426bf5..f74cb9f89c 100644 --- a/src/runtime/cmd/kata-runtime/kata-env.go +++ b/src/runtime/cmd/kata-runtime/kata-env.go @@ -113,8 +113,6 @@ type HypervisorInfo struct { SocketPath string Msize9p uint32 MemorySlots uint32 - PCIeRootPort uint32 - PCIeSwitchPort uint32 HotPlugVFIO config.PCIePort ColdPlugVFIO config.PCIePort HotplugVFIOOnRootBus bool @@ -322,8 +320,6 @@ func getHypervisorInfo(config oci.RuntimeConfig) (HypervisorInfo, error) { HotPlugVFIO: config.HypervisorConfig.HotPlugVFIO, ColdPlugVFIO: config.HypervisorConfig.ColdPlugVFIO, HotplugVFIOOnRootBus: config.HypervisorConfig.HotplugVFIOOnRootBus, - PCIeRootPort: config.HypervisorConfig.PCIeRootPort, - PCIeSwitchPort: config.HypervisorConfig.PCIeSwitchPort, SocketPath: socketPath, }, nil } diff --git a/src/runtime/cmd/kata-runtime/kata-env_test.go b/src/runtime/cmd/kata-runtime/kata-env_test.go index 4de2fb09ef..c8d4d0ea9f 100644 --- a/src/runtime/cmd/kata-runtime/kata-env_test.go +++ b/src/runtime/cmd/kata-runtime/kata-env_test.go @@ -88,8 +88,6 @@ func makeRuntimeConfig(prefixDir string) (configFile string, ociConfig oci.Runti blockStorageDriver := "virtio-scsi" enableIOThreads := true hotplugVFIOOnRootBus := true - pcieRootPort := uint32(2) - pcieSwitchPort := uint32(2) hotPlugVFIO = config.BridgePort coldPlugVFIO = config.NoPort disableNewNetNs := false @@ -137,8 +135,6 @@ func makeRuntimeConfig(prefixDir string) (configFile string, ociConfig oci.Runti HotplugVFIOOnRootBus: hotplugVFIOOnRootBus, HotPlugVFIO: hotPlugVFIO, ColdPlugVFIO: coldPlugVFIO, - PCIeRootPort: pcieRootPort, - PCIeSwitchPort: pcieSwitchPort, DisableNewNetNs: disableNewNetNs, DefaultVCPUCount: hypConfig.NumVCPUs, DefaultMaxVCPUCount: hypConfig.DefaultMaxVCPUs, @@ -282,8 +278,6 @@ func getExpectedHypervisor(config oci.RuntimeConfig) HypervisorInfo { VirtioFSDaemon: config.HypervisorConfig.VirtioFSDaemon, HotplugVFIOOnRootBus: config.HypervisorConfig.HotplugVFIOOnRootBus, - PCIeRootPort: config.HypervisorConfig.PCIeRootPort, - PCIeSwitchPort: config.HypervisorConfig.PCIeSwitchPort, HotPlugVFIO: config.HypervisorConfig.HotPlugVFIO, ColdPlugVFIO: config.HypervisorConfig.ColdPlugVFIO, } diff --git a/src/runtime/pkg/containerd-shim-v2/create_test.go b/src/runtime/pkg/containerd-shim-v2/create_test.go index f95b501b31..c24e3ced3d 100644 --- a/src/runtime/pkg/containerd-shim-v2/create_test.go +++ b/src/runtime/pkg/containerd-shim-v2/create_test.go @@ -331,8 +331,6 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (runtimeConfig string, blockDeviceDriver := "virtio-scsi" enableIOThreads := true hotplugVFIOOnRootBus := true - pcieRootPort := uint32(2) - pcieSwitchPort := uint32(3) disableNewNetNs := false sharedFS := "virtio-9p" virtioFSdaemon := path.Join(dir, "virtiofsd") @@ -352,8 +350,6 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (runtimeConfig string, BlockDeviceDriver: blockDeviceDriver, EnableIOThreads: enableIOThreads, HotplugVFIOOnRootBus: hotplugVFIOOnRootBus, - PCIeRootPort: pcieRootPort, - PCIeSwitchPort: pcieSwitchPort, DisableNewNetNs: disableNewNetNs, SharedFS: sharedFS, VirtioFSDaemon: virtioFSdaemon, diff --git a/src/runtime/pkg/govmm/qemu/qemu.go b/src/runtime/pkg/govmm/qemu/qemu.go index 7b4b9037f8..453012169f 100644 --- a/src/runtime/pkg/govmm/qemu/qemu.go +++ b/src/runtime/pkg/govmm/qemu/qemu.go @@ -244,6 +244,7 @@ const ( // SecExecGuest represents an s390x Secure Execution (Protected Virtualization in QEMU) object SecExecGuest ObjectType = "s390-pv-guest" + // PEFGuest represent ppc64le PEF(Protected Execution Facility) object. PEFGuest ObjectType = "pef-guest" ) @@ -377,7 +378,6 @@ func (object Object) QemuParams(config *Config) []string { deviceParams = append(deviceParams, string(object.Driver)) deviceParams = append(deviceParams, fmt.Sprintf("id=%s", object.DeviceID)) deviceParams = append(deviceParams, fmt.Sprintf("host-path=%s", object.File)) - } if len(deviceParams) > 0 { diff --git a/src/runtime/pkg/hypervisors/hypervisor_state.go b/src/runtime/pkg/hypervisors/hypervisor_state.go index db7e47c729..f0ba941deb 100644 --- a/src/runtime/pkg/hypervisors/hypervisor_state.go +++ b/src/runtime/pkg/hypervisors/hypervisor_state.go @@ -45,8 +45,6 @@ type HypervisorState struct { HotpluggedMemory int VirtiofsDaemonPid int Pid int - PCIeRootPort int - PCIeSwitchPort int HotPlugVFIO config.PCIePort ColdPlugVFIO config.PCIePort HotplugVFIOOnRootBus bool diff --git a/src/runtime/pkg/katatestutils/utils.go b/src/runtime/pkg/katatestutils/utils.go index bd76ae9a8b..ec1d85c3ac 100644 --- a/src/runtime/pkg/katatestutils/utils.go +++ b/src/runtime/pkg/katatestutils/utils.go @@ -224,8 +224,6 @@ type RuntimeConfigOptions struct { JaegerUser string JaegerPassword string PFlash []string - PCIeRootPort uint32 - PCIeSwitchPort uint32 HotPlugVFIO config.PCIePort ColdPlugVFIO config.PCIePort DefaultVCPUCount uint32 @@ -320,8 +318,6 @@ func MakeRuntimeConfigFileData(config RuntimeConfigOptions) string { disable_block_device_use = ` + strconv.FormatBool(config.DisableBlock) + ` enable_iothreads = ` + strconv.FormatBool(config.EnableIOThreads) + ` hotplug_vfio_on_root_bus = ` + strconv.FormatBool(config.HotplugVFIOOnRootBus) + ` - pcie_root_port = ` + strconv.FormatUint(uint64(config.PCIeRootPort), 10) + ` - pcie_switch_port = ` + strconv.FormatUint(uint64(config.PCIeSwitchPort), 10) + ` cold_plug_vfio = "` + config.ColdPlugVFIO.String() + `" msize_9p = ` + strconv.FormatUint(uint64(config.DefaultMsize9p), 10) + ` enable_debug = ` + strconv.FormatBool(config.HypervisorDebug) + ` diff --git a/src/runtime/pkg/katautils/config-settings.go.in b/src/runtime/pkg/katautils/config-settings.go.in index f3ce570aa3..d662f910f0 100644 --- a/src/runtime/pkg/katautils/config-settings.go.in +++ b/src/runtime/pkg/katautils/config-settings.go.in @@ -82,8 +82,6 @@ const defaultEnableDebug bool = false const defaultDisableNestingChecks bool = false const defaultMsize9p uint32 = 8192 const defaultHotplugVFIOOnRootBus bool = false -const defaultPCIeRootPort = 0 -const defaultPCIeSwitchPort = 0 const defaultEntropySource = "/dev/urandom" const defaultGuestHookPath string = "" const defaultVirtioFSCacheMode = "never" diff --git a/src/runtime/pkg/katautils/config.go b/src/runtime/pkg/katautils/config.go index d34ede93b6..297c7ca56a 100644 --- a/src/runtime/pkg/katautils/config.go +++ b/src/runtime/pkg/katautils/config.go @@ -130,8 +130,6 @@ type hypervisor struct { MemSlots uint32 `toml:"memory_slots"` DefaultBridges uint32 `toml:"default_bridges"` Msize9p uint32 `toml:"msize_9p"` - PCIeSwitchPort uint32 `toml:"pcie_switch_port"` - PCIeRootPort uint32 `toml:"pcie_root_port"` NumVCPUs int32 `toml:"default_vcpus"` BlockDeviceCacheSet bool `toml:"block_device_cache_set"` BlockDeviceCacheDirect bool `toml:"block_device_cache_direct"` @@ -872,8 +870,6 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) { HotplugVFIOOnRootBus: h.HotplugVFIOOnRootBus, HotPlugVFIO: h.hotPlugVFIO(), ColdPlugVFIO: h.coldPlugVFIO(), - PCIeRootPort: h.PCIeRootPort, - PCIeSwitchPort: h.PCIeSwitchPort, DisableVhostNet: h.DisableVhostNet, EnableVhostUserStore: h.EnableVhostUserStore, VhostUserStorePath: h.vhostUserStorePath(), @@ -1069,8 +1065,6 @@ func newClhHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) { HotplugVFIOOnRootBus: h.HotplugVFIOOnRootBus, ColdPlugVFIO: h.coldPlugVFIO(), HotPlugVFIO: h.hotPlugVFIO(), - PCIeRootPort: h.PCIeRootPort, - PCIeSwitchPort: h.PCIeSwitchPort, DisableVhostNet: true, GuestHookPath: h.guestHookPath(), VirtioFSExtraArgs: h.VirtioFSExtraArgs, @@ -1302,8 +1296,6 @@ func GetDefaultHypervisorConfig() vc.HypervisorConfig { HotplugVFIOOnRootBus: defaultHotplugVFIOOnRootBus, ColdPlugVFIO: defaultColdPlugVFIO, HotPlugVFIO: defaultHotPlugVFIO, - PCIeSwitchPort: defaultPCIeSwitchPort, - PCIeRootPort: defaultPCIeRootPort, GuestHookPath: defaultGuestHookPath, VhostUserStorePath: defaultVhostUserStorePath, VhostUserDeviceReconnect: defaultVhostUserDeviceReconnect, @@ -1698,6 +1690,9 @@ func checkPCIeConfig(coldPlug config.PCIePort, hotPlug config.PCIePort, machineT if coldPlug != config.NoPort && hotPlug != config.NoPort { return fmt.Errorf("invalid hot-plug=%s and cold-plug=%s settings, only one of them can be set", coldPlug, hotPlug) } + if coldPlug == config.NoPort && hotPlug == config.NoPort { + return nil + } var port config.PCIePort if coldPlug != config.NoPort { port = coldPlug diff --git a/src/runtime/pkg/katautils/config_test.go b/src/runtime/pkg/katautils/config_test.go index 2f062bd08a..9ebdc7d57c 100644 --- a/src/runtime/pkg/katautils/config_test.go +++ b/src/runtime/pkg/katautils/config_test.go @@ -86,8 +86,6 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (testConfig testRuntime blockDeviceAIO := "io_uring" enableIOThreads := true hotplugVFIOOnRootBus := true - pcieRootPort := uint32(2) - pcieSwitchPort := uint32(3) hotPlugVFIO = config.BridgePort coldPlugVFIO = config.RootPort disableNewNetNs := false @@ -111,8 +109,6 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (testConfig testRuntime BlockDeviceAIO: blockDeviceAIO, EnableIOThreads: enableIOThreads, HotplugVFIOOnRootBus: hotplugVFIOOnRootBus, - PCIeRootPort: pcieRootPort, - PCIeSwitchPort: pcieSwitchPort, HotPlugVFIO: hotPlugVFIO, ColdPlugVFIO: coldPlugVFIO, DisableNewNetNs: disableNewNetNs, @@ -177,8 +173,6 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (testConfig testRuntime DefaultBridges: defaultBridgesCount, EnableIOThreads: enableIOThreads, HotplugVFIOOnRootBus: hotplugVFIOOnRootBus, - PCIeRootPort: pcieRootPort, - PCIeSwitchPort: pcieSwitchPort, HotPlugVFIO: hotPlugVFIO, ColdPlugVFIO: coldPlugVFIO, Msize9p: defaultMsize9p, @@ -618,7 +612,6 @@ func TestNewQemuHypervisorConfig(t *testing.T) { disableBlock := true enableIOThreads := true hotplugVFIOOnRootBus := true - pcieRootPort := uint32(2) coldPlugVFIO = config.RootPort orgVHostVSockDevicePath := utils.VHostVSockDevicePath blockDeviceAIO := "io_uring" @@ -638,7 +631,6 @@ func TestNewQemuHypervisorConfig(t *testing.T) { DisableBlockDeviceUse: disableBlock, EnableIOThreads: enableIOThreads, HotplugVFIOOnRootBus: hotplugVFIOOnRootBus, - PCIeRootPort: pcieRootPort, ColdPlugVFIO: coldPlugVFIO, RxRateLimiterMaxRate: rxRateLimiterMaxRate, TxRateLimiterMaxRate: txRateLimiterMaxRate, @@ -694,10 +686,6 @@ func TestNewQemuHypervisorConfig(t *testing.T) { t.Errorf("Expected value for HotplugVFIOOnRootBus %v, got %v", hotplugVFIOOnRootBus, config.HotplugVFIOOnRootBus) } - if config.PCIeRootPort != pcieRootPort { - t.Errorf("Expected value for PCIeRootPort %v, got %v", pcieRootPort, config.PCIeRootPort) - } - if config.RxRateLimiterMaxRate != rxRateLimiterMaxRate { t.Errorf("Expected value for rx rate limiter %v, got %v", rxRateLimiterMaxRate, config.RxRateLimiterMaxRate) } @@ -820,7 +808,6 @@ func TestNewQemuHypervisorConfigImageAndInitrd(t *testing.T) { disableBlock := true enableIOThreads := true hotplugVFIOOnRootBus := true - pcieRootPort := uint32(2) hypervisor := hypervisor{ Path: hypervisorPath, @@ -831,7 +818,6 @@ func TestNewQemuHypervisorConfigImageAndInitrd(t *testing.T) { DisableBlockDeviceUse: disableBlock, EnableIOThreads: enableIOThreads, HotplugVFIOOnRootBus: hotplugVFIOOnRootBus, - PCIeRootPort: pcieRootPort, } _, err := newQemuHypervisorConfig(hypervisor) diff --git a/src/runtime/pkg/oci/utils.go b/src/runtime/pkg/oci/utils.go index ff5c1912b1..bcbf30f8f7 100644 --- a/src/runtime/pkg/oci/utils.go +++ b/src/runtime/pkg/oci/utils.go @@ -508,12 +508,6 @@ func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig, return err } - if err := newAnnotationConfiguration(ocispec, vcAnnotations.PCIeRootPort).setUint(func(pcieRootPort uint64) { - config.HypervisorConfig.PCIeRootPort = uint32(pcieRootPort) - }); err != nil { - return err - } - if value, ok := ocispec.Annotations[vcAnnotations.EntropySource]; ok { if !checkPathIsInGlobs(runtime.HypervisorConfig.EntropySourceList, value) { return fmt.Errorf("entropy source %v required from annotation is not valid", value) diff --git a/src/runtime/virtcontainers/documentation/api/1.0/api.md b/src/runtime/virtcontainers/documentation/api/1.0/api.md index a26e653cee..ca5cb4a1ad 100644 --- a/src/runtime/virtcontainers/documentation/api/1.0/api.md +++ b/src/runtime/virtcontainers/documentation/api/1.0/api.md @@ -288,14 +288,6 @@ type HypervisorConfig struct { // root bus instead of a bridge. HotplugVFIOOnRootBus bool - // PCIeRootPort is used to indicate the number of PCIe Root Port devices - // The PCIe Root Port device is used to hot(cold)-plug the PCIe device - PCIeRootPort uint32 - - // PCIeSwitchPort is used to indicate the number of PCIe Switch Ports - // The PCIe Switch port is used to hot(cold)-plug the PCIe device - PCIeSwitchPort uint32 - // HotPlugVFIO is used to indicate if devices need to be hotplugged on the // root port, switch, bridge or no port HotPlugVFIO hv.PCIePort diff --git a/src/runtime/virtcontainers/hypervisor.go b/src/runtime/virtcontainers/hypervisor.go index 62a8d866f5..bb9c86b217 100644 --- a/src/runtime/virtcontainers/hypervisor.go +++ b/src/runtime/virtcontainers/hypervisor.go @@ -517,14 +517,6 @@ type HypervisorConfig struct { // root port, switch or no port ColdPlugVFIO config.PCIePort - // PCIeRootPort is used to indicate the number of PCIe Root Port devices - // The PCIe Root Port device is used to hot-plug the PCIe device - PCIeRootPort uint32 - - // PCIeSwitchPort is used to indicate the number of PCIe Switch devices - // The PCIe Switch Port device is sued to hot-plug PCIe devices - PCIeSwitchPort uint32 - // NumVCPUs specifies default number of vCPUs for the VM. NumVCPUs uint32 diff --git a/src/runtime/virtcontainers/persist.go b/src/runtime/virtcontainers/persist.go index 02cdc83875..91ab51ebfb 100644 --- a/src/runtime/virtcontainers/persist.go +++ b/src/runtime/virtcontainers/persist.go @@ -245,8 +245,6 @@ func (s *Sandbox) dumpConfig(ss *persistapi.SandboxState) { DisableNestingChecks: sconfig.HypervisorConfig.DisableNestingChecks, DisableImageNvdimm: sconfig.HypervisorConfig.DisableImageNvdimm, HotplugVFIOOnRootBus: sconfig.HypervisorConfig.HotplugVFIOOnRootBus, - PCIeRootPort: sconfig.HypervisorConfig.PCIeRootPort, - PCIeSwitchPort: sconfig.HypervisorConfig.PCIeSwitchPort, BootToBeTemplate: sconfig.HypervisorConfig.BootToBeTemplate, BootFromTemplate: sconfig.HypervisorConfig.BootFromTemplate, DisableVhostNet: sconfig.HypervisorConfig.DisableVhostNet, @@ -490,8 +488,6 @@ func loadSandboxConfig(id string) (*SandboxConfig, error) { HotplugVFIOOnRootBus: hconf.HotplugVFIOOnRootBus, HotPlugVFIO: hconf.HotPlugVFIO, ColdPlugVFIO: hconf.ColdPlugVFIO, - PCIeRootPort: hconf.PCIeRootPort, - PCIeSwitchPort: hconf.PCIeSwitchPort, BootToBeTemplate: hconf.BootToBeTemplate, BootFromTemplate: hconf.BootFromTemplate, DisableVhostNet: hconf.DisableVhostNet, diff --git a/src/runtime/virtcontainers/persist/api/config.go b/src/runtime/virtcontainers/persist/api/config.go index aeb347127c..6ca5ee6906 100644 --- a/src/runtime/virtcontainers/persist/api/config.go +++ b/src/runtime/virtcontainers/persist/api/config.go @@ -131,14 +131,6 @@ type HypervisorConfig struct { // Enable SGX. Hardware-based isolation and memory encryption. SGXEPCSize int64 - // PCIeRootPort is used to indicate the number of PCIe Root Port devices - // The PCIe Root Port device is used to hot-plug the PCIe device - PCIeRootPort uint32 - - // PCIeSwitchPort is used to indicate the number of PCIe Switch Downstream Port - // devices. The PCIe Switch Downstream Port is used to hot-plug the PCIe devices. - PCIeSwitchPort uint32 - // NumVCPUs specifies default number of vCPUs for the VM. NumVCPUs uint32 diff --git a/src/runtime/virtcontainers/pkg/annotations/annotations.go b/src/runtime/virtcontainers/pkg/annotations/annotations.go index 3584ccd70a..238ab28901 100644 --- a/src/runtime/virtcontainers/pkg/annotations/annotations.go +++ b/src/runtime/virtcontainers/pkg/annotations/annotations.go @@ -126,10 +126,6 @@ const ( // root bus instead of a bridge. HotplugVFIOOnRootBus = kataAnnotHypervisorPrefix + "hotplug_vfio_on_root_bus" - // PCIeRootPort is used to indicate the number of PCIe Root Port devices - // The PCIe Root Port device is used to hot-plug the PCIe device - PCIeRootPort = kataAnnotHypervisorPrefix + "pcie_root_port" - // EntropySource is a sandbox annotation to specify the path to a host source of // entropy (/dev/random, /dev/urandom or real hardware RNG device) EntropySource = kataAnnotHypervisorPrefix + "entropy_source" diff --git a/src/runtime/virtcontainers/qemu.go b/src/runtime/virtcontainers/qemu.go index c1cde33c57..685cc791b2 100644 --- a/src/runtime/virtcontainers/qemu.go +++ b/src/runtime/virtcontainers/qemu.go @@ -81,8 +81,6 @@ type QemuState struct { HotpluggedVCPUs []hv.CPUDevice HotpluggedMemory int VirtiofsDaemonPid int - PCIeRootPort int - PCIeSwitchPort int HotplugVFIOOnRootBus bool HotplugVFIO config.PCIePort ColdPlugVFIO config.PCIePort @@ -287,8 +285,6 @@ func (q *qemu) setup(ctx context.Context, id string, hypervisorConfig *Hyperviso q.state.HotPlugVFIO = q.config.HotPlugVFIO q.state.ColdPlugVFIO = q.config.ColdPlugVFIO q.state.HotplugVFIOOnRootBus = q.config.HotplugVFIOOnRootBus - q.state.PCIeRootPort = int(q.config.PCIeRootPort) - q.state.PCIeSwitchPort = int(q.config.PCIeSwitchPort) q.state.HotPlugVFIO = q.config.HotPlugVFIO // The path might already exist, but in case of VM templating, @@ -704,6 +700,7 @@ func (q *qemu) CreateVM(ctx context.Context, id string, network Network, hypervi return err } } + if machine.Type == QemuQ35 { if err := q.createPCIeTopology(&qemuConfig, hypervisorConfig); err != nil { q.Logger().WithError(err).Errorf("Cannot create PCIe topology") @@ -792,24 +789,13 @@ func (q *qemu) createPCIeTopology(qemuConfig *govmmQemu.Config, hypervisorConfig // use up all slots or IO memory on the root bus and vfio-XXX-pci devices // cannot be added which are crucial for Kata max slots on root bus is 32 // max slots on the complete pci(e) topology is 256 in QEMU - if hypervisorConfig.PCIeRootPort > maxPCIeRootPort { + if numOfPluggablePorts > maxPCIeRootPort { return fmt.Errorf("Number of PCIe Root Ports exceeed allowed max of %d", maxPCIeRootPort) } - if hypervisorConfig.PCIeSwitchPort > maxPCIeSwitchPort { + if numOfPluggablePorts > maxPCIeSwitchPort { return fmt.Errorf("Number of PCIe Switch Ports exceeed allowed max of %d", maxPCIeRootPort) } - // If the user provided more root ports than we have detected - // use the user provided number of PCIe root ports - if numOfPluggablePorts < hypervisorConfig.PCIeRootPort { - numOfPluggablePorts = hypervisorConfig.PCIeRootPort - } - // If the user provided more switch ports than we have detected - // use the user provided number of PCIe root ports - if numOfPluggablePorts < hypervisorConfig.PCIeSwitchPort { - numOfPluggablePorts = hypervisorConfig.PCIeSwitchPort - } - if q.state.HotPlugVFIO == config.RootPort || q.state.ColdPlugVFIO == config.RootPort || q.state.HotplugVFIOOnRootBus { qemuConfig.Devices = q.arch.appendPCIeRootPortDevice(qemuConfig.Devices, numOfPluggablePorts, memSize32bit, memSize64bit) } @@ -1616,8 +1602,8 @@ func (q *qemu) hotplugAddVhostUserBlkDevice(ctx context.Context, vAttr *config.V switch machineType { case QemuVirt: - if q.state.PCIeRootPort <= 0 { - return fmt.Errorf("Vhost-user-blk device is a PCIe device if machine type is virt. Need to add the PCIe Root Port by setting the pcie_root_port parameter in the configuration for virt") + if q.state.ColdPlugVFIO.String() != "true" { + return fmt.Errorf("TODO: Vhost-user-blk device is a PCIe device if machine type is virt. Need to add the PCIe Root Port by setting the pcie_root_port parameter in the configuration for virt") } //The addr of a dev is corresponding with device:function for PCIe in qemu which starting from 0 @@ -1811,26 +1797,10 @@ func (q *qemu) qomGetPciPath(qemuID string) (types.PciPath, error) { } func (q *qemu) hotplugVFIODeviceRootPort(ctx context.Context, device *config.VFIODev) (err error) { - - if device.IsPCIe && (q.state.PCIeRootPort <= 0) { - q.Logger().WithField("dev-id", device.ID).Warn("VFIO device is a PCIe device." + - "It's recommended to add the PCIe Root Port by setting the pcie_root_port parameter in the configuration for q35") - return fmt.Errorf("VFIO device is a PCIe device. Hotplug (%v) only supported on PCIe Root (%d) or PCIe Switch Ports (%v)", - q.state.HotPlugVFIO, q.state.PCIeRootPort, q.state.PCIeSwitchPort) - } - return q.executeVFIODeviceAdd(device) } func (q *qemu) hotplugVFIODeviceSwitchPort(ctx context.Context, device *config.VFIODev) (err error) { - - if device.IsPCIe && (q.state.PCIeSwitchPort <= 0) { - q.Logger().WithField("dev-id", device.ID).Warn("VFIO device is a PCIe device." + - "It's recommended to add the PCIe Switch Port by setting the pcie_switch_port parameter in the configuration for q35") - return fmt.Errorf("VFIO device is a PCIe device. Hotplug (%v) only supported on PCIe Root (%d) or PCIe Switch Ports (%v)", - q.state.HotPlugVFIO, q.state.PCIeRootPort, q.state.PCIeSwitchPort) - } - return q.executeVFIODeviceAdd(device) } @@ -1882,11 +1852,9 @@ func (q *qemu) hotplugVFIODevice(ctx context.Context, device *config.VFIODev, op if op == AddDevice { buf, _ := json.Marshal(device) q.Logger().WithFields(logrus.Fields{ - "machine-type": q.HypervisorConfig().HypervisorMachineType, - "hot-plug-vfio": q.state.HotPlugVFIO, - "pcie-root-port": q.state.PCIeRootPort, - "pcie-switch-port": q.state.PCIeSwitchPort, - "device-info": string(buf), + "machine-type": q.HypervisorConfig().HypervisorMachineType, + "hot-plug-vfio": q.state.HotPlugVFIO, + "device-info": string(buf), }).Info("Start hot-plug VFIO device") // In case MachineType is q35, a PCIe device is hotplugged on // a PCIe Root Port or alternatively on a PCIe Switch Port @@ -2887,8 +2855,6 @@ func (q *qemu) Save() (s hv.HypervisorState) { s.UUID = q.state.UUID s.HotpluggedMemory = q.state.HotpluggedMemory s.HotplugVFIOOnRootBus = q.state.HotplugVFIOOnRootBus - s.PCIeRootPort = q.state.PCIeRootPort - s.PCIeSwitchPort = q.state.PCIeSwitchPort for _, bridge := range q.arch.getBridges() { s.Bridges = append(s.Bridges, hv.Bridge{ @@ -2912,8 +2878,6 @@ func (q *qemu) Load(s hv.HypervisorState) { q.state.HotpluggedMemory = s.HotpluggedMemory q.state.HotplugVFIOOnRootBus = s.HotplugVFIOOnRootBus q.state.VirtiofsDaemonPid = s.VirtiofsDaemonPid - q.state.PCIeRootPort = s.PCIeRootPort - q.state.PCIeSwitchPort = s.PCIeSwitchPort for _, bridge := range s.Bridges { q.state.Bridges = append(q.state.Bridges, types.NewBridge(types.Type(bridge.Type), bridge.ID, bridge.DeviceAddr, bridge.Addr)) diff --git a/src/runtime/virtcontainers/qemu_amd64.go b/src/runtime/virtcontainers/qemu_amd64.go index cb99ec1ace..7efb5c7538 100644 --- a/src/runtime/virtcontainers/qemu_amd64.go +++ b/src/runtime/virtcontainers/qemu_amd64.go @@ -305,6 +305,7 @@ func (q *qemuAmd64) appendProtectionDevice(devices []govmmQemu.Device, firmware, ReducedPhysBits: 1, }), "", nil case noneProtection: + return devices, firmware, nil default: