forked from kata-containers/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
direct.go
54 lines (43 loc) · 1.16 KB
/
direct.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2018 HyperHQ Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// direct implements base vm factory without vm templating.
package direct
import (
"context"
pb "github.com/kata-containers/runtime/protocols/cache"
vc "github.com/kata-containers/runtime/virtcontainers"
"github.com/kata-containers/runtime/virtcontainers/factory/base"
)
type direct struct {
config vc.VMConfig
}
// New returns a new direct vm factory.
func New(ctx context.Context, config vc.VMConfig) base.FactoryBase {
return &direct{config}
}
// Config returns the direct factory's configuration.
func (d *direct) Config() vc.VMConfig {
return d.config
}
// GetBaseVM create a new VM directly.
func (d *direct) GetBaseVM(ctx context.Context, config vc.VMConfig) (*vc.VM, error) {
vm, err := vc.NewVM(ctx, config)
if err != nil {
return nil, err
}
err = vm.Pause()
if err != nil {
vm.Stop()
return nil, err
}
return vm, nil
}
// CloseFactory closes the direct vm factory.
func (d *direct) CloseFactory(ctx context.Context) {
}
// GetVMStatus is not supported
func (d *direct) GetVMStatus() []*pb.GrpcVMStatus {
panic("ERROR: package direct does not support GetVMStatus")
}