From d4dc0a59c44556949f071bc9f7383d25936fad4e Mon Sep 17 00:00:00 2001 From: Ansuman Sahoo Date: Mon, 25 Aug 2025 21:27:47 +0530 Subject: [PATCH] support external drivers to recent changes Signed-off-by: Ansuman Sahoo --- cmd/limactl/clone.go | 4 +- cmd/limactl/edit.go | 4 +- cmd/limactl/prune.go | 4 +- cmd/limactl/start.go | 4 +- cmd/limactl/template.go | 4 +- .../boot/05-rosetta-volume.sh | 33 -- pkg/driver/driver.go | 8 +- pkg/driver/external/client/methods.go | 53 +++- pkg/driver/external/driver.pb.go | 291 ++++++++++++------ pkg/driver/external/driver.proto | 19 +- pkg/driver/external/driver_grpc.pb.go | 256 ++++++++------- pkg/driver/external/server/methods.go | 48 ++- pkg/driver/external/server/server.go | 69 ++++- pkg/driver/qemu/qemu_driver.go | 4 +- pkg/driver/vz/vz_driver_darwin.go | 11 +- pkg/driver/wsl2/wsl_driver_windows.go | 4 +- pkg/driverutil/instance.go | 2 +- pkg/driverutil/vm.go | 126 +++++++- pkg/hostagent/hostagent.go | 2 +- pkg/instance/create.go | 4 +- pkg/instance/start.go | 2 +- pkg/limatype/lima_yaml.go | 5 - pkg/limayaml/validate.go | 4 +- pkg/limayaml/validate_test.go | 12 +- pkg/registry/registry.go | 2 +- pkg/registry/registry_test.go | 40 +-- pkg/store/store.go | 4 +- 27 files changed, 693 insertions(+), 326 deletions(-) delete mode 100755 pkg/cidata/cidata.TEMPLATE.d/boot/05-rosetta-volume.sh diff --git a/cmd/limactl/clone.go b/cmd/limactl/clone.go index 87a7a980449..18e1c5a6fbd 100644 --- a/cmd/limactl/clone.go +++ b/cmd/limactl/clone.go @@ -80,8 +80,8 @@ func cloneAction(cmd *cobra.Command, args []string) error { if err != nil { return err } - if err := driverutil.ResolveVMType(y, filePath); err != nil { - return fmt.Errorf("failed to accept config for %q: %w", filePath, err) + if err := driverutil.ResolveVMType(ctx, y, filePath); err != nil { + return fmt.Errorf("failed to resolve vm for %q: %w", filePath, err) } if err := limayaml.Validate(y, true); err != nil { return saveRejectedYAML(yBytes, err) diff --git a/cmd/limactl/edit.go b/cmd/limactl/edit.go index 8685f17b1b4..c503e54abd0 100644 --- a/cmd/limactl/edit.go +++ b/cmd/limactl/edit.go @@ -121,8 +121,8 @@ func editAction(cmd *cobra.Command, args []string) error { if err != nil { return err } - if err := driverutil.ResolveVMType(y, filePath); err != nil { - return fmt.Errorf("failed to accept config for %q: %w", filePath, err) + if err := driverutil.ResolveVMType(ctx, y, filePath); err != nil { + return fmt.Errorf("failed to resolve vm for %q: %w", filePath, err) } if err := limayaml.Validate(y, true); err != nil { return saveRejectedYAML(yBytes, err) diff --git a/cmd/limactl/prune.go b/cmd/limactl/prune.go index c7ec78f00b9..ee1196e961a 100644 --- a/cmd/limactl/prune.go +++ b/cmd/limactl/prune.go @@ -97,8 +97,8 @@ func knownLocations(ctx context.Context) (map[string]limatype.File, error) { if err != nil { return nil, err } - if err := driverutil.ResolveVMType(y, t.Name); err != nil { - return nil, fmt.Errorf("failed to accept config for %q: %w", t.Name, err) + if err := driverutil.ResolveVMType(ctx, y, t.Name); err != nil { + return nil, fmt.Errorf("failed to resolve vm for %q: %w", t.Name, err) } maps.Copy(locations, locationsFromLimaYAML(y)) } diff --git a/cmd/limactl/start.go b/cmd/limactl/start.go index c3dd8261f80..4b6c2dc016f 100644 --- a/cmd/limactl/start.go +++ b/cmd/limactl/start.go @@ -363,8 +363,8 @@ func applyYQExpressionToExistingInstance(ctx context.Context, inst *limatype.Ins if err != nil { return nil, err } - if err := driverutil.ResolveVMType(y, filePath); err != nil { - return nil, fmt.Errorf("failed to accept config for %q: %w", filePath, err) + if err := driverutil.ResolveVMType(ctx, y, filePath); err != nil { + return nil, fmt.Errorf("failed to resolve vm for %q: %w", filePath, err) } if err := limayaml.Validate(y, true); err != nil { rejectedYAML := "lima.REJECTED.yaml" diff --git a/cmd/limactl/template.go b/cmd/limactl/template.go index 7913bf4e2bd..8880da9e76e 100644 --- a/cmd/limactl/template.go +++ b/cmd/limactl/template.go @@ -88,7 +88,7 @@ func fillDefaults(ctx context.Context, tmpl *limatmpl.Template) error { if err == nil { tmpl.Bytes, err = limayaml.Marshal(tmpl.Config, false) } - if err := driverutil.ResolveVMType(tmpl.Config, filePath); err != nil { + if err := driverutil.ResolveVMType(ctx, tmpl.Config, filePath); err != nil { logrus.Warnf("failed to resolve VM type for %q: %v", filePath, err) return nil } @@ -251,7 +251,7 @@ func templateValidateAction(cmd *cobra.Command, args []string) error { if err != nil { return err } - if err := driverutil.ResolveVMType(y, filePath); err != nil { + if err := driverutil.ResolveVMType(ctx, y, filePath); err != nil { logrus.Warnf("failed to resolve VM type for %q: %v", filePath, err) return nil } diff --git a/pkg/cidata/cidata.TEMPLATE.d/boot/05-rosetta-volume.sh b/pkg/cidata/cidata.TEMPLATE.d/boot/05-rosetta-volume.sh deleted file mode 100755 index 9fa517aeb17..00000000000 --- a/pkg/cidata/cidata.TEMPLATE.d/boot/05-rosetta-volume.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# SPDX-FileCopyrightText: Copyright The Lima Authors -# SPDX-License-Identifier: Apache-2.0 - -set -eux -o pipefail - -if [ "$LIMA_CIDATA_ROSETTA_ENABLED" != "true" ]; then - exit 0 -fi - -if [ -f /etc/alpine-release ]; then - rc-service procfs start --ifnotstarted - rc-service qemu-binfmt stop --ifexists --ifstarted -fi - -binfmt_entry=/proc/sys/fs/binfmt_misc/rosetta -binfmtd_conf=/usr/lib/binfmt.d/rosetta.conf -if [ "$LIMA_CIDATA_ROSETTA_BINFMT" = "true" ]; then - rosetta_binfmt=":rosetta:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00:\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/mnt/lima-rosetta/rosetta:OCF" - - # If rosetta is not registered in binfmt_misc, register it. - [ -f "$binfmt_entry" ] || echo "$rosetta_binfmt" >/proc/sys/fs/binfmt_misc/register - - # Create binfmt.d(5) configuration to prioritize rosetta even if qemu-user-static is installed on systemd based systems. - # If the binfmt.d directory exists, consider systemd-binfmt.service(8) to be enabled and create the configuration file. - [ ! -d "$(dirname "$binfmtd_conf")" ] || [ -f "$binfmtd_conf" ] || echo "$rosetta_binfmt" >"$binfmtd_conf" -else - # unregister rosetta from binfmt_misc if it exists - [ ! -f "$binfmt_entry" ] || echo -1 >"$binfmt_entry" - # remove binfmt.d(5) configuration if it exists - [ ! -f "$binfmtd_conf" ] || rm "$binfmtd_conf" -fi diff --git a/pkg/driver/driver.go b/pkg/driver/driver.go index 63820fd80d5..2ecaef08065 100644 --- a/pkg/driver/driver.go +++ b/pkg/driver/driver.go @@ -92,8 +92,6 @@ type ConfiguredDriver struct { } type Info struct { - DriverName string `json:"driverName"` - CanRunGUI bool `json:"canRunGui,omitempty"` VsockPort int `json:"vsockPort"` VirtioPort string `json:"virtioPort"` InstanceDir string `json:"instanceDir,omitempty"` @@ -101,6 +99,8 @@ type Info struct { } type DriverFeatures struct { - DynamicSSHAddress bool `json:"dynamicSSHAddress"` - SkipSocketForwarding bool `json:"skipSocketForwarding"` + DriverName string `json:"driverName"` + CanRunGUI bool `json:"canRunGui,omitempty"` + DynamicSSHAddress bool `json:"dynamicSSHAddress"` + SkipSocketForwarding bool `json:"skipSocketForwarding"` } diff --git a/pkg/driver/external/client/methods.go b/pkg/driver/external/client/methods.go index cb251d12cb9..af9d974b0f7 100644 --- a/pkg/driver/external/client/methods.go +++ b/pkg/driver/external/client/methods.go @@ -32,8 +32,17 @@ func (d *DriverClient) Validate(ctx context.Context) error { return nil } -func (d *DriverClient) Create(_ context.Context) error { - return errors.New("create not implemented for external drivers") +func (d *DriverClient) Create(ctx context.Context) error { + d.logger.Debug("Initializing driver instance") + + _, err := d.DriverSvc.Create(ctx, &emptypb.Empty{}) + if err != nil { + d.logger.Errorf("Initialization failed: %v", err) + return err + } + + d.logger.Debug("Driver instance initialized successfully") + return nil } func (d *DriverClient) CreateDisk(ctx context.Context) error { @@ -93,8 +102,17 @@ func (d *DriverClient) Stop(ctx context.Context) error { return nil } -func (d *DriverClient) Delete(_ context.Context) error { - return errors.New("delete not implemented for external drivers") +func (d *DriverClient) Delete(ctx context.Context) error { + d.logger.Debug("Deleting driver instance") + + _, err := d.DriverSvc.Delete(ctx, &emptypb.Empty{}) + if err != nil { + d.logger.Errorf("Failed to delete driver instance: %v", err) + return err + } + + d.logger.Debug("Driver instance deleted successfully") + return nil } func (d *DriverClient) AcceptConfig(_ *limatype.LimaYAML, _ string) error { @@ -239,7 +257,7 @@ func (d *DriverClient) Info() driver.Info { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - resp, err := d.DriverSvc.GetInfo(ctx, &emptypb.Empty{}) + resp, err := d.DriverSvc.Info(ctx, &emptypb.Empty{}) if err != nil { d.logger.Errorf("Failed to get driver info: %v", err) return driver.Info{} @@ -267,7 +285,7 @@ func (d *DriverClient) Configure(inst *limatype.Instance) *driver.ConfiguredDriv ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - _, err = d.DriverSvc.SetConfig(ctx, &pb.SetConfigRequest{ + _, err = d.DriverSvc.Configure(ctx, &pb.SetConfigRequest{ InstanceConfigJson: instJSON, }) if err != nil { @@ -285,10 +303,27 @@ func (d *DriverClient) InspectStatus(_ context.Context, _ *limatype.Instance) st return "" } -func (d *DriverClient) SSHAddress(_ context.Context) (string, error) { - return "", errors.New("sshAddress not implemented for external drivers") +func (d *DriverClient) SSHAddress(ctx context.Context) (string, error) { + d.logger.Debug("Getting SSH address for the driver instance") + + resp, err := d.DriverSvc.SSHAddress(ctx, &emptypb.Empty{}) + if err != nil { + d.logger.Errorf("Failed to get SSH address: %v", err) + return "", err + } + + d.logger.Debugf("SSH address retrieved: %s", resp.Address) + return resp.Address, nil } func (d *DriverClient) BootScripts() (map[string][]byte, error) { - return nil, errors.New("bootScripts not implemented for external drivers") + d.logger.Debug("Getting boot scripts for the driver instance") + resp, err := d.DriverSvc.BootScripts(context.Background(), &emptypb.Empty{}) + if err != nil { + d.logger.Errorf("Failed to get boot scripts: %v", err) + return nil, err + } + + d.logger.Debugf("Boot scripts retrieved successfully: %d scripts", len(resp.Scripts)) + return resp.Scripts, nil } diff --git a/pkg/driver/external/driver.pb.go b/pkg/driver/external/driver.pb.go index 96ae1b4befd..605191202c5 100644 --- a/pkg/driver/external/driver.pb.go +++ b/pkg/driver/external/driver.pb.go @@ -22,6 +22,94 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type BootScriptsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Scripts map[string][]byte `protobuf:"bytes,1,rep,name=scripts,proto3" json:"scripts,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BootScriptsResponse) Reset() { + *x = BootScriptsResponse{} + mi := &file_pkg_driver_external_driver_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BootScriptsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BootScriptsResponse) ProtoMessage() {} + +func (x *BootScriptsResponse) ProtoReflect() protoreflect.Message { + mi := &file_pkg_driver_external_driver_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BootScriptsResponse.ProtoReflect.Descriptor instead. +func (*BootScriptsResponse) Descriptor() ([]byte, []int) { + return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{0} +} + +func (x *BootScriptsResponse) GetScripts() map[string][]byte { + if x != nil { + return x.Scripts + } + return nil +} + +type SSHAddressResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SSHAddressResponse) Reset() { + *x = SSHAddressResponse{} + mi := &file_pkg_driver_external_driver_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SSHAddressResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SSHAddressResponse) ProtoMessage() {} + +func (x *SSHAddressResponse) ProtoReflect() protoreflect.Message { + mi := &file_pkg_driver_external_driver_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SSHAddressResponse.ProtoReflect.Descriptor instead. +func (*SSHAddressResponse) Descriptor() ([]byte, []int) { + return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{1} +} + +func (x *SSHAddressResponse) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + type InfoResponse struct { state protoimpl.MessageState `protogen:"open.v1"` InfoJson []byte `protobuf:"bytes,1,opt,name=info_json,json=infoJson,proto3" json:"info_json,omitempty"` @@ -31,7 +119,7 @@ type InfoResponse struct { func (x *InfoResponse) Reset() { *x = InfoResponse{} - mi := &file_pkg_driver_external_driver_proto_msgTypes[0] + mi := &file_pkg_driver_external_driver_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -43,7 +131,7 @@ func (x *InfoResponse) String() string { func (*InfoResponse) ProtoMessage() {} func (x *InfoResponse) ProtoReflect() protoreflect.Message { - mi := &file_pkg_driver_external_driver_proto_msgTypes[0] + mi := &file_pkg_driver_external_driver_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -56,7 +144,7 @@ func (x *InfoResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use InfoResponse.ProtoReflect.Descriptor instead. func (*InfoResponse) Descriptor() ([]byte, []int) { - return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{0} + return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{2} } func (x *InfoResponse) GetInfoJson() []byte { @@ -76,7 +164,7 @@ type StartResponse struct { func (x *StartResponse) Reset() { *x = StartResponse{} - mi := &file_pkg_driver_external_driver_proto_msgTypes[1] + mi := &file_pkg_driver_external_driver_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -88,7 +176,7 @@ func (x *StartResponse) String() string { func (*StartResponse) ProtoMessage() {} func (x *StartResponse) ProtoReflect() protoreflect.Message { - mi := &file_pkg_driver_external_driver_proto_msgTypes[1] + mi := &file_pkg_driver_external_driver_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -101,7 +189,7 @@ func (x *StartResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use StartResponse.ProtoReflect.Descriptor instead. func (*StartResponse) Descriptor() ([]byte, []int) { - return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{1} + return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{3} } func (x *StartResponse) GetSuccess() bool { @@ -127,7 +215,7 @@ type SetConfigRequest struct { func (x *SetConfigRequest) Reset() { *x = SetConfigRequest{} - mi := &file_pkg_driver_external_driver_proto_msgTypes[2] + mi := &file_pkg_driver_external_driver_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -139,7 +227,7 @@ func (x *SetConfigRequest) String() string { func (*SetConfigRequest) ProtoMessage() {} func (x *SetConfigRequest) ProtoReflect() protoreflect.Message { - mi := &file_pkg_driver_external_driver_proto_msgTypes[2] + mi := &file_pkg_driver_external_driver_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -152,7 +240,7 @@ func (x *SetConfigRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SetConfigRequest.ProtoReflect.Descriptor instead. func (*SetConfigRequest) Descriptor() ([]byte, []int) { - return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{2} + return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{4} } func (x *SetConfigRequest) GetInstanceConfigJson() []byte { @@ -171,7 +259,7 @@ type ChangeDisplayPasswordRequest struct { func (x *ChangeDisplayPasswordRequest) Reset() { *x = ChangeDisplayPasswordRequest{} - mi := &file_pkg_driver_external_driver_proto_msgTypes[3] + mi := &file_pkg_driver_external_driver_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -183,7 +271,7 @@ func (x *ChangeDisplayPasswordRequest) String() string { func (*ChangeDisplayPasswordRequest) ProtoMessage() {} func (x *ChangeDisplayPasswordRequest) ProtoReflect() protoreflect.Message { - mi := &file_pkg_driver_external_driver_proto_msgTypes[3] + mi := &file_pkg_driver_external_driver_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -196,7 +284,7 @@ func (x *ChangeDisplayPasswordRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ChangeDisplayPasswordRequest.ProtoReflect.Descriptor instead. func (*ChangeDisplayPasswordRequest) Descriptor() ([]byte, []int) { - return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{3} + return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{5} } func (x *ChangeDisplayPasswordRequest) GetPassword() string { @@ -215,7 +303,7 @@ type GetDisplayConnectionResponse struct { func (x *GetDisplayConnectionResponse) Reset() { *x = GetDisplayConnectionResponse{} - mi := &file_pkg_driver_external_driver_proto_msgTypes[4] + mi := &file_pkg_driver_external_driver_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -227,7 +315,7 @@ func (x *GetDisplayConnectionResponse) String() string { func (*GetDisplayConnectionResponse) ProtoMessage() {} func (x *GetDisplayConnectionResponse) ProtoReflect() protoreflect.Message { - mi := &file_pkg_driver_external_driver_proto_msgTypes[4] + mi := &file_pkg_driver_external_driver_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -240,7 +328,7 @@ func (x *GetDisplayConnectionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetDisplayConnectionResponse.ProtoReflect.Descriptor instead. func (*GetDisplayConnectionResponse) Descriptor() ([]byte, []int) { - return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{4} + return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{6} } func (x *GetDisplayConnectionResponse) GetConnection() string { @@ -259,7 +347,7 @@ type CreateSnapshotRequest struct { func (x *CreateSnapshotRequest) Reset() { *x = CreateSnapshotRequest{} - mi := &file_pkg_driver_external_driver_proto_msgTypes[5] + mi := &file_pkg_driver_external_driver_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -271,7 +359,7 @@ func (x *CreateSnapshotRequest) String() string { func (*CreateSnapshotRequest) ProtoMessage() {} func (x *CreateSnapshotRequest) ProtoReflect() protoreflect.Message { - mi := &file_pkg_driver_external_driver_proto_msgTypes[5] + mi := &file_pkg_driver_external_driver_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -284,7 +372,7 @@ func (x *CreateSnapshotRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateSnapshotRequest.ProtoReflect.Descriptor instead. func (*CreateSnapshotRequest) Descriptor() ([]byte, []int) { - return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{5} + return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{7} } func (x *CreateSnapshotRequest) GetTag() string { @@ -303,7 +391,7 @@ type ApplySnapshotRequest struct { func (x *ApplySnapshotRequest) Reset() { *x = ApplySnapshotRequest{} - mi := &file_pkg_driver_external_driver_proto_msgTypes[6] + mi := &file_pkg_driver_external_driver_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -315,7 +403,7 @@ func (x *ApplySnapshotRequest) String() string { func (*ApplySnapshotRequest) ProtoMessage() {} func (x *ApplySnapshotRequest) ProtoReflect() protoreflect.Message { - mi := &file_pkg_driver_external_driver_proto_msgTypes[6] + mi := &file_pkg_driver_external_driver_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -328,7 +416,7 @@ func (x *ApplySnapshotRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ApplySnapshotRequest.ProtoReflect.Descriptor instead. func (*ApplySnapshotRequest) Descriptor() ([]byte, []int) { - return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{6} + return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{8} } func (x *ApplySnapshotRequest) GetTag() string { @@ -347,7 +435,7 @@ type DeleteSnapshotRequest struct { func (x *DeleteSnapshotRequest) Reset() { *x = DeleteSnapshotRequest{} - mi := &file_pkg_driver_external_driver_proto_msgTypes[7] + mi := &file_pkg_driver_external_driver_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -359,7 +447,7 @@ func (x *DeleteSnapshotRequest) String() string { func (*DeleteSnapshotRequest) ProtoMessage() {} func (x *DeleteSnapshotRequest) ProtoReflect() protoreflect.Message { - mi := &file_pkg_driver_external_driver_proto_msgTypes[7] + mi := &file_pkg_driver_external_driver_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -372,7 +460,7 @@ func (x *DeleteSnapshotRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteSnapshotRequest.ProtoReflect.Descriptor instead. func (*DeleteSnapshotRequest) Descriptor() ([]byte, []int) { - return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{7} + return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{9} } func (x *DeleteSnapshotRequest) GetTag() string { @@ -391,7 +479,7 @@ type ListSnapshotsResponse struct { func (x *ListSnapshotsResponse) Reset() { *x = ListSnapshotsResponse{} - mi := &file_pkg_driver_external_driver_proto_msgTypes[8] + mi := &file_pkg_driver_external_driver_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -403,7 +491,7 @@ func (x *ListSnapshotsResponse) String() string { func (*ListSnapshotsResponse) ProtoMessage() {} func (x *ListSnapshotsResponse) ProtoReflect() protoreflect.Message { - mi := &file_pkg_driver_external_driver_proto_msgTypes[8] + mi := &file_pkg_driver_external_driver_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -416,7 +504,7 @@ func (x *ListSnapshotsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListSnapshotsResponse.ProtoReflect.Descriptor instead. func (*ListSnapshotsResponse) Descriptor() ([]byte, []int) { - return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{8} + return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{10} } func (x *ListSnapshotsResponse) GetSnapshots() string { @@ -435,7 +523,7 @@ type ForwardGuestAgentResponse struct { func (x *ForwardGuestAgentResponse) Reset() { *x = ForwardGuestAgentResponse{} - mi := &file_pkg_driver_external_driver_proto_msgTypes[9] + mi := &file_pkg_driver_external_driver_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -447,7 +535,7 @@ func (x *ForwardGuestAgentResponse) String() string { func (*ForwardGuestAgentResponse) ProtoMessage() {} func (x *ForwardGuestAgentResponse) ProtoReflect() protoreflect.Message { - mi := &file_pkg_driver_external_driver_proto_msgTypes[9] + mi := &file_pkg_driver_external_driver_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -460,7 +548,7 @@ func (x *ForwardGuestAgentResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ForwardGuestAgentResponse.ProtoReflect.Descriptor instead. func (*ForwardGuestAgentResponse) Descriptor() ([]byte, []int) { - return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{9} + return file_pkg_driver_external_driver_proto_rawDescGZIP(), []int{11} } func (x *ForwardGuestAgentResponse) GetShouldForward() bool { @@ -474,7 +562,14 @@ var File_pkg_driver_external_driver_proto protoreflect.FileDescriptor const file_pkg_driver_external_driver_proto_rawDesc = "" + "\n" + - " pkg/driver/external/driver.proto\x1a\x1bgoogle/protobuf/empty.proto\"+\n" + + " pkg/driver/external/driver.proto\x1a\x1bgoogle/protobuf/empty.proto\"\x8e\x01\n" + + "\x13BootScriptsResponse\x12;\n" + + "\ascripts\x18\x01 \x03(\v2!.BootScriptsResponse.ScriptsEntryR\ascripts\x1a:\n" + + "\fScriptsEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\fR\x05value:\x028\x01\".\n" + + "\x12SSHAddressResponse\x12\x18\n" + + "\aaddress\x18\x01 \x01(\tR\aaddress\"+\n" + "\fInfoResponse\x12\x1b\n" + "\tinfo_json\x18\x01 \x01(\fR\binfoJson\"?\n" + "\rStartResponse\x12\x18\n" + @@ -497,29 +592,29 @@ const file_pkg_driver_external_driver_proto_rawDesc = "" + "\x15ListSnapshotsResponse\x12\x1c\n" + "\tsnapshots\x18\x01 \x01(\tR\tsnapshots\"B\n" + "\x19ForwardGuestAgentResponse\x12%\n" + - "\x0eshould_forward\x18\x01 \x01(\bR\rshouldForward2\xf8\b\n" + + "\x0eshould_forward\x18\x01 \x01(\bR\rshouldForward2\xa9\t\n" + "\x06Driver\x12:\n" + - "\bValidate\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\x12<\n" + - "\n" + - "Initialize\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\x12<\n" + + "\bValidate\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\x128\n" + + "\x06Create\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\x12<\n" + "\n" + "CreateDisk\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\x121\n" + "\x05Start\x12\x16.google.protobuf.Empty\x1a\x0e.StartResponse0\x01\x126\n" + "\x04Stop\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\x128\n" + + "\x06Delete\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\x12;\n" + + "\vBootScripts\x12\x16.google.protobuf.Empty\x1a\x14.BootScriptsResponse\x128\n" + "\x06RunGUI\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\x12N\n" + "\x15ChangeDisplayPassword\x12\x1d.ChangeDisplayPasswordRequest\x1a\x16.google.protobuf.Empty\x12M\n" + "\x14GetDisplayConnection\x12\x16.google.protobuf.Empty\x1a\x1d.GetDisplayConnectionResponse\x12@\n" + "\x0eCreateSnapshot\x12\x16.CreateSnapshotRequest\x1a\x16.google.protobuf.Empty\x12>\n" + "\rApplySnapshot\x12\x15.ApplySnapshotRequest\x1a\x16.google.protobuf.Empty\x12@\n" + "\x0eDeleteSnapshot\x12\x16.DeleteSnapshotRequest\x1a\x16.google.protobuf.Empty\x12?\n" + - "\rListSnapshots\x12\x16.google.protobuf.Empty\x1a\x16.ListSnapshotsResponse\x12:\n" + - "\bRegister\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\x12<\n" + - "\n" + - "Unregister\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\x12G\n" + + "\rListSnapshots\x12\x16.google.protobuf.Empty\x1a\x16.ListSnapshotsResponse\x12G\n" + "\x11ForwardGuestAgent\x12\x16.google.protobuf.Empty\x1a\x1a.ForwardGuestAgentResponse\x12@\n" + "\x0eGuestAgentConn\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\x126\n" + - "\tSetConfig\x12\x11.SetConfigRequest\x1a\x16.google.protobuf.Empty\x120\n" + - "\aGetInfo\x12\x16.google.protobuf.Empty\x1a\r.InfoResponseB0Z.github.com/lima-vm/lima/v2/pkg/driver/externalb\x06proto3" + "\tConfigure\x12\x11.SetConfigRequest\x1a\x16.google.protobuf.Empty\x12-\n" + + "\x04Info\x12\x16.google.protobuf.Empty\x1a\r.InfoResponse\x129\n" + + "\n" + + "SSHAddress\x12\x16.google.protobuf.Empty\x1a\x13.SSHAddressResponseB0Z.github.com/lima-vm/lima/v2/pkg/driver/externalb\x06proto3" var ( file_pkg_driver_external_driver_proto_rawDescOnce sync.Once @@ -533,62 +628,68 @@ func file_pkg_driver_external_driver_proto_rawDescGZIP() []byte { return file_pkg_driver_external_driver_proto_rawDescData } -var file_pkg_driver_external_driver_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_pkg_driver_external_driver_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_pkg_driver_external_driver_proto_goTypes = []any{ - (*InfoResponse)(nil), // 0: InfoResponse - (*StartResponse)(nil), // 1: StartResponse - (*SetConfigRequest)(nil), // 2: SetConfigRequest - (*ChangeDisplayPasswordRequest)(nil), // 3: ChangeDisplayPasswordRequest - (*GetDisplayConnectionResponse)(nil), // 4: GetDisplayConnectionResponse - (*CreateSnapshotRequest)(nil), // 5: CreateSnapshotRequest - (*ApplySnapshotRequest)(nil), // 6: ApplySnapshotRequest - (*DeleteSnapshotRequest)(nil), // 7: DeleteSnapshotRequest - (*ListSnapshotsResponse)(nil), // 8: ListSnapshotsResponse - (*ForwardGuestAgentResponse)(nil), // 9: ForwardGuestAgentResponse - (*emptypb.Empty)(nil), // 10: google.protobuf.Empty + (*BootScriptsResponse)(nil), // 0: BootScriptsResponse + (*SSHAddressResponse)(nil), // 1: SSHAddressResponse + (*InfoResponse)(nil), // 2: InfoResponse + (*StartResponse)(nil), // 3: StartResponse + (*SetConfigRequest)(nil), // 4: SetConfigRequest + (*ChangeDisplayPasswordRequest)(nil), // 5: ChangeDisplayPasswordRequest + (*GetDisplayConnectionResponse)(nil), // 6: GetDisplayConnectionResponse + (*CreateSnapshotRequest)(nil), // 7: CreateSnapshotRequest + (*ApplySnapshotRequest)(nil), // 8: ApplySnapshotRequest + (*DeleteSnapshotRequest)(nil), // 9: DeleteSnapshotRequest + (*ListSnapshotsResponse)(nil), // 10: ListSnapshotsResponse + (*ForwardGuestAgentResponse)(nil), // 11: ForwardGuestAgentResponse + nil, // 12: BootScriptsResponse.ScriptsEntry + (*emptypb.Empty)(nil), // 13: google.protobuf.Empty } var file_pkg_driver_external_driver_proto_depIdxs = []int32{ - 10, // 0: Driver.Validate:input_type -> google.protobuf.Empty - 10, // 1: Driver.Initialize:input_type -> google.protobuf.Empty - 10, // 2: Driver.CreateDisk:input_type -> google.protobuf.Empty - 10, // 3: Driver.Start:input_type -> google.protobuf.Empty - 10, // 4: Driver.Stop:input_type -> google.protobuf.Empty - 10, // 5: Driver.RunGUI:input_type -> google.protobuf.Empty - 3, // 6: Driver.ChangeDisplayPassword:input_type -> ChangeDisplayPasswordRequest - 10, // 7: Driver.GetDisplayConnection:input_type -> google.protobuf.Empty - 5, // 8: Driver.CreateSnapshot:input_type -> CreateSnapshotRequest - 6, // 9: Driver.ApplySnapshot:input_type -> ApplySnapshotRequest - 7, // 10: Driver.DeleteSnapshot:input_type -> DeleteSnapshotRequest - 10, // 11: Driver.ListSnapshots:input_type -> google.protobuf.Empty - 10, // 12: Driver.Register:input_type -> google.protobuf.Empty - 10, // 13: Driver.Unregister:input_type -> google.protobuf.Empty - 10, // 14: Driver.ForwardGuestAgent:input_type -> google.protobuf.Empty - 10, // 15: Driver.GuestAgentConn:input_type -> google.protobuf.Empty - 2, // 16: Driver.SetConfig:input_type -> SetConfigRequest - 10, // 17: Driver.GetInfo:input_type -> google.protobuf.Empty - 10, // 18: Driver.Validate:output_type -> google.protobuf.Empty - 10, // 19: Driver.Initialize:output_type -> google.protobuf.Empty - 10, // 20: Driver.CreateDisk:output_type -> google.protobuf.Empty - 1, // 21: Driver.Start:output_type -> StartResponse - 10, // 22: Driver.Stop:output_type -> google.protobuf.Empty - 10, // 23: Driver.RunGUI:output_type -> google.protobuf.Empty - 10, // 24: Driver.ChangeDisplayPassword:output_type -> google.protobuf.Empty - 4, // 25: Driver.GetDisplayConnection:output_type -> GetDisplayConnectionResponse - 10, // 26: Driver.CreateSnapshot:output_type -> google.protobuf.Empty - 10, // 27: Driver.ApplySnapshot:output_type -> google.protobuf.Empty - 10, // 28: Driver.DeleteSnapshot:output_type -> google.protobuf.Empty - 8, // 29: Driver.ListSnapshots:output_type -> ListSnapshotsResponse - 10, // 30: Driver.Register:output_type -> google.protobuf.Empty - 10, // 31: Driver.Unregister:output_type -> google.protobuf.Empty - 9, // 32: Driver.ForwardGuestAgent:output_type -> ForwardGuestAgentResponse - 10, // 33: Driver.GuestAgentConn:output_type -> google.protobuf.Empty - 10, // 34: Driver.SetConfig:output_type -> google.protobuf.Empty - 0, // 35: Driver.GetInfo:output_type -> InfoResponse - 18, // [18:36] is the sub-list for method output_type - 0, // [0:18] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 12, // 0: BootScriptsResponse.scripts:type_name -> BootScriptsResponse.ScriptsEntry + 13, // 1: Driver.Validate:input_type -> google.protobuf.Empty + 13, // 2: Driver.Create:input_type -> google.protobuf.Empty + 13, // 3: Driver.CreateDisk:input_type -> google.protobuf.Empty + 13, // 4: Driver.Start:input_type -> google.protobuf.Empty + 13, // 5: Driver.Stop:input_type -> google.protobuf.Empty + 13, // 6: Driver.Delete:input_type -> google.protobuf.Empty + 13, // 7: Driver.BootScripts:input_type -> google.protobuf.Empty + 13, // 8: Driver.RunGUI:input_type -> google.protobuf.Empty + 5, // 9: Driver.ChangeDisplayPassword:input_type -> ChangeDisplayPasswordRequest + 13, // 10: Driver.GetDisplayConnection:input_type -> google.protobuf.Empty + 7, // 11: Driver.CreateSnapshot:input_type -> CreateSnapshotRequest + 8, // 12: Driver.ApplySnapshot:input_type -> ApplySnapshotRequest + 9, // 13: Driver.DeleteSnapshot:input_type -> DeleteSnapshotRequest + 13, // 14: Driver.ListSnapshots:input_type -> google.protobuf.Empty + 13, // 15: Driver.ForwardGuestAgent:input_type -> google.protobuf.Empty + 13, // 16: Driver.GuestAgentConn:input_type -> google.protobuf.Empty + 4, // 17: Driver.Configure:input_type -> SetConfigRequest + 13, // 18: Driver.Info:input_type -> google.protobuf.Empty + 13, // 19: Driver.SSHAddress:input_type -> google.protobuf.Empty + 13, // 20: Driver.Validate:output_type -> google.protobuf.Empty + 13, // 21: Driver.Create:output_type -> google.protobuf.Empty + 13, // 22: Driver.CreateDisk:output_type -> google.protobuf.Empty + 3, // 23: Driver.Start:output_type -> StartResponse + 13, // 24: Driver.Stop:output_type -> google.protobuf.Empty + 13, // 25: Driver.Delete:output_type -> google.protobuf.Empty + 0, // 26: Driver.BootScripts:output_type -> BootScriptsResponse + 13, // 27: Driver.RunGUI:output_type -> google.protobuf.Empty + 13, // 28: Driver.ChangeDisplayPassword:output_type -> google.protobuf.Empty + 6, // 29: Driver.GetDisplayConnection:output_type -> GetDisplayConnectionResponse + 13, // 30: Driver.CreateSnapshot:output_type -> google.protobuf.Empty + 13, // 31: Driver.ApplySnapshot:output_type -> google.protobuf.Empty + 13, // 32: Driver.DeleteSnapshot:output_type -> google.protobuf.Empty + 10, // 33: Driver.ListSnapshots:output_type -> ListSnapshotsResponse + 11, // 34: Driver.ForwardGuestAgent:output_type -> ForwardGuestAgentResponse + 13, // 35: Driver.GuestAgentConn:output_type -> google.protobuf.Empty + 13, // 36: Driver.Configure:output_type -> google.protobuf.Empty + 2, // 37: Driver.Info:output_type -> InfoResponse + 1, // 38: Driver.SSHAddress:output_type -> SSHAddressResponse + 20, // [20:39] is the sub-list for method output_type + 1, // [1:20] 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_pkg_driver_external_driver_proto_init() } @@ -602,7 +703,7 @@ func file_pkg_driver_external_driver_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_pkg_driver_external_driver_proto_rawDesc), len(file_pkg_driver_external_driver_proto_rawDesc)), NumEnums: 0, - NumMessages: 10, + NumMessages: 13, NumExtensions: 0, NumServices: 1, }, diff --git a/pkg/driver/external/driver.proto b/pkg/driver/external/driver.proto index 48282c50360..743cd491904 100644 --- a/pkg/driver/external/driver.proto +++ b/pkg/driver/external/driver.proto @@ -6,10 +6,12 @@ option go_package = "github.com/lima-vm/lima/v2/pkg/driver/external"; service Driver { rpc Validate(google.protobuf.Empty) returns (google.protobuf.Empty); - rpc Initialize(google.protobuf.Empty) returns (google.protobuf.Empty); + rpc Create(google.protobuf.Empty) returns (google.protobuf.Empty); rpc CreateDisk(google.protobuf.Empty) returns (google.protobuf.Empty); rpc Start(google.protobuf.Empty) returns (stream StartResponse); rpc Stop(google.protobuf.Empty) returns (google.protobuf.Empty); + rpc Delete(google.protobuf.Empty) returns (google.protobuf.Empty); + rpc BootScripts(google.protobuf.Empty) returns (BootScriptsResponse); rpc RunGUI(google.protobuf.Empty) returns (google.protobuf.Empty); rpc ChangeDisplayPassword(ChangeDisplayPasswordRequest) returns (google.protobuf.Empty); @@ -20,15 +22,20 @@ service Driver { rpc DeleteSnapshot(DeleteSnapshotRequest) returns (google.protobuf.Empty); rpc ListSnapshots(google.protobuf.Empty) returns (ListSnapshotsResponse); - rpc Register(google.protobuf.Empty) returns (google.protobuf.Empty); - rpc Unregister(google.protobuf.Empty) returns (google.protobuf.Empty); - rpc ForwardGuestAgent(google.protobuf.Empty) returns (ForwardGuestAgentResponse); rpc GuestAgentConn(google.protobuf.Empty) returns (google.protobuf.Empty); - rpc SetConfig(SetConfigRequest) returns (google.protobuf.Empty); + rpc Configure(SetConfigRequest) returns (google.protobuf.Empty); + rpc Info(google.protobuf.Empty) returns (InfoResponse); + rpc SSHAddress(google.protobuf.Empty) returns (SSHAddressResponse); +} + +message BootScriptsResponse { + map scripts = 1; +} - rpc GetInfo(google.protobuf.Empty) returns (InfoResponse); +message SSHAddressResponse { + string address = 1; } message InfoResponse{ diff --git a/pkg/driver/external/driver_grpc.pb.go b/pkg/driver/external/driver_grpc.pb.go index 5e1dcde983c..dd5deb6d8e5 100644 --- a/pkg/driver/external/driver_grpc.pb.go +++ b/pkg/driver/external/driver_grpc.pb.go @@ -21,10 +21,12 @@ const _ = grpc.SupportPackageIsVersion9 const ( Driver_Validate_FullMethodName = "/Driver/Validate" - Driver_Initialize_FullMethodName = "/Driver/Initialize" + Driver_Create_FullMethodName = "/Driver/Create" Driver_CreateDisk_FullMethodName = "/Driver/CreateDisk" Driver_Start_FullMethodName = "/Driver/Start" Driver_Stop_FullMethodName = "/Driver/Stop" + Driver_Delete_FullMethodName = "/Driver/Delete" + Driver_BootScripts_FullMethodName = "/Driver/BootScripts" Driver_RunGUI_FullMethodName = "/Driver/RunGUI" Driver_ChangeDisplayPassword_FullMethodName = "/Driver/ChangeDisplayPassword" Driver_GetDisplayConnection_FullMethodName = "/Driver/GetDisplayConnection" @@ -32,12 +34,11 @@ const ( Driver_ApplySnapshot_FullMethodName = "/Driver/ApplySnapshot" Driver_DeleteSnapshot_FullMethodName = "/Driver/DeleteSnapshot" Driver_ListSnapshots_FullMethodName = "/Driver/ListSnapshots" - Driver_Register_FullMethodName = "/Driver/Register" - Driver_Unregister_FullMethodName = "/Driver/Unregister" Driver_ForwardGuestAgent_FullMethodName = "/Driver/ForwardGuestAgent" Driver_GuestAgentConn_FullMethodName = "/Driver/GuestAgentConn" - Driver_SetConfig_FullMethodName = "/Driver/SetConfig" - Driver_GetInfo_FullMethodName = "/Driver/GetInfo" + Driver_Configure_FullMethodName = "/Driver/Configure" + Driver_Info_FullMethodName = "/Driver/Info" + Driver_SSHAddress_FullMethodName = "/Driver/SSHAddress" ) // DriverClient is the client API for Driver service. @@ -45,10 +46,12 @@ const ( // 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 DriverClient interface { Validate(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) - Initialize(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) + Create(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) CreateDisk(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) Start(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (grpc.ServerStreamingClient[StartResponse], error) Stop(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) + Delete(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) + BootScripts(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*BootScriptsResponse, error) RunGUI(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) ChangeDisplayPassword(ctx context.Context, in *ChangeDisplayPasswordRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) GetDisplayConnection(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*GetDisplayConnectionResponse, error) @@ -56,12 +59,11 @@ type DriverClient interface { ApplySnapshot(ctx context.Context, in *ApplySnapshotRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) DeleteSnapshot(ctx context.Context, in *DeleteSnapshotRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) ListSnapshots(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ListSnapshotsResponse, error) - Register(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) - Unregister(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) ForwardGuestAgent(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ForwardGuestAgentResponse, error) GuestAgentConn(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) - SetConfig(ctx context.Context, in *SetConfigRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) - GetInfo(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*InfoResponse, error) + Configure(ctx context.Context, in *SetConfigRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + Info(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*InfoResponse, error) + SSHAddress(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*SSHAddressResponse, error) } type driverClient struct { @@ -82,10 +84,10 @@ func (c *driverClient) Validate(ctx context.Context, in *emptypb.Empty, opts ... return out, nil } -func (c *driverClient) Initialize(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { +func (c *driverClient) Create(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, Driver_Initialize_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, Driver_Create_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -131,6 +133,26 @@ func (c *driverClient) Stop(ctx context.Context, in *emptypb.Empty, opts ...grpc return out, nil } +func (c *driverClient) Delete(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, Driver_Delete_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *driverClient) BootScripts(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*BootScriptsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(BootScriptsResponse) + err := c.cc.Invoke(ctx, Driver_BootScripts_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *driverClient) RunGUI(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) @@ -201,60 +223,50 @@ func (c *driverClient) ListSnapshots(ctx context.Context, in *emptypb.Empty, opt return out, nil } -func (c *driverClient) Register(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { +func (c *driverClient) ForwardGuestAgent(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ForwardGuestAgentResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, Driver_Register_FullMethodName, in, out, cOpts...) + out := new(ForwardGuestAgentResponse) + err := c.cc.Invoke(ctx, Driver_ForwardGuestAgent_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *driverClient) Unregister(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { +func (c *driverClient) GuestAgentConn(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, Driver_Unregister_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *driverClient) ForwardGuestAgent(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ForwardGuestAgentResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ForwardGuestAgentResponse) - err := c.cc.Invoke(ctx, Driver_ForwardGuestAgent_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, Driver_GuestAgentConn_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *driverClient) GuestAgentConn(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { +func (c *driverClient) Configure(ctx context.Context, in *SetConfigRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, Driver_GuestAgentConn_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, Driver_Configure_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *driverClient) SetConfig(ctx context.Context, in *SetConfigRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { +func (c *driverClient) Info(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*InfoResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, Driver_SetConfig_FullMethodName, in, out, cOpts...) + out := new(InfoResponse) + err := c.cc.Invoke(ctx, Driver_Info_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *driverClient) GetInfo(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*InfoResponse, error) { +func (c *driverClient) SSHAddress(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*SSHAddressResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(InfoResponse) - err := c.cc.Invoke(ctx, Driver_GetInfo_FullMethodName, in, out, cOpts...) + out := new(SSHAddressResponse) + err := c.cc.Invoke(ctx, Driver_SSHAddress_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -266,10 +278,12 @@ func (c *driverClient) GetInfo(ctx context.Context, in *emptypb.Empty, opts ...g // for forward compatibility. type DriverServer interface { Validate(context.Context, *emptypb.Empty) (*emptypb.Empty, error) - Initialize(context.Context, *emptypb.Empty) (*emptypb.Empty, error) + Create(context.Context, *emptypb.Empty) (*emptypb.Empty, error) CreateDisk(context.Context, *emptypb.Empty) (*emptypb.Empty, error) Start(*emptypb.Empty, grpc.ServerStreamingServer[StartResponse]) error Stop(context.Context, *emptypb.Empty) (*emptypb.Empty, error) + Delete(context.Context, *emptypb.Empty) (*emptypb.Empty, error) + BootScripts(context.Context, *emptypb.Empty) (*BootScriptsResponse, error) RunGUI(context.Context, *emptypb.Empty) (*emptypb.Empty, error) ChangeDisplayPassword(context.Context, *ChangeDisplayPasswordRequest) (*emptypb.Empty, error) GetDisplayConnection(context.Context, *emptypb.Empty) (*GetDisplayConnectionResponse, error) @@ -277,12 +291,11 @@ type DriverServer interface { ApplySnapshot(context.Context, *ApplySnapshotRequest) (*emptypb.Empty, error) DeleteSnapshot(context.Context, *DeleteSnapshotRequest) (*emptypb.Empty, error) ListSnapshots(context.Context, *emptypb.Empty) (*ListSnapshotsResponse, error) - Register(context.Context, *emptypb.Empty) (*emptypb.Empty, error) - Unregister(context.Context, *emptypb.Empty) (*emptypb.Empty, error) ForwardGuestAgent(context.Context, *emptypb.Empty) (*ForwardGuestAgentResponse, error) GuestAgentConn(context.Context, *emptypb.Empty) (*emptypb.Empty, error) - SetConfig(context.Context, *SetConfigRequest) (*emptypb.Empty, error) - GetInfo(context.Context, *emptypb.Empty) (*InfoResponse, error) + Configure(context.Context, *SetConfigRequest) (*emptypb.Empty, error) + Info(context.Context, *emptypb.Empty) (*InfoResponse, error) + SSHAddress(context.Context, *emptypb.Empty) (*SSHAddressResponse, error) mustEmbedUnimplementedDriverServer() } @@ -296,8 +309,8 @@ type UnimplementedDriverServer struct{} func (UnimplementedDriverServer) Validate(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method Validate not implemented") } -func (UnimplementedDriverServer) Initialize(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method Initialize not implemented") +func (UnimplementedDriverServer) Create(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") } func (UnimplementedDriverServer) CreateDisk(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateDisk not implemented") @@ -308,6 +321,12 @@ func (UnimplementedDriverServer) Start(*emptypb.Empty, grpc.ServerStreamingServe func (UnimplementedDriverServer) Stop(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method Stop not implemented") } +func (UnimplementedDriverServer) Delete(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") +} +func (UnimplementedDriverServer) BootScripts(context.Context, *emptypb.Empty) (*BootScriptsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BootScripts not implemented") +} func (UnimplementedDriverServer) RunGUI(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method RunGUI not implemented") } @@ -329,23 +348,20 @@ func (UnimplementedDriverServer) DeleteSnapshot(context.Context, *DeleteSnapshot func (UnimplementedDriverServer) ListSnapshots(context.Context, *emptypb.Empty) (*ListSnapshotsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListSnapshots not implemented") } -func (UnimplementedDriverServer) Register(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") -} -func (UnimplementedDriverServer) Unregister(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method Unregister not implemented") -} func (UnimplementedDriverServer) ForwardGuestAgent(context.Context, *emptypb.Empty) (*ForwardGuestAgentResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ForwardGuestAgent not implemented") } func (UnimplementedDriverServer) GuestAgentConn(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method GuestAgentConn not implemented") } -func (UnimplementedDriverServer) SetConfig(context.Context, *SetConfigRequest) (*emptypb.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetConfig not implemented") +func (UnimplementedDriverServer) Configure(context.Context, *SetConfigRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Configure not implemented") +} +func (UnimplementedDriverServer) Info(context.Context, *emptypb.Empty) (*InfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Info not implemented") } -func (UnimplementedDriverServer) GetInfo(context.Context, *emptypb.Empty) (*InfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetInfo not implemented") +func (UnimplementedDriverServer) SSHAddress(context.Context, *emptypb.Empty) (*SSHAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SSHAddress not implemented") } func (UnimplementedDriverServer) mustEmbedUnimplementedDriverServer() {} func (UnimplementedDriverServer) testEmbeddedByValue() {} @@ -386,20 +402,20 @@ func _Driver_Validate_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } -func _Driver_Initialize_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Driver_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(DriverServer).Initialize(ctx, in) + return srv.(DriverServer).Create(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Driver_Initialize_FullMethodName, + FullMethod: Driver_Create_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DriverServer).Initialize(ctx, req.(*emptypb.Empty)) + return srv.(DriverServer).Create(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } @@ -451,6 +467,42 @@ func _Driver_Stop_Handler(srv interface{}, ctx context.Context, dec func(interfa return interceptor(ctx, in, info, handler) } +func _Driver_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(emptypb.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DriverServer).Delete(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Driver_Delete_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DriverServer).Delete(ctx, req.(*emptypb.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _Driver_BootScripts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(emptypb.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DriverServer).BootScripts(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Driver_BootScripts_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DriverServer).BootScripts(ctx, req.(*emptypb.Empty)) + } + return interceptor(ctx, in, info, handler) +} + func _Driver_RunGUI_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { @@ -577,110 +629,92 @@ func _Driver_ListSnapshots_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } -func _Driver_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Driver_ForwardGuestAgent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(DriverServer).Register(ctx, in) + return srv.(DriverServer).ForwardGuestAgent(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Driver_Register_FullMethodName, + FullMethod: Driver_ForwardGuestAgent_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DriverServer).Register(ctx, req.(*emptypb.Empty)) + return srv.(DriverServer).ForwardGuestAgent(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } -func _Driver_Unregister_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Driver_GuestAgentConn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(DriverServer).Unregister(ctx, in) + return srv.(DriverServer).GuestAgentConn(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Driver_Unregister_FullMethodName, + FullMethod: Driver_GuestAgentConn_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DriverServer).Unregister(ctx, req.(*emptypb.Empty)) + return srv.(DriverServer).GuestAgentConn(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } -func _Driver_ForwardGuestAgent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(emptypb.Empty) +func _Driver_Configure_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SetConfigRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(DriverServer).ForwardGuestAgent(ctx, in) + return srv.(DriverServer).Configure(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Driver_ForwardGuestAgent_FullMethodName, + FullMethod: Driver_Configure_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DriverServer).ForwardGuestAgent(ctx, req.(*emptypb.Empty)) + return srv.(DriverServer).Configure(ctx, req.(*SetConfigRequest)) } return interceptor(ctx, in, info, handler) } -func _Driver_GuestAgentConn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Driver_Info_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(DriverServer).GuestAgentConn(ctx, in) + return srv.(DriverServer).Info(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Driver_GuestAgentConn_FullMethodName, + FullMethod: Driver_Info_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DriverServer).GuestAgentConn(ctx, req.(*emptypb.Empty)) + return srv.(DriverServer).Info(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } -func _Driver_SetConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SetConfigRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DriverServer).SetConfig(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Driver_SetConfig_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DriverServer).SetConfig(ctx, req.(*SetConfigRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Driver_GetInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Driver_SSHAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(DriverServer).GetInfo(ctx, in) + return srv.(DriverServer).SSHAddress(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Driver_GetInfo_FullMethodName, + FullMethod: Driver_SSHAddress_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DriverServer).GetInfo(ctx, req.(*emptypb.Empty)) + return srv.(DriverServer).SSHAddress(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } @@ -697,8 +731,8 @@ var Driver_ServiceDesc = grpc.ServiceDesc{ Handler: _Driver_Validate_Handler, }, { - MethodName: "Initialize", - Handler: _Driver_Initialize_Handler, + MethodName: "Create", + Handler: _Driver_Create_Handler, }, { MethodName: "CreateDisk", @@ -708,6 +742,14 @@ var Driver_ServiceDesc = grpc.ServiceDesc{ MethodName: "Stop", Handler: _Driver_Stop_Handler, }, + { + MethodName: "Delete", + Handler: _Driver_Delete_Handler, + }, + { + MethodName: "BootScripts", + Handler: _Driver_BootScripts_Handler, + }, { MethodName: "RunGUI", Handler: _Driver_RunGUI_Handler, @@ -736,14 +778,6 @@ var Driver_ServiceDesc = grpc.ServiceDesc{ MethodName: "ListSnapshots", Handler: _Driver_ListSnapshots_Handler, }, - { - MethodName: "Register", - Handler: _Driver_Register_Handler, - }, - { - MethodName: "Unregister", - Handler: _Driver_Unregister_Handler, - }, { MethodName: "ForwardGuestAgent", Handler: _Driver_ForwardGuestAgent_Handler, @@ -753,12 +787,16 @@ var Driver_ServiceDesc = grpc.ServiceDesc{ Handler: _Driver_GuestAgentConn_Handler, }, { - MethodName: "SetConfig", - Handler: _Driver_SetConfig_Handler, + MethodName: "Configure", + Handler: _Driver_Configure_Handler, + }, + { + MethodName: "Info", + Handler: _Driver_Info_Handler, }, { - MethodName: "GetInfo", - Handler: _Driver_GetInfo_Handler, + MethodName: "SSHAddress", + Handler: _Driver_SSHAddress_Handler, }, }, Streams: []grpc.StreamDesc{ diff --git a/pkg/driver/external/server/methods.go b/pkg/driver/external/server/methods.go index 176b5c9cc11..44fdcc54fd4 100644 --- a/pkg/driver/external/server/methods.go +++ b/pkg/driver/external/server/methods.go @@ -6,6 +6,7 @@ package server import ( "context" "encoding/json" + "maps" "net" "path/filepath" @@ -53,7 +54,7 @@ func (s *DriverServer) Start(_ *emptypb.Empty, stream pb.Driver_StartServer) err } } -func (s *DriverServer) SetConfig(_ context.Context, req *pb.SetConfigRequest) (*emptypb.Empty, error) { +func (s *DriverServer) Configure(_ context.Context, req *pb.SetConfigRequest) (*emptypb.Empty, error) { s.logger.Debugf("Received SetConfig request") var inst limatype.Instance @@ -102,7 +103,7 @@ func (s *DriverServer) GuestAgentConn(ctx context.Context, _ *emptypb.Empty) (*e return &emptypb.Empty{}, nil } -func (s *DriverServer) GetInfo(_ context.Context, _ *emptypb.Empty) (*pb.InfoResponse, error) { +func (s *DriverServer) Info(_ context.Context, _ *emptypb.Empty) (*pb.InfoResponse, error) { s.logger.Debug("Received GetInfo request") info := s.driver.Info() @@ -128,7 +129,7 @@ func (s *DriverServer) Validate(ctx context.Context, empty *emptypb.Empty) (*emp return empty, nil } -func (s *DriverServer) Initialize(ctx context.Context, empty *emptypb.Empty) (*emptypb.Empty, error) { +func (s *DriverServer) Create(ctx context.Context, empty *emptypb.Empty) (*emptypb.Empty, error) { s.logger.Debug("Received Initialize request") err := s.driver.Create(ctx) if err != nil { @@ -172,6 +173,47 @@ func (s *DriverServer) RunGUI(_ context.Context, empty *emptypb.Empty) (*emptypb return empty, nil } +func (s *DriverServer) Delete(ctx context.Context, empty *emptypb.Empty) (*emptypb.Empty, error) { + s.logger.Debug("Received Delete request") + err := s.driver.Delete(ctx) + if err != nil { + s.logger.Errorf("Delete failed: %v", err) + return empty, err + } + s.logger.Debug("Delete succeeded") + return empty, nil +} + +func (s *DriverServer) BootScripts(_ context.Context, _ *emptypb.Empty) (*pb.BootScriptsResponse, error) { + s.logger.Debug("Received BootScripts request") + scripts, err := s.driver.BootScripts() + if err != nil { + s.logger.Errorf("BootScripts failed: %v", err) + return nil, err + } + + resp := &pb.BootScriptsResponse{ + Scripts: make(map[string][]byte), + } + + maps.Copy(resp.Scripts, scripts) + + s.logger.Debugf("BootScripts succeeded with %d scripts", len(resp.Scripts)) + return resp, nil +} + +func (s *DriverServer) SSHAddress(ctx context.Context, _ *emptypb.Empty) (*pb.SSHAddressResponse, error) { + s.logger.Debug("Received SSHAddress request") + address, err := s.driver.SSHAddress(ctx) + if err != nil { + s.logger.Errorf("SSHAddress failed: %v", err) + return nil, err + } + + s.logger.Debugf("SSHAddress succeeded with address: %s", address) + return &pb.SSHAddressResponse{Address: address}, nil +} + func (s *DriverServer) ChangeDisplayPassword(ctx context.Context, req *pb.ChangeDisplayPasswordRequest) (*emptypb.Empty, error) { s.logger.Debug("Received ChangeDisplayPassword request") err := s.driver.ChangeDisplayPassword(ctx, req.Password) diff --git a/pkg/driver/external/server/server.go b/pkg/driver/external/server/server.go index eaf130ebcbe..2f5c37c93d4 100644 --- a/pkg/driver/external/server/server.go +++ b/pkg/driver/external/server/server.go @@ -8,6 +8,7 @@ import ( "context" "encoding/json" "errors" + "flag" "fmt" "net" "os" @@ -25,6 +26,7 @@ import ( "github.com/lima-vm/lima/v2/pkg/driver" pb "github.com/lima-vm/lima/v2/pkg/driver/external" "github.com/lima-vm/lima/v2/pkg/driver/external/client" + "github.com/lima-vm/lima/v2/pkg/limatype" "github.com/lima-vm/lima/v2/pkg/limatype/dirnames" "github.com/lima-vm/lima/v2/pkg/limatype/filenames" "github.com/lima-vm/lima/v2/pkg/registry" @@ -51,10 +53,22 @@ func (t *listenerTracker) Accept() (net.Conn, error) { } func Serve(ctx context.Context, driver driver.Driver) { + preConfiguredDriverAction := flag.Bool("pre-driver-action", false, "Run pre-driver action before starting the gRPC server") + inspectStatus := flag.Bool("inspect-status", false, "Inspect status of the driver") + flag.Parse() + if *preConfiguredDriverAction { + handlePreConfiguredDriverAction(driver) + return + } + if *inspectStatus { + handleInspectStatus(driver) + return + } + logger := logrus.New() logger.SetLevel(logrus.DebugLevel) - socketPath := filepath.Join(os.TempDir(), fmt.Sprintf("lima-driver-%s-%d.sock", driver.Info().DriverName, os.Getpid())) + socketPath := filepath.Join(os.TempDir(), fmt.Sprintf("lima-driver-%s-%d.sock", driver.Info().Features.DriverName, os.Getpid())) defer func() { if err := os.Remove(socketPath); err != nil && !os.IsNotExist(err) { @@ -115,7 +129,6 @@ func Serve(ctx context.Context, driver driver.Driver) { logger.Info("Received shutdown signal, stopping server...") closeShutdown() }() - go func() { timer := time.NewTimer(60 * time.Second) defer timer.Stop() @@ -133,7 +146,7 @@ func Serve(ctx context.Context, driver driver.Driver) { }() go func() { - logger.Infof("Starting external driver server for %s", driver.Info().DriverName) + logger.Infof("Starting external driver server for %s", driver.Info().Features.DriverName) logger.Infof("Server starting on Unix socket: %s", socketPath) if err := server.Serve(tListener); err != nil { if errors.Is(err, grpc.ErrServerStopped) { @@ -148,6 +161,56 @@ func Serve(ctx context.Context, driver driver.Driver) { server.GracefulStop() } +func handleInspectStatus(driver driver.Driver) { + decoder := json.NewDecoder(os.Stdin) + encoder := json.NewEncoder(os.Stdout) + + var payload []byte + if err := decoder.Decode(&payload); err != nil { + fmt.Fprintf(os.Stderr, "Failed to decode instance payload from stdin: %v", err) + } + + var inst limatype.Instance + if err := inst.UnmarshalJSON(payload); err != nil { + fmt.Fprintf(os.Stderr, "Failed to unmarshal instance: %v", err) + } + + status := driver.InspectStatus(context.Background(), &inst) + inst.Status = status + + resp, err := inst.MarshalJSON() + if err != nil { + fmt.Fprintf(os.Stderr, "Failed to marshal instance response: %v", err) + } + + if err := encoder.Encode(resp); err != nil { + fmt.Fprintf(os.Stderr, "Failed to encode instance response: %v", err) + } +} + +func handlePreConfiguredDriverAction(driver driver.Driver) { + decoder := json.NewDecoder(os.Stdin) + encoder := json.NewEncoder(os.Stdout) + + var payload limatype.PreConfiguredDriverPayload + if err := decoder.Decode(&payload); err != nil { + fmt.Fprintf(os.Stderr, "Failed to decode pre-configured driver payload from stdin: %v", err) + } + + config := &payload.Config + if err := driver.AcceptConfig(config, payload.FilePath); err != nil { + fmt.Fprintf(os.Stderr, "Failed to accept config: %v", err) + } + + if err := driver.FillConfig(config, payload.FilePath); err != nil { + fmt.Fprintf(os.Stderr, "Failed to fill config: %v", err) + } + + if err := encoder.Encode(*config); err != nil { + fmt.Fprintf(os.Stderr, "Error encoding response: %v", err) + } +} + func Start(extDriver *registry.ExternalDriver, instName string) error { extDriver.Logger.Debugf("Starting external driver at %s", extDriver.Path) if instName == "" { diff --git a/pkg/driver/qemu/qemu_driver.go b/pkg/driver/qemu/qemu_driver.go index 2310ad6df18..24ae8f2b45f 100644 --- a/pkg/driver/qemu/qemu_driver.go +++ b/pkg/driver/qemu/qemu_driver.go @@ -677,14 +677,14 @@ func (l *LimaQemuDriver) Info() driver.Info { if l.Instance != nil && l.Instance.Dir != "" { info.InstanceDir = l.Instance.Dir } - info.DriverName = "qemu" - info.CanRunGUI = false info.VirtioPort = l.virtioPort info.VsockPort = l.vSockPort info.Features = driver.DriverFeatures{ DynamicSSHAddress: false, SkipSocketForwarding: false, + DriverName: "qemu", + CanRunGUI: false, } return info } diff --git a/pkg/driver/vz/vz_driver_darwin.go b/pkg/driver/vz/vz_driver_darwin.go index d21870da9f4..decfc10f12a 100644 --- a/pkg/driver/vz/vz_driver_darwin.go +++ b/pkg/driver/vz/vz_driver_darwin.go @@ -371,20 +371,23 @@ func (l *LimaVzDriver) GuestAgentConn(_ context.Context) (net.Conn, string, erro func (l *LimaVzDriver) Info() driver.Info { var info driver.Info - if l.Instance != nil { - info.CanRunGUI = l.canRunGUI() - } - info.DriverName = "vz" + info.Features.DriverName = "vz" info.VsockPort = l.vSockPort info.VirtioPort = l.virtioPort if l.Instance != nil { info.InstanceDir = l.Instance.Dir } + var guiFlag bool + if l.Instance != nil { + guiFlag = l.canRunGUI() + } info.Features = driver.DriverFeatures{ DynamicSSHAddress: false, SkipSocketForwarding: false, + DriverName: "vz", + CanRunGUI: guiFlag, } return info } diff --git a/pkg/driver/wsl2/wsl_driver_windows.go b/pkg/driver/wsl2/wsl_driver_windows.go index 5d433897a98..ef49dd736f2 100644 --- a/pkg/driver/wsl2/wsl_driver_windows.go +++ b/pkg/driver/wsl2/wsl_driver_windows.go @@ -309,14 +309,14 @@ func (l *LimaWslDriver) Info() driver.Info { if l.Instance != nil { info.InstanceDir = l.Instance.Dir } - info.DriverName = "wsl2" - info.CanRunGUI = l.canRunGUI() info.VirtioPort = l.virtioPort info.VsockPort = l.vSockPort info.Features = driver.DriverFeatures{ DynamicSSHAddress: true, SkipSocketForwarding: true, + DriverName: "wsl2", + CanRunGUI: l.canRunGUI(), } return info } diff --git a/pkg/driverutil/instance.go b/pkg/driverutil/instance.go index 53ae318c52c..e861b1cf3f4 100644 --- a/pkg/driverutil/instance.go +++ b/pkg/driverutil/instance.go @@ -39,6 +39,6 @@ func CreateConfiguredDriver(inst *limatype.Instance, sshLocalPort int) (*driver. return extDriver.Client.Configure(inst), nil } - logrus.Debugf("Using internal driver %q", intDriver.Info().DriverName) + logrus.Debugf("Using internal driver %q", intDriver.Info().Features.DriverName) return intDriver.Configure(inst), nil } diff --git a/pkg/driverutil/vm.go b/pkg/driverutil/vm.go index c1cc5af9e49..4e54235505b 100644 --- a/pkg/driverutil/vm.go +++ b/pkg/driverutil/vm.go @@ -4,9 +4,12 @@ package driverutil import ( + "bytes" "context" + "encoding/json" "errors" "fmt" + "os/exec" "github.com/sirupsen/logrus" @@ -14,9 +17,9 @@ import ( "github.com/lima-vm/lima/v2/pkg/registry" ) -func ResolveVMType(y *limatype.LimaYAML, filePath string) error { +func ResolveVMType(ctx context.Context, y *limatype.LimaYAML, filePath string) error { if y.VMType != nil && *y.VMType != "" { - if err := validateConfigAgainstDriver(y, filePath, *y.VMType); err != nil { + if err := validateConfigAgainstDriver(ctx, y, filePath, *y.VMType); err != nil { return err } logrus.Debugf("Using specified vmType %q for %q", *y.VMType, filePath) @@ -25,17 +28,17 @@ func ResolveVMType(y *limatype.LimaYAML, filePath string) error { // If VMType is not specified, we go with the default platform driver. vmType := limatype.DefaultDriver() - return validateConfigAgainstDriver(y, filePath, vmType) + return validateConfigAgainstDriver(ctx, y, filePath, vmType) } -func validateConfigAgainstDriver(y *limatype.LimaYAML, filePath, vmType string) error { +func validateConfigAgainstDriver(ctx context.Context, y *limatype.LimaYAML, filePath, vmType string) error { extDriver, intDriver, exists := registry.Get(vmType) if !exists { return fmt.Errorf("vmType %q is not a registered driver", vmType) } if extDriver != nil { - return errors.New("not supported for external drivers") + return handlePreConfiguredDriverAction(ctx, y, extDriver.Path, filePath) } if err := intDriver.AcceptConfig(y, filePath); err != nil { @@ -48,6 +51,56 @@ func validateConfigAgainstDriver(y *limatype.LimaYAML, filePath, vmType string) return nil } +func handlePreConfiguredDriverAction(ctx context.Context, y *limatype.LimaYAML, extDriverPath, filePath string) error { + cmd := exec.CommandContext(ctx, extDriverPath, "--pre-driver-action") + + var stderrBuf bytes.Buffer + cmd.Stderr = &stderrBuf + + stdout, err := cmd.StdoutPipe() + if err != nil { + return fmt.Errorf("failed to get stdout pipe: %w", err) + } + stdin, err := cmd.StdinPipe() + if err != nil { + return fmt.Errorf("failed to get stdin pipe: %w", err) + } + if err := cmd.Start(); err != nil { + return fmt.Errorf("failed to start external driver: %w", err) + } + + encoder := json.NewEncoder(stdin) + if err := encoder.Encode(limatype.PreConfiguredDriverPayload{ + Config: *y, + FilePath: filePath, + }); err != nil { + stdin.Close() + return fmt.Errorf("failed to encode pre-configured driver payload: %w", err) + } + stdin.Close() + + decoder := json.NewDecoder(stdout) + var res limatype.LimaYAML + if err := decoder.Decode(&res); err != nil { + return fmt.Errorf("failed to decode pre-configured driver response: %w", err) + } + + if err := cmd.Wait(); err != nil { + if stderrBuf.Len() > 0 { + return fmt.Errorf("pre-configured driver command failed: %w; stderr: %s", err, stderrBuf.String()) + } + return fmt.Errorf("pre-configured driver command failed: %w", err) + } + + if stderrBuf.Len() > 0 { + return fmt.Errorf("external driver stderr: %s", stderrBuf.String()) + } + + *y = res + logrus.Debugf("Pre-configured driver action completed successfully for %q", extDriverPath) + return nil +} + func InspectStatus(ctx context.Context, inst *limatype.Instance) (string, error) { if inst == nil || inst.Config == nil || inst.Config.VMType == nil { return "", errors.New("instance or its configuration is not properly initialized") @@ -59,8 +112,69 @@ func InspectStatus(ctx context.Context, inst *limatype.Instance) (string, error) } if extDriver != nil { - return "", errors.New("InspectStatus is not supported for external drivers") + status, err := handleInspectStatusAction(ctx, inst, extDriver.Path) + if err != nil { + extDriver.Logger.Errorf("Failed to inspect status for instance %q: %v", inst.Name, err) + return "", err + } + extDriver.Logger.Debugf("Instance %q inspected successfully with status: %s", inst.Name, inst.Status) + return status, nil } return intDriver.InspectStatus(ctx, inst), nil } + +func handleInspectStatusAction(ctx context.Context, inst *limatype.Instance, extDriverPath string) (string, error) { + cmd := exec.CommandContext(ctx, extDriverPath, "--inspect-status") + + var stderrBuf bytes.Buffer + cmd.Stderr = &stderrBuf + + stdin, err := cmd.StdinPipe() + if err != nil { + return "", err + } + stdout, err := cmd.StdoutPipe() + if err != nil { + return "", err + } + if err := cmd.Start(); err != nil { + return "", err + } + + encoder := json.NewEncoder(stdin) + payload, err := inst.MarshalJSON() + if err != nil { + return "", fmt.Errorf("failed to marshal instance config: %w", err) + } + if err := encoder.Encode(payload); err != nil { + return "", err + } + stdin.Close() + + decoder := json.NewDecoder(stdout) + var response []byte + if err := decoder.Decode(&response); err != nil { + return "", err + } + + var respInst limatype.Instance + if err := respInst.UnmarshalJSON(response); err != nil { + return "", fmt.Errorf("failed to unmarshal instance response: %w", err) + } + + if err := cmd.Wait(); err != nil { + if stderrBuf.Len() > 0 { + return "", fmt.Errorf("inspect status command failed: %w; stderr: %s", err, stderrBuf.String()) + } + return "", fmt.Errorf("inspect status command failed: %w", err) + } + + if stderrBuf.Len() > 0 { + return "", fmt.Errorf("external driver stderr: %s", stderrBuf.String()) + } + + *inst = respInst + logrus.Debugf("Inspecting instance status action completed successfully for %q", extDriverPath) + return inst.Status, nil +} diff --git a/pkg/hostagent/hostagent.go b/pkg/hostagent/hostagent.go index bdc71e2d3e0..ef9a055482b 100644 --- a/pkg/hostagent/hostagent.go +++ b/pkg/hostagent/hostagent.go @@ -391,7 +391,7 @@ func (a *HostAgent) Run(ctx context.Context) error { logrus.Infof("VNC Password: `%s`", vncpwdfile) } - if a.driver.Info().CanRunGUI { + if a.driver.Info().Features.CanRunGUI { go func() { err = a.startRoutinesAndWait(ctx, errCh) if err != nil { diff --git a/pkg/instance/create.go b/pkg/instance/create.go index 8f6ef76e0eb..08c5bd42212 100644 --- a/pkg/instance/create.go +++ b/pkg/instance/create.go @@ -49,8 +49,8 @@ func Create(ctx context.Context, instName string, instConfig []byte, saveBrokenY if err != nil { return nil, err } - if err := driverutil.ResolveVMType(loadedInstConfig, filePath); err != nil { - return nil, fmt.Errorf("failed to accept config for %q: %w", filePath, err) + if err := driverutil.ResolveVMType(ctx, loadedInstConfig, filePath); err != nil { + return nil, fmt.Errorf("failed to resolve vm for %q: %w", filePath, err) } if err := limayaml.Validate(loadedInstConfig, true); err != nil { if !saveBrokenYAML { diff --git a/pkg/instance/start.go b/pkg/instance/start.go index a4357e7fe2d..2671e31d95a 100644 --- a/pkg/instance/start.go +++ b/pkg/instance/start.go @@ -226,7 +226,7 @@ func Start(ctx context.Context, inst *limatype.Instance, limactl string, launchH "hostagent", "--pidfile", haPIDPath, "--socket", haSockPath) - if prepared.Driver.Info().CanRunGUI { + if prepared.Driver.Info().Features.CanRunGUI { args = append(args, "--run-gui") } if prepared.GuestAgent != "" { diff --git a/pkg/limatype/lima_yaml.go b/pkg/limatype/lima_yaml.go index 93008dfee1a..5c5106aa0c5 100644 --- a/pkg/limatype/lima_yaml.go +++ b/pkg/limatype/lima_yaml.go @@ -334,11 +334,6 @@ type PreConfiguredDriverPayload struct { FilePath string `json:"filePath"` } -type PreConfiguredDriverResponse struct { - Config LimaYAML `json:"config"` - Error string `json:"error,omitempty"` -} - func NewOS(osname string) OS { switch osname { case "linux": diff --git a/pkg/limayaml/validate.go b/pkg/limayaml/validate.go index cd869ec6d9c..ab67baa158c 100644 --- a/pkg/limayaml/validate.go +++ b/pkg/limayaml/validate.go @@ -587,8 +587,8 @@ func ValidateAgainstLatestConfig(ctx context.Context, yNew, yLatest []byte) erro if err != nil { errs = errors.Join(errs, err) } - if err := driverutil.ResolveVMType(l, ""); err != nil { - errs = errors.Join(errs, fmt.Errorf("failed to accept config for %q: %w", "", err)) + if err := driverutil.ResolveVMType(ctx, l, ""); err != nil { + errs = errors.Join(errs, fmt.Errorf("failed to resolve vm for %q: %w", "", err)) } if err := Unmarshal(yNew, &n, "Unmarshal new YAML bytes"); err != nil { errs = errors.Join(errs, err) diff --git a/pkg/limayaml/validate_test.go b/pkg/limayaml/validate_test.go index 943786b6c72..0eca03dfc6f 100644 --- a/pkg/limayaml/validate_test.go +++ b/pkg/limayaml/validate_test.go @@ -348,37 +348,37 @@ func TestValidateAgainstLatestConfig(t *testing.T) { name: "Valid disk size unchanged", yNew: `disk: 100GiB`, yLatest: `disk: 100GiB`, - wantErr: fmt.Sprintf("failed to accept config for \"\": vmType %q is not a registered driver", limatype.DefaultDriver()), + wantErr: fmt.Sprintf("failed to resolve vm for \"\": vmType %q is not a registered driver", limatype.DefaultDriver()), }, { name: "Valid disk size increased", yNew: `disk: 200GiB`, yLatest: `disk: 100GiB`, - wantErr: fmt.Sprintf("failed to accept config for \"\": vmType %q is not a registered driver", limatype.DefaultDriver()), + wantErr: fmt.Sprintf("failed to resolve vm for \"\": vmType %q is not a registered driver", limatype.DefaultDriver()), }, { name: "No disk field in both YAMLs", yNew: ``, yLatest: ``, - wantErr: fmt.Sprintf("failed to accept config for \"\": vmType %q is not a registered driver", limatype.DefaultDriver()), + wantErr: fmt.Sprintf("failed to resolve vm for \"\": vmType %q is not a registered driver", limatype.DefaultDriver()), }, { name: "No disk field in new YAMLs", yNew: ``, yLatest: `disk: 100GiB`, - wantErr: fmt.Sprintf("failed to accept config for \"\": vmType %q is not a registered driver", limatype.DefaultDriver()), + wantErr: fmt.Sprintf("failed to resolve vm for \"\": vmType %q is not a registered driver", limatype.DefaultDriver()), }, { name: "No disk field in latest YAMLs", yNew: `disk: 100GiB`, yLatest: ``, - wantErr: fmt.Sprintf("failed to accept config for \"\": vmType %q is not a registered driver", limatype.DefaultDriver()), + wantErr: fmt.Sprintf("failed to resolve vm for \"\": vmType %q is not a registered driver", limatype.DefaultDriver()), }, { name: "Disk size shrunk", yNew: `disk: 50GiB`, yLatest: `disk: 100GiB`, - wantErr: fmt.Sprintf("failed to accept config for \"\": vmType %q is not a registered driver\n", limatype.DefaultDriver()) + + wantErr: fmt.Sprintf("failed to resolve vm for \"\": vmType %q is not a registered driver\n", limatype.DefaultDriver()) + "field `disk`: shrinking the disk (100GiB --> 50GiB) is not supported", }, } diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index 7ea99543b1c..d69146c50ec 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -195,7 +195,7 @@ func isExecutable(mode os.FileMode) bool { } func Register(driver driver.Driver) { - name := driver.Info().DriverName + name := driver.Info().Features.DriverName if _, exists := internalDrivers[name]; exists { return } diff --git a/pkg/registry/registry_test.go b/pkg/registry/registry_test.go index c672e971940..d75565af885 100644 --- a/pkg/registry/registry_test.go +++ b/pkg/registry/registry_test.go @@ -27,24 +27,26 @@ func newMockDriver(name string) *mockDriver { var _ driver.Driver = (*mockDriver)(nil) -func (m *mockDriver) Validate(_ context.Context) error { return nil } -func (m *mockDriver) Create(_ context.Context) error { return nil } -func (m *mockDriver) Delete(_ context.Context) error { return nil } -func (m *mockDriver) CreateDisk(_ context.Context) error { return nil } -func (m *mockDriver) Start(_ context.Context) (chan error, error) { return nil, nil } -func (m *mockDriver) Stop(_ context.Context) error { return nil } -func (m *mockDriver) RunGUI() error { return nil } -func (m *mockDriver) ChangeDisplayPassword(_ context.Context, _ string) error { return nil } -func (m *mockDriver) DisplayConnection(_ context.Context) (string, error) { return "", nil } -func (m *mockDriver) CreateSnapshot(_ context.Context, _ string) error { return nil } -func (m *mockDriver) ApplySnapshot(_ context.Context, _ string) error { return nil } -func (m *mockDriver) DeleteSnapshot(_ context.Context, _ string) error { return nil } -func (m *mockDriver) ListSnapshots(_ context.Context) (string, error) { return "", nil } -func (m *mockDriver) Register(_ context.Context) error { return nil } -func (m *mockDriver) Unregister(_ context.Context) error { return nil } -func (m *mockDriver) ForwardGuestAgent() bool { return false } -func (m *mockDriver) GuestAgentConn(_ context.Context) (net.Conn, string, error) { return nil, "", nil } -func (m *mockDriver) Info() driver.Info { return driver.Info{DriverName: m.Name} } +func (m *mockDriver) Validate(_ context.Context) error { return nil } +func (m *mockDriver) Create(_ context.Context) error { return nil } +func (m *mockDriver) Delete(_ context.Context) error { return nil } +func (m *mockDriver) CreateDisk(_ context.Context) error { return nil } +func (m *mockDriver) Start(_ context.Context) (chan error, error) { return nil, nil } +func (m *mockDriver) Stop(_ context.Context) error { return nil } +func (m *mockDriver) RunGUI() error { return nil } +func (m *mockDriver) ChangeDisplayPassword(_ context.Context, _ string) error { return nil } +func (m *mockDriver) DisplayConnection(_ context.Context) (string, error) { return "", nil } +func (m *mockDriver) CreateSnapshot(_ context.Context, _ string) error { return nil } +func (m *mockDriver) ApplySnapshot(_ context.Context, _ string) error { return nil } +func (m *mockDriver) DeleteSnapshot(_ context.Context, _ string) error { return nil } +func (m *mockDriver) ListSnapshots(_ context.Context) (string, error) { return "", nil } +func (m *mockDriver) Register(_ context.Context) error { return nil } +func (m *mockDriver) Unregister(_ context.Context) error { return nil } +func (m *mockDriver) ForwardGuestAgent() bool { return false } +func (m *mockDriver) GuestAgentConn(_ context.Context) (net.Conn, string, error) { return nil, "", nil } +func (m *mockDriver) Info() driver.Info { + return driver.Info{Features: driver.DriverFeatures{DriverName: m.Name}} +} func (m *mockDriver) Configure(_ *limatype.Instance) *driver.ConfiguredDriver { return nil } func (m *mockDriver) AcceptConfig(_ *limatype.LimaYAML, _ string) error { return nil } func (m *mockDriver) FillConfig(_ *limatype.LimaYAML, _ string) error { return nil } @@ -78,7 +80,7 @@ func TestRegister(t *testing.T) { assert.Equal(t, exists, true) assert.Assert(t, extDriver == nil) assert.Assert(t, intDriver != nil) - assert.Equal(t, intDriver.Info().DriverName, "test-driver") + assert.Equal(t, intDriver.Info().Features.DriverName, "test-driver") vmTypes := List() assert.Equal(t, vmTypes["test-driver-2"], Internal) diff --git a/pkg/store/store.go b/pkg/store/store.go index af8646da540..93249bae09a 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -121,8 +121,8 @@ func LoadYAMLByFilePath(ctx context.Context, filePath string) (*limatype.LimaYAM if err != nil { return nil, err } - if err := driverutil.ResolveVMType(y, filePath); err != nil { - return nil, fmt.Errorf("failed to accept config for %q: %w", filePath, err) + if err := driverutil.ResolveVMType(ctx, y, filePath); err != nil { + return nil, fmt.Errorf("failed to resolve vm for %q: %w", filePath, err) } if err := limayaml.Validate(y, false); err != nil { return nil, err