mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-04 15:04:25 +01:00
This commit adds a new gRPC function Status to CacheService. VMCache server will reply the status of VMCache server. Factory destroy will call gRPC Status to get the status of VMCache server and output it when VMCache is enabled. Fixes: #1395 Signed-off-by: Hui Zhu <teawater@hyper.sh>
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
// 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")
|
|
}
|