mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-25 11:13:15 +00:00
Merge pull request #8520 from stevenhorsman/hypervisor-ttrpc
runtime: Update hypervisor generated code
This commit is contained in:
commit
c6110284d5
@ -10,5 +10,5 @@ protoc \
|
||||
-I=$GOPATH/src \
|
||||
--proto_path=$HYPERVISOR_PATH \
|
||||
--go_out=$HYPERVISOR_PATH \
|
||||
--go-grpc_out=$HYPERVISOR_PATH \
|
||||
--go-ttrpc_out=$HYPERVISOR_PATH \
|
||||
$HYPERVISOR_PATH/hypervisor.proto
|
||||
|
@ -1,223 +0,0 @@
|
||||
// (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",
|
||||
}
|
92
src/runtime/protocols/hypervisor/hypervisor_ttrpc.pb.go
Normal file
92
src/runtime/protocols/hypervisor/hypervisor_ttrpc.pb.go
Normal file
@ -0,0 +1,92 @@
|
||||
// Code generated by protoc-gen-go-ttrpc. DO NOT EDIT.
|
||||
// source: hypervisor.proto
|
||||
package __
|
||||
|
||||
import (
|
||||
context "context"
|
||||
ttrpc "github.com/containerd/ttrpc"
|
||||
)
|
||||
|
||||
type HypervisorService 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)
|
||||
}
|
||||
|
||||
func RegisterHypervisorService(srv *ttrpc.Server, svc HypervisorService) {
|
||||
srv.RegisterService("hypervisor.Hypervisor", &ttrpc.ServiceDesc{
|
||||
Methods: map[string]ttrpc.Method{
|
||||
"CreateVM": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
|
||||
var req CreateVMRequest
|
||||
if err := unmarshal(&req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return svc.CreateVM(ctx, &req)
|
||||
},
|
||||
"StartVM": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
|
||||
var req StartVMRequest
|
||||
if err := unmarshal(&req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return svc.StartVM(ctx, &req)
|
||||
},
|
||||
"StopVM": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
|
||||
var req StopVMRequest
|
||||
if err := unmarshal(&req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return svc.StopVM(ctx, &req)
|
||||
},
|
||||
"Version": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
|
||||
var req VersionRequest
|
||||
if err := unmarshal(&req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return svc.Version(ctx, &req)
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
type hypervisorClient struct {
|
||||
client *ttrpc.Client
|
||||
}
|
||||
|
||||
func NewHypervisorClient(client *ttrpc.Client) HypervisorService {
|
||||
return &hypervisorClient{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *hypervisorClient) CreateVM(ctx context.Context, req *CreateVMRequest) (*CreateVMResponse, error) {
|
||||
var resp CreateVMResponse
|
||||
if err := c.client.Call(ctx, "hypervisor.Hypervisor", "CreateVM", req, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (c *hypervisorClient) StartVM(ctx context.Context, req *StartVMRequest) (*StartVMResponse, error) {
|
||||
var resp StartVMResponse
|
||||
if err := c.client.Call(ctx, "hypervisor.Hypervisor", "StartVM", req, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (c *hypervisorClient) StopVM(ctx context.Context, req *StopVMRequest) (*StopVMResponse, error) {
|
||||
var resp StopVMResponse
|
||||
if err := c.client.Call(ctx, "hypervisor.Hypervisor", "StopVM", req, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (c *hypervisorClient) Version(ctx context.Context, req *VersionRequest) (*VersionResponse, error) {
|
||||
var resp VersionResponse
|
||||
if err := c.client.Call(ctx, "hypervisor.Hypervisor", "Version", req, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
@ -6,19 +6,19 @@ package virtcontainers
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
cri "github.com/containerd/containerd/pkg/cri/annotations"
|
||||
"github.com/containerd/ttrpc"
|
||||
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
|
||||
@ -32,18 +32,20 @@ type remoteHypervisor struct {
|
||||
type remoteHypervisorSandboxID string
|
||||
|
||||
type remoteService struct {
|
||||
conn *grpc.ClientConn
|
||||
client pb.HypervisorClient
|
||||
conn net.Conn
|
||||
client pb.HypervisorService
|
||||
}
|
||||
|
||||
func openRemoteService(socketPath string) (*remoteService, error) {
|
||||
|
||||
conn, err := grpc.Dial(fmt.Sprintf("unix://%s", socketPath), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
conn, err := net.Dial("unix", socketPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to connect to remote hypervisor socket: %w", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
client := pb.NewHypervisorClient(conn)
|
||||
|
||||
ttrpcClient := ttrpc.NewClient(conn)
|
||||
|
||||
client := pb.NewHypervisorClient(ttrpcClient)
|
||||
|
||||
s := &remoteService{
|
||||
conn: conn,
|
||||
|
Loading…
Reference in New Issue
Block a user