mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-03 14:07:24 +00:00
gpu: Add cold-plug test
Cold plug setting is now correctly decoded in toml Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
This commit is contained in:
parent
dded731db3
commit
0fec2e6986
@ -19,6 +19,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
|
hv "github.com/kata-containers/kata-containers/src/runtime/pkg/hypervisors"
|
||||||
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
||||||
vcUtils "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
vcUtils "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
@ -74,6 +75,7 @@ func createConfig(configPath string, fileData string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func makeRuntimeConfig(prefixDir string) (configFile string, config oci.RuntimeConfig, err error) {
|
func makeRuntimeConfig(prefixDir string) (configFile string, config oci.RuntimeConfig, err error) {
|
||||||
|
var coldPlugVFIO hv.PCIePort
|
||||||
const logPath = "/log/path"
|
const logPath = "/log/path"
|
||||||
hypervisorPath := filepath.Join(prefixDir, "hypervisor")
|
hypervisorPath := filepath.Join(prefixDir, "hypervisor")
|
||||||
kernelPath := filepath.Join(prefixDir, "kernel")
|
kernelPath := filepath.Join(prefixDir, "kernel")
|
||||||
@ -86,6 +88,7 @@ func makeRuntimeConfig(prefixDir string) (configFile string, config oci.RuntimeC
|
|||||||
enableIOThreads := true
|
enableIOThreads := true
|
||||||
hotplugVFIOOnRootBus := true
|
hotplugVFIOOnRootBus := true
|
||||||
pcieRootPort := uint32(2)
|
pcieRootPort := uint32(2)
|
||||||
|
coldPlugVFIO = hv.NoPort
|
||||||
disableNewNetNs := false
|
disableNewNetNs := false
|
||||||
sharedFS := "virtio-9p"
|
sharedFS := "virtio-9p"
|
||||||
virtioFSdaemon := filepath.Join(prefixDir, "virtiofsd")
|
virtioFSdaemon := filepath.Join(prefixDir, "virtiofsd")
|
||||||
@ -129,6 +132,7 @@ func makeRuntimeConfig(prefixDir string) (configFile string, config oci.RuntimeC
|
|||||||
BlockDeviceDriver: blockStorageDriver,
|
BlockDeviceDriver: blockStorageDriver,
|
||||||
EnableIOThreads: enableIOThreads,
|
EnableIOThreads: enableIOThreads,
|
||||||
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: hotplugVFIOOnRootBus,
|
||||||
|
ColdPlugVFIO: coldPlugVFIO,
|
||||||
PCIeRootPort: pcieRootPort,
|
PCIeRootPort: pcieRootPort,
|
||||||
DisableNewNetNs: disableNewNetNs,
|
DisableNewNetNs: disableNewNetNs,
|
||||||
DefaultVCPUCount: hypConfig.NumVCPUs,
|
DefaultVCPUCount: hypConfig.NumVCPUs,
|
||||||
@ -191,6 +195,7 @@ func genericGetExpectedHostDetails(tmpdir string, expectedVendor string, expecte
|
|||||||
|
|
||||||
expectedSupportVSocks, _ := vcUtils.SupportsVsocks()
|
expectedSupportVSocks, _ := vcUtils.SupportsVsocks()
|
||||||
expectedHostDetails := HostInfo{
|
expectedHostDetails := HostInfo{
|
||||||
|
AvailableGuestProtections: vc.AvailableGuestProtections(),
|
||||||
Kernel: expectedKernelVersion,
|
Kernel: expectedKernelVersion,
|
||||||
Architecture: expectedArch,
|
Architecture: expectedArch,
|
||||||
Distro: expectedDistro,
|
Distro: expectedDistro,
|
||||||
@ -273,6 +278,7 @@ func getExpectedHypervisor(config oci.RuntimeConfig) HypervisorInfo {
|
|||||||
|
|
||||||
HotplugVFIOOnRootBus: config.HypervisorConfig.HotplugVFIOOnRootBus,
|
HotplugVFIOOnRootBus: config.HypervisorConfig.HotplugVFIOOnRootBus,
|
||||||
PCIeRootPort: config.HypervisorConfig.PCIeRootPort,
|
PCIeRootPort: config.HypervisorConfig.PCIeRootPort,
|
||||||
|
ColdPlugVFIO: config.HypervisorConfig.ColdPlugVFIO,
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Geteuid() == 0 {
|
if os.Geteuid() == 0 {
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
package hypervisors
|
package hypervisors
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
// Bridge is a bridge where devices can be hot plugged
|
// Bridge is a bridge where devices can be hot plugged
|
||||||
type Bridge struct {
|
type Bridge struct {
|
||||||
// DeviceAddr contains information about devices plugged and its address in the bridge
|
// DeviceAddr contains information about devices plugged and its address in the bridge
|
||||||
@ -40,6 +42,18 @@ const (
|
|||||||
NoPort = "no-port"
|
NoPort = "no-port"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (p PCIePort) String() string {
|
||||||
|
switch p {
|
||||||
|
case RootPort:
|
||||||
|
return "root-port"
|
||||||
|
case SwitchPort:
|
||||||
|
return "switch-port"
|
||||||
|
case NoPort:
|
||||||
|
return "no-port"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("unknown PCIePort: %s", string(p))
|
||||||
|
}
|
||||||
|
|
||||||
type HypervisorState struct {
|
type HypervisorState struct {
|
||||||
BlockIndexMap map[int]struct{}
|
BlockIndexMap map[int]struct{}
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ func MakeRuntimeConfigFileData(config RuntimeConfigOptions) string {
|
|||||||
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_root_port = ` + strconv.FormatUint(uint64(config.PCIeRootPort), 10) + `
|
||||||
cold_plug_vfio = "` + config.ColdPlugVFIO + `"
|
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) + `
|
||||||
guest_hook_path = "` + config.DefaultGuestHookPath + `"
|
guest_hook_path = "` + config.DefaultGuestHookPath + `"
|
||||||
|
@ -199,7 +199,7 @@ type HypervisorConfig struct {
|
|||||||
// root bus instead of a bridge.
|
// root bus instead of a bridge.
|
||||||
HotplugVFIOOnRootBus bool
|
HotplugVFIOOnRootBus bool
|
||||||
|
|
||||||
// ColdPlugVFIO is used to indicate if devices need to be coldlugged on the
|
// ColdPlugVFIO is used to indicate if devices need to be coldplugged on the
|
||||||
// root port or a switch or no-port
|
// root port or a switch or no-port
|
||||||
ColdPlugVFIO hv.PCIePort
|
ColdPlugVFIO hv.PCIePort
|
||||||
|
|
||||||
|
@ -710,8 +710,6 @@ func (q *qemu) CreateVM(ctx context.Context, id string, network Network, hypervi
|
|||||||
qemuConfig.Devices = q.arch.appendPCIeRootPortDevice(qemuConfig.Devices, hypervisorConfig.PCIeRootPort, memSize32bit, memSize64bit)
|
qemuConfig.Devices = q.arch.appendPCIeRootPortDevice(qemuConfig.Devices, hypervisorConfig.PCIeRootPort, memSize32bit, memSize64bit)
|
||||||
}
|
}
|
||||||
|
|
||||||
q.virtiofsDaemon, err = q.createVirtiofsDaemon(hypervisorConfig.SharedPath)
|
|
||||||
|
|
||||||
// The default OVMF MMIO aperture is too small for some PCIe devices
|
// The default OVMF MMIO aperture is too small for some PCIe devices
|
||||||
// with huge BARs so we need to increase it.
|
// with huge BARs so we need to increase it.
|
||||||
// memSize64bit is in bytes, convert to MB, OVMF expects MB as a string
|
// memSize64bit is in bytes, convert to MB, OVMF expects MB as a string
|
||||||
@ -726,6 +724,7 @@ func (q *qemu) CreateVM(ctx context.Context, id string, network Network, hypervi
|
|||||||
|
|
||||||
q.qemuConfig = qemuConfig
|
q.qemuConfig = qemuConfig
|
||||||
|
|
||||||
|
q.virtiofsDaemon, err = q.createVirtiofsDaemon(hypervisorConfig.SharedPath)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user