Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
state: Load the state from storage early on
Browse files Browse the repository at this point in the history
The hypervisor.createSandbox may need to access the state.
For eg, ACRN today needs to access the block index to assign
it to the root image of the VM. Hence load this early on.

Fixes #2026

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
  • Loading branch information
amshinde committed Oct 8, 2019
1 parent f62bceb commit fa4acad
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,11 @@ func createSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Fac
}
s.devManager = deviceManager.NewDeviceManager(sandboxConfig.HypervisorConfig.BlockDeviceDriver, devices)

// We first try to fetch the sandbox state from storage.
// If it exists, this means this is a re-creation, i.e.
// Sandbox state has been loaded from storage.
// If the Stae is not empty, this is a re-creation, i.e.
// we don't need to talk to the guest's agent, but only
// want to create the sandbox and its containers in memory.
state, err := s.store.LoadState()
if err == nil && state.State != "" {
s.state = state
if s.state.State != "" {
return s, nil
}
}
Expand Down Expand Up @@ -588,6 +586,12 @@ func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factor
return nil, err
}
} else {
// Load sandbox state. The hypervisor.createSandbox call, may need to access statei.
state, err := s.store.LoadState()
if err == nil {
s.state = state
}

if err = s.hypervisor.createSandbox(ctx, s.id, s.networkNS, &sandboxConfig.HypervisorConfig, s.store); err != nil {
return nil, err
}
Expand Down

0 comments on commit fa4acad

Please sign in to comment.