1
0
mirror of https://github.com/kata-containers/kata-containers.git synced 2025-05-11 18:05:43 +00:00

Merge pull request from stevenhorsman/remote-hypervisor-cherry-picks

CC: Remote hypervisor merge to main
This commit is contained in:
Wainer Moschetta 2023-11-20 15:22:37 -03:00 committed by GitHub
commit 728565d1e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 1908 additions and 30 deletions

View File

@ -105,6 +105,7 @@ GENERATED_VARS = \
CONFIG_CLH_IN \
CONFIG_FC_IN \
CONFIG_STRATOVIRT_IN \
CONFIG_REMOTE_IN \
$(USER_VARS)
SCRIPTS += $(COLLECT_SCRIPT)
SCRIPTS_DIR := $(BINDIR)
@ -149,12 +150,13 @@ HYPERVISOR_FC = firecracker
HYPERVISOR_QEMU = qemu
HYPERVISOR_CLH = cloud-hypervisor
HYPERVISOR_STRATOVIRT = stratovirt
HYPERVISOR_REMOTE = remote
# Determines which hypervisor is specified in $(CONFIG_FILE).
DEFAULT_HYPERVISOR ?= $(HYPERVISOR_QEMU)
# List of hypervisors this build system can generate configuration for.
HYPERVISORS := $(HYPERVISOR_ACRN) $(HYPERVISOR_FC) $(HYPERVISOR_QEMU) $(HYPERVISOR_CLH) $(HYPERVISOR_STRATOVIRT)
HYPERVISORS := $(HYPERVISOR_ACRN) $(HYPERVISOR_FC) $(HYPERVISOR_QEMU) $(HYPERVISOR_CLH) $(HYPERVISOR_STRATOVIRT) $(HYPERVISOR_REMOTE)
QEMUPATH := $(QEMUBINDIR)/$(QEMUCMD)
QEMUVALIDHYPERVISORPATHS := [\"$(QEMUPATH)\"]
@ -342,6 +344,18 @@ ifneq (,$(QEMUCMD))
CONFIGS += $(CONFIG_QEMU_NVIDIA_GPU)
CONFIG_FILE_REMOTE = configuration-remote.toml
CONFIG_REMOTE = config/$(CONFIG_FILE_REMOTE)
CONFIG_REMOTE_IN = $(CONFIG_REMOTE).in
CONFIG_PATH_REMOTE = $(abspath $(CONFDIR)/$(CONFIG_FILE_REMOTE))
CONFIG_PATHS += $(CONFIG_PATH_REMOTE)
SYSCONFIG_REMOTE = $(abspath $(SYSCONFDIR)/$(CONFIG_FILE_REMOTE))
SYSCONFIG_PATHS += $(SYSCONFIG_REMOTE)
CONFIGS += $(CONFIG_REMOTE)
# qemu-specific options (all should be suffixed by "_QEMU")
DEFBLOCKSTORAGEDRIVER_QEMU := virtio-scsi
DEFBLOCKDEVICEAIO_QEMU := io_uring
@ -519,6 +533,7 @@ USER_VARS += CONFIG_FC_IN
USER_VARS += CONFIG_STRATOVIRT_IN
USER_VARS += CONFIG_PATH
USER_VARS += CONFIG_QEMU_IN
USER_VARS += CONFIG_REMOTE_IN
USER_VARS += DESTDIR
USER_VARS += DEFAULT_HYPERVISOR
USER_VARS += ACRNCMD

View File

@ -323,6 +323,8 @@ func archHostCanCreateVMContainer(hypervisorType vc.HypervisorType) error {
return kvmIsUsable()
case vc.AcrnHypervisor:
return acrnIsUsable()
case vc.RemoteHypervisor:
return nil
case vc.MockHypervisor:
return nil
default:

View File

@ -86,6 +86,9 @@ func checkKVMExtensions() error {
}
func archHostCanCreateVMContainer(hypervisorType vc.HypervisorType) error {
if hypervisorType == "remote" {
return nil
}
if err := kvmIsUsable(); err != nil {
return err
}

View File

@ -61,6 +61,9 @@ func setCPUtype(hypervisorType vc.HypervisorType) error {
}
func archHostCanCreateVMContainer(hypervisorType vc.HypervisorType) error {
if hypervisorType == "remote" {
return nil
}
return kvmIsUsable()
}

View File

@ -55,6 +55,9 @@ func kvmIsUsable() error {
}
func archHostCanCreateVMContainer(hypervisorType vc.HypervisorType) error {
if hypervisorType == "remote" {
return nil
}
return kvmIsUsable()
}

View File

@ -0,0 +1,318 @@
# Copyright (c) 2017-2019 Intel Corporation
# Copyright (c) 2023 IBM Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
# XXX: WARNING: this file is auto-generated.
# XXX:
# XXX: Source file: "@CONFIG_REMOTE_IN@"
# XXX: Project:
# XXX: Name: @PROJECT_NAME@
# XXX: Type: @PROJECT_TYPE@
[hypervisor.remote]
remote_hypervisor_socket = "/run/peerpod/hypervisor.sock"
remote_hypervisor_timeout = 600
# Enable confidential guest support.
# Toggling that setting may trigger different hardware features, ranging
# from memory encryption to both memory and CPU-state encryption and integrity.
# The Kata Containers runtime dynamically detects the available feature set and
# aims at enabling the largest possible one, returning an error if none is
# available, or none is supported by the hypervisor.
#
# Known limitations:
# * Does not work by design:
# - CPU Hotplug
# - Memory Hotplug
# - NVDIMM devices
#
# Default false
# confidential_guest = true
# List of valid annotation names for the hypervisor
# Each member of the list is a regular expression, which is the base name
# of the annotation, e.g. "path" for io.katacontainers.config.hypervisor.path"
# Note: Remote hypervisor is only handling the following annotations
enable_annotations = ["machine_type", "default_memory", "default_vcpus"]
# Optional space-separated list of options to pass to the guest kernel.
# For example, use `kernel_params = "vsyscall=emulate"` if you are having
# trouble running pre-2.15 glibc.
#
# WARNING: - any parameter specified here will take priority over the default
# parameter value of the same name used to start the virtual machine.
# Do not set values here unless you understand the impact of doing so as you
# may stop the virtual machine from booting.
# To see the list of default parameters, enable hypervisor debug, create a
# container and look for 'default-kernel-parameters' log entries.
# NOTE: kernel_params are not currently passed over in remote hypervisor
# kernel_params = ""
# Path to the firmware.
# If you want that qemu uses the default firmware leave this option empty
firmware = "@FIRMWAREPATH@"
# Default number of vCPUs per SB/VM:
# unspecified or 0 --> will be set to @DEFVCPUS@
# < 0 --> will be set to the actual number of physical cores
# > 0 <= number of physical cores --> will be set to the specified number
# > number of physical cores --> will be set to the actual number of physical cores
# default_vcpus = 1
# Default maximum number of vCPUs per SB/VM:
# unspecified or == 0 --> will be set to the actual number of physical cores or to the maximum number
# of vCPUs supported by KVM if that number is exceeded
# > 0 <= number of physical cores --> will be set to the specified number
# > number of physical cores --> will be set to the actual number of physical cores or to the maximum number
# of vCPUs supported by KVM if that number is exceeded
# WARNING: Depending of the architecture, the maximum number of vCPUs supported by KVM is used when
# the actual number of physical cores is greater than it.
# WARNING: Be aware that this value impacts the virtual machine's memory footprint and CPU
# the hotplug functionality. For example, `default_maxvcpus = 240` specifies that until 240 vCPUs
# can be added to a SB/VM, but the memory footprint will be big. Another example, with
# `default_maxvcpus = 8` the memory footprint will be small, but 8 will be the maximum number of
# vCPUs supported by the SB/VM. In general, we recommend that you do not edit this variable,
# unless you know what are you doing.
# NOTICE: on arm platform with gicv2 interrupt controller, set it to 8.
# default_maxvcpus = @DEFMAXVCPUS@
# Bridges can be used to hot plug devices.
# Limitations:
# * Currently only pci bridges are supported
# * Until 30 devices per bridge can be hot plugged.
# * Until 5 PCI bridges can be cold plugged per VM.
# This limitation could be a bug in qemu or in the kernel
# Default number of bridges per SB/VM:
# unspecified or 0 --> will be set to @DEFBRIDGES@
# > 1 <= 5 --> will be set to the specified number
# > 5 --> will be set to 5
default_bridges = @DEFBRIDGES@
# Default memory size in MiB for SB/VM.
# If unspecified then it will be set @DEFMEMSZ@ MiB.
# Note: the remote hypervisor uses the peer pod config to determine the memory of the VM
# default_memory = @DEFMEMSZ@
#
# Default memory slots per SB/VM.
# If unspecified then it will be set @DEFMEMSLOTS@.
# This is will determine the times that memory will be hotadded to sandbox/VM.
# Note: the remote hypervisor uses the peer pod config to determine the memory of the VM
#memory_slots = @DEFMEMSLOTS@
# This option changes the default hypervisor and kernel parameters
# to enable debug output where available. And Debug also enable the hmp socket.
#
# Default false
#enable_debug = true
# Path to OCI hook binaries in the *guest rootfs*.
# This does not affect host-side hooks which must instead be added to
# the OCI spec passed to the runtime.
#
# You can create a rootfs with hooks by customizing the osbuilder scripts:
# https://github.com/kata-containers/kata-containers/tree/main/tools/osbuilder
#
# Hooks must be stored in a subdirectory of guest_hook_path according to their
# hook type, i.e. "guest_hook_path/{prestart,poststart,poststop}".
# The agent will scan these directories for executable files and add them, in
# lexicographical order, to the lifecycle of the guest container.
# Hooks are executed in the runtime namespace of the guest. See the official documentation:
# https://github.com/opencontainers/runtime-spec/blob/v1.0.1/config.md#posix-platform-hooks
# Warnings will be logged if any error is encountered while scanning for hooks,
# but it will not abort container execution.
#guest_hook_path = "/usr/share/oci/hooks"
# disable applying SELinux on the VMM process (default false)
disable_selinux=@DEFDISABLESELINUX@
# disable applying SELinux on the container process
# If set to false, the type `container_t` is applied to the container process by default.
# Note: To enable guest SELinux, the guest rootfs must be CentOS that is created and built
# with `SELINUX=yes`.
# (default: true)
# Note: The remote hypervisor has a different guest, so currently requires this to be disabled
disable_guest_selinux = true
[agent.@PROJECT_TYPE@]
# If enabled, make the agent display debug-level messages.
# (default: disabled)
#enable_debug = true
# Enable agent tracing.
#
# If enabled, the agent will generate OpenTelemetry trace spans.
#
# Notes:
#
# - If the runtime also has tracing enabled, the agent spans will be
# associated with the appropriate runtime parent span.
# - If enabled, the runtime will wait for the container to shutdown,
# increasing the container shutdown time slightly.
#
# (default: disabled)
#enable_tracing = true
# Enable debug console.
# If enabled, user can connect guest OS running inside hypervisor
# through "kata-runtime exec <sandbox-id>" command
#debug_console_enabled = true
# Agent connection dialing timeout value in seconds
# (default: 30)
#dial_timeout = 30
[runtime]
# If enabled, the runtime will log additional debug messages to the
# system log
# (default: disabled)
#enable_debug = true
#
# Internetworking model
# Determines how the VM should be connected to the
# the container network interface
# Options:
#
# - macvtap
# Used when the Container network interface can be bridged using
# macvtap.
#
# - none
# Used when customize network. Only creates a tap device. No veth pair.
#
# - tcfilter
# Uses tc filter rules to redirect traffic from the network interface
# provided by plugin to a tap interface connected to the VM.
#
# Note: The remote hypervisor, uses it's own network, so "none" is required
internetworking_model="none"
# disable guest seccomp
# Determines whether container seccomp profiles are passed to the virtual
# machine and applied by the kata agent. If set to true, seccomp is not applied
# within the guest
# (default: true)
# Note: The remote hypervisor has a different guest, so currently requires this to be set to true
disable_guest_seccomp=true
# Apply a custom SELinux security policy to the container process inside the VM.
# This is used when you want to apply a type other than the default `container_t`,
# so general users should not uncomment and apply it.
# (format: "user:role:type")
# Note: You cannot specify MCS policy with the label because the sensitivity levels and
# categories are determined automatically by high-level container runtimes such as containerd.
#guest_selinux_label="@DEFGUESTSELINUXLABEL@"
# If enabled, the runtime will create opentracing.io traces and spans.
# (See https://www.jaegertracing.io/docs/getting-started).
# (default: disabled)
#enable_tracing = true
# Set the full url to the Jaeger HTTP Thrift collector.
# The default if not set will be "http://localhost:14268/api/traces"
#jaeger_endpoint = ""
# Sets the username to be used if basic auth is required for Jaeger.
#jaeger_user = ""
# Sets the password to be used if basic auth is required for Jaeger.
#jaeger_password = ""
# If enabled, the runtime will not create a network namespace for shim and hypervisor processes.
# This option may have some potential impacts to your host. It should only be used when you know what you're doing.
# `disable_new_netns` conflicts with `internetworking_model=tcfilter` and `internetworking_model=macvtap`. It works only
# with `internetworking_model=none`. The tap device will be in the host network namespace and can connect to a bridge
# (like OVS) directly.
# (default: false)
# Note: The remote hypervisor has a different networking model, which requires true
disable_new_netns = true
# if enabled, the runtime will add all the kata processes inside one dedicated cgroup.
# The container cgroups in the host are not created, just one single cgroup per sandbox.
# The runtime caller is free to restrict or collect cgroup stats of the overall Kata sandbox.
# The sandbox cgroup path is the parent cgroup of a container with the PodSandbox annotation.
# The sandbox cgroup is constrained if there is no container type annotation.
# See: https://pkg.go.dev/github.com/kata-containers/kata-containers/src/runtime/virtcontainers#ContainerType
sandbox_cgroup_only=@DEFSANDBOXCGROUPONLY@
# If enabled, the runtime will attempt to determine appropriate sandbox size (memory, CPU) before booting the virtual machine. In
# this case, the runtime will not dynamically update the amount of memory and CPU in the virtual machine. This is generally helpful
# when a hardware architecture or hypervisor solutions is utilized which does not support CPU and/or memory hotplug.
# Compatibility for determining appropriate sandbox (VM) size:
# - When running with pods, sandbox sizing information will only be available if using Kubernetes >= 1.23 and containerd >= 1.6. CRI-O
# does not yet support sandbox sizing annotations.
# - When running single containers using a tool like ctr, container sizing information will be available.
# Note: the remote hypervisor uses the peer pod config to determine the sandbox size, so requires this to be set to true
static_sandbox_resource_mgmt=true
# VFIO Mode
# Determines how VFIO devices should be be presented to the container.
# Options:
#
# - vfio
# Matches behaviour of OCI runtimes (e.g. runc) as much as
# possible. VFIO devices will appear in the container as VFIO
# character devices under /dev/vfio. The exact names may differ
# from the host (they need to match the VM's IOMMU group numbers
# rather than the host's)
#
# - guest-kernel
# This is a Kata-specific behaviour that's useful in certain cases.
# The VFIO device is managed by whatever driver in the VM kernel
# claims it. This means it will appear as one or more device nodes
# or network interfaces depending on the nature of the device.
# Using this mode requires specially built workloads that know how
# to locate the relevant device interfaces within the VM.
#
vfio_mode="@DEFVFIOMODE@"
# If enabled, the runtime will not create Kubernetes emptyDir mounts on the guest filesystem. Instead, emptyDir mounts will
# be created on the host and shared via virtio-fs. This is potentially slower, but allows sharing of files from host to guest.
# Note: remote hypervisor has no sharing of emptydir mounts from host to guest
disable_guest_empty_dir=false
# Enabled experimental feature list, format: ["a", "b"].
# Experimental features are features not stable enough for production,
# they may break compatibility, and are prepared for a big version bump.
# Supported experimental features:
# (default: [])
experimental=@DEFAULTEXPFEATURES@
# If enabled, user can run pprof tools with shim v2 process through kata-monitor.
# (default: false)
# enable_pprof = true
# WARNING: All the options in the following section have not been implemented yet.
# This section was added as a placeholder. DO NOT USE IT!
[image]
# Container image service.
#
# Offload the CRI image management service to the Kata agent.
# (default: false)
# Note: The remote hypervisor offloads the pulling on images on the peer pod VM, so requries this to be true
service_offload = true
# Container image decryption keys provisioning.
# Applies only if service_offload is true.
# Keys can be provisioned locally (e.g. through a special command or
# a local file) or remotely (usually after the guest is remotely attested).
# The provision setting is a complete URL that lets the Kata agent decide
# which method to use in order to fetch the keys.
#
# Keys can be stored in a local file, in a measured and attested initrd:
#provision=data:///local/key/file
#
# Keys could be fetched through a special command or binary from the
# initrd (guest) image, e.g. a firmware call:
#provision=file:///path/to/bin/fetcher/in/guest
#
# Keys can be remotely provisioned. The Kata agent fetches them from e.g.
# a HTTPS URL:
#provision=https://my-key-broker.foo/tenant/<tenant-id>

View File

@ -0,0 +1,14 @@
#!/bin/bash
# (C) Copyright IBM Corp. 2022, 2023
# SPDX-License-Identifier: Apache-2.0
set -o errexit -o pipefail -o nounset
HYPERVISOR_PATH="protocols/hypervisor"
protoc \
-I=$GOPATH/src \
--proto_path=$HYPERVISOR_PATH \
--go_out=$HYPERVISOR_PATH \
--go-grpc_out=$HYPERVISOR_PATH \
$HYPERVISOR_PATH/hypervisor.proto

View File

@ -110,3 +110,6 @@ var defaultRuntimeConfiguration = "@CONFIG_PATH@"
const defaultHotPlugVFIO = config.NoPort
const defaultColdPlugVFIO = config.NoPort
const defaultRemoteHypervisorSocket = "/run/peerpod/hypervisor.sock"
const defaultRemoteHypervisorTimeout = 600

View File

@ -53,6 +53,7 @@ const (
acrnHypervisorTableType = "acrn"
dragonballHypervisorTableType = "dragonball"
stratovirtHypervisorTableType = "stratovirt"
remoteHypervisorTableType = "remote"
// the maximum amount of PCI bridges that can be cold plugged in a VM
maxPCIBridges uint32 = 5
@ -105,6 +106,7 @@ type hypervisor struct {
GuestMemoryDumpPath string `toml:"guest_memory_dump_path"`
SeccompSandbox string `toml:"seccompsandbox"`
BlockDeviceAIO string `toml:"block_device_aio"`
RemoteHypervisorSocket string `toml:"remote_hypervisor_socket"`
HypervisorPathList []string `toml:"valid_hypervisor_paths"`
JailerPathList []string `toml:"valid_jailer_paths"`
CtlPathList []string `toml:"valid_ctlpaths"`
@ -134,6 +136,7 @@ type hypervisor struct {
MemSlots uint32 `toml:"memory_slots"`
DefaultBridges uint32 `toml:"default_bridges"`
Msize9p uint32 `toml:"msize_9p"`
RemoteHypervisorTimeout uint32 `toml:"remote_hypervisor_timeout"`
NumVCPUs float32 `toml:"default_vcpus"`
BlockDeviceCacheSet bool `toml:"block_device_cache_set"`
BlockDeviceCacheDirect bool `toml:"block_device_cache_direct"`
@ -647,6 +650,20 @@ func (h hypervisor) getIOMMUPlatform() bool {
return h.IOMMUPlatform
}
func (h hypervisor) getRemoteHypervisorSocket() string {
if h.RemoteHypervisorSocket == "" {
return defaultRemoteHypervisorSocket
}
return h.RemoteHypervisorSocket
}
func (h hypervisor) getRemoteHypervisorTimeout() uint32 {
if h.RemoteHypervisorTimeout == 0 {
return defaultRemoteHypervisorTimeout
}
return h.RemoteHypervisorTimeout
}
func (a agent) debugConsoleEnabled() bool {
return a.DebugConsoleEnabled
}
@ -1242,6 +1259,20 @@ func newStratovirtHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
}, nil
}
func newRemoteHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
return vc.HypervisorConfig{
RemoteHypervisorSocket: h.getRemoteHypervisorSocket(),
RemoteHypervisorTimeout: h.getRemoteHypervisorTimeout(),
DisableGuestSeLinux: true, // The remote hypervisor has a different guest, so Guest SELinux config doesn't work
// No valid value so avoid to append block device to list in kata_agent.appendDevices
BlockDeviceDriver: "dummy",
EnableAnnotations: h.EnableAnnotations,
GuestHookPath: h.guestHookPath(),
}, nil
}
func newFactoryConfig(f factory) (oci.FactoryConfig, error) {
if f.TemplatePath == "" {
f.TemplatePath = defaultTemplatePath
@ -1281,6 +1312,9 @@ func updateRuntimeConfigHypervisor(configPath string, tomlConf tomlConfig, confi
case stratovirtHypervisorTableType:
config.HypervisorType = vc.StratovirtHypervisor
hConfig, err = newStratovirtHypervisorConfig(hypervisor)
case remoteHypervisorTableType:
config.HypervisorType = vc.RemoteHypervisor
hConfig, err = newRemoteHypervisorConfig(hypervisor)
default:
err = fmt.Errorf("%s: %+q", errInvalidHypervisorPrefix, k)
}
@ -1882,6 +1916,11 @@ func checkFactoryConfig(config oci.RuntimeConfig) error {
// checkHypervisorConfig performs basic "sanity checks" on the hypervisor
// config.
func checkHypervisorConfig(config vc.HypervisorConfig) error {
if config.RemoteHypervisorSocket != "" {
return nil
}
type image struct {
path string
initrd bool

View File

@ -1564,6 +1564,17 @@ func TestCheckHypervisorConfig(t *testing.T) {
// reset logger
kataUtilsLogger.Logger.Out = savedOut
}
// Check remote hypervisor doesn't error with missing unnescessary config
remoteConfig := vc.HypervisorConfig{
RemoteHypervisorSocket: "dummy_socket",
ImagePath: "",
InitrdPath: "",
MemorySize: 0,
}
err := checkHypervisorConfig(remoteConfig)
assert.NoError(err, "remote hypervisor config")
}
func TestCheckNetNsConfig(t *testing.T) {

View File

@ -0,0 +1,619 @@
// (C) Copyright IBM Corp. 2022.
// SPDX-License-Identifier: Apache-2.0
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc v3.12.4
// source: hypervisor.proto
package __
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type VersionRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
}
func (x *VersionRequest) Reset() {
*x = VersionRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_hypervisor_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *VersionRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*VersionRequest) ProtoMessage() {}
func (x *VersionRequest) ProtoReflect() protoreflect.Message {
mi := &file_hypervisor_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use VersionRequest.ProtoReflect.Descriptor instead.
func (*VersionRequest) Descriptor() ([]byte, []int) {
return file_hypervisor_proto_rawDescGZIP(), []int{0}
}
func (x *VersionRequest) GetVersion() string {
if x != nil {
return x.Version
}
return ""
}
type VersionResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
}
func (x *VersionResponse) Reset() {
*x = VersionResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_hypervisor_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *VersionResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*VersionResponse) ProtoMessage() {}
func (x *VersionResponse) ProtoReflect() protoreflect.Message {
mi := &file_hypervisor_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use VersionResponse.ProtoReflect.Descriptor instead.
func (*VersionResponse) Descriptor() ([]byte, []int) {
return file_hypervisor_proto_rawDescGZIP(), []int{1}
}
func (x *VersionResponse) GetVersion() string {
if x != nil {
return x.Version
}
return ""
}
type CreateVMRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Annotations map[string]string `protobuf:"bytes,2,rep,name=annotations,proto3" json:"annotations,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
NetworkNamespacePath string `protobuf:"bytes,3,opt,name=networkNamespacePath,proto3" json:"networkNamespacePath,omitempty"`
}
func (x *CreateVMRequest) Reset() {
*x = CreateVMRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_hypervisor_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateVMRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateVMRequest) ProtoMessage() {}
func (x *CreateVMRequest) ProtoReflect() protoreflect.Message {
mi := &file_hypervisor_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateVMRequest.ProtoReflect.Descriptor instead.
func (*CreateVMRequest) Descriptor() ([]byte, []int) {
return file_hypervisor_proto_rawDescGZIP(), []int{2}
}
func (x *CreateVMRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *CreateVMRequest) GetAnnotations() map[string]string {
if x != nil {
return x.Annotations
}
return nil
}
func (x *CreateVMRequest) GetNetworkNamespacePath() string {
if x != nil {
return x.NetworkNamespacePath
}
return ""
}
type CreateVMResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
AgentSocketPath string `protobuf:"bytes,1,opt,name=agentSocketPath,proto3" json:"agentSocketPath,omitempty"`
}
func (x *CreateVMResponse) Reset() {
*x = CreateVMResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_hypervisor_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateVMResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateVMResponse) ProtoMessage() {}
func (x *CreateVMResponse) ProtoReflect() protoreflect.Message {
mi := &file_hypervisor_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateVMResponse.ProtoReflect.Descriptor instead.
func (*CreateVMResponse) Descriptor() ([]byte, []int) {
return file_hypervisor_proto_rawDescGZIP(), []int{3}
}
func (x *CreateVMResponse) GetAgentSocketPath() string {
if x != nil {
return x.AgentSocketPath
}
return ""
}
type StartVMRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
}
func (x *StartVMRequest) Reset() {
*x = StartVMRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_hypervisor_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StartVMRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StartVMRequest) ProtoMessage() {}
func (x *StartVMRequest) ProtoReflect() protoreflect.Message {
mi := &file_hypervisor_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use StartVMRequest.ProtoReflect.Descriptor instead.
func (*StartVMRequest) Descriptor() ([]byte, []int) {
return file_hypervisor_proto_rawDescGZIP(), []int{4}
}
func (x *StartVMRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type StartVMResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *StartVMResponse) Reset() {
*x = StartVMResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_hypervisor_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StartVMResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StartVMResponse) ProtoMessage() {}
func (x *StartVMResponse) ProtoReflect() protoreflect.Message {
mi := &file_hypervisor_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use StartVMResponse.ProtoReflect.Descriptor instead.
func (*StartVMResponse) Descriptor() ([]byte, []int) {
return file_hypervisor_proto_rawDescGZIP(), []int{5}
}
type StopVMRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
}
func (x *StopVMRequest) Reset() {
*x = StopVMRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_hypervisor_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StopVMRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StopVMRequest) ProtoMessage() {}
func (x *StopVMRequest) ProtoReflect() protoreflect.Message {
mi := &file_hypervisor_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use StopVMRequest.ProtoReflect.Descriptor instead.
func (*StopVMRequest) Descriptor() ([]byte, []int) {
return file_hypervisor_proto_rawDescGZIP(), []int{6}
}
func (x *StopVMRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type StopVMResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *StopVMResponse) Reset() {
*x = StopVMResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_hypervisor_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StopVMResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StopVMResponse) ProtoMessage() {}
func (x *StopVMResponse) ProtoReflect() protoreflect.Message {
mi := &file_hypervisor_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use StopVMResponse.ProtoReflect.Descriptor instead.
func (*StopVMResponse) Descriptor() ([]byte, []int) {
return file_hypervisor_proto_rawDescGZIP(), []int{7}
}
var File_hypervisor_proto protoreflect.FileDescriptor
var file_hypervisor_proto_rawDesc = []byte{
0x0a, 0x10, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x12, 0x0a, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x22, 0x2a,
0x0a, 0x0e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x2b, 0x0a, 0x0f, 0x56, 0x65,
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a,
0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xe5, 0x01, 0x0a, 0x0f, 0x43, 0x72, 0x65, 0x61,
0x74, 0x65, 0x56, 0x4d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x4e, 0x0a, 0x0b, 0x61,
0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x2c, 0x2e, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x56, 0x4d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x41, 0x6e,
0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b,
0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x32, 0x0a, 0x14, 0x6e,
0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x50,
0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x6e, 0x65, 0x74, 0x77, 0x6f,
0x72, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x74, 0x68, 0x1a,
0x3e, 0x0a, 0x10, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e,
0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22,
0x3c, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x4d, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x63, 0x6b,
0x65, 0x74, 0x50, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x61, 0x67,
0x65, 0x6e, 0x74, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x50, 0x61, 0x74, 0x68, 0x22, 0x20, 0x0a,
0x0e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x56, 0x4d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22,
0x11, 0x0a, 0x0f, 0x53, 0x74, 0x61, 0x72, 0x74, 0x56, 0x4d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x22, 0x1f, 0x0a, 0x0d, 0x53, 0x74, 0x6f, 0x70, 0x56, 0x4d, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x02, 0x69, 0x64, 0x22, 0x10, 0x0a, 0x0e, 0x53, 0x74, 0x6f, 0x70, 0x56, 0x4d, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xa4, 0x02, 0x0a, 0x0a, 0x48, 0x79, 0x70, 0x65, 0x72, 0x76,
0x69, 0x73, 0x6f, 0x72, 0x12, 0x47, 0x0a, 0x08, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x4d,
0x12, 0x1b, 0x2e, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x56, 0x4d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e,
0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74,
0x65, 0x56, 0x4d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x44, 0x0a,
0x07, 0x53, 0x74, 0x61, 0x72, 0x74, 0x56, 0x4d, 0x12, 0x1a, 0x2e, 0x68, 0x79, 0x70, 0x65, 0x72,
0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x56, 0x4d, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f,
0x72, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x56, 0x4d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x06, 0x53, 0x74, 0x6f, 0x70, 0x56, 0x4d, 0x12, 0x19, 0x2e,
0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x56,
0x4d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x68, 0x79, 0x70, 0x65, 0x72,
0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x56, 0x4d, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f,
0x6e, 0x12, 0x1a, 0x2e, 0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x56,
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e,
0x68, 0x79, 0x70, 0x65, 0x72, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69,
0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x04, 0x5a, 0x02,
0x2e, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_hypervisor_proto_rawDescOnce sync.Once
file_hypervisor_proto_rawDescData = file_hypervisor_proto_rawDesc
)
func file_hypervisor_proto_rawDescGZIP() []byte {
file_hypervisor_proto_rawDescOnce.Do(func() {
file_hypervisor_proto_rawDescData = protoimpl.X.CompressGZIP(file_hypervisor_proto_rawDescData)
})
return file_hypervisor_proto_rawDescData
}
var file_hypervisor_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_hypervisor_proto_goTypes = []interface{}{
(*VersionRequest)(nil), // 0: hypervisor.VersionRequest
(*VersionResponse)(nil), // 1: hypervisor.VersionResponse
(*CreateVMRequest)(nil), // 2: hypervisor.CreateVMRequest
(*CreateVMResponse)(nil), // 3: hypervisor.CreateVMResponse
(*StartVMRequest)(nil), // 4: hypervisor.StartVMRequest
(*StartVMResponse)(nil), // 5: hypervisor.StartVMResponse
(*StopVMRequest)(nil), // 6: hypervisor.StopVMRequest
(*StopVMResponse)(nil), // 7: hypervisor.StopVMResponse
nil, // 8: hypervisor.CreateVMRequest.AnnotationsEntry
}
var file_hypervisor_proto_depIdxs = []int32{
8, // 0: hypervisor.CreateVMRequest.annotations:type_name -> hypervisor.CreateVMRequest.AnnotationsEntry
2, // 1: hypervisor.Hypervisor.CreateVM:input_type -> hypervisor.CreateVMRequest
4, // 2: hypervisor.Hypervisor.StartVM:input_type -> hypervisor.StartVMRequest
6, // 3: hypervisor.Hypervisor.StopVM:input_type -> hypervisor.StopVMRequest
0, // 4: hypervisor.Hypervisor.Version:input_type -> hypervisor.VersionRequest
3, // 5: hypervisor.Hypervisor.CreateVM:output_type -> hypervisor.CreateVMResponse
5, // 6: hypervisor.Hypervisor.StartVM:output_type -> hypervisor.StartVMResponse
7, // 7: hypervisor.Hypervisor.StopVM:output_type -> hypervisor.StopVMResponse
1, // 8: hypervisor.Hypervisor.Version:output_type -> hypervisor.VersionResponse
5, // [5:9] is the sub-list for method output_type
1, // [1:5] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_hypervisor_proto_init() }
func file_hypervisor_proto_init() {
if File_hypervisor_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_hypervisor_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*VersionRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_hypervisor_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*VersionResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_hypervisor_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateVMRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_hypervisor_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateVMResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_hypervisor_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StartVMRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_hypervisor_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StartVMResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_hypervisor_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StopVMRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_hypervisor_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StopVMResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_hypervisor_proto_rawDesc,
NumEnums: 0,
NumMessages: 9,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_hypervisor_proto_goTypes,
DependencyIndexes: file_hypervisor_proto_depIdxs,
MessageInfos: file_hypervisor_proto_msgTypes,
}.Build()
File_hypervisor_proto = out.File
file_hypervisor_proto_rawDesc = nil
file_hypervisor_proto_goTypes = nil
file_hypervisor_proto_depIdxs = nil
}

View File

@ -0,0 +1,48 @@
// (C) Copyright IBM Corp. 2022.
// SPDX-License-Identifier: Apache-2.0
syntax = "proto3";
option go_package = "./";
package hypervisor;
service Hypervisor {
rpc CreateVM(CreateVMRequest) returns (CreateVMResponse) {}
rpc StartVM(StartVMRequest) returns (StartVMResponse) {}
rpc StopVM(StopVMRequest) returns (StopVMResponse) {}
rpc Version(VersionRequest) returns (VersionResponse) {}
}
message VersionRequest {
string version = 1;
}
message VersionResponse {
string version = 1;
}
message CreateVMRequest {
string id = 1;
map<string, string> annotations = 2;
string networkNamespacePath = 3;
}
message CreateVMResponse {
string agentSocketPath = 1;
}
message StartVMRequest {
string id = 1;
}
message StartVMResponse {
}
message StopVMRequest {
string id = 1;
}
message StopVMResponse {
}

View File

@ -0,0 +1,223 @@
// (C) Copyright IBM Corp. 2022.
// SPDX-License-Identifier: Apache-2.0
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v3.12.4
// source: hypervisor.proto
package __
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
Hypervisor_CreateVM_FullMethodName = "/hypervisor.Hypervisor/CreateVM"
Hypervisor_StartVM_FullMethodName = "/hypervisor.Hypervisor/StartVM"
Hypervisor_StopVM_FullMethodName = "/hypervisor.Hypervisor/StopVM"
Hypervisor_Version_FullMethodName = "/hypervisor.Hypervisor/Version"
)
// HypervisorClient is the client API for Hypervisor service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type HypervisorClient interface {
CreateVM(ctx context.Context, in *CreateVMRequest, opts ...grpc.CallOption) (*CreateVMResponse, error)
StartVM(ctx context.Context, in *StartVMRequest, opts ...grpc.CallOption) (*StartVMResponse, error)
StopVM(ctx context.Context, in *StopVMRequest, opts ...grpc.CallOption) (*StopVMResponse, error)
Version(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*VersionResponse, error)
}
type hypervisorClient struct {
cc grpc.ClientConnInterface
}
func NewHypervisorClient(cc grpc.ClientConnInterface) HypervisorClient {
return &hypervisorClient{cc}
}
func (c *hypervisorClient) CreateVM(ctx context.Context, in *CreateVMRequest, opts ...grpc.CallOption) (*CreateVMResponse, error) {
out := new(CreateVMResponse)
err := c.cc.Invoke(ctx, Hypervisor_CreateVM_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *hypervisorClient) StartVM(ctx context.Context, in *StartVMRequest, opts ...grpc.CallOption) (*StartVMResponse, error) {
out := new(StartVMResponse)
err := c.cc.Invoke(ctx, Hypervisor_StartVM_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *hypervisorClient) StopVM(ctx context.Context, in *StopVMRequest, opts ...grpc.CallOption) (*StopVMResponse, error) {
out := new(StopVMResponse)
err := c.cc.Invoke(ctx, Hypervisor_StopVM_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *hypervisorClient) Version(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*VersionResponse, error) {
out := new(VersionResponse)
err := c.cc.Invoke(ctx, Hypervisor_Version_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// HypervisorServer is the server API for Hypervisor service.
// All implementations must embed UnimplementedHypervisorServer
// for forward compatibility
type HypervisorServer interface {
CreateVM(context.Context, *CreateVMRequest) (*CreateVMResponse, error)
StartVM(context.Context, *StartVMRequest) (*StartVMResponse, error)
StopVM(context.Context, *StopVMRequest) (*StopVMResponse, error)
Version(context.Context, *VersionRequest) (*VersionResponse, error)
mustEmbedUnimplementedHypervisorServer()
}
// UnimplementedHypervisorServer must be embedded to have forward compatible implementations.
type UnimplementedHypervisorServer struct {
}
func (UnimplementedHypervisorServer) CreateVM(context.Context, *CreateVMRequest) (*CreateVMResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateVM not implemented")
}
func (UnimplementedHypervisorServer) StartVM(context.Context, *StartVMRequest) (*StartVMResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method StartVM not implemented")
}
func (UnimplementedHypervisorServer) StopVM(context.Context, *StopVMRequest) (*StopVMResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method StopVM not implemented")
}
func (UnimplementedHypervisorServer) Version(context.Context, *VersionRequest) (*VersionResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Version not implemented")
}
func (UnimplementedHypervisorServer) mustEmbedUnimplementedHypervisorServer() {}
// UnsafeHypervisorServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to HypervisorServer will
// result in compilation errors.
type UnsafeHypervisorServer interface {
mustEmbedUnimplementedHypervisorServer()
}
func RegisterHypervisorServer(s grpc.ServiceRegistrar, srv HypervisorServer) {
s.RegisterService(&Hypervisor_ServiceDesc, srv)
}
func _Hypervisor_CreateVM_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateVMRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HypervisorServer).CreateVM(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Hypervisor_CreateVM_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HypervisorServer).CreateVM(ctx, req.(*CreateVMRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Hypervisor_StartVM_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(StartVMRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HypervisorServer).StartVM(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Hypervisor_StartVM_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HypervisorServer).StartVM(ctx, req.(*StartVMRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Hypervisor_StopVM_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(StopVMRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HypervisorServer).StopVM(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Hypervisor_StopVM_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HypervisorServer).StopVM(ctx, req.(*StopVMRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Hypervisor_Version_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(VersionRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HypervisorServer).Version(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Hypervisor_Version_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HypervisorServer).Version(ctx, req.(*VersionRequest))
}
return interceptor(ctx, in, info, handler)
}
// Hypervisor_ServiceDesc is the grpc.ServiceDesc for Hypervisor service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Hypervisor_ServiceDesc = grpc.ServiceDesc{
ServiceName: "hypervisor.Hypervisor",
HandlerType: (*HypervisorServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CreateVM",
Handler: _Hypervisor_CreateVM_Handler,
},
{
MethodName: "StartVM",
Handler: _Hypervisor_StartVM_Handler,
},
{
MethodName: "StopVM",
Handler: _Hypervisor_StopVM_Handler,
},
{
MethodName: "Version",
Handler: _Hypervisor_Version_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "hypervisor.proto",
}

View File

@ -57,6 +57,9 @@ const (
// VirtFrameworkHypervisor is the Darwin Virtualization.framework hypervisor
VirtframeworkHypervisor HypervisorType = "virtframework"
// RemoteHypervisor is the Remote hypervisor.
RemoteHypervisor HypervisorType = "remote"
// MockHypervisor is a mock hypervisor for testing purposes
MockHypervisor HypervisorType = "mock"
@ -240,6 +243,9 @@ func (hType *HypervisorType) Set(value string) error {
case "virtframework":
*hType = VirtframeworkHypervisor
return nil
case "remote":
*hType = RemoteHypervisor
return nil
case "mock":
*hType = MockHypervisor
return nil
@ -261,6 +267,8 @@ func (hType *HypervisorType) String() string {
return string(ClhHypervisor)
case StratovirtHypervisor:
return string(StratovirtHypervisor)
case RemoteHypervisor:
return string(RemoteHypervisor)
case MockHypervisor:
return string(MockHypervisor)
default:
@ -455,6 +463,15 @@ type HypervisorConfig struct {
// BlockiDeviceAIO specifies the I/O API to be used.
BlockDeviceAIO string
// The socket to connect to the remote hypervisor implementation on
RemoteHypervisorSocket string
// The name of the sandbox (pod)
SandboxName string
// The name of the namespace of the sandbox (pod)
SandboxNamespace string
// The user maps to the uid.
User string
@ -563,6 +580,9 @@ type HypervisorConfig struct {
// Group ID.
Gid uint32
// Timeout for actions e.g. startVM for the remote hypervisor
RemoteHypervisorTimeout uint32
// BlockDeviceCacheSet specifies cache-related options will be set to block devices or not.
BlockDeviceCacheSet bool

View File

@ -11,6 +11,10 @@ import (
func validateHypervisorConfig(conf *HypervisorConfig) error {
if conf.RemoteHypervisorSocket != "" {
return nil
}
if conf.KernelPath == "" {
return fmt.Errorf("Missing kernel path")
}

View File

@ -13,6 +13,10 @@ import (
func validateHypervisorConfig(conf *HypervisorConfig) error {
if conf.RemoteHypervisorSocket != "" {
return nil
}
if conf.KernelPath == "" {
return fmt.Errorf("Missing kernel path")
}

View File

@ -28,3 +28,12 @@ func TestHypervisorConfigNoKernelPath(t *testing.T) {
testHypervisorConfigValid(t, hypervisorConfig, false)
}
func TestRemoteHypervisorConfigNoKernelPath(t *testing.T) {
hypervisorConfig := &HypervisorConfig{
RemoteHypervisorSocket: "dummy_socket",
KernelPath: "",
}
testHypervisorConfigValid(t, hypervisorConfig, true)
}

View File

@ -40,6 +40,8 @@ func NewHypervisor(hType HypervisorType) (Hypervisor, error) {
return &stratovirt{}, nil
case DragonballHypervisor:
return &mockHypervisor{}, nil
case RemoteHypervisor:
return &remoteHypervisor{}, nil
case MockHypervisor:
return &mockHypervisor{}, nil
default:

View File

@ -7,11 +7,12 @@ package virtcontainers
import (
"fmt"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
"github.com/stretchr/testify/assert"
"os"
"strings"
"testing"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
"github.com/stretchr/testify/assert"
)
func TestGetKernelRootParams(t *testing.T) {
@ -186,6 +187,10 @@ func TestSetMockHypervisorType(t *testing.T) {
testSetHypervisorType(t, "mock", MockHypervisor)
}
func TestSetRemoteHypervisorType(t *testing.T) {
testSetHypervisorType(t, "remote", RemoteHypervisor)
}
func TestSetUnknownHypervisorType(t *testing.T) {
var hypervisorType HypervisorType
assert := assert.New(t)
@ -207,6 +212,11 @@ func TestStringFromQemuHypervisorType(t *testing.T) {
testStringFromHypervisorType(t, hypervisorType, "qemu")
}
func TestStringFromRemoteHypervisorType(t *testing.T) {
hypervisorType := RemoteHypervisor
testStringFromHypervisorType(t, hypervisorType, "remote")
}
func TestStringFromMockHypervisorType(t *testing.T) {
hypervisorType := MockHypervisor
testStringFromHypervisorType(t, hypervisorType, "mock")
@ -224,6 +234,12 @@ func testNewHypervisorFromHypervisorType(t *testing.T, hypervisorType Hypervisor
assert.Exactly(hy, expected)
}
func TestNewHypervisorFromRemoteHypervisorType(t *testing.T) {
hypervisorType := RemoteHypervisor
expectedHypervisor := &remoteHypervisor{}
testNewHypervisorFromHypervisorType(t, hypervisorType, expectedHypervisor)
}
func TestNewHypervisorFromMockHypervisorType(t *testing.T) {
hypervisorType := MockHypervisor
expectedHypervisor := &mockHypervisor{}

View File

@ -78,9 +78,13 @@ const (
defaultSeLinuxContainerType = "container_t"
)
type customRequestTimeoutKeyType struct{}
var (
checkRequestTimeout = 30 * time.Second
defaultRequestTimeout = 60 * time.Second
remoteRequestTimeout = 300 * time.Second
customRequestTimeoutKey = customRequestTimeoutKeyType(struct{}{})
errorMissingOCISpec = errors.New("Missing OCI specification")
defaultKataHostSharedDir = "/run/kata-containers/shared/sandboxes/"
defaultKataGuestSharedDir = "/run/kata-containers/shared/containers/"
@ -376,6 +380,8 @@ func (k *kataAgent) agentURL() (string, error) {
return s.String(), nil
case types.HybridVSock:
return s.String(), nil
case types.RemoteSock:
return s.String(), nil
case types.MockHybridVSock:
return s.String(), nil
default:
@ -426,6 +432,7 @@ func (k *kataAgent) configure(ctx context.Context, h Hypervisor, id, sharePath s
if err != nil {
return err
}
case types.RemoteSock:
case types.MockHybridVSock:
default:
return types.ErrInvalidConfigType
@ -745,37 +752,43 @@ func (k *kataAgent) startSandbox(ctx context.Context, sandbox *Sandbox) error {
return err
}
// Check grpc server is serving
if err = k.check(ctx); err != nil {
return err
}
var kmodules []*grpc.KernelModule
// If a Policy has been specified, send it to the agent.
if len(sandbox.config.AgentConfig.Policy) > 0 {
if err := sandbox.agent.setPolicy(ctx, sandbox.config.AgentConfig.Policy); err != nil {
if sandbox.config.HypervisorType == RemoteHypervisor {
ctx = context.WithValue(ctx, customRequestTimeoutKey, remoteRequestTimeout)
} else {
// Check grpc server is serving
if err = k.check(ctx); err != nil {
return err
}
}
// Setup network interfaces and routes
interfaces, routes, neighs, err := generateVCNetworkStructures(ctx, sandbox.network)
if err != nil {
return err
}
if err = k.updateInterfaces(ctx, interfaces); err != nil {
return err
}
if _, err = k.updateRoutes(ctx, routes); err != nil {
return err
}
if err = k.addARPNeighbors(ctx, neighs); err != nil {
return err
// If a Policy has been specified, send it to the agent.
if len(sandbox.config.AgentConfig.Policy) > 0 {
if err := sandbox.agent.setPolicy(ctx, sandbox.config.AgentConfig.Policy); err != nil {
return err
}
}
// Setup network interfaces and routes
interfaces, routes, neighs, err := generateVCNetworkStructures(ctx, sandbox.network)
if err != nil {
return err
}
if err = k.updateInterfaces(ctx, interfaces); err != nil {
return err
}
if _, err = k.updateRoutes(ctx, routes); err != nil {
return err
}
if err = k.addARPNeighbors(ctx, neighs); err != nil {
return err
}
kmodules = setupKernelModules(k.kmodules)
}
storages := setupStorages(ctx, sandbox)
kmodules := setupKernelModules(k.kmodules)
req := &grpc.CreateSandboxRequest{
Hostname: hostname,
Dns: dns,
@ -1194,7 +1207,7 @@ func (k *kataAgent) appendDevices(deviceList []*grpc.Device, c *Container) []*gr
kataDevice = k.appendVfioDevice(dev, device, c)
}
if kataDevice == nil {
if kataDevice == nil || kataDevice.Type == "" {
continue
}
@ -2104,7 +2117,12 @@ func (k *kataAgent) getReqContext(ctx context.Context, reqName string) (newCtx c
case grpcCheckRequest:
newCtx, cancel = context.WithTimeout(ctx, checkRequestTimeout)
default:
newCtx, cancel = context.WithTimeout(ctx, defaultRequestTimeout)
var requestTimeout = defaultRequestTimeout
if timeout, ok := ctx.Value(customRequestTimeoutKey).(time.Duration); ok {
requestTimeout = timeout
}
newCtx, cancel = context.WithTimeout(ctx, requestTimeout)
}
return newCtx, cancel

View File

@ -34,6 +34,7 @@ import (
const (
VSockSocketScheme = "vsock"
HybridVSockScheme = "hvsock"
RemoteSockScheme = "remote"
MockHybridVSockScheme = "mock"
)
@ -235,6 +236,11 @@ func parse(sock string) (string, *url.URL, error) {
}
hybridVSockPort = uint32(port)
grpcAddr = HybridVSockScheme + ":" + hvsocket[0]
case RemoteSockScheme:
if addr.Host != "" {
return "", nil, grpcStatus.Errorf(codes.InvalidArgument, "Invalid remote sock scheme: host address must be empty: %s", sock)
}
grpcAddr = RemoteSockScheme + ":" + addr.Path
// just for tests use.
case MockHybridVSockScheme:
if addr.Path == "" {
@ -255,6 +261,8 @@ func agentDialer(addr *url.URL) dialer {
return VsockDialer
case HybridVSockScheme:
return HybridVSockDialer
case RemoteSockScheme:
return RemoteSockDialer
case MockHybridVSockScheme:
return MockHybridVSockDialer
default:
@ -435,6 +443,31 @@ func HybridVSockDialer(sock string, timeout time.Duration) (net.Conn, error) {
return commonDialer(timeout, dialFunc, timeoutErr)
}
// RemoteSockDialer dials to an agent in a remote hypervisor sandbox
func RemoteSockDialer(sock string, timeout time.Duration) (net.Conn, error) {
s := strings.Split(sock, ":")
if !(len(s) == 2 && s[0] == RemoteSockScheme) {
return nil, fmt.Errorf("failed to parse remote sock: %q", sock)
}
socketPath := s[1]
logrus.Printf("Dialing remote sock: %q %q", socketPath, sock)
dialFunc := func() (net.Conn, error) {
conn, err := net.Dial("unix", socketPath)
if err != nil {
logrus.Errorf("failed to dial remote sock %q: %v", socketPath, err)
return nil, err
}
return conn, nil
}
timeoutErr := grpcStatus.Errorf(codes.DeadlineExceeded, "timed out connecting to remote sock: %s", socketPath)
return commonDialer(timeout, dialFunc, timeoutErr)
}
// just for tests use.
func MockHybridVSockDialer(sock string, timeout time.Duration) (net.Conn, error) {
sock = strings.TrimPrefix(sock, "mock:")

View File

@ -0,0 +1,293 @@
// Copyright (c) 2022 IBM Corporation
// SPDX-License-Identifier: Apache-2.0
package virtcontainers
import (
"context"
"fmt"
"os"
"strconv"
"time"
cri "github.com/containerd/containerd/pkg/cri/annotations"
persistapi "github.com/kata-containers/kata-containers/src/runtime/pkg/hypervisors"
pb "github.com/kata-containers/kata-containers/src/runtime/protocols/hypervisor"
hypannotations "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/annotations"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
const defaultMinTimeout = 60
type remoteHypervisor struct {
sandboxID remoteHypervisorSandboxID
agentSocketPath string
config HypervisorConfig
}
type remoteHypervisorSandboxID string
type remoteService struct {
conn *grpc.ClientConn
client pb.HypervisorClient
}
func openRemoteService(socketPath string) (*remoteService, error) {
conn, err := grpc.Dial(fmt.Sprintf("unix://%s", socketPath), grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, fmt.Errorf("failed to connect to remote hypervisor socket: %w", err)
}
defer conn.Close()
client := pb.NewHypervisorClient(conn)
s := &remoteService{
conn: conn,
client: client,
}
return s, nil
}
func (s *remoteService) Close() error {
return s.conn.Close()
}
func (rh *remoteHypervisor) CreateVM(ctx context.Context, id string, network Network, hypervisorConfig *HypervisorConfig) error {
rh.sandboxID = remoteHypervisorSandboxID(id)
if err := rh.setConfig(hypervisorConfig); err != nil {
return err
}
s, err := openRemoteService(hypervisorConfig.RemoteHypervisorSocket)
if err != nil {
return err
}
defer s.Close()
annotations := map[string]string{}
annotations[cri.SandboxName] = hypervisorConfig.SandboxName
annotations[cri.SandboxNamespace] = hypervisorConfig.SandboxNamespace
annotations[hypannotations.MachineType] = hypervisorConfig.HypervisorMachineType
annotations[hypannotations.DefaultVCPUs] = strconv.FormatUint(uint64(hypervisorConfig.NumVCPUs()), 10)
annotations[hypannotations.DefaultMemory] = strconv.FormatUint(uint64(hypervisorConfig.MemorySize), 10)
req := &pb.CreateVMRequest{
Id: id,
Annotations: annotations,
NetworkNamespacePath: network.NetworkID(),
}
res, err := s.client.CreateVM(ctx, req)
if err != nil {
return fmt.Errorf("remote hypervisor call failed: %w", err)
}
if res.AgentSocketPath == "" {
return errors.New("remote hypervisor does not return tunnel socket path")
}
rh.agentSocketPath = res.AgentSocketPath
return nil
}
func (rh *remoteHypervisor) StartVM(ctx context.Context, timeout int) error {
minTimeout := defaultMinTimeout
if rh.config.RemoteHypervisorTimeout > 0 {
minTimeout = int(rh.config.RemoteHypervisorTimeout)
}
if timeout < minTimeout {
timeout = minTimeout
}
s, err := openRemoteService(rh.config.RemoteHypervisorSocket)
if err != nil {
return err
}
defer s.Close()
req := &pb.StartVMRequest{
Id: string(rh.sandboxID),
}
ctx2, cancel := context.WithTimeout(context.Background(), time.Duration(timeout)*time.Second)
defer cancel()
logrus.Printf("calling remote hypervisor StartVM (timeout: %d)", timeout)
if _, err := s.client.StartVM(ctx2, req); err != nil {
return fmt.Errorf("remote hypervisor call failed: %w", err)
}
return nil
}
func (rh *remoteHypervisor) AttestVM(ctx context.Context) error {
return nil
}
func (rh *remoteHypervisor) StopVM(ctx context.Context, waitOnly bool) error {
s, err := openRemoteService(rh.config.RemoteHypervisorSocket)
if err != nil {
return err
}
defer s.Close()
req := &pb.StopVMRequest{
Id: string(rh.sandboxID),
}
if _, err := s.client.StopVM(ctx, req); err != nil {
return fmt.Errorf("remote hypervisor call failed: %w", err)
}
return nil
}
func (rh *remoteHypervisor) GenerateSocket(id string) (interface{}, error) {
socketPath := rh.agentSocketPath
if len(socketPath) == 0 {
return nil, errors.New("failed to generate remote sock: TunnelSocketPath is not set")
}
remoteSock := types.RemoteSock{
SandboxID: id,
TunnelSocketPath: socketPath,
}
return remoteSock, nil
}
func notImplemented(name string) error {
err := errors.Errorf("%s: not implemented", name)
logrus.Errorf(err.Error())
if tracer, ok := err.(interface{ StackTrace() errors.StackTrace }); ok {
for _, f := range tracer.StackTrace() {
logrus.Errorf("%+s:%d\n", f, f)
}
}
return err
}
func (rh *remoteHypervisor) PauseVM(ctx context.Context) error {
return notImplemented("PauseVM")
}
func (rh *remoteHypervisor) SaveVM() error {
return notImplemented("SaveVM")
}
func (rh *remoteHypervisor) ResumeVM(ctx context.Context) error {
return notImplemented("ResumeVM")
}
func (rh *remoteHypervisor) AddDevice(ctx context.Context, devInfo interface{}, devType DeviceType) error {
// TODO should we return notImplemented("AddDevice"), rather than nil and ignoring it?
logrus.Printf("addDevice: deviceType=%v devInfo=%#v", devType, devInfo)
return nil
}
func (rh *remoteHypervisor) HotplugAddDevice(ctx context.Context, devInfo interface{}, devType DeviceType) (interface{}, error) {
return nil, notImplemented("HotplugAddDevice")
}
func (rh *remoteHypervisor) HotplugRemoveDevice(ctx context.Context, devInfo interface{}, devType DeviceType) (interface{}, error) {
return nil, notImplemented("HotplugRemoveDevice")
}
func (rh *remoteHypervisor) ResizeMemory(ctx context.Context, memMB uint32, memoryBlockSizeMB uint32, probe bool) (uint32, MemoryDevice, error) {
return memMB, MemoryDevice{}, nil
}
func (rh *remoteHypervisor) GetTotalMemoryMB(ctx context.Context) uint32 {
//The remote hypervisor uses the peer pod config to determine the memory of the VM, so we need to use static resource management
logrus.Error("GetTotalMemoryMB - remote hypervisor cannot update resources")
return 0
}
func (rh *remoteHypervisor) ResizeVCPUs(ctx context.Context, vcpus uint32) (uint32, uint32, error) {
return vcpus, vcpus, nil
}
func (rh *remoteHypervisor) GetVMConsole(ctx context.Context, sandboxID string) (string, string, error) {
return "", "", notImplemented("GetVMConsole")
}
func (rh *remoteHypervisor) Disconnect(ctx context.Context) {
notImplemented("Disconnect")
}
func (rh *remoteHypervisor) Capabilities(ctx context.Context) types.Capabilities {
var caps types.Capabilities
caps.SetBlockDeviceHotplugSupport()
return caps
}
func (rh *remoteHypervisor) HypervisorConfig() HypervisorConfig {
return rh.config
}
func (rh *remoteHypervisor) GetThreadIDs(ctx context.Context) (VcpuThreadIDs, error) {
// Not supported. return success
// Just allocating an empty map
return VcpuThreadIDs{}, nil
}
func (rh *remoteHypervisor) Cleanup(ctx context.Context) error {
return nil
}
func (rh *remoteHypervisor) setConfig(config *HypervisorConfig) error {
// Create a Validator specific for remote hypervisor
rh.config = *config
return nil
}
func (rh *remoteHypervisor) GetPids() []int {
// let's use shim pid as it used by crio to fetch start time
return []int{os.Getpid()}
}
func (rh *remoteHypervisor) GetVirtioFsPid() *int {
panic(notImplemented("GetVirtioFsPid"))
}
func (rh *remoteHypervisor) fromGrpc(ctx context.Context, hypervisorConfig *HypervisorConfig, j []byte) error {
panic(notImplemented("fromGrpc"))
}
func (rh *remoteHypervisor) toGrpc(ctx context.Context) ([]byte, error) {
panic(notImplemented("toGrpc"))
}
func (rh *remoteHypervisor) Check() error {
return nil
}
func (rh *remoteHypervisor) Save() persistapi.HypervisorState {
return persistapi.HypervisorState{}
}
func (rh *remoteHypervisor) Load(persistapi.HypervisorState) {
notImplemented("Load")
}
func (rh *remoteHypervisor) IsRateLimiterBuiltin() bool {
return false
}

View File

@ -0,0 +1,45 @@
// Copyright (c) 2023 IBM Corporation
// SPDX-License-Identifier: Apache-2.0
package virtcontainers
import (
"testing"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
"github.com/stretchr/testify/assert"
)
func newRemoteConfig() HypervisorConfig {
return HypervisorConfig{
RemoteHypervisorSocket: "/run/peerpod/hypervisor.sock",
RemoteHypervisorTimeout: 600,
DisableGuestSeLinux: true,
EnableAnnotations: []string{},
}
}
func TestRemoteHypervisorGenerateSocket(t *testing.T) {
assert := assert.New(t)
remoteHypervisor := remoteHypervisor{
config: newRemoteConfig(),
}
id := "sandboxId"
// No socketPath should error
_, err := remoteHypervisor.GenerateSocket(id)
assert.Error(err)
socketPath := "socketPath"
remoteHypervisor.agentSocketPath = socketPath
result, err := remoteHypervisor.GenerateSocket(id)
assert.NoError(err)
expected := types.RemoteSock{
SandboxID: id,
TunnelSocketPath: socketPath,
}
assert.Equal(result, expected)
}

View File

@ -28,6 +28,8 @@ import (
"github.com/sirupsen/logrus"
"github.com/vishvananda/netlink"
cri "github.com/containerd/containerd/pkg/cri/annotations"
crio "github.com/containers/podman/v4/pkg/annotations"
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/api"
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/config"
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/drivers"
@ -635,6 +637,8 @@ func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factor
}
setHypervisorConfigAnnotations(&sandboxConfig)
coldPlugVFIO, err := s.coldOrHotPlugVFIO(&sandboxConfig)
if err != nil {
return nil, err
@ -722,6 +726,23 @@ func (s *Sandbox) coldOrHotPlugVFIO(sandboxConfig *SandboxConfig) (bool, error)
return coldPlugVFIO, nil
}
func setHypervisorConfigAnnotations(sandboxConfig *SandboxConfig) {
if len(sandboxConfig.Containers) > 0 {
// These values are required by remote hypervisor
for _, a := range []string{cri.SandboxName, crio.SandboxName} {
if value, ok := sandboxConfig.Containers[0].Annotations[a]; ok {
sandboxConfig.HypervisorConfig.SandboxName = value
}
}
for _, a := range []string{cri.SandboxNamespace, crio.Namespace} {
if value, ok := sandboxConfig.Containers[0].Annotations[a]; ok {
sandboxConfig.HypervisorConfig.SandboxNamespace = value
}
}
}
}
func (s *Sandbox) createResourceController() error {
var err error
cgroupPath := ""

View File

@ -7,6 +7,7 @@ package types
import (
"fmt"
"net"
"os"
"strings"
@ -37,6 +38,7 @@ const (
HybridVSockScheme = "hvsock"
MockHybridVSockScheme = "mock"
VSockScheme = "vsock"
RemoteSockScheme = "remote"
)
// SandboxState is a sandbox state structure
@ -210,6 +212,16 @@ func (s *HybridVSock) String() string {
return fmt.Sprintf("%s://%s:%d", HybridVSockScheme, s.UdsPath, s.Port)
}
type RemoteSock struct {
Conn net.Conn
SandboxID string
TunnelSocketPath string
}
func (s *RemoteSock) String() string {
return fmt.Sprintf("%s://%s", RemoteSockScheme, s.TunnelSocketPath)
}
// MockHybridVSock defines a mock hybrid vsocket for tests only.
type MockHybridVSock struct {
UdsPath string

View File

@ -6,6 +6,8 @@
package types
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
@ -163,6 +165,78 @@ func TestVolumesStringSuccessful(t *testing.T) {
assert.Equal(t, result, expected)
}
func TestStringFromVSock(t *testing.T) {
assert := assert.New(t)
dir := t.TempDir()
contextID := uint64(16187)
port := uint32(1024)
vsockFilename := filepath.Join(dir, "vsock")
vsockFile, err := os.Create(vsockFilename)
assert.NoError(err)
defer vsockFile.Close()
vsock := VSock{
ContextID: contextID,
Port: port,
VhostFd: vsockFile,
}
expected := "vsock://16187:1024"
assert.Equal(vsock.String(), expected)
}
func TestStringFromHybridVSock(t *testing.T) {
assert := assert.New(t)
udsPath := "udspath"
contextID := uint64(16187)
port := uint32(1024)
sock := HybridVSock{
UdsPath: udsPath,
ContextID: contextID,
Port: port,
}
expected := "hvsock://udspath:1024"
assert.Equal(sock.String(), expected)
}
func TestStringFromRemoteSock(t *testing.T) {
assert := assert.New(t)
sandboxID := "sandboxID"
tunnelSockerPath := "tunnelSocketPath"
sock := RemoteSock{
SandboxID: sandboxID,
TunnelSocketPath: tunnelSockerPath,
}
expected := "remote://tunnelSocketPath"
assert.Equal(sock.String(), expected)
}
func TestStringFromMockHybridVSock(t *testing.T) {
assert := assert.New(t)
udsPath := "udspath"
sock := MockHybridVSock{
UdsPath: udsPath,
}
expected := "mock://udspath"
assert.Equal(sock.String(), expected)
}
func TestSocketsSetSuccessful(t *testing.T) {
sockets := &Sockets{}

View File

@ -30,7 +30,7 @@ spec:
- name: DEBUG
value: "false"
- name: SHIMS
value: "clh dragonball fc qemu-nvidia-gpu qemu-sev qemu-snp qemu-tdx qemu stratovirt"
value: "clh dragonball fc qemu-nvidia-gpu qemu-sev qemu-snp qemu-tdx qemu remote stratovirt"
- name: DEFAULT_SHIM
value: "qemu"
- name: CREATE_RUNTIMECLASSES

View File

@ -32,7 +32,7 @@ spec:
- name: DEBUG
value: "false"
- name: SHIMS
value: "clh dragonball fc qemu qemu-nvidia-gpu qemu-sev qemu-snp qemu-tdx stratovirt"
value: "clh dragonball fc qemu qemu-nvidia-gpu qemu-sev qemu-snp qemu-tdx remote stratovirt"
- name: DEFAULT_SHIM
value: "qemu"
- name: CREATE_RUNTIMECLASSES

View File

@ -0,0 +1,13 @@
---
kind: RuntimeClass
apiVersion: node.k8s.io/v1
metadata:
name: kata-remote
handler: kata-remote
overhead:
podFixed:
memory: "120Mi"
cpu: "250m"
scheduling:
nodeSelector:
katacontainers.io/kata-runtime: "true"

View File

@ -105,6 +105,19 @@ scheduling:
---
kind: RuntimeClass
apiVersion: node.k8s.io/v1
metadata:
name: kata-remote
handler: kata-remote
overhead:
podFixed:
memory: "120Mi"
cpu: "250m"
scheduling:
nodeSelector:
katacontainers.io/kata-runtime: "true"
---
kind: RuntimeClass
apiVersion: node.k8s.io/v1
metadata:
name: kata-stratovirt
handler: kata-stratovirt