Files
kata-containers/src/runtime/virtcontainers/persist/api/sandbox.go
Eric Ernst 4c2883f7e2 vc: hypervisor: remove dependency on persist API
Today the hypervisor code in vc relies on persist pkg for two things:
1. To get the VM/run store path on the host filesystem,
2. For type definition of the Load/Save functions of the hypervisor
   interface.

For (1), we can simply remove the store interface from the hypervisor
config and replace it with just the path, since this is all we really
need. When we create a NewHypervisor structure, outside of the
hypervisor, we can populate this path.

For (2), rather than have the persist pkg define the structure, let's
let the hypervisor code (soon to be pkg) define the structure. persist
API already needs to call into hypervisor anyway; let's allow us to
define the structure.

We'll probably want to look at following similar pattern for other parts
of vc that we want to make independent of the persist API.

In doing this, we started an initial hypervisors pkg, to hold these
types (avoid a circular dependency between virtcontainers and persist
pkg). Next step will be to remove all other dependencies and move the
hypervisor specific code into this pkg, and out of virtcontaienrs.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2021-11-19 12:20:41 -08:00

65 lines
1.7 KiB
Go

// Copyright (c) 2016 Intel Corporation
// Copyright (c) 2019 Huawei Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
package persistapi
import (
hv "github.com/kata-containers/kata-containers/src/runtime/pkg/hypervisors"
)
// ============= sandbox level resources =============
// AgentState save agent state data
type AgentState struct {
// URL to connect to agent
URL string
}
// SandboxState contains state information of sandbox
// nolint: maligned
type SandboxState struct {
// CgroupPath is the cgroup hierarchy where sandbox's processes
// including the hypervisor are placed.
CgroupPaths map[string]string
// Devices plugged to sandbox(hypervisor)
Devices []DeviceState
// State is sandbox running status
State string
// SandboxContainer specifies which container is used to start the sandbox/vm
SandboxContainer string
// SandboxCgroupPath is the sandbox cgroup path
SandboxCgroupPath string
// OverheadCgroupPath is the sandbox overhead cgroup path.
// It can be an empty string if sandbox_cgroup_only is set.
OverheadCgroupPath string
// HypervisorState saves hypervisor specific data
HypervisorState hv.HypervisorState
// AgentState saves state data of agent
AgentState AgentState
// Network saves network configuration of sandbox
Network NetworkInfo
// Config saves config information of sandbox
Config SandboxConfig
// PersistVersion of persist data format, can be used for keeping compatibility later
PersistVersion uint
// GuestMemoryBlockSizeMB is the size of memory block of guestos
GuestMemoryBlockSizeMB uint32
// GuestMemoryHotplugProbe determines whether guest kernel supports memory hotplug probe interface
GuestMemoryHotplugProbe bool
}