diff --git a/firecracker-control/local.go b/firecracker-control/local.go index 0d59ecabe..998cf049d 100644 --- a/firecracker-control/local.go +++ b/firecracker-control/local.go @@ -78,7 +78,7 @@ func newLocal(ic *plugin.InitContext) (*local, error) { // CreateVM creates new Firecracker VM instance. It creates a runtime shim for the VM and the forwards // the CreateVM request to that shim. If there is already a VM created with the provided VMID, then // AlreadyExists is returned. -func (s *local) CreateVM(requestCtx context.Context, req *proto.CreateVMRequest) (*empty.Empty, error) { +func (s *local) CreateVM(requestCtx context.Context, req *proto.CreateVMRequest) (*proto.CreateVMResponse, error) { var err error id := req.GetVMID() diff --git a/firecracker-control/service.go b/firecracker-control/service.go index 715d9259b..e7f691272 100644 --- a/firecracker-control/service.go +++ b/firecracker-control/service.go @@ -67,7 +67,7 @@ func (s *service) RegisterTTRPC(server *ttrpc.Server) error { return nil } -func (s *service) CreateVM(ctx context.Context, req *proto.CreateVMRequest) (*empty.Empty, error) { +func (s *service) CreateVM(ctx context.Context, req *proto.CreateVMRequest) (*proto.CreateVMResponse, error) { log.G(ctx).Debugf("create VM request: %+v", req) return s.local.CreateVM(ctx, req) } diff --git a/proto/firecracker.pb.go b/proto/firecracker.pb.go index 6c0457384..8c92c26c2 100644 --- a/proto/firecracker.pb.go +++ b/proto/firecracker.pb.go @@ -140,6 +140,76 @@ func (m *CreateVMRequest) GetJailerConfig() *JailerConfig { return nil } +type CreateVMResponse struct { + VMID string `protobuf:"bytes,1,opt,name=VMID,json=vMID,proto3" json:"VMID,omitempty"` + SocketPath string `protobuf:"bytes,2,opt,name=SocketPath,json=socketPath,proto3" json:"SocketPath,omitempty"` + LogFifoPath string `protobuf:"bytes,3,opt,name=LogFifoPath,json=logFifoPath,proto3" json:"LogFifoPath,omitempty"` + MetricsFifoPath string `protobuf:"bytes,4,opt,name=MetricsFifoPath,json=metricsFifoPath,proto3" json:"MetricsFifoPath,omitempty"` + CgroupPath string `protobuf:"bytes,5,opt,name=CgroupPath,json=cgroupPath,proto3" json:"CgroupPath,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CreateVMResponse) Reset() { *m = CreateVMResponse{} } +func (m *CreateVMResponse) String() string { return proto.CompactTextString(m) } +func (*CreateVMResponse) ProtoMessage() {} +func (*CreateVMResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a73317e9fb8da571, []int{1} +} +func (m *CreateVMResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CreateVMResponse.Unmarshal(m, b) +} +func (m *CreateVMResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CreateVMResponse.Marshal(b, m, deterministic) +} +func (m *CreateVMResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CreateVMResponse.Merge(m, src) +} +func (m *CreateVMResponse) XXX_Size() int { + return xxx_messageInfo_CreateVMResponse.Size(m) +} +func (m *CreateVMResponse) XXX_DiscardUnknown() { + xxx_messageInfo_CreateVMResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_CreateVMResponse proto.InternalMessageInfo + +func (m *CreateVMResponse) GetVMID() string { + if m != nil { + return m.VMID + } + return "" +} + +func (m *CreateVMResponse) GetSocketPath() string { + if m != nil { + return m.SocketPath + } + return "" +} + +func (m *CreateVMResponse) GetLogFifoPath() string { + if m != nil { + return m.LogFifoPath + } + return "" +} + +func (m *CreateVMResponse) GetMetricsFifoPath() string { + if m != nil { + return m.MetricsFifoPath + } + return "" +} + +func (m *CreateVMResponse) GetCgroupPath() string { + if m != nil { + return m.CgroupPath + } + return "" +} + type StopVMRequest struct { VMID string `protobuf:"bytes,1,opt,name=VMID,json=vMID,proto3" json:"VMID,omitempty"` TimeoutSeconds uint32 `protobuf:"varint,2,opt,name=TimeoutSeconds,json=timeoutSeconds,proto3" json:"TimeoutSeconds,omitempty"` @@ -152,7 +222,7 @@ func (m *StopVMRequest) Reset() { *m = StopVMRequest{} } func (m *StopVMRequest) String() string { return proto.CompactTextString(m) } func (*StopVMRequest) ProtoMessage() {} func (*StopVMRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a73317e9fb8da571, []int{1} + return fileDescriptor_a73317e9fb8da571, []int{2} } func (m *StopVMRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_StopVMRequest.Unmarshal(m, b) @@ -197,7 +267,7 @@ func (m *GetVMInfoRequest) Reset() { *m = GetVMInfoRequest{} } func (m *GetVMInfoRequest) String() string { return proto.CompactTextString(m) } func (*GetVMInfoRequest) ProtoMessage() {} func (*GetVMInfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a73317e9fb8da571, []int{2} + return fileDescriptor_a73317e9fb8da571, []int{3} } func (m *GetVMInfoRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetVMInfoRequest.Unmarshal(m, b) @@ -226,10 +296,10 @@ func (m *GetVMInfoRequest) GetVMID() string { type GetVMInfoResponse struct { VMID string `protobuf:"bytes,1,opt,name=VMID,json=vMID,proto3" json:"VMID,omitempty"` - ContextID uint32 `protobuf:"varint,2,opt,name=ContextID,json=contextID,proto3" json:"ContextID,omitempty"` - SocketPath string `protobuf:"bytes,3,opt,name=SocketPath,json=socketPath,proto3" json:"SocketPath,omitempty"` - LogFifoPath string `protobuf:"bytes,4,opt,name=LogFifoPath,json=logFifoPath,proto3" json:"LogFifoPath,omitempty"` - MetricsFifoPath string `protobuf:"bytes,5,opt,name=MetricsFifoPath,json=metricsFifoPath,proto3" json:"MetricsFifoPath,omitempty"` + SocketPath string `protobuf:"bytes,2,opt,name=SocketPath,json=socketPath,proto3" json:"SocketPath,omitempty"` + LogFifoPath string `protobuf:"bytes,3,opt,name=LogFifoPath,json=logFifoPath,proto3" json:"LogFifoPath,omitempty"` + MetricsFifoPath string `protobuf:"bytes,4,opt,name=MetricsFifoPath,json=metricsFifoPath,proto3" json:"MetricsFifoPath,omitempty"` + CgroupPath string `protobuf:"bytes,5,opt,name=CgroupPath,json=cgroupPath,proto3" json:"CgroupPath,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -239,7 +309,7 @@ func (m *GetVMInfoResponse) Reset() { *m = GetVMInfoResponse{} } func (m *GetVMInfoResponse) String() string { return proto.CompactTextString(m) } func (*GetVMInfoResponse) ProtoMessage() {} func (*GetVMInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a73317e9fb8da571, []int{3} + return fileDescriptor_a73317e9fb8da571, []int{4} } func (m *GetVMInfoResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetVMInfoResponse.Unmarshal(m, b) @@ -266,13 +336,6 @@ func (m *GetVMInfoResponse) GetVMID() string { return "" } -func (m *GetVMInfoResponse) GetContextID() uint32 { - if m != nil { - return m.ContextID - } - return 0 -} - func (m *GetVMInfoResponse) GetSocketPath() string { if m != nil { return m.SocketPath @@ -294,6 +357,13 @@ func (m *GetVMInfoResponse) GetMetricsFifoPath() string { return "" } +func (m *GetVMInfoResponse) GetCgroupPath() string { + if m != nil { + return m.CgroupPath + } + return "" +} + type SetVMMetadataRequest struct { VMID string `protobuf:"bytes,1,opt,name=VMID,json=vMID,proto3" json:"VMID,omitempty"` Metadata string `protobuf:"bytes,2,opt,name=Metadata,json=metadata,proto3" json:"Metadata,omitempty"` @@ -306,7 +376,7 @@ func (m *SetVMMetadataRequest) Reset() { *m = SetVMMetadataRequest{} } func (m *SetVMMetadataRequest) String() string { return proto.CompactTextString(m) } func (*SetVMMetadataRequest) ProtoMessage() {} func (*SetVMMetadataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a73317e9fb8da571, []int{4} + return fileDescriptor_a73317e9fb8da571, []int{5} } func (m *SetVMMetadataRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetVMMetadataRequest.Unmarshal(m, b) @@ -352,7 +422,7 @@ func (m *UpdateVMMetadataRequest) Reset() { *m = UpdateVMMetadataRequest func (m *UpdateVMMetadataRequest) String() string { return proto.CompactTextString(m) } func (*UpdateVMMetadataRequest) ProtoMessage() {} func (*UpdateVMMetadataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a73317e9fb8da571, []int{5} + return fileDescriptor_a73317e9fb8da571, []int{6} } func (m *UpdateVMMetadataRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UpdateVMMetadataRequest.Unmarshal(m, b) @@ -397,7 +467,7 @@ func (m *GetVMMetadataRequest) Reset() { *m = GetVMMetadataRequest{} } func (m *GetVMMetadataRequest) String() string { return proto.CompactTextString(m) } func (*GetVMMetadataRequest) ProtoMessage() {} func (*GetVMMetadataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a73317e9fb8da571, []int{6} + return fileDescriptor_a73317e9fb8da571, []int{7} } func (m *GetVMMetadataRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetVMMetadataRequest.Unmarshal(m, b) @@ -435,7 +505,7 @@ func (m *GetVMMetadataResponse) Reset() { *m = GetVMMetadataResponse{} } func (m *GetVMMetadataResponse) String() string { return proto.CompactTextString(m) } func (*GetVMMetadataResponse) ProtoMessage() {} func (*GetVMMetadataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a73317e9fb8da571, []int{7} + return fileDescriptor_a73317e9fb8da571, []int{8} } func (m *GetVMMetadataResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetVMMetadataResponse.Unmarshal(m, b) @@ -473,7 +543,7 @@ func (m *JailerConfig) Reset() { *m = JailerConfig{} } func (m *JailerConfig) String() string { return proto.CompactTextString(m) } func (*JailerConfig) ProtoMessage() {} func (*JailerConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_a73317e9fb8da571, []int{8} + return fileDescriptor_a73317e9fb8da571, []int{9} } func (m *JailerConfig) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_JailerConfig.Unmarshal(m, b) @@ -502,6 +572,7 @@ func (m *JailerConfig) GetNetNS() string { func init() { proto.RegisterType((*CreateVMRequest)(nil), "CreateVMRequest") + proto.RegisterType((*CreateVMResponse)(nil), "CreateVMResponse") proto.RegisterType((*StopVMRequest)(nil), "StopVMRequest") proto.RegisterType((*GetVMInfoRequest)(nil), "GetVMInfoRequest") proto.RegisterType((*GetVMInfoResponse)(nil), "GetVMInfoResponse") @@ -515,39 +586,40 @@ func init() { func init() { proto.RegisterFile("firecracker.proto", fileDescriptor_a73317e9fb8da571) } var fileDescriptor_a73317e9fb8da571 = []byte{ - // 541 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4f, 0x6f, 0xd3, 0x4e, - 0x10, 0x95, 0x7f, 0x4d, 0xda, 0x78, 0xdc, 0xa6, 0xbf, 0xac, 0x5a, 0x58, 0x55, 0x15, 0xb2, 0x2c, - 0x54, 0x45, 0x1c, 0x2a, 0xd1, 0x5e, 0x10, 0x27, 0x4a, 0x42, 0x2b, 0xb7, 0xb8, 0x42, 0x9b, 0xd2, - 0x03, 0xb7, 0xc5, 0x19, 0xa7, 0x26, 0xce, 0x6e, 0xd8, 0x9d, 0x94, 0x72, 0xe6, 0x13, 0xf1, 0x0d, - 0x91, 0x37, 0xff, 0x9c, 0x08, 0x2a, 0x24, 0x4e, 0x9e, 0x79, 0xf3, 0x66, 0xe6, 0x69, 0xfc, 0x6c, - 0x68, 0x65, 0xb9, 0xc1, 0xd4, 0xc8, 0x74, 0x88, 0xe6, 0x78, 0x6c, 0x34, 0xe9, 0x83, 0x80, 0xbe, - 0x8f, 0xd1, 0x4e, 0x93, 0xe8, 0x47, 0x0d, 0x76, 0x3b, 0x06, 0x25, 0xe1, 0x6d, 0x22, 0xf0, 0xeb, - 0x04, 0x2d, 0x31, 0x06, 0xb5, 0xdb, 0x24, 0xee, 0x72, 0x2f, 0xf4, 0xda, 0xbe, 0xa8, 0xdd, 0x27, - 0x71, 0x97, 0xbd, 0x01, 0x48, 0x64, 0x7a, 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, 0x3c, 0x5f, 0xf5, 0x13, 0xdb, 0x83, 0xfa, 0x35, 0xd2, 0x75, 0x6f, 0x46, - 0xac, 0xab, 0x32, 0x79, 0xbb, 0xf5, 0xa9, 0xee, 0xfe, 0x28, 0x9f, 0x37, 0xdd, 0xe3, 0xf4, 0x57, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xcd, 0x16, 0x31, 0x73, 0x7a, 0x04, 0x00, 0x00, + // 550 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x54, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0x95, 0xdb, 0xb8, 0x4d, 0xc6, 0x6d, 0xd2, 0xac, 0x5a, 0x58, 0x55, 0xa8, 0xb2, 0x2c, 0x54, + 0x59, 0x1c, 0x2a, 0xd1, 0x5e, 0x10, 0x27, 0x4a, 0x42, 0x2b, 0xb7, 0xb8, 0x42, 0x4e, 0xe9, 0x81, + 0xdb, 0xe2, 0x8c, 0x5d, 0x63, 0x67, 0xd7, 0xec, 0x6e, 0x0a, 0x9c, 0xf9, 0x23, 0xf8, 0x41, 0xe4, + 0x4d, 0xea, 0x38, 0x11, 0x54, 0x48, 0x9c, 0x38, 0x65, 0xe7, 0xcd, 0x9b, 0x99, 0xa7, 0x99, 0x17, + 0x43, 0x3f, 0xc9, 0x24, 0xc6, 0x92, 0xc5, 0x39, 0xca, 0xa3, 0x52, 0x0a, 0x2d, 0xf6, 0x1d, 0xfd, + 0xad, 0x44, 0x35, 0x0b, 0xbc, 0xef, 0x2d, 0xe8, 0x0d, 0x24, 0x32, 0x8d, 0x37, 0x61, 0x84, 0x9f, + 0xa7, 0xa8, 0x34, 0x21, 0xd0, 0xba, 0x09, 0x83, 0x21, 0xb5, 0x5c, 0xcb, 0xef, 0x44, 0xad, 0xbb, + 0x30, 0x18, 0x92, 0x57, 0x00, 0x21, 0x8b, 0x6f, 0x33, 0x8e, 0x83, 0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87, 0xad, 0x0b, 0x96, 0x15, 0x55, 0xab, 0xea, 0x16, 0x14, 0xcc, 0x86, 0xb6, 0x8f, 0x9a, + 0x60, 0xb4, 0xf5, 0xa9, 0x11, 0x79, 0x3f, 0x2c, 0xd8, 0x59, 0xb8, 0x40, 0x95, 0x82, 0x2b, 0xfc, + 0xad, 0x0d, 0x0e, 0x00, 0x46, 0x22, 0xce, 0x51, 0x9b, 0xfb, 0xad, 0xcd, 0x4e, 0xa3, 0x6a, 0x84, + 0xb8, 0xe0, 0xbc, 0x15, 0xe9, 0x59, 0x96, 0x88, 0xc6, 0x81, 0x9d, 0x62, 0x01, 0x55, 0x36, 0x08, + 0x51, 0xcb, 0x2c, 0x56, 0x35, 0x6b, 0x76, 0xe1, 0xde, 0x64, 0x19, 0xae, 0x66, 0x0d, 0x52, 0x29, + 0xa6, 0xa5, 0x21, 0xd9, 0xb3, 0x59, 0x71, 0x8d, 0x78, 0x97, 0xb0, 0x3d, 0xd2, 0xa2, 0x7c, 0xd8, + 0xb7, 0x87, 0xd0, 0xbd, 0xce, 0x26, 0x28, 0xa6, 0x7a, 0x84, 0xb1, 0xe0, 0x63, 0x65, 0x44, 0x6f, + 0x47, 0x5d, 0xbd, 0x84, 0x7a, 0x87, 0xb0, 0x73, 0x8e, 0xfa, 0x26, 0x0c, 0x78, 0x22, 0x1e, 0xe8, + 0xe7, 0xfd, 0xb4, 0xa0, 0xdf, 0x20, 0xfe, 0x27, 0xab, 0x3a, 0x83, 0xdd, 0x51, 0x25, 0x3a, 0x44, + 0xcd, 0xc6, 0x4c, 0xb3, 0x87, 0x36, 0xb6, 0x0f, 0xed, 0x7b, 0xda, 0x5c, 0x75, 0x7b, 0x32, 0x8f, + 0xbd, 0x00, 0x1e, 0xbf, 0x2f, 0xc7, 0xc6, 0x26, 0xff, 0xda, 0xea, 0x19, 0xec, 0x9e, 0xff, 0xa5, + 0x24, 0xef, 0x04, 0xf6, 0x56, 0xb8, 0xf3, 0xbd, 0x37, 0x07, 0x58, 0x2b, 0x03, 0x9e, 0x2e, 0xff, + 0x0d, 0xc8, 0x2e, 0xd8, 0x57, 0xa8, 0xaf, 0x46, 0x73, 0xa2, 0xcd, 0xab, 0xe0, 0xf5, 0xe6, 0x07, + 0xdb, 0x7c, 0x08, 0x3f, 0x6e, 0x98, 0x9f, 0x93, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x62, + 0xbf, 0xbf, 0x31, 0x05, 0x00, 0x00, } diff --git a/proto/firecracker.proto b/proto/firecracker.proto index 9be1e22cc..7361ca902 100644 --- a/proto/firecracker.proto +++ b/proto/firecracker.proto @@ -36,6 +36,14 @@ message CreateVMRequest { JailerConfig JailerConfig = 10; } +message CreateVMResponse { + string VMID = 1; + string SocketPath = 2; + string LogFifoPath = 3; + string MetricsFifoPath = 4; + string CgroupPath = 5; +} + message StopVMRequest { string VMID = 1; uint32 TimeoutSeconds = 2; @@ -47,10 +55,10 @@ message GetVMInfoRequest { message GetVMInfoResponse { string VMID = 1; - uint32 ContextID = 2; - string SocketPath = 3; - string LogFifoPath = 4; - string MetricsFifoPath = 5; + string SocketPath = 2; + string LogFifoPath = 3; + string MetricsFifoPath = 4; + string CgroupPath = 5; } message SetVMMetadataRequest { diff --git a/proto/service/fccontrol/fccontrol.proto b/proto/service/fccontrol/fccontrol.proto index 87800806e..a55ff09f6 100644 --- a/proto/service/fccontrol/fccontrol.proto +++ b/proto/service/fccontrol/fccontrol.proto @@ -8,7 +8,7 @@ option go_package = "fccontrol"; service Firecracker { // Runs new Firecracker VM instance - rpc CreateVM(CreateVMRequest) returns (google.protobuf.Empty); + rpc CreateVM(CreateVMRequest) returns (CreateVMResponse); // Stops existing Firecracker instance by VM ID rpc StopVM(StopVMRequest) returns (google.protobuf.Empty); diff --git a/proto/service/fccontrol/ttrpc/fccontrol.pb.go b/proto/service/fccontrol/ttrpc/fccontrol.pb.go index b1fed2e68..9ffb89bb3 100644 --- a/proto/service/fccontrol/ttrpc/fccontrol.pb.go +++ b/proto/service/fccontrol/ttrpc/fccontrol.pb.go @@ -27,27 +27,28 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package func init() { proto.RegisterFile("fccontrol.proto", fileDescriptor_b99f53e2bf82c5ef) } var fileDescriptor_b99f53e2bf82c5ef = []byte{ - // 255 bytes of a gzipped FileDescriptorProto + // 261 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4f, 0x4b, 0x4e, 0xce, 0xcf, 0x2b, 0x29, 0xca, 0xcf, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x97, 0x92, 0x4e, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0xd5, 0x07, 0xf3, 0x92, 0x4a, 0xd3, 0xf4, 0x53, 0x73, 0x0b, 0x4a, 0x2a, 0xa1, 0x92, 0x82, 0x69, 0x99, 0x45, 0xa9, 0xc9, 0x45, 0x89, 0xc9, 0xd9, 0xa9, 0x45, 0x10, 0x21, 0xa3, - 0xf7, 0x4c, 0x5c, 0xdc, 0x6e, 0x08, 0x51, 0x21, 0x13, 0x2e, 0x0e, 0xe7, 0xa2, 0xd4, 0xc4, 0x92, + 0x57, 0x4c, 0x5c, 0xdc, 0x6e, 0x08, 0x51, 0x21, 0x7d, 0x2e, 0x0e, 0xe7, 0xa2, 0xd4, 0xc4, 0x92, 0xd4, 0x30, 0x5f, 0x21, 0x01, 0x3d, 0x18, 0x33, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, 0x4a, - 0x4c, 0x0f, 0x62, 0xbc, 0x1e, 0xcc, 0x78, 0x3d, 0x57, 0x90, 0xf1, 0x42, 0x06, 0x5c, 0x6c, 0xc1, - 0x25, 0xf9, 0x05, 0x61, 0xbe, 0x42, 0x7c, 0x7a, 0x10, 0x06, 0x21, 0x1d, 0x46, 0x5c, 0x9c, 0xee, - 0xa9, 0x25, 0x61, 0xbe, 0x9e, 0x79, 0x69, 0xf9, 0x42, 0x82, 0x7a, 0x70, 0x36, 0x4c, 0x9f, 0x10, - 0xb2, 0x50, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0x90, 0x1d, 0x17, 0x6f, 0x30, 0x48, 0xd0, 0x37, - 0xb5, 0x24, 0x31, 0x25, 0xb1, 0x24, 0x51, 0x48, 0x54, 0x0f, 0x85, 0x4f, 0xc8, 0x4e, 0x17, 0x2e, - 0x81, 0xd0, 0x82, 0x14, 0xb0, 0x87, 0xe0, 0x46, 0x48, 0xe8, 0xa1, 0x0b, 0x11, 0x32, 0xc5, 0x8e, - 0x8b, 0xd7, 0x1d, 0xcd, 0x15, 0xee, 0xd8, 0x5d, 0x81, 0x26, 0x0c, 0xf1, 0x85, 0x93, 0xf2, 0x89, - 0x87, 0x72, 0x0c, 0x37, 0x1e, 0xca, 0x31, 0x34, 0x3c, 0x92, 0x63, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, - 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0xa3, 0x38, 0xe1, 0x91, 0x99, 0xc4, 0x06, 0xb6, - 0xd4, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xfe, 0x0d, 0x1a, 0xa7, 0xe0, 0x01, 0x00, 0x00, + 0x10, 0x49, 0xa4, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0xc8, 0x80, 0x8b, 0x2d, 0xb8, 0x24, 0xbf, + 0x20, 0xcc, 0x57, 0x88, 0x4f, 0x0f, 0xc2, 0x80, 0x29, 0x16, 0xd3, 0x83, 0xb8, 0x45, 0x0f, 0xe6, + 0x16, 0x3d, 0x57, 0x90, 0x5b, 0x84, 0x8c, 0xb8, 0x38, 0xdd, 0x53, 0x4b, 0xc2, 0x7c, 0x3d, 0xf3, + 0xd2, 0xf2, 0x85, 0x04, 0xf5, 0xe0, 0x6c, 0x98, 0x3e, 0x21, 0x64, 0x21, 0xa8, 0x2d, 0x76, 0x5c, + 0xbc, 0xc1, 0x20, 0x41, 0xdf, 0xd4, 0x92, 0xc4, 0x94, 0xc4, 0x92, 0x44, 0x21, 0x51, 0x3d, 0x14, + 0x3e, 0x21, 0x3b, 0x5d, 0xb8, 0x04, 0x42, 0x0b, 0x52, 0xc0, 0x2e, 0x87, 0x1b, 0x21, 0xa1, 0x87, + 0x2e, 0x44, 0xc8, 0x14, 0x3b, 0x2e, 0x5e, 0x77, 0x34, 0x57, 0xb8, 0x63, 0x77, 0x05, 0x9a, 0x30, + 0xc4, 0x17, 0x4e, 0xca, 0x27, 0x1e, 0xca, 0x31, 0xdc, 0x78, 0x28, 0xc7, 0xd0, 0xf0, 0x48, 0x8e, + 0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x8c, 0xe2, 0x84, + 0xc7, 0x63, 0x12, 0x1b, 0xd8, 0x52, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0c, 0x15, 0x3e, + 0x05, 0xdb, 0x01, 0x00, 0x00, } type FirecrackerService interface { - CreateVM(ctx context.Context, req *proto1.CreateVMRequest) (*empty.Empty, error) + CreateVM(ctx context.Context, req *proto1.CreateVMRequest) (*proto1.CreateVMResponse, error) StopVM(ctx context.Context, req *proto1.StopVMRequest) (*empty.Empty, error) GetVMInfo(ctx context.Context, req *proto1.GetVMInfoRequest) (*proto1.GetVMInfoResponse, error) SetVMMetadata(ctx context.Context, req *proto1.SetVMMetadataRequest) (*empty.Empty, error) @@ -112,8 +113,8 @@ func NewFirecrackerClient(client *github_com_containerd_ttrpc.Client) Firecracke } } -func (c *firecrackerClient) CreateVM(ctx context.Context, req *proto1.CreateVMRequest) (*empty.Empty, error) { - var resp empty.Empty +func (c *firecrackerClient) CreateVM(ctx context.Context, req *proto1.CreateVMRequest) (*proto1.CreateVMResponse, error) { + var resp proto1.CreateVMResponse if err := c.client.Call(ctx, "Firecracker", "CreateVM", req, &resp); err != nil { return nil, err } diff --git a/runtime/jailer.go b/runtime/jailer.go index 33bea1e83..6b543d1c0 100644 --- a/runtime/jailer.go +++ b/runtime/jailer.go @@ -58,6 +58,10 @@ type jailer interface { StubDrivesOptions() []stubDrivesOpt } +type cgroupPather interface { + CgroupPath() string +} + // newJailer is used to construct a jailer from the CreateVM request. If no // request or jailer config was provided, then the noopJailer will be returned. func newJailer( @@ -73,5 +77,13 @@ func newJailer( } l := logger.WithField("jailer", "runc") - return newRuncJailer(ctx, l, ociBundlePath, service.config.JailerConfig.RuncBinaryPath, jailerUID, jailerGID) + return newRuncJailer( + ctx, + l, + service.vmID, + ociBundlePath, + service.config.JailerConfig.RuncBinaryPath, + jailerUID, + jailerGID, + ) } diff --git a/runtime/runc_jailer.go b/runtime/runc_jailer.go index 1f1207da3..f1790b98e 100644 --- a/runtime/runc_jailer.go +++ b/runtime/runc_jailer.go @@ -50,22 +50,29 @@ type runcJailer struct { runcBinaryPath string uid uint32 gid uint32 + vmID string configSpec specs.Spec } const firecrackerFileName = "firecracker" -func newRuncJailer(ctx context.Context, logger *logrus.Entry, ociBundlePath, runcBinPath string, uid, gid uint32) (*runcJailer, error) { - l := logger.WithField("ociBundlePath", ociBundlePath). - WithField("runcBinaryPath", runcBinPath) - +func newRuncJailer( + ctx context.Context, + logger *logrus.Entry, + vmID string, + ociBundlePath string, + runcBinaryPath string, + uid uint32, + gid uint32) (*runcJailer, error) { + l := logger.WithField("ociBundlePath", ociBundlePath).WithField("runcBinaryPath", runcBinaryPath) j := &runcJailer{ ctx: ctx, logger: l, ociBundlePath: ociBundlePath, - runcBinaryPath: runcBinPath, + runcBinaryPath: runcBinaryPath, uid: uid, gid: gid, + vmID: vmID, } spec := specs.Spec{} @@ -418,6 +425,10 @@ func (j *runcJailer) overwriteConfig(cfg *Config, machineConfig *firecracker.Con return nil } +func (j runcJailer) CgroupPath() string { + return filepath.Join("/firecracker-containerd", j.vmID) +} + // setDefaultConfigValues will process the spec file provided and allow any // empty/zero values to be replaced with default values. func (j *runcJailer) setDefaultConfigValues(cfg *Config, socketPath string, spec specs.Spec) specs.Spec { @@ -436,6 +447,10 @@ func (j *runcJailer) setDefaultConfigValues(cfg *Config, socketPath string, spec spec.Process.Args = cmd.Args } + cgroupPath := j.CgroupPath() + j.logger.WithField("CgroupPath", cgroupPath).Debug("using cgroup path") + spec.Linux.CgroupsPath = cgroupPath + return spec } diff --git a/runtime/runc_jailer_test.go b/runtime/runc_jailer_test.go index bb7d085b4..3e3056204 100644 --- a/runtime/runc_jailer_test.go +++ b/runtime/runc_jailer_test.go @@ -53,7 +53,8 @@ func TestBuildJailedRootHandler_Isolated(t *testing.T) { defer firecrackerFd.Close() l := logrus.NewEntry(logrus.New()) - jailer, err := newRuncJailer(context.Background(), l, dir, "bin-path", 123, 456) + vmID := "foo" + jailer, err := newRuncJailer(context.Background(), l, vmID, dir, "path/to/runc", 123, 456) require.NoError(t, err, "failed to create runc jailer") cfg := Config{ @@ -72,7 +73,6 @@ func TestBuildJailedRootHandler_Isolated(t *testing.T) { }, }, } - vmID := "foo" handler := jailer.BuildJailedRootHandler(&cfg, &machineConfig, vmID) machine := firecracker.Machine{ diff --git a/runtime/service.go b/runtime/service.go index 4d4ebe527..c8f27cc1f 100644 --- a/runtime/service.go +++ b/runtime/service.go @@ -410,12 +410,13 @@ func (s *service) waitVMReady() error { // CreateVM will attempt to create the VM as specified in the provided request, but only on the first request // received. Any subsequent requests will be ignored and get an AlreadyExists error response. -func (s *service) CreateVM(requestCtx context.Context, request *proto.CreateVMRequest) (*empty.Empty, error) { +func (s *service) CreateVM(requestCtx context.Context, request *proto.CreateVMRequest) (*proto.CreateVMResponse, error) { defer logPanicAndDie(s.logger) var ( err error createRan bool + resp proto.CreateVMResponse ) s.vmStartOnce.Do(func() { @@ -445,7 +446,11 @@ func (s *service) CreateVM(requestCtx context.Context, request *proto.CreateVMRe // let all the other methods know that the VM is ready for tasks close(s.vmReady) - return &empty.Empty{}, nil + + if c, ok := s.jailer.(cgroupPather); ok { + resp.CgroupPath = c.CgroupPath() + } + return &resp, nil } func (s *service) publishVMStart() error { diff --git a/runtime/service_integ_test.go b/runtime/service_integ_test.go index 423d7c098..27ea346f7 100644 --- a/runtime/service_integ_test.go +++ b/runtime/service_integ_test.go @@ -274,9 +274,10 @@ func TestMultipleVMs_Isolated(t *testing.T) { rootfsPath := defaultVMRootfsPath + vmIDStr := strconv.Itoa(vmID) fcClient := fccontrol.NewFirecrackerClient(pluginClient.Client()) req := &proto.CreateVMRequest{ - VMID: strconv.Itoa(vmID), + VMID: vmIDStr, MachineCfg: &proto.FirecrackerMachineConfiguration{ MemSizeMib: 512, }, @@ -296,7 +297,7 @@ func TestMultipleVMs_Isolated(t *testing.T) { JailerConfig: jailerConfig, } - _, err = fcClient.CreateVM(ctx, req) + resp, err := fcClient.CreateVM(ctx, req) require.NoError(t, err, "failed to create vm") var containerWg sync.WaitGroup @@ -403,9 +404,13 @@ func TestMultipleVMs_Isolated(t *testing.T) { jailer := &runcJailer{ ociBundlePath: string(shimDir), + vmID: vmIDStr, } _, err = os.Stat(jailer.RootPath()) require.NoError(t, err, "failed to stat root path of jailer") + _, err = os.Stat(filepath.Join("/sys/fs/cgroup/cpu", resp.CgroupPath)) + require.NoError(t, err, "failed to stat cgroup path of jailer") + assert.Equal(t, filepath.Join("/firecracker-containerd", vmIDStr), resp.CgroupPath) } // Verify each exec had the same stdout and use that value as the mount namespace that will be compared