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

Conversation

Copy link
Contributor

@unsuman unsuman commented Aug 25, 2025

Note

This is the last PR of the three PRs, which depends on #3901. Merging all will close #3769.

Key Changes

  • Changes to the .proto files to incorporate with the driver interface.
  • Since FillConfig() and AcceptConfig() are both pre-configured driver operations, I have implemented stdio piping transport using json between limactl and the driver binary. The driver binary can know that limactl is calling for a pre-grpc action by a boolean flag --pre-driver-action.

One more thing, we tend to inspect instances a lot throughout the codebase(even for simply listing Lima instances through limactl ls) so I have also implemented the same stdio transport mechanism for InspectStatus() so that it saves us time and resource but it is an add-on, let me know if we don't need this then I can revert the changes!

@AkihiroSuda AkihiroSuda added gsoc/2025 Google Summer of Code 2025 area/vmdrivers VM driver infrastructure labels Aug 25, 2025
@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Aug 25, 2025
Copy link
Member

Please rebase

"github.com/lima-vm/lima/v2/pkg/driver/external/server"
"github.com/lima-vm/lima/v2/pkg/driver/vz"
)

// To be used as an external driver for Lima.
func main() {
server.Serve(context.Background(), vz.New())
server.Serve(vz.New())
Copy link
Member

@AkihiroSuda AkihiroSuda Aug 26, 2025

Choose a reason for hiding this comment

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

?

unsuman reacted with thumbs up emoji

var payload []byte
if err := decoder.Decode(&payload); err != nil {
fmt.Fprintf(os.Stderr, "Error encoding response: %v\n", err)
Copy link
Member

@AkihiroSuda AkihiroSuda Aug 26, 2025

Choose a reason for hiding this comment

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

Can't we use logrus?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we change this to logrus, it will not be clean. For e.g:

➜ lima2 git:(refactor/support-external-drivers) ✗ ./_output/bin/limactl edit default2 --mount-type virtiofs
FATA[0000] failed to resolve vm for "/Users/ansumansahoo/.lima/default2/lima.yaml": external driver stderr:
 time="2025-08-27T01:51:33+05:30" level=error msg="Failed to accept config: config not supported by the QEMU driver: 
 field `mountType` must be \"reverse-sshfs\" or \"9p\" for QEMU driver on non-Linux, got \"virtiofs\"" 

Using fmt.Fprintf results in a clean error:

➜ lima2 git:(refactor/support-external-drivers) ✗ ./_output/bin/limactl edit default2 --mount-type virtiofs
FATA[0000] failed to resolve vm for "/Users/ansumansahoo/.lima/default2/lima.yaml": 
external driver stderr: Failed to accept config: config not supported by the QEMU driver: 
field `mountType` must be "reverse-sshfs" or "9p" for QEMU driver on non-Linux, got "virtiofs" 

And since it will be never be stored in the driver.stderr.log

@@ -48,6 +50,48 @@ func validateConfigAgainstDriver(y *limatype.LimaYAML, filePath, vmType string)
return nil
}

func handlePreConfiguredDriverAction(y *limatype.LimaYAML, extDriverPath, filePath string) error {
cmd := exec.CommandContext(context.Background(), extDriverPath, "--pre-driver-action")
Copy link
Member

@AkihiroSuda AkihiroSuda Aug 26, 2025

Choose a reason for hiding this comment

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

ctx should be passed from the caller

unsuman reacted with thumbs up emoji
}

return intDriver.InspectStatus(ctx, inst), nil
}

func handleInspectStatusAction(inst *limatype.Instance, extDriverPath string) (string, error) {
cmd := exec.CommandContext(context.Background(), extDriverPath, "--inspect-status")
Copy link
Member

@AkihiroSuda AkihiroSuda Aug 26, 2025

Choose a reason for hiding this comment

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

Same

unsuman reacted with thumbs up emoji
VirtioPort string `json:"virtioPort"`
InstanceDir string `json:"instanceDir,omitempty"`
DriverName string `json:"driverName"`
CanRunGUI bool `json:"canRunGui,omitempty"`
Copy link
Member

@AkihiroSuda AkihiroSuda Aug 26, 2025

Choose a reason for hiding this comment

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

This can be moved to DriverFeatures

unsuman reacted with thumbs up emoji
@unsuman unsuman force-pushed the refactor/support-external-drivers branch from 7e99f45 to 3cf0d16 Compare August 26, 2025 06:26
Copy link
Contributor Author

unsuman commented Aug 26, 2025

I will open the PR after some time, working on making the pre-validation action error handling better.

@unsuman unsuman force-pushed the refactor/support-external-drivers branch 4 times, most recently from 8c27373 to 3990779 Compare August 26, 2025 20:52
Signed-off-by: Ansuman Sahoo <anshumansahoo500@gmail.com>
@unsuman unsuman force-pushed the refactor/support-external-drivers branch from 3990779 to d4dc0a5 Compare August 26, 2025 21:01
@unsuman unsuman marked this pull request as ready for review August 26, 2025 21:55
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
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

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

unsuman reacted with heart emoji
@AkihiroSuda AkihiroSuda merged commit f7861fb into lima-vm:master Aug 27, 2025
88 of 90 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@AkihiroSuda AkihiroSuda AkihiroSuda approved these changes

Assignees
No one assigned
Labels
area/vmdrivers VM driver infrastructure gsoc/2025 Google Summer of Code 2025
Projects
None yet
Milestone
v2.0.0
Development

Successfully merging this pull request may close these issues.

Refactor: Lima Config and External Drivers

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