mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-25 15:02:45 +00:00
hypervisor: Expose the hypervisor itself
Export the top level hypervisor type s/hypervisor/Hypervisor Fixes: #2880 Signed-off-by: Manohar Castelino <mcastelino@apple.com> Signed-off-by: Eric Ernst <eric_ernst@apple.com>
This commit is contained in:
parent
a72bed5b34
commit
52268d0ece
@ -140,10 +140,10 @@ type agent interface {
|
|||||||
resumeContainer(ctx context.Context, sandbox *Sandbox, c Container) error
|
resumeContainer(ctx context.Context, sandbox *Sandbox, c Container) error
|
||||||
|
|
||||||
// configure will update agent settings based on provided arguments
|
// configure will update agent settings based on provided arguments
|
||||||
configure(ctx context.Context, h hypervisor, id, sharePath string, config KataAgentConfig) error
|
configure(ctx context.Context, h Hypervisor, id, sharePath string, config KataAgentConfig) error
|
||||||
|
|
||||||
// configureFromGrpc will update agent settings based on provided arguments which from Grpc
|
// configureFromGrpc will update agent settings based on provided arguments which from Grpc
|
||||||
configureFromGrpc(ctx context.Context, h hypervisor, id string, config KataAgentConfig) error
|
configureFromGrpc(ctx context.Context, h Hypervisor, id string, config KataAgentConfig) error
|
||||||
|
|
||||||
// reseedRNG will reseed the guest random number generator
|
// reseedRNG will reseed the guest random number generator
|
||||||
reseedRNG(ctx context.Context, data []byte) error
|
reseedRNG(ctx context.Context, data []byte) error
|
||||||
|
@ -9,13 +9,13 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/fs"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
ktu "github.com/kata-containers/kata-containers/src/runtime/pkg/katatestutils"
|
ktu "github.com/kata-containers/kata-containers/src/runtime/pkg/katatestutils"
|
||||||
|
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/fs"
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/annotations"
|
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/annotations"
|
||||||
vccgroups "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/cgroups"
|
vccgroups "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/cgroups"
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/mock"
|
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/mock"
|
||||||
|
@ -121,12 +121,12 @@ func (endpoint *BridgedMacvlanEndpoint) Detach(ctx context.Context, netNsCreated
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HotAttach for bridged macvlan endpoint not supported yet
|
// HotAttach for bridged macvlan endpoint not supported yet
|
||||||
func (endpoint *BridgedMacvlanEndpoint) HotAttach(ctx context.Context, h hypervisor) error {
|
func (endpoint *BridgedMacvlanEndpoint) HotAttach(ctx context.Context, h Hypervisor) error {
|
||||||
return fmt.Errorf("BridgedMacvlanEndpoint does not support Hot attach")
|
return fmt.Errorf("BridgedMacvlanEndpoint does not support Hot attach")
|
||||||
}
|
}
|
||||||
|
|
||||||
// HotDetach for bridged macvlan endpoint not supported yet
|
// HotDetach for bridged macvlan endpoint not supported yet
|
||||||
func (endpoint *BridgedMacvlanEndpoint) HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error {
|
func (endpoint *BridgedMacvlanEndpoint) HotDetach(ctx context.Context, h Hypervisor, netNsCreated bool, netNsPath string) error {
|
||||||
return fmt.Errorf("BridgedMacvlanEndpoint does not support Hot detach")
|
return fmt.Errorf("BridgedMacvlanEndpoint does not support Hot detach")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ type Endpoint interface {
|
|||||||
SetPciPath(vcTypes.PciPath)
|
SetPciPath(vcTypes.PciPath)
|
||||||
Attach(context.Context, *Sandbox) error
|
Attach(context.Context, *Sandbox) error
|
||||||
Detach(ctx context.Context, netNsCreated bool, netNsPath string) error
|
Detach(ctx context.Context, netNsCreated bool, netNsPath string) error
|
||||||
HotAttach(ctx context.Context, h hypervisor) error
|
HotAttach(ctx context.Context, h Hypervisor) error
|
||||||
HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error
|
HotDetach(ctx context.Context, h Hypervisor, netNsCreated bool, netNsPath string) error
|
||||||
|
|
||||||
save() persistapi.NetworkEndpoint
|
save() persistapi.NetworkEndpoint
|
||||||
load(persistapi.NetworkEndpoint)
|
load(persistapi.NetworkEndpoint)
|
||||||
|
@ -186,7 +186,7 @@ func (hType *HypervisorType) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewHypervisor returns an hypervisor from and hypervisor type.
|
// NewHypervisor returns an hypervisor from and hypervisor type.
|
||||||
func NewHypervisor(hType HypervisorType) (hypervisor, error) {
|
func NewHypervisor(hType HypervisorType) (Hypervisor, error) {
|
||||||
store, err := persist.GetDriver()
|
store, err := persist.GetDriver()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -874,7 +874,7 @@ func RunningOnVMM(cpuInfoPath string) (bool, error) {
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetHypervisorPid(h hypervisor) int {
|
func GetHypervisorPid(h Hypervisor) int {
|
||||||
pids := h.GetPids()
|
pids := h.GetPids()
|
||||||
if len(pids) == 0 {
|
if len(pids) == 0 {
|
||||||
return 0
|
return 0
|
||||||
@ -897,8 +897,7 @@ func generateVMSocket(id string, vmStogarePath string) (interface{}, error) {
|
|||||||
|
|
||||||
// hypervisor is the virtcontainers hypervisor interface.
|
// hypervisor is the virtcontainers hypervisor interface.
|
||||||
// The default hypervisor implementation is Qemu.
|
// The default hypervisor implementation is Qemu.
|
||||||
type hypervisor interface {
|
type Hypervisor interface {
|
||||||
setConfig(config *HypervisorConfig) error
|
|
||||||
CreateVM(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig) error
|
CreateVM(ctx context.Context, id string, networkNS NetworkNamespace, hypervisorConfig *HypervisorConfig) error
|
||||||
StartVM(ctx context.Context, timeout int) error
|
StartVM(ctx context.Context, timeout int) error
|
||||||
|
|
||||||
@ -921,6 +920,7 @@ type hypervisor interface {
|
|||||||
Cleanup(ctx context.Context) error
|
Cleanup(ctx context.Context) error
|
||||||
// getPids returns a slice of hypervisor related process ids.
|
// getPids returns a slice of hypervisor related process ids.
|
||||||
// The hypervisor pid must be put at index 0.
|
// The hypervisor pid must be put at index 0.
|
||||||
|
setConfig(config *HypervisorConfig) error
|
||||||
GetPids() []int
|
GetPids() []int
|
||||||
GetVirtioFsPid() *int
|
GetVirtioFsPid() *int
|
||||||
fromGrpc(ctx context.Context, hypervisorConfig *HypervisorConfig, j []byte) error
|
fromGrpc(ctx context.Context, hypervisorConfig *HypervisorConfig, j []byte) error
|
||||||
|
@ -65,7 +65,7 @@ func TestStringFromUnknownHypervisorType(t *testing.T) {
|
|||||||
testStringFromHypervisorType(t, hypervisorType, "")
|
testStringFromHypervisorType(t, hypervisorType, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testNewHypervisorFromHypervisorType(t *testing.T, hypervisorType HypervisorType, expected hypervisor) {
|
func testNewHypervisorFromHypervisorType(t *testing.T, hypervisorType HypervisorType, expected Hypervisor) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
hy, err := NewHypervisor(hypervisorType)
|
hy, err := NewHypervisor(hypervisorType)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
@ -93,6 +93,7 @@ func (endpoint *IPVlanEndpoint) NetworkPair() *NetworkInterfacePair {
|
|||||||
|
|
||||||
// Attach for ipvlan endpoint bridges the network pair and adds the
|
// Attach for ipvlan endpoint bridges the network pair and adds the
|
||||||
// tap interface of the network pair to the hypervisor.
|
// tap interface of the network pair to the hypervisor.
|
||||||
|
// tap interface of the network pair to the Hypervisor.
|
||||||
func (endpoint *IPVlanEndpoint) Attach(ctx context.Context, s *Sandbox) error {
|
func (endpoint *IPVlanEndpoint) Attach(ctx context.Context, s *Sandbox) error {
|
||||||
span, ctx := ipvlanTrace(ctx, "Attach", endpoint)
|
span, ctx := ipvlanTrace(ctx, "Attach", endpoint)
|
||||||
defer span.End()
|
defer span.End()
|
||||||
@ -124,12 +125,12 @@ func (endpoint *IPVlanEndpoint) Detach(ctx context.Context, netNsCreated bool, n
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HotAttach for ipvlan endpoint not supported yet
|
// HotAttach for ipvlan endpoint not supported yet
|
||||||
func (endpoint *IPVlanEndpoint) HotAttach(ctx context.Context, h hypervisor) error {
|
func (endpoint *IPVlanEndpoint) HotAttach(ctx context.Context, h Hypervisor) error {
|
||||||
return fmt.Errorf("IPVlanEndpoint does not support Hot attach")
|
return fmt.Errorf("IPVlanEndpoint does not support Hot attach")
|
||||||
}
|
}
|
||||||
|
|
||||||
// HotDetach for ipvlan endpoint not supported yet
|
// HotDetach for ipvlan endpoint not supported yet
|
||||||
func (endpoint *IPVlanEndpoint) HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error {
|
func (endpoint *IPVlanEndpoint) HotDetach(ctx context.Context, h Hypervisor, netNsCreated bool, netNsPath string) error {
|
||||||
return fmt.Errorf("IPVlanEndpoint does not support Hot detach")
|
return fmt.Errorf("IPVlanEndpoint does not support Hot detach")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ func (k *kataAgent) capabilities() types.Capabilities {
|
|||||||
return caps
|
return caps
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) internalConfigure(ctx context.Context, h hypervisor, id string, config KataAgentConfig) error {
|
func (k *kataAgent) internalConfigure(ctx context.Context, h Hypervisor, id string, config KataAgentConfig) error {
|
||||||
span, _ := katatrace.Trace(ctx, k.Logger(), "configure", kataAgentTracingTags)
|
span, _ := katatrace.Trace(ctx, k.Logger(), "configure", kataAgentTracingTags)
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
@ -421,7 +421,7 @@ func (k *kataAgent) cleanupSandboxBindMounts(sandbox *Sandbox) error {
|
|||||||
return retErr
|
return retErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) configure(ctx context.Context, h hypervisor, id, sharePath string, config KataAgentConfig) error {
|
func (k *kataAgent) configure(ctx context.Context, h Hypervisor, id, sharePath string, config KataAgentConfig) error {
|
||||||
span, ctx := katatrace.Trace(ctx, k.Logger(), "configure", kataAgentTracingTags)
|
span, ctx := katatrace.Trace(ctx, k.Logger(), "configure", kataAgentTracingTags)
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
@ -466,7 +466,7 @@ func (k *kataAgent) configure(ctx context.Context, h hypervisor, id, sharePath s
|
|||||||
return h.AddDevice(ctx, sharedVolume, FsDev)
|
return h.AddDevice(ctx, sharedVolume, FsDev)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) configureFromGrpc(ctx context.Context, h hypervisor, id string, config KataAgentConfig) error {
|
func (k *kataAgent) configureFromGrpc(ctx context.Context, h Hypervisor, id string, config KataAgentConfig) error {
|
||||||
return k.internalConfigure(ctx, h, id, config)
|
return k.internalConfigure(ctx, h, id, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,12 +91,12 @@ func (endpoint *MacvtapEndpoint) Detach(ctx context.Context, netNsCreated bool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HotAttach for macvtap endpoint not supported yet
|
// HotAttach for macvtap endpoint not supported yet
|
||||||
func (endpoint *MacvtapEndpoint) HotAttach(ctx context.Context, h hypervisor) error {
|
func (endpoint *MacvtapEndpoint) HotAttach(ctx context.Context, h Hypervisor) error {
|
||||||
return fmt.Errorf("MacvtapEndpoint does not support Hot attach")
|
return fmt.Errorf("MacvtapEndpoint does not support Hot attach")
|
||||||
}
|
}
|
||||||
|
|
||||||
// HotDetach for macvtap endpoint not supported yet
|
// HotDetach for macvtap endpoint not supported yet
|
||||||
func (endpoint *MacvtapEndpoint) HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error {
|
func (endpoint *MacvtapEndpoint) HotDetach(ctx context.Context, h Hypervisor, netNsCreated bool, netNsPath string) error {
|
||||||
return fmt.Errorf("MacvtapEndpoint does not support Hot detach")
|
return fmt.Errorf("MacvtapEndpoint does not support Hot detach")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,11 +173,11 @@ func (n *mockAgent) resumeContainer(ctx context.Context, sandbox *Sandbox, c Con
|
|||||||
}
|
}
|
||||||
|
|
||||||
// configure is the Noop agent configuration implementation. It does nothing.
|
// configure is the Noop agent configuration implementation. It does nothing.
|
||||||
func (n *mockAgent) configure(ctx context.Context, h hypervisor, id, sharePath string, config KataAgentConfig) error {
|
func (n *mockAgent) configure(ctx context.Context, h Hypervisor, id, sharePath string, config KataAgentConfig) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *mockAgent) configureFromGrpc(ctx context.Context, h hypervisor, id string, config KataAgentConfig) error {
|
func (n *mockAgent) configureFromGrpc(ctx context.Context, h Hypervisor, id string, config KataAgentConfig) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ func TestMockHypervisorCreateVM(t *testing.T) {
|
|||||||
func TestMockHypervisorStartSandbox(t *testing.T) {
|
func TestMockHypervisorStartSandbox(t *testing.T) {
|
||||||
var m *mockHypervisor
|
var m *mockHypervisor
|
||||||
|
|
||||||
assert.NoError(t, m.StartVM(context.Background(), vmStartTimeout))
|
assert.NoError(t, m.StartVM(context.Background(), VmStartTimeout))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMockHypervisorStopSandbox(t *testing.T) {
|
func TestMockHypervisorStopSandbox(t *testing.T) {
|
||||||
|
@ -142,6 +142,7 @@ func (m *monitor) watchAgent(ctx context.Context) {
|
|||||||
func (m *monitor) watchHypervisor(ctx context.Context) error {
|
func (m *monitor) watchHypervisor(ctx context.Context) error {
|
||||||
if err := m.sandbox.hypervisor.Check(); err != nil {
|
if err := m.sandbox.hypervisor.Check(); err != nil {
|
||||||
m.notify(ctx, errors.Wrapf(err, "failed to ping hypervisor process"))
|
m.notify(ctx, errors.Wrapf(err, "failed to ping hypervisor process"))
|
||||||
|
m.notify(ctx, errors.Wrapf(err, "failed to ping Hypervisor process"))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -426,7 +426,7 @@ func getLinkByName(netHandle *netlink.Handle, name string, expectedLink netlink.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The endpoint type should dictate how the connection needs to happen.
|
// The endpoint type should dictate how the connection needs to happen.
|
||||||
func xConnectVMNetwork(ctx context.Context, endpoint Endpoint, h hypervisor) error {
|
func xConnectVMNetwork(ctx context.Context, endpoint Endpoint, h Hypervisor) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
span, ctx := networkTrace(ctx, "xConnectVMNetwork", endpoint)
|
span, ctx := networkTrace(ctx, "xConnectVMNetwork", endpoint)
|
||||||
@ -701,7 +701,7 @@ func setupTCFiltering(ctx context.Context, endpoint Endpoint, queues int, disabl
|
|||||||
attrs = link.Attrs()
|
attrs = link.Attrs()
|
||||||
|
|
||||||
// Save the veth MAC address to the TAP so that it can later be used
|
// Save the veth MAC address to the TAP so that it can later be used
|
||||||
// to build the hypervisor command line. This MAC address has to be
|
// to build the Hypervisor command line. This MAC address has to be
|
||||||
// the one inside the VM in order to avoid any firewall issues. The
|
// the one inside the VM in order to avoid any firewall issues. The
|
||||||
// bridge created by the network plugin on the host actually expects
|
// bridge created by the network plugin on the host actually expects
|
||||||
// to see traffic from this MAC address and not another one.
|
// to see traffic from this MAC address and not another one.
|
||||||
@ -1413,7 +1413,7 @@ func (n *Network) PostAdd(ctx context.Context, ns *NetworkNamespace, hotplug boo
|
|||||||
|
|
||||||
// Remove network endpoints in the network namespace. It also deletes the network
|
// Remove network endpoints in the network namespace. It also deletes the network
|
||||||
// namespace in case the namespace has been created by us.
|
// namespace in case the namespace has been created by us.
|
||||||
func (n *Network) Remove(ctx context.Context, ns *NetworkNamespace, hypervisor hypervisor) error {
|
func (n *Network) Remove(ctx context.Context, ns *NetworkNamespace, hypervisor Hypervisor) error {
|
||||||
span, ctx := n.trace(ctx, "Remove")
|
span, ctx := n.trace(ctx, "Remove")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
|
@ -121,12 +121,12 @@ func (endpoint *PhysicalEndpoint) Detach(ctx context.Context, netNsCreated bool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HotAttach for physical endpoint not supported yet
|
// HotAttach for physical endpoint not supported yet
|
||||||
func (endpoint *PhysicalEndpoint) HotAttach(ctx context.Context, h hypervisor) error {
|
func (endpoint *PhysicalEndpoint) HotAttach(ctx context.Context, h Hypervisor) error {
|
||||||
return fmt.Errorf("PhysicalEndpoint does not support Hot attach")
|
return fmt.Errorf("PhysicalEndpoint does not support Hot attach")
|
||||||
}
|
}
|
||||||
|
|
||||||
// HotDetach for physical endpoint not supported yet
|
// HotDetach for physical endpoint not supported yet
|
||||||
func (endpoint *PhysicalEndpoint) HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error {
|
func (endpoint *PhysicalEndpoint) HotDetach(ctx context.Context, h Hypervisor, netNsCreated bool, netNsPath string) error {
|
||||||
return fmt.Errorf("PhysicalEndpoint does not support Hot detach")
|
return fmt.Errorf("PhysicalEndpoint does not support Hot detach")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,9 +54,9 @@ var sandboxTracingTags = map[string]string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// vmStartTimeout represents the time in seconds a sandbox can wait before
|
// VmStartTimeout represents the time in seconds a sandbox can wait before
|
||||||
// to consider the VM starting operation failed.
|
// to consider the VM starting operation failed.
|
||||||
vmStartTimeout = 10
|
VmStartTimeout = 10
|
||||||
|
|
||||||
// DirMode is the permission bits used for creating a directory
|
// DirMode is the permission bits used for creating a directory
|
||||||
DirMode = os.FileMode(0750) | os.ModeDir
|
DirMode = os.FileMode(0750) | os.ModeDir
|
||||||
@ -171,7 +171,7 @@ type Sandbox struct {
|
|||||||
ctx context.Context
|
ctx context.Context
|
||||||
devManager api.DeviceManager
|
devManager api.DeviceManager
|
||||||
factory Factory
|
factory Factory
|
||||||
hypervisor hypervisor
|
hypervisor Hypervisor
|
||||||
agent agent
|
agent agent
|
||||||
store persistapi.PersistDriver
|
store persistapi.PersistDriver
|
||||||
|
|
||||||
@ -1199,7 +1199,7 @@ func (s *Sandbox) startVM(ctx context.Context) (err error) {
|
|||||||
return vm.assignSandbox(s)
|
return vm.assignSandbox(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.hypervisor.StartVM(ctx, vmStartTimeout)
|
return s.hypervisor.StartVM(ctx, VmStartTimeout)
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ func (endpoint *TapEndpoint) Detach(ctx context.Context, netNsCreated bool, netN
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HotAttach for the tap endpoint uses hot plug device
|
// HotAttach for the tap endpoint uses hot plug device
|
||||||
func (endpoint *TapEndpoint) HotAttach(ctx context.Context, h hypervisor) error {
|
func (endpoint *TapEndpoint) HotAttach(ctx context.Context, h Hypervisor) error {
|
||||||
networkLogger().Info("Hot attaching tap endpoint")
|
networkLogger().Info("Hot attaching tap endpoint")
|
||||||
|
|
||||||
span, ctx := tapTrace(ctx, "HotAttach", endpoint)
|
span, ctx := tapTrace(ctx, "HotAttach", endpoint)
|
||||||
@ -109,7 +109,7 @@ func (endpoint *TapEndpoint) HotAttach(ctx context.Context, h hypervisor) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HotDetach for the tap endpoint uses hot pull device
|
// HotDetach for the tap endpoint uses hot pull device
|
||||||
func (endpoint *TapEndpoint) HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error {
|
func (endpoint *TapEndpoint) HotDetach(ctx context.Context, h Hypervisor, netNsCreated bool, netNsPath string) error {
|
||||||
networkLogger().Info("Hot detaching tap endpoint")
|
networkLogger().Info("Hot detaching tap endpoint")
|
||||||
|
|
||||||
span, ctx := tapTrace(ctx, "HotDetach", endpoint)
|
span, ctx := tapTrace(ctx, "HotDetach", endpoint)
|
||||||
|
@ -101,7 +101,7 @@ func (endpoint *TuntapEndpoint) Detach(ctx context.Context, netNsCreated bool, n
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HotAttach for the tun/tap endpoint uses hot plug device
|
// HotAttach for the tun/tap endpoint uses hot plug device
|
||||||
func (endpoint *TuntapEndpoint) HotAttach(ctx context.Context, h hypervisor) error {
|
func (endpoint *TuntapEndpoint) HotAttach(ctx context.Context, h Hypervisor) error {
|
||||||
networkLogger().Info("Hot attaching tun/tap endpoint")
|
networkLogger().Info("Hot attaching tun/tap endpoint")
|
||||||
|
|
||||||
span, ctx := tuntapTrace(ctx, "HotAttach", endpoint)
|
span, ctx := tuntapTrace(ctx, "HotAttach", endpoint)
|
||||||
@ -120,7 +120,7 @@ func (endpoint *TuntapEndpoint) HotAttach(ctx context.Context, h hypervisor) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HotDetach for the tun/tap endpoint uses hot pull device
|
// HotDetach for the tun/tap endpoint uses hot pull device
|
||||||
func (endpoint *TuntapEndpoint) HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error {
|
func (endpoint *TuntapEndpoint) HotDetach(ctx context.Context, h Hypervisor, netNsCreated bool, netNsPath string) error {
|
||||||
networkLogger().Info("Hot detaching tun/tap endpoint")
|
networkLogger().Info("Hot detaching tun/tap endpoint")
|
||||||
|
|
||||||
span, ctx := tuntapTrace(ctx, "HotDetach", endpoint)
|
span, ctx := tuntapTrace(ctx, "HotDetach", endpoint)
|
||||||
|
@ -124,7 +124,7 @@ func (endpoint *VethEndpoint) Detach(ctx context.Context, netNsCreated bool, net
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HotAttach for the veth endpoint uses hot plug device
|
// HotAttach for the veth endpoint uses hot plug device
|
||||||
func (endpoint *VethEndpoint) HotAttach(ctx context.Context, h hypervisor) error {
|
func (endpoint *VethEndpoint) HotAttach(ctx context.Context, h Hypervisor) error {
|
||||||
span, ctx := vethTrace(ctx, "HotAttach", endpoint)
|
span, ctx := vethTrace(ctx, "HotAttach", endpoint)
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ func (endpoint *VethEndpoint) HotAttach(ctx context.Context, h hypervisor) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HotDetach for the veth endpoint uses hot pull device
|
// HotDetach for the veth endpoint uses hot pull device
|
||||||
func (endpoint *VethEndpoint) HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error {
|
func (endpoint *VethEndpoint) HotDetach(ctx context.Context, h Hypervisor, netNsCreated bool, netNsPath string) error {
|
||||||
if !netNsCreated {
|
if !netNsCreated {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -105,12 +105,12 @@ func (endpoint *VhostUserEndpoint) Detach(ctx context.Context, netNsCreated bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HotAttach for vhostuser endpoint not supported yet
|
// HotAttach for vhostuser endpoint not supported yet
|
||||||
func (endpoint *VhostUserEndpoint) HotAttach(ctx context.Context, h hypervisor) error {
|
func (endpoint *VhostUserEndpoint) HotAttach(ctx context.Context, h Hypervisor) error {
|
||||||
return fmt.Errorf("VhostUserEndpoint does not support Hot attach")
|
return fmt.Errorf("VhostUserEndpoint does not support Hot attach")
|
||||||
}
|
}
|
||||||
|
|
||||||
// HotDetach for vhostuser endpoint not supported yet
|
// HotDetach for vhostuser endpoint not supported yet
|
||||||
func (endpoint *VhostUserEndpoint) HotDetach(ctx context.Context, h hypervisor, netNsCreated bool, netNsPath string) error {
|
func (endpoint *VhostUserEndpoint) HotDetach(ctx context.Context, h Hypervisor, netNsCreated bool, netNsPath string) error {
|
||||||
return fmt.Errorf("VhostUserEndpoint does not support Hot detach")
|
return fmt.Errorf("VhostUserEndpoint does not support Hot detach")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ var urandomDev = "/dev/urandom"
|
|||||||
|
|
||||||
// VM is abstraction of a virtual machine.
|
// VM is abstraction of a virtual machine.
|
||||||
type VM struct {
|
type VM struct {
|
||||||
hypervisor hypervisor
|
hypervisor Hypervisor
|
||||||
agent agent
|
agent agent
|
||||||
store persistapi.PersistDriver
|
store persistapi.PersistDriver
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ func NewVM(ctx context.Context, config VMConfig) (*VM, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3. boot up guest vm
|
// 3. boot up guest vm
|
||||||
if err = hypervisor.StartVM(ctx, vmStartTimeout); err != nil {
|
if err = hypervisor.StartVM(ctx, VmStartTimeout); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ func (v *VM) Resume(ctx context.Context) error {
|
|||||||
// Start kicks off a configured VM.
|
// Start kicks off a configured VM.
|
||||||
func (v *VM) Start(ctx context.Context) error {
|
func (v *VM) Start(ctx context.Context) error {
|
||||||
v.logger().Info("start vm")
|
v.logger().Info("start vm")
|
||||||
return v.hypervisor.StartVM(ctx, vmStartTimeout)
|
return v.hypervisor.StartVM(ctx, VmStartTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disconnect agent connections to a VM
|
// Disconnect agent connections to a VM
|
||||||
|
Loading…
Reference in New Issue
Block a user