mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-26 18:44:47 +01:00
The PR moves ahead the start of proxy process for vm factory so that it waits for both vm and proxy to be up at the same time. This saves about 300ms for new container creation in my local test machine. Fixes: #683 Signed-off-by: Peng Tao <bergwolf@gmail.com>
49 lines
984 B
Go
49 lines
984 B
Go
// Copyright (c) 2018 HyperHQ Inc.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
// direct implements base vm factory without vm templating.
|
|
|
|
package direct
|
|
|
|
import (
|
|
"context"
|
|
|
|
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) {
|
|
}
|