Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor: support external drivers for the recent changes #3910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/limactl/clone.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cmd/limactl/edit.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cmd/limactl/prune.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/limactl/start.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions cmd/limactl/template.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
33 changes: 0 additions & 33 deletions pkg/cidata/cidata.TEMPLATE.d/boot/05-rosetta-volume.sh
View file Open in desktop
Copy link
Member

@AkihiroSuda AkihiroSuda Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next time please split a commit for this

unsuman reacted with thumbs up emoji

This file was deleted.

8 changes: 4 additions & 4 deletions pkg/driver/driver.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ 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"`
Features DriverFeatures `json:"features"`
}

type DriverFeatures struct {
DynamicSSHAddress bool `json:"dynamicSSHAddress"`
SkipSocketForwarding bool `json:"skipSocketForwarding"`
DriverName string `json:"driverName"`
Copy link
Member

@AkihiroSuda AkihiroSuda Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name does not seem to be a feature

unsuman reacted with thumbs up emoji
Copy link
Member

@AkihiroSuda AkihiroSuda Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

CanRunGUI bool `json:"canRunGui,omitempty"`
DynamicSSHAddress bool `json:"dynamicSSHAddress"`
SkipSocketForwarding bool `json:"skipSocketForwarding"`
}
53 changes: 44 additions & 9 deletions pkg/driver/external/client/methods.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
Loading

AltStyle によって変換されたページ (->オリジナル) /