mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-19 12:14:11 +00:00
vfio: Cleanup of Cold and Hot Plug
Removed the configuration of PCIeRootPort and PCIeSwitchPort, those values can be deduced in createPCIeTopology Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
This commit is contained in:
parent
b5c4677e0e
commit
8f0d4e2612
@ -113,8 +113,6 @@ type HypervisorInfo struct {
|
|||||||
SocketPath string
|
SocketPath string
|
||||||
Msize9p uint32
|
Msize9p uint32
|
||||||
MemorySlots uint32
|
MemorySlots uint32
|
||||||
PCIeRootPort uint32
|
|
||||||
PCIeSwitchPort uint32
|
|
||||||
HotPlugVFIO config.PCIePort
|
HotPlugVFIO config.PCIePort
|
||||||
ColdPlugVFIO config.PCIePort
|
ColdPlugVFIO config.PCIePort
|
||||||
HotplugVFIOOnRootBus bool
|
HotplugVFIOOnRootBus bool
|
||||||
@ -322,8 +320,6 @@ func getHypervisorInfo(config oci.RuntimeConfig) (HypervisorInfo, error) {
|
|||||||
HotPlugVFIO: config.HypervisorConfig.HotPlugVFIO,
|
HotPlugVFIO: config.HypervisorConfig.HotPlugVFIO,
|
||||||
ColdPlugVFIO: config.HypervisorConfig.ColdPlugVFIO,
|
ColdPlugVFIO: config.HypervisorConfig.ColdPlugVFIO,
|
||||||
HotplugVFIOOnRootBus: config.HypervisorConfig.HotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: config.HypervisorConfig.HotplugVFIOOnRootBus,
|
||||||
PCIeRootPort: config.HypervisorConfig.PCIeRootPort,
|
|
||||||
PCIeSwitchPort: config.HypervisorConfig.PCIeSwitchPort,
|
|
||||||
SocketPath: socketPath,
|
SocketPath: socketPath,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,6 @@ func makeRuntimeConfig(prefixDir string) (configFile string, ociConfig oci.Runti
|
|||||||
blockStorageDriver := "virtio-scsi"
|
blockStorageDriver := "virtio-scsi"
|
||||||
enableIOThreads := true
|
enableIOThreads := true
|
||||||
hotplugVFIOOnRootBus := true
|
hotplugVFIOOnRootBus := true
|
||||||
pcieRootPort := uint32(2)
|
|
||||||
pcieSwitchPort := uint32(2)
|
|
||||||
hotPlugVFIO = config.BridgePort
|
hotPlugVFIO = config.BridgePort
|
||||||
coldPlugVFIO = config.NoPort
|
coldPlugVFIO = config.NoPort
|
||||||
disableNewNetNs := false
|
disableNewNetNs := false
|
||||||
@ -137,8 +135,6 @@ func makeRuntimeConfig(prefixDir string) (configFile string, ociConfig oci.Runti
|
|||||||
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
|
||||||
HotPlugVFIO: hotPlugVFIO,
|
HotPlugVFIO: hotPlugVFIO,
|
||||||
ColdPlugVFIO: coldPlugVFIO,
|
ColdPlugVFIO: coldPlugVFIO,
|
||||||
PCIeRootPort: pcieRootPort,
|
|
||||||
PCIeSwitchPort: pcieSwitchPort,
|
|
||||||
DisableNewNetNs: disableNewNetNs,
|
DisableNewNetNs: disableNewNetNs,
|
||||||
DefaultVCPUCount: hypConfig.NumVCPUs,
|
DefaultVCPUCount: hypConfig.NumVCPUs,
|
||||||
DefaultMaxVCPUCount: hypConfig.DefaultMaxVCPUs,
|
DefaultMaxVCPUCount: hypConfig.DefaultMaxVCPUs,
|
||||||
@ -282,8 +278,6 @@ func getExpectedHypervisor(config oci.RuntimeConfig) HypervisorInfo {
|
|||||||
VirtioFSDaemon: config.HypervisorConfig.VirtioFSDaemon,
|
VirtioFSDaemon: config.HypervisorConfig.VirtioFSDaemon,
|
||||||
|
|
||||||
HotplugVFIOOnRootBus: config.HypervisorConfig.HotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: config.HypervisorConfig.HotplugVFIOOnRootBus,
|
||||||
PCIeRootPort: config.HypervisorConfig.PCIeRootPort,
|
|
||||||
PCIeSwitchPort: config.HypervisorConfig.PCIeSwitchPort,
|
|
||||||
HotPlugVFIO: config.HypervisorConfig.HotPlugVFIO,
|
HotPlugVFIO: config.HypervisorConfig.HotPlugVFIO,
|
||||||
ColdPlugVFIO: config.HypervisorConfig.ColdPlugVFIO,
|
ColdPlugVFIO: config.HypervisorConfig.ColdPlugVFIO,
|
||||||
}
|
}
|
||||||
|
@ -331,8 +331,6 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (runtimeConfig string,
|
|||||||
blockDeviceDriver := "virtio-scsi"
|
blockDeviceDriver := "virtio-scsi"
|
||||||
enableIOThreads := true
|
enableIOThreads := true
|
||||||
hotplugVFIOOnRootBus := true
|
hotplugVFIOOnRootBus := true
|
||||||
pcieRootPort := uint32(2)
|
|
||||||
pcieSwitchPort := uint32(3)
|
|
||||||
disableNewNetNs := false
|
disableNewNetNs := false
|
||||||
sharedFS := "virtio-9p"
|
sharedFS := "virtio-9p"
|
||||||
virtioFSdaemon := path.Join(dir, "virtiofsd")
|
virtioFSdaemon := path.Join(dir, "virtiofsd")
|
||||||
@ -352,8 +350,6 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (runtimeConfig string,
|
|||||||
BlockDeviceDriver: blockDeviceDriver,
|
BlockDeviceDriver: blockDeviceDriver,
|
||||||
EnableIOThreads: enableIOThreads,
|
EnableIOThreads: enableIOThreads,
|
||||||
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
|
||||||
PCIeRootPort: pcieRootPort,
|
|
||||||
PCIeSwitchPort: pcieSwitchPort,
|
|
||||||
DisableNewNetNs: disableNewNetNs,
|
DisableNewNetNs: disableNewNetNs,
|
||||||
SharedFS: sharedFS,
|
SharedFS: sharedFS,
|
||||||
VirtioFSDaemon: virtioFSdaemon,
|
VirtioFSDaemon: virtioFSdaemon,
|
||||||
|
@ -244,6 +244,7 @@ const (
|
|||||||
|
|
||||||
// SecExecGuest represents an s390x Secure Execution (Protected Virtualization in QEMU) object
|
// SecExecGuest represents an s390x Secure Execution (Protected Virtualization in QEMU) object
|
||||||
SecExecGuest ObjectType = "s390-pv-guest"
|
SecExecGuest ObjectType = "s390-pv-guest"
|
||||||
|
|
||||||
// PEFGuest represent ppc64le PEF(Protected Execution Facility) object.
|
// PEFGuest represent ppc64le PEF(Protected Execution Facility) object.
|
||||||
PEFGuest ObjectType = "pef-guest"
|
PEFGuest ObjectType = "pef-guest"
|
||||||
)
|
)
|
||||||
@ -377,7 +378,6 @@ func (object Object) QemuParams(config *Config) []string {
|
|||||||
deviceParams = append(deviceParams, string(object.Driver))
|
deviceParams = append(deviceParams, string(object.Driver))
|
||||||
deviceParams = append(deviceParams, fmt.Sprintf("id=%s", object.DeviceID))
|
deviceParams = append(deviceParams, fmt.Sprintf("id=%s", object.DeviceID))
|
||||||
deviceParams = append(deviceParams, fmt.Sprintf("host-path=%s", object.File))
|
deviceParams = append(deviceParams, fmt.Sprintf("host-path=%s", object.File))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(deviceParams) > 0 {
|
if len(deviceParams) > 0 {
|
||||||
|
@ -45,8 +45,6 @@ type HypervisorState struct {
|
|||||||
HotpluggedMemory int
|
HotpluggedMemory int
|
||||||
VirtiofsDaemonPid int
|
VirtiofsDaemonPid int
|
||||||
Pid int
|
Pid int
|
||||||
PCIeRootPort int
|
|
||||||
PCIeSwitchPort int
|
|
||||||
HotPlugVFIO config.PCIePort
|
HotPlugVFIO config.PCIePort
|
||||||
ColdPlugVFIO config.PCIePort
|
ColdPlugVFIO config.PCIePort
|
||||||
HotplugVFIOOnRootBus bool
|
HotplugVFIOOnRootBus bool
|
||||||
|
@ -224,8 +224,6 @@ type RuntimeConfigOptions struct {
|
|||||||
JaegerUser string
|
JaegerUser string
|
||||||
JaegerPassword string
|
JaegerPassword string
|
||||||
PFlash []string
|
PFlash []string
|
||||||
PCIeRootPort uint32
|
|
||||||
PCIeSwitchPort uint32
|
|
||||||
HotPlugVFIO config.PCIePort
|
HotPlugVFIO config.PCIePort
|
||||||
ColdPlugVFIO config.PCIePort
|
ColdPlugVFIO config.PCIePort
|
||||||
DefaultVCPUCount uint32
|
DefaultVCPUCount uint32
|
||||||
@ -320,8 +318,6 @@ func MakeRuntimeConfigFileData(config RuntimeConfigOptions) string {
|
|||||||
disable_block_device_use = ` + strconv.FormatBool(config.DisableBlock) + `
|
disable_block_device_use = ` + strconv.FormatBool(config.DisableBlock) + `
|
||||||
enable_iothreads = ` + strconv.FormatBool(config.EnableIOThreads) + `
|
enable_iothreads = ` + strconv.FormatBool(config.EnableIOThreads) + `
|
||||||
hotplug_vfio_on_root_bus = ` + strconv.FormatBool(config.HotplugVFIOOnRootBus) + `
|
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() + `"
|
cold_plug_vfio = "` + config.ColdPlugVFIO.String() + `"
|
||||||
msize_9p = ` + strconv.FormatUint(uint64(config.DefaultMsize9p), 10) + `
|
msize_9p = ` + strconv.FormatUint(uint64(config.DefaultMsize9p), 10) + `
|
||||||
enable_debug = ` + strconv.FormatBool(config.HypervisorDebug) + `
|
enable_debug = ` + strconv.FormatBool(config.HypervisorDebug) + `
|
||||||
|
@ -82,8 +82,6 @@ const defaultEnableDebug bool = false
|
|||||||
const defaultDisableNestingChecks bool = false
|
const defaultDisableNestingChecks bool = false
|
||||||
const defaultMsize9p uint32 = 8192
|
const defaultMsize9p uint32 = 8192
|
||||||
const defaultHotplugVFIOOnRootBus bool = false
|
const defaultHotplugVFIOOnRootBus bool = false
|
||||||
const defaultPCIeRootPort = 0
|
|
||||||
const defaultPCIeSwitchPort = 0
|
|
||||||
const defaultEntropySource = "/dev/urandom"
|
const defaultEntropySource = "/dev/urandom"
|
||||||
const defaultGuestHookPath string = ""
|
const defaultGuestHookPath string = ""
|
||||||
const defaultVirtioFSCacheMode = "never"
|
const defaultVirtioFSCacheMode = "never"
|
||||||
|
@ -130,8 +130,6 @@ type hypervisor struct {
|
|||||||
MemSlots uint32 `toml:"memory_slots"`
|
MemSlots uint32 `toml:"memory_slots"`
|
||||||
DefaultBridges uint32 `toml:"default_bridges"`
|
DefaultBridges uint32 `toml:"default_bridges"`
|
||||||
Msize9p uint32 `toml:"msize_9p"`
|
Msize9p uint32 `toml:"msize_9p"`
|
||||||
PCIeSwitchPort uint32 `toml:"pcie_switch_port"`
|
|
||||||
PCIeRootPort uint32 `toml:"pcie_root_port"`
|
|
||||||
NumVCPUs int32 `toml:"default_vcpus"`
|
NumVCPUs int32 `toml:"default_vcpus"`
|
||||||
BlockDeviceCacheSet bool `toml:"block_device_cache_set"`
|
BlockDeviceCacheSet bool `toml:"block_device_cache_set"`
|
||||||
BlockDeviceCacheDirect bool `toml:"block_device_cache_direct"`
|
BlockDeviceCacheDirect bool `toml:"block_device_cache_direct"`
|
||||||
@ -872,8 +870,6 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
|
|||||||
HotplugVFIOOnRootBus: h.HotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: h.HotplugVFIOOnRootBus,
|
||||||
HotPlugVFIO: h.hotPlugVFIO(),
|
HotPlugVFIO: h.hotPlugVFIO(),
|
||||||
ColdPlugVFIO: h.coldPlugVFIO(),
|
ColdPlugVFIO: h.coldPlugVFIO(),
|
||||||
PCIeRootPort: h.PCIeRootPort,
|
|
||||||
PCIeSwitchPort: h.PCIeSwitchPort,
|
|
||||||
DisableVhostNet: h.DisableVhostNet,
|
DisableVhostNet: h.DisableVhostNet,
|
||||||
EnableVhostUserStore: h.EnableVhostUserStore,
|
EnableVhostUserStore: h.EnableVhostUserStore,
|
||||||
VhostUserStorePath: h.vhostUserStorePath(),
|
VhostUserStorePath: h.vhostUserStorePath(),
|
||||||
@ -1069,8 +1065,6 @@ func newClhHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
|
|||||||
HotplugVFIOOnRootBus: h.HotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: h.HotplugVFIOOnRootBus,
|
||||||
ColdPlugVFIO: h.coldPlugVFIO(),
|
ColdPlugVFIO: h.coldPlugVFIO(),
|
||||||
HotPlugVFIO: h.hotPlugVFIO(),
|
HotPlugVFIO: h.hotPlugVFIO(),
|
||||||
PCIeRootPort: h.PCIeRootPort,
|
|
||||||
PCIeSwitchPort: h.PCIeSwitchPort,
|
|
||||||
DisableVhostNet: true,
|
DisableVhostNet: true,
|
||||||
GuestHookPath: h.guestHookPath(),
|
GuestHookPath: h.guestHookPath(),
|
||||||
VirtioFSExtraArgs: h.VirtioFSExtraArgs,
|
VirtioFSExtraArgs: h.VirtioFSExtraArgs,
|
||||||
@ -1302,8 +1296,6 @@ func GetDefaultHypervisorConfig() vc.HypervisorConfig {
|
|||||||
HotplugVFIOOnRootBus: defaultHotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: defaultHotplugVFIOOnRootBus,
|
||||||
ColdPlugVFIO: defaultColdPlugVFIO,
|
ColdPlugVFIO: defaultColdPlugVFIO,
|
||||||
HotPlugVFIO: defaultHotPlugVFIO,
|
HotPlugVFIO: defaultHotPlugVFIO,
|
||||||
PCIeSwitchPort: defaultPCIeSwitchPort,
|
|
||||||
PCIeRootPort: defaultPCIeRootPort,
|
|
||||||
GuestHookPath: defaultGuestHookPath,
|
GuestHookPath: defaultGuestHookPath,
|
||||||
VhostUserStorePath: defaultVhostUserStorePath,
|
VhostUserStorePath: defaultVhostUserStorePath,
|
||||||
VhostUserDeviceReconnect: defaultVhostUserDeviceReconnect,
|
VhostUserDeviceReconnect: defaultVhostUserDeviceReconnect,
|
||||||
@ -1698,6 +1690,9 @@ func checkPCIeConfig(coldPlug config.PCIePort, hotPlug config.PCIePort, machineT
|
|||||||
if coldPlug != config.NoPort && hotPlug != config.NoPort {
|
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)
|
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
|
var port config.PCIePort
|
||||||
if coldPlug != config.NoPort {
|
if coldPlug != config.NoPort {
|
||||||
port = coldPlug
|
port = coldPlug
|
||||||
|
@ -86,8 +86,6 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (testConfig testRuntime
|
|||||||
blockDeviceAIO := "io_uring"
|
blockDeviceAIO := "io_uring"
|
||||||
enableIOThreads := true
|
enableIOThreads := true
|
||||||
hotplugVFIOOnRootBus := true
|
hotplugVFIOOnRootBus := true
|
||||||
pcieRootPort := uint32(2)
|
|
||||||
pcieSwitchPort := uint32(3)
|
|
||||||
hotPlugVFIO = config.BridgePort
|
hotPlugVFIO = config.BridgePort
|
||||||
coldPlugVFIO = config.RootPort
|
coldPlugVFIO = config.RootPort
|
||||||
disableNewNetNs := false
|
disableNewNetNs := false
|
||||||
@ -111,8 +109,6 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (testConfig testRuntime
|
|||||||
BlockDeviceAIO: blockDeviceAIO,
|
BlockDeviceAIO: blockDeviceAIO,
|
||||||
EnableIOThreads: enableIOThreads,
|
EnableIOThreads: enableIOThreads,
|
||||||
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
|
||||||
PCIeRootPort: pcieRootPort,
|
|
||||||
PCIeSwitchPort: pcieSwitchPort,
|
|
||||||
HotPlugVFIO: hotPlugVFIO,
|
HotPlugVFIO: hotPlugVFIO,
|
||||||
ColdPlugVFIO: coldPlugVFIO,
|
ColdPlugVFIO: coldPlugVFIO,
|
||||||
DisableNewNetNs: disableNewNetNs,
|
DisableNewNetNs: disableNewNetNs,
|
||||||
@ -177,8 +173,6 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (testConfig testRuntime
|
|||||||
DefaultBridges: defaultBridgesCount,
|
DefaultBridges: defaultBridgesCount,
|
||||||
EnableIOThreads: enableIOThreads,
|
EnableIOThreads: enableIOThreads,
|
||||||
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
|
||||||
PCIeRootPort: pcieRootPort,
|
|
||||||
PCIeSwitchPort: pcieSwitchPort,
|
|
||||||
HotPlugVFIO: hotPlugVFIO,
|
HotPlugVFIO: hotPlugVFIO,
|
||||||
ColdPlugVFIO: coldPlugVFIO,
|
ColdPlugVFIO: coldPlugVFIO,
|
||||||
Msize9p: defaultMsize9p,
|
Msize9p: defaultMsize9p,
|
||||||
@ -618,7 +612,6 @@ func TestNewQemuHypervisorConfig(t *testing.T) {
|
|||||||
disableBlock := true
|
disableBlock := true
|
||||||
enableIOThreads := true
|
enableIOThreads := true
|
||||||
hotplugVFIOOnRootBus := true
|
hotplugVFIOOnRootBus := true
|
||||||
pcieRootPort := uint32(2)
|
|
||||||
coldPlugVFIO = config.RootPort
|
coldPlugVFIO = config.RootPort
|
||||||
orgVHostVSockDevicePath := utils.VHostVSockDevicePath
|
orgVHostVSockDevicePath := utils.VHostVSockDevicePath
|
||||||
blockDeviceAIO := "io_uring"
|
blockDeviceAIO := "io_uring"
|
||||||
@ -638,7 +631,6 @@ func TestNewQemuHypervisorConfig(t *testing.T) {
|
|||||||
DisableBlockDeviceUse: disableBlock,
|
DisableBlockDeviceUse: disableBlock,
|
||||||
EnableIOThreads: enableIOThreads,
|
EnableIOThreads: enableIOThreads,
|
||||||
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
|
||||||
PCIeRootPort: pcieRootPort,
|
|
||||||
ColdPlugVFIO: coldPlugVFIO,
|
ColdPlugVFIO: coldPlugVFIO,
|
||||||
RxRateLimiterMaxRate: rxRateLimiterMaxRate,
|
RxRateLimiterMaxRate: rxRateLimiterMaxRate,
|
||||||
TxRateLimiterMaxRate: txRateLimiterMaxRate,
|
TxRateLimiterMaxRate: txRateLimiterMaxRate,
|
||||||
@ -694,10 +686,6 @@ func TestNewQemuHypervisorConfig(t *testing.T) {
|
|||||||
t.Errorf("Expected value for HotplugVFIOOnRootBus %v, got %v", hotplugVFIOOnRootBus, config.HotplugVFIOOnRootBus)
|
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 {
|
if config.RxRateLimiterMaxRate != rxRateLimiterMaxRate {
|
||||||
t.Errorf("Expected value for rx rate limiter %v, got %v", rxRateLimiterMaxRate, config.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
|
disableBlock := true
|
||||||
enableIOThreads := true
|
enableIOThreads := true
|
||||||
hotplugVFIOOnRootBus := true
|
hotplugVFIOOnRootBus := true
|
||||||
pcieRootPort := uint32(2)
|
|
||||||
|
|
||||||
hypervisor := hypervisor{
|
hypervisor := hypervisor{
|
||||||
Path: hypervisorPath,
|
Path: hypervisorPath,
|
||||||
@ -831,7 +818,6 @@ func TestNewQemuHypervisorConfigImageAndInitrd(t *testing.T) {
|
|||||||
DisableBlockDeviceUse: disableBlock,
|
DisableBlockDeviceUse: disableBlock,
|
||||||
EnableIOThreads: enableIOThreads,
|
EnableIOThreads: enableIOThreads,
|
||||||
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
|
||||||
PCIeRootPort: pcieRootPort,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := newQemuHypervisorConfig(hypervisor)
|
_, err := newQemuHypervisorConfig(hypervisor)
|
||||||
|
@ -508,12 +508,6 @@ func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig,
|
|||||||
return err
|
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 value, ok := ocispec.Annotations[vcAnnotations.EntropySource]; ok {
|
||||||
if !checkPathIsInGlobs(runtime.HypervisorConfig.EntropySourceList, value) {
|
if !checkPathIsInGlobs(runtime.HypervisorConfig.EntropySourceList, value) {
|
||||||
return fmt.Errorf("entropy source %v required from annotation is not valid", value)
|
return fmt.Errorf("entropy source %v required from annotation is not valid", value)
|
||||||
|
@ -288,14 +288,6 @@ type HypervisorConfig struct {
|
|||||||
// root bus instead of a bridge.
|
// root bus instead of a bridge.
|
||||||
HotplugVFIOOnRootBus bool
|
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
|
// HotPlugVFIO is used to indicate if devices need to be hotplugged on the
|
||||||
// root port, switch, bridge or no port
|
// root port, switch, bridge or no port
|
||||||
HotPlugVFIO hv.PCIePort
|
HotPlugVFIO hv.PCIePort
|
||||||
|
@ -517,14 +517,6 @@ type HypervisorConfig struct {
|
|||||||
// root port, switch or no port
|
// root port, switch or no port
|
||||||
ColdPlugVFIO config.PCIePort
|
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 specifies default number of vCPUs for the VM.
|
||||||
NumVCPUs uint32
|
NumVCPUs uint32
|
||||||
|
|
||||||
|
@ -245,8 +245,6 @@ func (s *Sandbox) dumpConfig(ss *persistapi.SandboxState) {
|
|||||||
DisableNestingChecks: sconfig.HypervisorConfig.DisableNestingChecks,
|
DisableNestingChecks: sconfig.HypervisorConfig.DisableNestingChecks,
|
||||||
DisableImageNvdimm: sconfig.HypervisorConfig.DisableImageNvdimm,
|
DisableImageNvdimm: sconfig.HypervisorConfig.DisableImageNvdimm,
|
||||||
HotplugVFIOOnRootBus: sconfig.HypervisorConfig.HotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: sconfig.HypervisorConfig.HotplugVFIOOnRootBus,
|
||||||
PCIeRootPort: sconfig.HypervisorConfig.PCIeRootPort,
|
|
||||||
PCIeSwitchPort: sconfig.HypervisorConfig.PCIeSwitchPort,
|
|
||||||
BootToBeTemplate: sconfig.HypervisorConfig.BootToBeTemplate,
|
BootToBeTemplate: sconfig.HypervisorConfig.BootToBeTemplate,
|
||||||
BootFromTemplate: sconfig.HypervisorConfig.BootFromTemplate,
|
BootFromTemplate: sconfig.HypervisorConfig.BootFromTemplate,
|
||||||
DisableVhostNet: sconfig.HypervisorConfig.DisableVhostNet,
|
DisableVhostNet: sconfig.HypervisorConfig.DisableVhostNet,
|
||||||
@ -490,8 +488,6 @@ func loadSandboxConfig(id string) (*SandboxConfig, error) {
|
|||||||
HotplugVFIOOnRootBus: hconf.HotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: hconf.HotplugVFIOOnRootBus,
|
||||||
HotPlugVFIO: hconf.HotPlugVFIO,
|
HotPlugVFIO: hconf.HotPlugVFIO,
|
||||||
ColdPlugVFIO: hconf.ColdPlugVFIO,
|
ColdPlugVFIO: hconf.ColdPlugVFIO,
|
||||||
PCIeRootPort: hconf.PCIeRootPort,
|
|
||||||
PCIeSwitchPort: hconf.PCIeSwitchPort,
|
|
||||||
BootToBeTemplate: hconf.BootToBeTemplate,
|
BootToBeTemplate: hconf.BootToBeTemplate,
|
||||||
BootFromTemplate: hconf.BootFromTemplate,
|
BootFromTemplate: hconf.BootFromTemplate,
|
||||||
DisableVhostNet: hconf.DisableVhostNet,
|
DisableVhostNet: hconf.DisableVhostNet,
|
||||||
|
@ -131,14 +131,6 @@ type HypervisorConfig struct {
|
|||||||
// Enable SGX. Hardware-based isolation and memory encryption.
|
// Enable SGX. Hardware-based isolation and memory encryption.
|
||||||
SGXEPCSize int64
|
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 specifies default number of vCPUs for the VM.
|
||||||
NumVCPUs uint32
|
NumVCPUs uint32
|
||||||
|
|
||||||
|
@ -126,10 +126,6 @@ const (
|
|||||||
// root bus instead of a bridge.
|
// root bus instead of a bridge.
|
||||||
HotplugVFIOOnRootBus = kataAnnotHypervisorPrefix + "hotplug_vfio_on_root_bus"
|
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
|
// EntropySource is a sandbox annotation to specify the path to a host source of
|
||||||
// entropy (/dev/random, /dev/urandom or real hardware RNG device)
|
// entropy (/dev/random, /dev/urandom or real hardware RNG device)
|
||||||
EntropySource = kataAnnotHypervisorPrefix + "entropy_source"
|
EntropySource = kataAnnotHypervisorPrefix + "entropy_source"
|
||||||
|
@ -81,8 +81,6 @@ type QemuState struct {
|
|||||||
HotpluggedVCPUs []hv.CPUDevice
|
HotpluggedVCPUs []hv.CPUDevice
|
||||||
HotpluggedMemory int
|
HotpluggedMemory int
|
||||||
VirtiofsDaemonPid int
|
VirtiofsDaemonPid int
|
||||||
PCIeRootPort int
|
|
||||||
PCIeSwitchPort int
|
|
||||||
HotplugVFIOOnRootBus bool
|
HotplugVFIOOnRootBus bool
|
||||||
HotplugVFIO config.PCIePort
|
HotplugVFIO config.PCIePort
|
||||||
ColdPlugVFIO 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.HotPlugVFIO = q.config.HotPlugVFIO
|
||||||
q.state.ColdPlugVFIO = q.config.ColdPlugVFIO
|
q.state.ColdPlugVFIO = q.config.ColdPlugVFIO
|
||||||
q.state.HotplugVFIOOnRootBus = q.config.HotplugVFIOOnRootBus
|
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
|
q.state.HotPlugVFIO = q.config.HotPlugVFIO
|
||||||
|
|
||||||
// The path might already exist, but in case of VM templating,
|
// 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
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if machine.Type == QemuQ35 {
|
if machine.Type == QemuQ35 {
|
||||||
if err := q.createPCIeTopology(&qemuConfig, hypervisorConfig); err != nil {
|
if err := q.createPCIeTopology(&qemuConfig, hypervisorConfig); err != nil {
|
||||||
q.Logger().WithError(err).Errorf("Cannot create PCIe topology")
|
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
|
// 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
|
// 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
|
// 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)
|
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)
|
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 {
|
if q.state.HotPlugVFIO == config.RootPort || q.state.ColdPlugVFIO == config.RootPort || q.state.HotplugVFIOOnRootBus {
|
||||||
qemuConfig.Devices = q.arch.appendPCIeRootPortDevice(qemuConfig.Devices, numOfPluggablePorts, memSize32bit, memSize64bit)
|
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 {
|
switch machineType {
|
||||||
case QemuVirt:
|
case QemuVirt:
|
||||||
if q.state.PCIeRootPort <= 0 {
|
if q.state.ColdPlugVFIO.String() != "true" {
|
||||||
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")
|
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
|
//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) {
|
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)
|
return q.executeVFIODeviceAdd(device)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemu) hotplugVFIODeviceSwitchPort(ctx context.Context, device *config.VFIODev) (err error) {
|
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)
|
return q.executeVFIODeviceAdd(device)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1882,11 +1852,9 @@ func (q *qemu) hotplugVFIODevice(ctx context.Context, device *config.VFIODev, op
|
|||||||
if op == AddDevice {
|
if op == AddDevice {
|
||||||
buf, _ := json.Marshal(device)
|
buf, _ := json.Marshal(device)
|
||||||
q.Logger().WithFields(logrus.Fields{
|
q.Logger().WithFields(logrus.Fields{
|
||||||
"machine-type": q.HypervisorConfig().HypervisorMachineType,
|
"machine-type": q.HypervisorConfig().HypervisorMachineType,
|
||||||
"hot-plug-vfio": q.state.HotPlugVFIO,
|
"hot-plug-vfio": q.state.HotPlugVFIO,
|
||||||
"pcie-root-port": q.state.PCIeRootPort,
|
"device-info": string(buf),
|
||||||
"pcie-switch-port": q.state.PCIeSwitchPort,
|
|
||||||
"device-info": string(buf),
|
|
||||||
}).Info("Start hot-plug VFIO device")
|
}).Info("Start hot-plug VFIO device")
|
||||||
// In case MachineType is q35, a PCIe device is hotplugged on
|
// In case MachineType is q35, a PCIe device is hotplugged on
|
||||||
// a PCIe Root Port or alternatively on a PCIe Switch Port
|
// 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.UUID = q.state.UUID
|
||||||
s.HotpluggedMemory = q.state.HotpluggedMemory
|
s.HotpluggedMemory = q.state.HotpluggedMemory
|
||||||
s.HotplugVFIOOnRootBus = q.state.HotplugVFIOOnRootBus
|
s.HotplugVFIOOnRootBus = q.state.HotplugVFIOOnRootBus
|
||||||
s.PCIeRootPort = q.state.PCIeRootPort
|
|
||||||
s.PCIeSwitchPort = q.state.PCIeSwitchPort
|
|
||||||
|
|
||||||
for _, bridge := range q.arch.getBridges() {
|
for _, bridge := range q.arch.getBridges() {
|
||||||
s.Bridges = append(s.Bridges, hv.Bridge{
|
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.HotpluggedMemory = s.HotpluggedMemory
|
||||||
q.state.HotplugVFIOOnRootBus = s.HotplugVFIOOnRootBus
|
q.state.HotplugVFIOOnRootBus = s.HotplugVFIOOnRootBus
|
||||||
q.state.VirtiofsDaemonPid = s.VirtiofsDaemonPid
|
q.state.VirtiofsDaemonPid = s.VirtiofsDaemonPid
|
||||||
q.state.PCIeRootPort = s.PCIeRootPort
|
|
||||||
q.state.PCIeSwitchPort = s.PCIeSwitchPort
|
|
||||||
|
|
||||||
for _, bridge := range s.Bridges {
|
for _, bridge := range s.Bridges {
|
||||||
q.state.Bridges = append(q.state.Bridges, types.NewBridge(types.Type(bridge.Type), bridge.ID, bridge.DeviceAddr, bridge.Addr))
|
q.state.Bridges = append(q.state.Bridges, types.NewBridge(types.Type(bridge.Type), bridge.ID, bridge.DeviceAddr, bridge.Addr))
|
||||||
|
@ -305,6 +305,7 @@ func (q *qemuAmd64) appendProtectionDevice(devices []govmmQemu.Device, firmware,
|
|||||||
ReducedPhysBits: 1,
|
ReducedPhysBits: 1,
|
||||||
}), "", nil
|
}), "", nil
|
||||||
case noneProtection:
|
case noneProtection:
|
||||||
|
|
||||||
return devices, firmware, nil
|
return devices, firmware, nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user