mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-02 13:44:33 +00:00
runtime: delete Stateful from SandboxConfig
Since all containers are started from shim v2, `Stateful` is not needed. Fixes: #332 Signed-off-by: bin liu <bin@hyper.sh>
This commit is contained in:
parent
069505e2d5
commit
3cf8b470cd
@ -113,8 +113,6 @@ func CreateSandbox(ctx context.Context, vci vc.VC, ociSpec specs.Spec, runtimeCo
|
|||||||
return nil, vc.Process{}, err
|
return nil, vc.Process{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
sandboxConfig.Stateful = true
|
|
||||||
|
|
||||||
if err := checkForFIPS(&sandboxConfig); err != nil {
|
if err := checkForFIPS(&sandboxConfig); err != nil {
|
||||||
return nil, vc.Process{}, err
|
return nil, vc.Process{}, err
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ func (a *Acrn) createDummyVirtioBlkDev(devices []Device) ([]Device, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// createSandbox is the Hypervisor sandbox creation.
|
// createSandbox is the Hypervisor sandbox creation.
|
||||||
func (a *Acrn) createSandbox(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig, stateful bool) error {
|
func (a *Acrn) createSandbox(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig) error {
|
||||||
// Save the tracing context
|
// Save the tracing context
|
||||||
a.ctx = ctx
|
a.ctx = ctx
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ func TestAcrnCreateSandbox(t *testing.T) {
|
|||||||
//set PID to 1 to ignore hypercall to get UUID and set a random UUID
|
//set PID to 1 to ignore hypercall to get UUID and set a random UUID
|
||||||
a.state.PID = 1
|
a.state.PID = 1
|
||||||
a.state.UUID = "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
|
a.state.UUID = "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
|
||||||
err = a.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig, false)
|
err = a.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Exactly(acrnConfig, a.config)
|
assert.Exactly(acrnConfig, a.config)
|
||||||
}
|
}
|
||||||
|
@ -62,9 +62,6 @@ func CreateSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Fac
|
|||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
s, err := createSandboxFromConfig(ctx, sandboxConfig, factory)
|
s, err := createSandboxFromConfig(ctx, sandboxConfig, factory)
|
||||||
if err == nil {
|
|
||||||
s.releaseStatelessSandbox()
|
|
||||||
}
|
|
||||||
|
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
@ -157,7 +154,6 @@ func DeleteSandbox(ctx context.Context, sandboxID string) (VCSandbox, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
// Delete it.
|
// Delete it.
|
||||||
if err := s.Delete(); err != nil {
|
if err := s.Delete(); err != nil {
|
||||||
@ -227,7 +223,6 @@ func StartSandbox(ctx context.Context, sandboxID string) (VCSandbox, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
// Start it
|
// Start it
|
||||||
err = s.Start()
|
err = s.Start()
|
||||||
@ -263,7 +258,6 @@ func StopSandbox(ctx context.Context, sandboxID string, force bool) (VCSandbox,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
// Stop it.
|
// Stop it.
|
||||||
err = s.Stop(force)
|
err = s.Stop(force)
|
||||||
@ -289,7 +283,6 @@ func RunSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factor
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
unlock, err := rwLockSandbox(s.id)
|
unlock, err := rwLockSandbox(s.id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -365,7 +358,6 @@ func StatusSandbox(ctx context.Context, sandboxID string) (SandboxStatus, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return SandboxStatus{}, err
|
return SandboxStatus{}, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
var contStatusList []ContainerStatus
|
var contStatusList []ContainerStatus
|
||||||
for _, container := range s.containers {
|
for _, container := range s.containers {
|
||||||
@ -409,7 +401,6 @@ func CreateContainer(ctx context.Context, sandboxID string, containerConfig Cont
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
c, err := s.CreateContainer(containerConfig)
|
c, err := s.CreateContainer(containerConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -448,7 +439,6 @@ func DeleteContainer(ctx context.Context, sandboxID, containerID string) (VCCont
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
return s.DeleteContainer(containerID)
|
return s.DeleteContainer(containerID)
|
||||||
}
|
}
|
||||||
@ -477,7 +467,6 @@ func StartContainer(ctx context.Context, sandboxID, containerID string) (VCConta
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
return s.StartContainer(containerID)
|
return s.StartContainer(containerID)
|
||||||
}
|
}
|
||||||
@ -506,7 +495,6 @@ func StopContainer(ctx context.Context, sandboxID, containerID string) (VCContai
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
return s.StopContainer(containerID, false)
|
return s.StopContainer(containerID, false)
|
||||||
}
|
}
|
||||||
@ -535,7 +523,6 @@ func EnterContainer(ctx context.Context, sandboxID, containerID string, cmd type
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
c, process, err := s.EnterContainer(containerID, cmd)
|
c, process, err := s.EnterContainer(containerID, cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -569,7 +556,6 @@ func StatusContainer(ctx context.Context, sandboxID, containerID string) (Contai
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerStatus{}, err
|
return ContainerStatus{}, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
return statusContainer(s, containerID)
|
return statusContainer(s, containerID)
|
||||||
}
|
}
|
||||||
@ -616,7 +602,6 @@ func KillContainer(ctx context.Context, sandboxID, containerID string, signal sy
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
return s.KillContainer(containerID, signal, all)
|
return s.KillContainer(containerID, signal, all)
|
||||||
}
|
}
|
||||||
@ -645,7 +630,6 @@ func ProcessListContainer(ctx context.Context, sandboxID, containerID string, op
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
return s.ProcessListContainer(containerID, options)
|
return s.ProcessListContainer(containerID, options)
|
||||||
}
|
}
|
||||||
@ -674,7 +658,6 @@ func UpdateContainer(ctx context.Context, sandboxID, containerID string, resourc
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
return s.UpdateContainer(containerID, resources)
|
return s.UpdateContainer(containerID, resources)
|
||||||
}
|
}
|
||||||
@ -703,7 +686,6 @@ func StatsContainer(ctx context.Context, sandboxID, containerID string) (Contain
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerStats{}, err
|
return ContainerStats{}, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
return s.StatsContainer(containerID)
|
return s.StatsContainer(containerID)
|
||||||
}
|
}
|
||||||
@ -728,7 +710,6 @@ func StatsSandbox(ctx context.Context, sandboxID string) (SandboxStats, []Contai
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return SandboxStats{}, []ContainerStats{}, err
|
return SandboxStats{}, []ContainerStats{}, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
sandboxStats, err := s.Stats()
|
sandboxStats, err := s.Stats()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -766,7 +747,6 @@ func togglePauseContainer(ctx context.Context, sandboxID, containerID string, pa
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
if pause {
|
if pause {
|
||||||
return s.PauseContainer(containerID)
|
return s.PauseContainer(containerID)
|
||||||
@ -810,7 +790,6 @@ func AddDevice(ctx context.Context, sandboxID string, info deviceConfig.DeviceIn
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
return s.AddDevice(info)
|
return s.AddDevice(info)
|
||||||
}
|
}
|
||||||
@ -830,7 +809,6 @@ func toggleInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interfa
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
if add {
|
if add {
|
||||||
return s.AddInterface(inf)
|
return s.AddInterface(inf)
|
||||||
@ -874,7 +852,6 @@ func ListInterfaces(ctx context.Context, sandboxID string) ([]*vcTypes.Interface
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
return s.ListInterfaces()
|
return s.ListInterfaces()
|
||||||
}
|
}
|
||||||
@ -898,7 +875,6 @@ func UpdateRoutes(ctx context.Context, sandboxID string, routes []*vcTypes.Route
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
return s.UpdateRoutes(routes)
|
return s.UpdateRoutes(routes)
|
||||||
}
|
}
|
||||||
@ -922,7 +898,6 @@ func ListRoutes(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer s.releaseStatelessSandbox()
|
|
||||||
|
|
||||||
return s.ListRoutes()
|
return s.ListRoutes()
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ func (clh *cloudHypervisor) checkVersion() error {
|
|||||||
|
|
||||||
// For cloudHypervisor this call only sets the internal structure up.
|
// For cloudHypervisor this call only sets the internal structure up.
|
||||||
// The VM will be created and started through startSandbox().
|
// The VM will be created and started through startSandbox().
|
||||||
func (clh *cloudHypervisor) createSandbox(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig, stateful bool) error {
|
func (clh *cloudHypervisor) createSandbox(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig) error {
|
||||||
clh.ctx = ctx
|
clh.ctx = ctx
|
||||||
|
|
||||||
span, _ := clh.trace("createSandbox")
|
span, _ := clh.trace("createSandbox")
|
||||||
|
@ -241,7 +241,7 @@ func TestClhCreateSandbox(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err = clh.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig, false)
|
err = clh.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Exactly(clhConfig, clh.config)
|
assert.Exactly(clhConfig, clh.config)
|
||||||
}
|
}
|
||||||
|
@ -149,9 +149,8 @@ type firecracker struct {
|
|||||||
config HypervisorConfig
|
config HypervisorConfig
|
||||||
pendingDevices []firecrackerDevice // Devices to be added before the FC VM ready
|
pendingDevices []firecrackerDevice // Devices to be added before the FC VM ready
|
||||||
|
|
||||||
state firecrackerState
|
state firecrackerState
|
||||||
jailed bool //Set to true if jailer is enabled
|
jailed bool //Set to true if jailer is enabled
|
||||||
stateful bool //Set to true if running with shimv2
|
|
||||||
|
|
||||||
fcConfigPath string
|
fcConfigPath string
|
||||||
fcConfig *types.FcConfig // Parameters configured before VM starts
|
fcConfig *types.FcConfig // Parameters configured before VM starts
|
||||||
@ -196,7 +195,7 @@ func (fc *firecracker) truncateID(id string) string {
|
|||||||
|
|
||||||
// For firecracker this call only sets the internal structure up.
|
// For firecracker this call only sets the internal structure up.
|
||||||
// The sandbox will be created and started through startSandbox().
|
// The sandbox will be created and started through startSandbox().
|
||||||
func (fc *firecracker) createSandbox(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig, stateful bool) error {
|
func (fc *firecracker) createSandbox(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig) error {
|
||||||
fc.ctx = ctx
|
fc.ctx = ctx
|
||||||
|
|
||||||
span, _ := fc.trace("createSandbox")
|
span, _ := fc.trace("createSandbox")
|
||||||
@ -207,7 +206,6 @@ func (fc *firecracker) createSandbox(ctx context.Context, id string, networkNS N
|
|||||||
fc.id = fc.truncateID(id)
|
fc.id = fc.truncateID(id)
|
||||||
fc.state.set(notReady)
|
fc.state.set(notReady)
|
||||||
fc.config = *hypervisorConfig
|
fc.config = *hypervisorConfig
|
||||||
fc.stateful = stateful
|
|
||||||
|
|
||||||
// When running with jailer all resources need to be under
|
// When running with jailer all resources need to be under
|
||||||
// a specific location and that location needs to have
|
// a specific location and that location needs to have
|
||||||
@ -367,7 +365,7 @@ func (fc *firecracker) fcInit(timeout int) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !fc.config.Debug && fc.stateful {
|
if !fc.config.Debug {
|
||||||
args = append(args, "--daemonize")
|
args = append(args, "--daemonize")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,7 +397,7 @@ func (fc *firecracker) fcInit(timeout int) error {
|
|||||||
cmd = exec.Command(fc.config.HypervisorPath, args...)
|
cmd = exec.Command(fc.config.HypervisorPath, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if fc.config.Debug && fc.stateful {
|
if fc.config.Debug {
|
||||||
stdin, err := fc.watchConsole()
|
stdin, err := fc.watchConsole()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -697,7 +695,7 @@ func (fc *firecracker) fcInitConfiguration() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if fc.config.Debug && fc.stateful {
|
if fc.config.Debug {
|
||||||
fcKernelParams = append(fcKernelParams, Param{"console", "ttyS0"})
|
fcKernelParams = append(fcKernelParams, Param{"console", "ttyS0"})
|
||||||
} else {
|
} else {
|
||||||
fcKernelParams = append(fcKernelParams, []Param{
|
fcKernelParams = append(fcKernelParams, []Param{
|
||||||
|
@ -776,7 +776,7 @@ func generateVMSocket(id string, useVsock bool, vmStogarePath string) (interface
|
|||||||
// hypervisor is the virtcontainers hypervisor interface.
|
// hypervisor is the virtcontainers hypervisor interface.
|
||||||
// The default hypervisor implementation is Qemu.
|
// The default hypervisor implementation is Qemu.
|
||||||
type hypervisor interface {
|
type hypervisor interface {
|
||||||
createSandbox(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig, stateful bool) error
|
createSandbox(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig) error
|
||||||
startSandbox(timeout int) error
|
startSandbox(timeout int) error
|
||||||
stopSandbox() error
|
stopSandbox() error
|
||||||
pauseSandbox() error
|
pauseSandbox() error
|
||||||
|
@ -26,7 +26,7 @@ func (m *mockHypervisor) hypervisorConfig() HypervisorConfig {
|
|||||||
return HypervisorConfig{}
|
return HypervisorConfig{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockHypervisor) createSandbox(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig, stateful bool) error {
|
func (m *mockHypervisor) createSandbox(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig) error {
|
||||||
err := hypervisorConfig.valid()
|
err := hypervisorConfig.valid()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -31,7 +31,7 @@ func TestMockHypervisorCreateSandbox(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
// wrong config
|
// wrong config
|
||||||
err := m.createSandbox(ctx, sandbox.config.ID, NetworkNamespace{}, &sandbox.config.HypervisorConfig, false)
|
err := m.createSandbox(ctx, sandbox.config.ID, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
|
|
||||||
sandbox.config.HypervisorConfig = HypervisorConfig{
|
sandbox.config.HypervisorConfig = HypervisorConfig{
|
||||||
@ -40,7 +40,7 @@ func TestMockHypervisorCreateSandbox(t *testing.T) {
|
|||||||
HypervisorPath: fmt.Sprintf("%s/%s", testDir, testHypervisor),
|
HypervisorPath: fmt.Sprintf("%s/%s", testDir, testHypervisor),
|
||||||
}
|
}
|
||||||
|
|
||||||
err = m.createSandbox(ctx, sandbox.config.ID, NetworkNamespace{}, &sandbox.config.HypervisorConfig, false)
|
err = m.createSandbox(ctx, sandbox.config.ID, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,6 @@ func (s *Sandbox) dumpConfig(ss *persistapi.SandboxState) {
|
|||||||
|
|
||||||
ShmSize: sconfig.ShmSize,
|
ShmSize: sconfig.ShmSize,
|
||||||
SharePidNs: sconfig.SharePidNs,
|
SharePidNs: sconfig.SharePidNs,
|
||||||
Stateful: sconfig.Stateful,
|
|
||||||
SystemdCgroup: sconfig.SystemdCgroup,
|
SystemdCgroup: sconfig.SystemdCgroup,
|
||||||
SandboxCgroupOnly: sconfig.SandboxCgroupOnly,
|
SandboxCgroupOnly: sconfig.SandboxCgroupOnly,
|
||||||
DisableGuestSeccomp: sconfig.DisableGuestSeccomp,
|
DisableGuestSeccomp: sconfig.DisableGuestSeccomp,
|
||||||
@ -458,7 +457,6 @@ func loadSandboxConfig(id string) (*SandboxConfig, error) {
|
|||||||
|
|
||||||
ShmSize: savedConf.ShmSize,
|
ShmSize: savedConf.ShmSize,
|
||||||
SharePidNs: savedConf.SharePidNs,
|
SharePidNs: savedConf.SharePidNs,
|
||||||
Stateful: savedConf.Stateful,
|
|
||||||
SystemdCgroup: savedConf.SystemdCgroup,
|
SystemdCgroup: savedConf.SystemdCgroup,
|
||||||
SandboxCgroupOnly: savedConf.SandboxCgroupOnly,
|
SandboxCgroupOnly: savedConf.SandboxCgroupOnly,
|
||||||
DisableGuestSeccomp: savedConf.DisableGuestSeccomp,
|
DisableGuestSeccomp: savedConf.DisableGuestSeccomp,
|
||||||
|
@ -459,7 +459,7 @@ func (q *qemu) setupFileBackedMem(knobs *govmmQemu.Knobs, memory *govmmQemu.Memo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// createSandbox is the Hypervisor sandbox creation implementation for govmmQemu.
|
// createSandbox is the Hypervisor sandbox creation implementation for govmmQemu.
|
||||||
func (q *qemu) createSandbox(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig, stateful bool) error {
|
func (q *qemu) createSandbox(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig) error {
|
||||||
// Save the tracing context
|
// Save the tracing context
|
||||||
q.ctx = ctx
|
q.ctx = ctx
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ func TestQemuCreateSandbox(t *testing.T) {
|
|||||||
parentDir := filepath.Join(q.store.RunStoragePath(), sandbox.id)
|
parentDir := filepath.Join(q.store.RunStoragePath(), sandbox.id)
|
||||||
assert.NoError(os.MkdirAll(parentDir, DirMode))
|
assert.NoError(os.MkdirAll(parentDir, DirMode))
|
||||||
|
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig, false)
|
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NoError(os.RemoveAll(parentDir))
|
assert.NoError(os.RemoveAll(parentDir))
|
||||||
assert.Exactly(qemuConfig, q.config)
|
assert.Exactly(qemuConfig, q.config)
|
||||||
@ -131,7 +131,7 @@ func TestQemuCreateSandboxMissingParentDirFail(t *testing.T) {
|
|||||||
parentDir := filepath.Join(q.store.RunStoragePath(), sandbox.id)
|
parentDir := filepath.Join(q.store.RunStoragePath(), sandbox.id)
|
||||||
assert.NoError(os.RemoveAll(parentDir))
|
assert.NoError(os.RemoveAll(parentDir))
|
||||||
|
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig, false)
|
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ func TestQemuQemuPath(t *testing.T) {
|
|||||||
qemuConfig.HypervisorPath = expectedPath
|
qemuConfig.HypervisorPath = expectedPath
|
||||||
qkvm := &qemuArchBase{
|
qkvm := &qemuArchBase{
|
||||||
qemuMachine: govmmQemu.Machine{
|
qemuMachine: govmmQemu.Machine{
|
||||||
Type: "pc",
|
Type: "pc",
|
||||||
Options: "",
|
Options: "",
|
||||||
},
|
},
|
||||||
qemuExePath: expectedPath,
|
qemuExePath: expectedPath,
|
||||||
@ -445,7 +445,7 @@ func TestQemuFileBackedMem(t *testing.T) {
|
|||||||
store: sandbox.newStore,
|
store: sandbox.newStore,
|
||||||
}
|
}
|
||||||
sandbox.config.HypervisorConfig.SharedFS = config.VirtioFS
|
sandbox.config.HypervisorConfig.SharedFS = config.VirtioFS
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig, false)
|
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
assert.Equal(q.qemuConfig.Knobs.FileBackedMem, true)
|
assert.Equal(q.qemuConfig.Knobs.FileBackedMem, true)
|
||||||
@ -463,7 +463,7 @@ func TestQemuFileBackedMem(t *testing.T) {
|
|||||||
sandbox.config.HypervisorConfig.SharedFS = config.VirtioFS
|
sandbox.config.HypervisorConfig.SharedFS = config.VirtioFS
|
||||||
sandbox.config.HypervisorConfig.MemoryPath = fallbackFileBackedMemDir
|
sandbox.config.HypervisorConfig.MemoryPath = fallbackFileBackedMemDir
|
||||||
|
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig, false)
|
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
|
|
||||||
expectErr := errors.New("VM templating has been enabled with either virtio-fs or file backed memory and this configuration will not work")
|
expectErr := errors.New("VM templating has been enabled with either virtio-fs or file backed memory and this configuration will not work")
|
||||||
assert.Equal(expectErr.Error(), err.Error())
|
assert.Equal(expectErr.Error(), err.Error())
|
||||||
@ -476,7 +476,7 @@ func TestQemuFileBackedMem(t *testing.T) {
|
|||||||
store: sandbox.newStore,
|
store: sandbox.newStore,
|
||||||
}
|
}
|
||||||
sandbox.config.HypervisorConfig.FileBackedMemRootDir = "/tmp/xyzabc"
|
sandbox.config.HypervisorConfig.FileBackedMemRootDir = "/tmp/xyzabc"
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig, false)
|
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(q.qemuConfig.Knobs.FileBackedMem, false)
|
assert.Equal(q.qemuConfig.Knobs.FileBackedMem, false)
|
||||||
assert.Equal(q.qemuConfig.Knobs.MemShared, false)
|
assert.Equal(q.qemuConfig.Knobs.MemShared, false)
|
||||||
@ -491,7 +491,7 @@ func TestQemuFileBackedMem(t *testing.T) {
|
|||||||
}
|
}
|
||||||
sandbox.config.HypervisorConfig.EnableVhostUserStore = true
|
sandbox.config.HypervisorConfig.EnableVhostUserStore = true
|
||||||
sandbox.config.HypervisorConfig.HugePages = true
|
sandbox.config.HypervisorConfig.HugePages = true
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig, false)
|
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(q.qemuConfig.Knobs.MemShared, true)
|
assert.Equal(q.qemuConfig.Knobs.MemShared, true)
|
||||||
|
|
||||||
@ -504,7 +504,7 @@ func TestQemuFileBackedMem(t *testing.T) {
|
|||||||
}
|
}
|
||||||
sandbox.config.HypervisorConfig.EnableVhostUserStore = true
|
sandbox.config.HypervisorConfig.EnableVhostUserStore = true
|
||||||
sandbox.config.HypervisorConfig.HugePages = false
|
sandbox.config.HypervisorConfig.HugePages = false
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig, false)
|
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
|
|
||||||
expectErr = errors.New("Vhost-user-blk/scsi is enabled without HugePages. This configuration will not work")
|
expectErr = errors.New("Vhost-user-blk/scsi is enabled without HugePages. This configuration will not work")
|
||||||
assert.Equal(expectErr.Error(), err.Error())
|
assert.Equal(expectErr.Error(), err.Error())
|
||||||
|
@ -105,10 +105,6 @@ type SandboxConfig struct {
|
|||||||
// SharePidNs sets all containers to share the same sandbox level pid namespace.
|
// SharePidNs sets all containers to share the same sandbox level pid namespace.
|
||||||
SharePidNs bool
|
SharePidNs bool
|
||||||
|
|
||||||
// types.Stateful keeps sandbox resources in memory across APIs. Users will be responsible
|
|
||||||
// for calling Release() to release the memory resources.
|
|
||||||
Stateful bool
|
|
||||||
|
|
||||||
// SystemdCgroup enables systemd cgroup support
|
// SystemdCgroup enables systemd cgroup support
|
||||||
SystemdCgroup bool
|
SystemdCgroup bool
|
||||||
|
|
||||||
@ -200,7 +196,6 @@ type Sandbox struct {
|
|||||||
|
|
||||||
shmSize uint64
|
shmSize uint64
|
||||||
sharePidNs bool
|
sharePidNs bool
|
||||||
stateful bool
|
|
||||||
seccompSupported bool
|
seccompSupported bool
|
||||||
disableVMShutdown bool
|
disableVMShutdown bool
|
||||||
|
|
||||||
@ -291,14 +286,6 @@ func (s *Sandbox) Release() error {
|
|||||||
return s.agent.disconnect()
|
return s.agent.disconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sandbox) releaseStatelessSandbox() error {
|
|
||||||
if s.stateful {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.Release()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Status gets the status of the sandbox
|
// Status gets the status of the sandbox
|
||||||
// TODO: update container status properly, see kata-containers/runtime#253
|
// TODO: update container status properly, see kata-containers/runtime#253
|
||||||
func (s *Sandbox) Status() SandboxStatus {
|
func (s *Sandbox) Status() SandboxStatus {
|
||||||
@ -526,7 +513,6 @@ func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factor
|
|||||||
wg: &sync.WaitGroup{},
|
wg: &sync.WaitGroup{},
|
||||||
shmSize: sandboxConfig.ShmSize,
|
shmSize: sandboxConfig.ShmSize,
|
||||||
sharePidNs: sandboxConfig.SharePidNs,
|
sharePidNs: sandboxConfig.SharePidNs,
|
||||||
stateful: sandboxConfig.Stateful,
|
|
||||||
networkNS: NetworkNamespace{NetNsPath: sandboxConfig.NetworkConfig.NetNSPath},
|
networkNS: NetworkNamespace{NetNsPath: sandboxConfig.NetworkConfig.NetNSPath},
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
}
|
}
|
||||||
@ -562,7 +548,7 @@ func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// new store doesn't require hypervisor to be stored immediately
|
// new store doesn't require hypervisor to be stored immediately
|
||||||
if err = s.hypervisor.createSandbox(ctx, s.id, s.networkNS, &sandboxConfig.HypervisorConfig, s.stateful); err != nil {
|
if err = s.hypervisor.createSandbox(ctx, s.id, s.networkNS, &sandboxConfig.HypervisorConfig); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ func NewVM(ctx context.Context, config VMConfig) (*VM, error) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err = hypervisor.createSandbox(ctx, id, NetworkNamespace{}, &config.HypervisorConfig, false); err != nil {
|
if err = hypervisor.createSandbox(ctx, id, NetworkNamespace{}, &config.HypervisorConfig); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user