Skip to content

Conversation

@cgwalters
Copy link
Collaborator

When I say --force I mean it; needing to stop the VM manually was just annoying.

Add run --replace/-R to forcibly destroy and recreate a VM with the same name, matching podman run --replace behavior. This is useful for quick iteration during development and testing.

Assisted-by: Claude Code (Sonnet 4.5)

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces two useful features: making rm -f stop running VMs by default, and adding a --replace flag to the run command, aligning its behavior more closely with tools like podman. The implementation looks correct and is supported by new integration tests.

My review focuses on improving code quality and maintainability. I've pointed out a couple of areas with code duplication:

  • In the integration tests, the logic for creating test VMs is repeated. Extracting this into a helper function would make the tests cleaner.
  • In the libvirt::rm module, there's redundant fetching of domain information, which is inefficient. A small refactoring could eliminate this.

Overall, these are solid additions. Addressing the suggested refactorings would improve the long-term health of the codebase.

println!("Removing VM '{}'...", opts.name);

// Use the shared removal logic
remove_vm_forced(global_opts, &opts.name, opts.stop || opts.force)?;

Choose a reason for hiding this comment

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

medium

This call to remove_vm_forced introduces redundant operations. The run function fetches the domain state and domain_info (lines 115-122), and then remove_vm_forced fetches the exact same information again (lines 43-50). This results in unnecessary virsh command executions.

To improve efficiency and code structure, consider refactoring this. One approach is to create a private core removal function that accepts the already-fetched state and domain_info. Both run and the public remove_vm_forced could then call this core function after fetching the domain information once.

When I say `--force` I mean it; needing to stop the VM manually
was just annoying.

Add run --replace/-R to forcibly destroy and recreate a VM with the
same name, matching podman run --replace behavior. This is useful for
quick iteration during development and testing.

Assisted-by: Claude Code (Sonnet 4.5)
Signed-off-by: Colin Walters <walters@verbum.org>
@cgwalters cgwalters merged commit 48f2cf0 into bootc-dev:main Nov 17, 2025
9 checks passed
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.

2 participants