mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-16 23:17:42 +00:00
acrn: remove dependency on sandbox, persistapi datatypes
Today, acrn relies on sandbox level information, as well as a store provided by common parts of the hypervisor. As we cleanup the abstractions within our runtime, we need to ensure that there aren't cross dependencies between the sandbox, the persistence logic and the hypervisor. Ensure that ACRN still compiles, but remove the setSandbox usage as well as persist driver setup. Signed-off-by: Eric Ernst <eric_ernst@apple.com>
This commit is contained in:
parent
a0e0e18639
commit
c28e5a7807
@ -7,7 +7,6 @@ package virtcontainers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -20,6 +19,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
hv "github.com/kata-containers/kata-containers/src/runtime/pkg/hypervisors"
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils/katatrace"
|
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils/katatrace"
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/uuid"
|
"github.com/kata-containers/kata-containers/src/runtime/pkg/uuid"
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/config"
|
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/config"
|
||||||
@ -39,11 +39,13 @@ var acrnTracingTags = map[string]string{
|
|||||||
|
|
||||||
// Since ACRN is using the store in a quite abnormal way, let's first draw it back from store to here
|
// Since ACRN is using the store in a quite abnormal way, let's first draw it back from store to here
|
||||||
|
|
||||||
|
/*
|
||||||
// UUIDPathSuffix is the suffix used for uuid storage
|
// UUIDPathSuffix is the suffix used for uuid storage
|
||||||
const (
|
const (
|
||||||
UUIDPathSuffix = "uuid"
|
UUIDPathSuffix = "uuid"
|
||||||
uuidFile = "uuid.json"
|
uuidFile = "uuid.json"
|
||||||
)
|
)
|
||||||
|
*/
|
||||||
|
|
||||||
// ACRN currently supports only known UUIDs for security
|
// ACRN currently supports only known UUIDs for security
|
||||||
// reasons (FuSa). When launching VM, only these pre-defined
|
// reasons (FuSa). When launching VM, only these pre-defined
|
||||||
@ -312,7 +314,7 @@ func (a *Acrn) setup(ctx context.Context, id string, hypervisorConfig *Hyperviso
|
|||||||
|
|
||||||
// The path might already exist, but in case of VM templating,
|
// The path might already exist, but in case of VM templating,
|
||||||
// we have to create it since the sandbox has not created it yet.
|
// we have to create it since the sandbox has not created it yet.
|
||||||
if err = os.MkdirAll(filepath.Join(a.store.RunStoragePath(), id), DirMode); err != nil {
|
if err = os.MkdirAll(filepath.Join(a.config.RunStorePath, id), DirMode); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,7 +440,7 @@ func (a *Acrn) StartVM(ctx context.Context, timeoutSecs int) error {
|
|||||||
a.Logger().WithField("default-kernel-parameters", formatted).Debug()
|
a.Logger().WithField("default-kernel-parameters", formatted).Debug()
|
||||||
}
|
}
|
||||||
|
|
||||||
vmPath := filepath.Join(a.store.RunVMStoragePath(), a.id)
|
vmPath := filepath.Join(a.config.VMStorePath, a.id)
|
||||||
err := os.MkdirAll(vmPath, DirMode)
|
err := os.MkdirAll(vmPath, DirMode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -634,7 +636,7 @@ func (a *Acrn) GetVMConsole(ctx context.Context, id string) (string, string, err
|
|||||||
span, _ := katatrace.Trace(ctx, a.Logger(), "GetVMConsole", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
span, _ := katatrace.Trace(ctx, a.Logger(), "GetVMConsole", acrnTracingTags, map[string]string{"sandbox_id": a.id})
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
consoleURL, err := utils.BuildSocketPath(a.store.RunVMStoragePath(), id, acrnConsoleSocket)
|
consoleURL, err := utils.BuildSocketPath(a.config.VMStorePath, id, acrnConsoleSocket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return consoleProtoUnix, "", err
|
return consoleProtoUnix, "", err
|
||||||
}
|
}
|
||||||
@ -698,14 +700,14 @@ func (a *Acrn) toGrpc(ctx context.Context) ([]byte, error) {
|
|||||||
return nil, errors.New("acrn is not supported by VM cache")
|
return nil, errors.New("acrn is not supported by VM cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Acrn) Save() (s persistapi.HypervisorState) {
|
func (a *Acrn) Save() (s hv.HypervisorState) {
|
||||||
s.Pid = a.state.PID
|
s.Pid = a.state.PID
|
||||||
s.Type = string(AcrnHypervisor)
|
s.Type = string(AcrnHypervisor)
|
||||||
s.UUID = a.state.UUID
|
s.UUID = a.state.UUID
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Acrn) Load(s persistapi.HypervisorState) {
|
func (a *Acrn) Load(s hv.HypervisorState) {
|
||||||
a.state.PID = s.Pid
|
a.state.PID = s.Pid
|
||||||
a.state.UUID = s.UUID
|
a.state.UUID = s.UUID
|
||||||
}
|
}
|
||||||
@ -719,7 +721,7 @@ func (a *Acrn) Check() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Acrn) GenerateSocket(id string) (interface{}, error) {
|
func (a *Acrn) GenerateSocket(id string) (interface{}, error) {
|
||||||
return generateVMSocket(id, a.store.RunVMStoragePath())
|
return generateVMSocket(id, a.config.VMStorePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetACRNUUIDBytes returns UUID bytes that is used for VM creation
|
// GetACRNUUIDBytes returns UUID bytes that is used for VM creation
|
||||||
@ -782,6 +784,7 @@ func (a *Acrn) GetMaxSupportedACRNVM() (uint8, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Acrn) storeInfo() error {
|
func (a *Acrn) storeInfo() error {
|
||||||
|
/*
|
||||||
relPath := filepath.Join(UUIDPathSuffix, uuidFile)
|
relPath := filepath.Join(UUIDPathSuffix, uuidFile)
|
||||||
|
|
||||||
jsonOut, err := json.Marshal(a.info)
|
jsonOut, err := json.Marshal(a.info)
|
||||||
@ -791,14 +794,14 @@ func (a *Acrn) storeInfo() error {
|
|||||||
|
|
||||||
if err := a.store.GlobalWrite(relPath, jsonOut); err != nil {
|
if err := a.store.GlobalWrite(relPath, jsonOut); err != nil {
|
||||||
return fmt.Errorf("failed to write uuid to file: %v", err)
|
return fmt.Errorf("failed to write uuid to file: %v", err)
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Acrn) loadInfo() error {
|
func (a *Acrn) loadInfo() error {
|
||||||
|
/*
|
||||||
relPath := filepath.Join(UUIDPathSuffix, uuidFile)
|
relPath := filepath.Join(UUIDPathSuffix, uuidFile)
|
||||||
|
|
||||||
data, err := a.store.GlobalRead(relPath)
|
data, err := a.store.GlobalRead(relPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to read uuid from file: %v", err)
|
return fmt.Errorf("failed to read uuid from file: %v", err)
|
||||||
@ -806,14 +809,11 @@ func (a *Acrn) loadInfo() error {
|
|||||||
|
|
||||||
if err := json.Unmarshal(data, &a.info); err != nil {
|
if err := json.Unmarshal(data, &a.info); err != nil {
|
||||||
return fmt.Errorf("failed to unmarshal uuid info: %v", err)
|
return fmt.Errorf("failed to unmarshal uuid info: %v", err)
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Acrn) IsRateLimiterBuiltin() bool {
|
func (a *Acrn) IsRateLimiterBuiltin() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Acrn) setSandbox(sandbox *Sandbox) {
|
|
||||||
a.sandbox = sandbox
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user