mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-28 11:34:40 +01:00
We convert the whole virtcontainers code to use the store package
instead of the resource_storage one. The resource_storage removal will
happen in a separate change for a more logical split.
This change is fairly big but mostly does not change the code logic.
What really changes is when we create a store for a container or a
sandbox. We now need to explictly do so instead of just assigning a
filesystem{} instance. Other than that, the logic is kept intact.
Fixes: #1099
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
103 lines
2.1 KiB
Go
103 lines
2.1 KiB
Go
// Copyright (c) 2016 Intel Corporation
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package virtcontainers
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
|
|
"github.com/kata-containers/runtime/virtcontainers/store"
|
|
"github.com/kata-containers/runtime/virtcontainers/types"
|
|
)
|
|
|
|
type mockHypervisor struct {
|
|
}
|
|
|
|
func (m *mockHypervisor) capabilities() types.Capabilities {
|
|
return types.Capabilities{}
|
|
}
|
|
|
|
func (m *mockHypervisor) hypervisorConfig() HypervisorConfig {
|
|
return HypervisorConfig{}
|
|
}
|
|
|
|
func (m *mockHypervisor) createSandbox(ctx context.Context, id string, hypervisorConfig *HypervisorConfig, store *store.VCStore) error {
|
|
err := hypervisorConfig.valid()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *mockHypervisor) startSandbox(timeout int) error {
|
|
return nil
|
|
}
|
|
|
|
func (m *mockHypervisor) stopSandbox() error {
|
|
return nil
|
|
}
|
|
|
|
func (m *mockHypervisor) pauseSandbox() error {
|
|
return nil
|
|
}
|
|
|
|
func (m *mockHypervisor) resumeSandbox() error {
|
|
return nil
|
|
}
|
|
|
|
func (m *mockHypervisor) saveSandbox() error {
|
|
return nil
|
|
}
|
|
|
|
func (m *mockHypervisor) addDevice(devInfo interface{}, devType deviceType) error {
|
|
return nil
|
|
}
|
|
|
|
func (m *mockHypervisor) hotplugAddDevice(devInfo interface{}, devType deviceType) (interface{}, error) {
|
|
switch devType {
|
|
case cpuDev:
|
|
return devInfo.(uint32), nil
|
|
case memoryDev:
|
|
memdev := devInfo.(*memoryDevice)
|
|
return memdev.sizeMB, nil
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (m *mockHypervisor) hotplugRemoveDevice(devInfo interface{}, devType deviceType) (interface{}, error) {
|
|
switch devType {
|
|
case cpuDev:
|
|
return devInfo.(uint32), nil
|
|
case memoryDev:
|
|
return 0, nil
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (m *mockHypervisor) getSandboxConsole(sandboxID string) (string, error) {
|
|
return "", nil
|
|
}
|
|
|
|
func (m *mockHypervisor) resizeMemory(memMB uint32, memorySectionSizeMB uint32) (uint32, error) {
|
|
return 0, nil
|
|
}
|
|
func (m *mockHypervisor) resizeVCPUs(cpus uint32) (uint32, uint32, error) {
|
|
return 0, 0, nil
|
|
}
|
|
|
|
func (m *mockHypervisor) disconnect() {
|
|
}
|
|
|
|
func (m *mockHypervisor) getThreadIDs() (*threadIDs, error) {
|
|
vcpus := []int{os.Getpid()}
|
|
return &threadIDs{vcpus}, nil
|
|
}
|
|
|
|
func (m *mockHypervisor) cleanup() error {
|
|
return nil
|
|
}
|