Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AkihiroSuda
Copy link
Member

limactl clone OLDINST NEWINST clones an instance.

Not to be confused with limactl copy SRC DST (copy files).

Fix #3658

@AkihiroSuda AkihiroSuda added this to the v1.1.2 milestone Jul 1, 2025
@AkihiroSuda AkihiroSuda force-pushed the limactl-clone branch 2 times, most recently from b209d0d to addc8f2 Compare July 1, 2025 11:00
Copy link
Member

@jandubois jandubois left a 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.

@AkihiroSuda
Copy link
Member Author

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.

@AkihiroSuda AkihiroSuda force-pushed the limactl-clone branch 3 times, most recently from 02d5c14 to 1e6504f Compare July 3, 2025 02:59
`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]>
Copy link

@Copilot Copilot AI left a 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'.

Use: "clone OLDINST NEWINST",
Short: "Clone an instance of Lima",
Long: `Clone an instance of Lima.
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to include an example, like we did for the copy command?

lima/cmd/limactl/copy.go

Lines 24 to 30 in 2f4aeda

const copyHelp = `Copy files between host and guest
Prefix guest filenames with the instance name and a colon.
Example: limactl copy default:/etc/os-release .
Not to be confused with 'limactl clone'.

Copy link
Member Author

Choose a reason for hiding this comment

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

clone OLDINST NEWINST should suffice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command for cloning an existing instance
3 participants