mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 20:24:31 +00:00
virtcontainers: Split hypervisor into Linux and OS agnostic bits
Keep all the OS agnostic bits in the hypervisor.go and hypervisor_ARCH.go files. Fixes #3614 Signed-off-by: Eric Ernst <eric_ernst@apple.com> Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
This commit is contained in:
parent
fa0e9dc6b1
commit
26b3f0017c
@ -20,7 +20,6 @@ import (
|
||||
hv "github.com/kata-containers/kata-containers/src/runtime/pkg/hypervisors"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/config"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -198,25 +197,6 @@ func (hType *HypervisorType) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
// NewHypervisor returns an hypervisor from a hypervisor type.
|
||||
func NewHypervisor(hType HypervisorType) (Hypervisor, error) {
|
||||
|
||||
switch hType {
|
||||
case QemuHypervisor:
|
||||
return &qemu{}, nil
|
||||
case FirecrackerHypervisor:
|
||||
return &firecracker{}, nil
|
||||
case AcrnHypervisor:
|
||||
return &Acrn{}, nil
|
||||
case ClhHypervisor:
|
||||
return &cloudHypervisor{}, nil
|
||||
case MockHypervisor:
|
||||
return &mockHypervisor{}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("Unknown hypervisor type %s", hType)
|
||||
}
|
||||
}
|
||||
|
||||
// GetHypervisorSocketTemplate returns the full "template" path to the
|
||||
// hypervisor socket. If the specified hypervisor doesn't use a socket,
|
||||
// an empty string is returned.
|
||||
@ -900,19 +880,6 @@ func GetHypervisorPid(h Hypervisor) int {
|
||||
return pids[0]
|
||||
}
|
||||
|
||||
func generateVMSocket(id string, vmStogarePath string) (interface{}, error) {
|
||||
vhostFd, contextID, err := utils.FindContextID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.VSock{
|
||||
VhostFd: vhostFd,
|
||||
ContextID: contextID,
|
||||
Port: uint32(vSockPort),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Kind of guest protection
|
||||
type guestProtection uint8
|
||||
|
||||
|
45
src/runtime/virtcontainers/hypervisor_linux.go
Normal file
45
src/runtime/virtcontainers/hypervisor_linux.go
Normal file
@ -0,0 +1,45 @@
|
||||
// Copyright (c) 2021 Apple Inc.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
package virtcontainers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
||||
)
|
||||
|
||||
func generateVMSocket(id string, vmStogarePath string) (interface{}, error) {
|
||||
vhostFd, contextID, err := utils.FindContextID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.VSock{
|
||||
VhostFd: vhostFd,
|
||||
ContextID: contextID,
|
||||
Port: uint32(vSockPort),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NewHypervisor returns an hypervisor from a hypervisor type.
|
||||
func NewHypervisor(hType HypervisorType) (Hypervisor, error) {
|
||||
|
||||
switch hType {
|
||||
case QemuHypervisor:
|
||||
return &qemu{}, nil
|
||||
case FirecrackerHypervisor:
|
||||
return &firecracker{}, nil
|
||||
case AcrnHypervisor:
|
||||
return &Acrn{}, nil
|
||||
case ClhHypervisor:
|
||||
return &cloudHypervisor{}, nil
|
||||
case MockHypervisor:
|
||||
return &mockHypervisor{}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("Unknown hypervisor type %s", hType)
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
|
||||
package virtcontainers
|
||||
|
||||
//Returns pefProtection if the firmware directory exists
|
||||
// Guest protection is not supported on ARM64.
|
||||
func availableGuestProtection() (guestProtection, error) {
|
||||
return noneProtection, nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user