Skip to content

Conversation

unsuman
Copy link
Contributor

@unsuman unsuman commented Aug 24, 2025

Note

This is the second PR out of the three PRs, which depends on #3900. Merging all will close #3769.

Key Changes

  • Validation and filling of driver-specific values are now done through AcceptConfig() and FillConfig(), respectively, for all three drivers. These actions are performed before configuring the driver(driverutil/vm.go).
  • The driver resolution has been updated. If a user doesn’t specify the driver type explicitly, Lima will choose the default type based on the operating system(OSX: [VZ], Linux: [QEMU], Windows: [WSL2]). Lima will no longer guess the vm-type based on the config and will throw an error if a setting is incompatible or the driver is not available. Users must specify the vm-type to use other VMs.
  • Inspecting the status of an instance(driver.InspectStatus()) and providing boot scripts(driver.BootScripts()) are all done at the driver level. InspectStatus() has been implemented by all the drivers(~wsl2. Others return "" because their status is figured out through PID files). VM-specific boot scripts(vz and wsl2), only wsl2 is left to be decoupled(already done in refactor: move driver specific code to drivers #3770, but having some problems connecting to hostagent through ssh).
  • Deleted Register() and Unregister() from the driver interface. Renamed Initialize() to Create() and added its counterpart Delete(). Also added two driver features DynamicSSHAddress and SkipSocketForwarding, these were added only for WSL2(not in this PR but soon if that error gets fixed) and future drivers.

@unsuman unsuman force-pushed the refactor/internal-drivers branch 4 times, most recently from c3a8755 to e887f1c Compare August 24, 2025 22:34
@AkihiroSuda AkihiroSuda added gsoc/2025 Google Summer of Code 2025 area/vmdrivers VM driver infrastructure labels Aug 24, 2025
@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Aug 24, 2025
@unsuman unsuman force-pushed the refactor/internal-drivers branch 3 times, most recently from 258c9b2 to 5fc24e4 Compare August 25, 2025 13:37
@unsuman unsuman force-pushed the refactor/internal-drivers branch 2 times, most recently from c2e8e60 to aa26f46 Compare August 25, 2025 15:20
@AkihiroSuda
Copy link
Member

Still draft?

@unsuman
Copy link
Contributor Author

unsuman commented Aug 25, 2025

Still draft?

I'll open it shortly, testing some more things.

@AkihiroSuda AkihiroSuda requested a review from a team August 25, 2025 16:44
@unsuman unsuman force-pushed the refactor/internal-drivers branch from aa26f46 to 0a74ee7 Compare August 25, 2025 16:53
… drivers

Signed-off-by: Ansuman Sahoo <[email protected]>

experiment with wsl2 in ha

Signed-off-by: Ansuman Sahoo <[email protected]>

boot scripts for wsl2

Signed-off-by: Ansuman Sahoo <[email protected]>
@unsuman unsuman force-pushed the refactor/internal-drivers branch from 0a74ee7 to 2076ff1 Compare August 25, 2025 17:08
@unsuman unsuman marked this pull request as ready for review August 25, 2025 17:29
return []string{"10", "30", "50", "100", "200"}, cobra.ShellCompDirectiveNoFileComp
})

flags.String("vm-type", "", commentPrefix+"Virtual machine type")
Copy link
Member

Choose a reason for hiding this comment

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

--vm-type is not guaranteed to work as an edit flag.

e.g., this will probably not work

limactl create --vm-type qemu
limactl edit --vm-type vz

Probably we need a warning when --vm-type is specified as an edit flag for an existing instance, but it can be worked out later.

VirtioPort string `json:"virtioPort"`
InstanceDir string `json:"instanceDir,omitempty"`
DriverName string `json:"driverName"`
CanRunGUI bool `json:"canRunGui,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be in a "DriverFeatures" ?

Can be fixed later

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

@AkihiroSuda AkihiroSuda merged commit 6aceec3 into lima-vm:master Aug 25, 2025
62 of 63 checks passed
@norio-nomura
Copy link
Contributor

Is copying pkg/driver/vz/boot/05-rosetta-volume.sh intended instead of moving it?

args.RosettaEnabled = *instConfig.VMOpts.VZ.Rosetta.Enabled
}
if instConfig.VMOpts.VZ.Rosetta.BinFmt != nil {
args.RosettaEnabled = *instConfig.VMOpts.VZ.Rosetta.BinFmt
Copy link
Contributor

Choose a reason for hiding this comment

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

- args.RosettaEnabled = *instConfig.VMOpts.VZ.Rosetta.BinFmt
+ args.RosettaBinFmt = *instConfig.VMOpts.VZ.Rosetta.BinFmt

Copy link
Contributor

Choose a reason for hiding this comment

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

opened #3921

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

@AkihiroSuda
Copy link
Member

Lima will no longer guess the vm-type based on the config and will throw an error if a setting is incompatible or the driver is not available. Users must specify the vm-type to use other VMs.

Linking the discussion: https://cloud-native.slack.com/archives/C08KKELMQ92/p1754425219854189?thread_ts=1754414764.412809&cid=C08KKELMQ92 (Aug 6)

return nil
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

These remnant of ResolveVMType could be removed.

I'll open a PR.

Copy link
Member

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 a lot🙇‍♂️

This was referenced Aug 27, 2025
@afbjorklund
Copy link
Member

This PR broke the SSHStatus, reverting to the previous setup when always returning localhost for all instances.

i.e. not a pure refactoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vmdrivers VM driver infrastructure gsoc/2025 Google Summer of Code 2025 impact/changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor: Lima Config and External Drivers
4 participants