diff --git a/src/runtime/virtcontainers/hypervisor.go b/src/runtime/virtcontainers/hypervisor.go index 67c725442d..713280be72 100644 --- a/src/runtime/virtcontainers/hypervisor.go +++ b/src/runtime/virtcontainers/hypervisor.go @@ -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 diff --git a/src/runtime/virtcontainers/hypervisor_linux.go b/src/runtime/virtcontainers/hypervisor_linux.go new file mode 100644 index 0000000000..1fd0375b81 --- /dev/null +++ b/src/runtime/virtcontainers/hypervisor_linux.go @@ -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) + } +} diff --git a/src/runtime/virtcontainers/hypervisor_amd64.go b/src/runtime/virtcontainers/hypervisor_linux_amd64.go similarity index 100% rename from src/runtime/virtcontainers/hypervisor_amd64.go rename to src/runtime/virtcontainers/hypervisor_linux_amd64.go diff --git a/src/runtime/virtcontainers/hypervisor_arm64.go b/src/runtime/virtcontainers/hypervisor_linux_arm64.go similarity index 76% rename from src/runtime/virtcontainers/hypervisor_arm64.go rename to src/runtime/virtcontainers/hypervisor_linux_arm64.go index cdf38165a4..9c6a13ea91 100644 --- a/src/runtime/virtcontainers/hypervisor_arm64.go +++ b/src/runtime/virtcontainers/hypervisor_linux_arm64.go @@ -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 } diff --git a/src/runtime/virtcontainers/hypervisor_arm64_test.go b/src/runtime/virtcontainers/hypervisor_linux_arm64_test.go similarity index 100% rename from src/runtime/virtcontainers/hypervisor_arm64_test.go rename to src/runtime/virtcontainers/hypervisor_linux_arm64_test.go