-
Notifications
You must be signed in to change notification settings - Fork 694
Implement limactl clone
#3673
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
Implement limactl clone
#3673
Conversation
b209d0d
to
addc8f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, don't have time to do a full review right now, so just one comment.
Also, if you think clone
is too similar to copy
, then maybe we can use duplicate
(with short alias dup
). But I think clone
is fine too.
"clone" corresponds to the lingo used by VMware, VirtualBox, etc. |
1e6504f
to
2f4aeda
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new limactl clone
command to duplicate existing Lima instances by copying most files while skipping or nullifying instance-specific artifacts.
- Introduces file‐filtering lists (
SkipOnClone
,NullifyOnClone
,TmpFileSuffixes
) and wires them into both the stop and clone implementations - Updates Darwin VM logic to regenerate an empty or missing VzIdentifier
- Adds the Cobra command, flags and end‐to‐end test cases for
limactl clone
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
pkg/vz/vm_darwin.go | Regenerate empty or missing VzIdentifier on clone |
pkg/store/filenames/filenames.go | Define skip/nullify lists and tmp suffixes for cloning |
pkg/instance/stop.go | Reuse TmpFileSuffixes when cleaning up stopped instances |
pkg/instance/clone.go | Core clone logic: directory walk, file skip, nullify and copy |
hack/test-templates.sh | Enable and implement a basic clone test in CI templates |
cmd/limactl/main.go | Wire newCloneCommand into the root Cobra app |
cmd/limactl/copy.go | Clarify help text to distinguish copy vs. clone commands |
cmd/limactl/clone.go | New Cobra command, argument handling and post‐clone editing logic |
cmd/limactl/editflags/editflags.go | Adjust RegisterEdit signature to accept a comment prefix |
cmd/limactl/edit.go | Update call site for new RegisterEdit signature |
Comments suppressed due to low confidence (1)
cmd/limactl/copy.go:30
- [nitpick] Consider using backticks for code references in help text (e.g.
limactl clone
) to match existing formatting conventions.
Not to be confused with 'limactl clone'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I have some feedback, but maybe you find it nit-picky. I think even though it isn't critical, it should be addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one issue that is surprising, but not specific to clone
; it applies e.g. to edit
too:
If I use l clone --yes foo bar
I would expect the command to take the default action (which right now means to start the instance).
So it would work better if the default was to not start the instance, even when you ask, but you would have to explicitly enter y
and ↩
.
But I guess this is a separate discussion outside the scope of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But limactl (edit|clone) --tty=false
should not do an extra operation?
Probably --yes
shouldn't be just an alias of --tty=false
?
Should be discussed in a separate issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be discussed in a separate issue.
👍
2f4aeda
to
5301479
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM
`limactl clone OLDINST NEWINST` clones an instance. Not to be confused with `limactl copy SRC DST` (copy files). Fix issue 3658 Signed-off-by: Akihiro Suda <[email protected]>
5301479
to
2f7c401
Compare
Rebased |
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [lima-vm/lima](https://github.com/lima-vm/lima) | minor | `v1.1.1` -> `v1.2.1` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>lima-vm/lima (lima-vm/lima)</summary> ### [`v1.2.1`](https://github.com/lima-vm/lima/releases/tag/v1.2.1) [Compare Source](lima-vm/lima@v1.2.0...v1.2.1) #### Changes - Cherry-picks from `master` to `release/1.2` ([#​3750](lima-vm/lima#3750)) - portfwd: create separate gRPC streams for each UDP client ([#​3724](lima-vm/lima#3724), thanks to [@​stek29](https://github.com/stek29)) - qemuimgutil: fix "Failed to get "write" lock" error ([#​3742](lima-vm/lima#3742), thanks to [@​pavelanni](https://github.com/pavelanni)) - Embed templates edited from the user interface ([#​3745](lima-vm/lima#3745), thanks to [@​afbjorklund](https://github.com/afbjorklund)) #### Usage ```console $ limactl create $ limactl start ... INFO[0029] READY. Run `lima` to open the shell. $ lima uname Linux ``` *** The binaries were built automatically on GitHub Actions. The build log is available for 90 days: https://github.com/lima-vm/lima/actions/runs/16405168554 The sha256sum of the SHA256SUMS file itself is `fda636e062d8f75a689071b308a94dc902111620f7122746fc0d172959d7d26a` . *** Release manager: [@​AkihiroSuda](https://github.com/AkihiroSuda) ### [`v1.2.0`](https://github.com/lima-vm/lima/releases/tag/v1.2.0) [Compare Source](lima-vm/lima@v1.1.1...v1.2.0) #### Changes - `limactl` CLI: - Add `limactl network (list|create|delete)` commands ([#​3677](lima-vm/lima#3677)) - Add `limactl clone OLDINST NEWINST` command. Not to be confused with `limactl copy`, which copies files. ([#​3673](lima-vm/lima#3673)) - Add `limactl edit --mount-none` flag ([#​3647](lima-vm/lima#3647)) - Port forwarding: - Improve stability ([#​3684](lima-vm/lima#3684). [#​3708](lima-vm/lima#3708), thanks to [@​balajiv113](https://github.com/balajiv113)) - De-deprecate `LIMA_SSH_PORT_FORWARDER` that was once deprecated in v1.1 ([#​3709](lima-vm/lima#3709)) - nerdctl: - Update from v2.1.2 to [v2.1.3](https://github.com/containerd/nerdctl/releases/tag/v2.1.3) ([#​3701](lima-vm/lima#3701)) - Templates: - `default`: update from Ubuntu 24.10 to 25.04 ([#​3643](lima-vm/lima#3643)) - `fedora`: update from Fedora 41 to 42 ([#​3643](lima-vm/lima#3643)) - `almalinux-10`: new template ([#​3602](lima-vm/lima#3602), thanks to [@​refi64](https://github.com/refi64)) - `rocky-10`: new template ([#​3642](lima-vm/lima#3642)) - `experimental/debian-testing`: new template ([#​3645](lima-vm/lima#3645)) - `experimental/ubuntu-next`: new template ([#​3645](lima-vm/lima#3645)) - Makefile: - Kconfig: deprecate ([#​3706](lima-vm/lima#3706)) > \[!NOTE] > On Intel Mac, macOS 15.5 or later is needed to boot the default Ubuntu 25.04 template. > > Workarounds for macOS <= 15.4 : > > - Option 1: Use QEMU > > ``` > limactl create --vm-type=qemu > ``` > > - Option2: Use Ubuntu 24.04 template > > ``` > limactl create --name=default template://ubuntu-24.04 > ``` Full changes: https://github.com/lima-vm/lima/milestone/61?closed=1 Thanks to [@​AkinoKaede](https://github.com/AkinoKaede) [@​Horiodino](https://github.com/Horiodino) [@​afbjorklund](https://github.com/afbjorklund) [@​alexandear](https://github.com/alexandear) [@​arixmkii](https://github.com/arixmkii) [@​balajiv113](https://github.com/balajiv113) [@​fruzitent](https://github.com/fruzitent) [@​jandubois](https://github.com/jandubois) [@​kachick](https://github.com/kachick) [@​mazzz1y](https://github.com/mazzz1y) [@​nirs](https://github.com/nirs) [@​refi64](https://github.com/refi64) [@​songponssw](https://github.com/songponssw) [@​thomasjm](https://github.com/thomasjm) [@​unsuman](https://github.com/unsuman) #### Usage ```console $ limactl create $ limactl start ... INFO[0029] READY. Run `lima` to open the shell. $ lima uname Linux ``` *** The binaries were built automatically on GitHub Actions. The build log is available for 90 days: https://github.com/lima-vm/lima/actions/runs/16187325385 The sha256sum of the SHA256SUMS file itself is `f4d57cdd637022ead291af680c0c88a8d07fd35fd6a779b7c6348e2c9a2ec2cc` . *** Release manager: [@​AkihiroSuda](https://github.com/AkihiroSuda) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC42Mi4xIiwidXBkYXRlZEluVmVyIjoiNDAuNjIuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
limactl clone OLDINST NEWINST
clones an instance.Not to be confused with
limactl copy SRC DST
(copy files).Fix #3658