mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-01 13:34:20 +01:00
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>
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
// 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)
|
|
}
|
|
}
|