Skip to content

Conversation

@bdkabiruddin
Copy link

Description

This PR addresses issue #599 by enabling trellis-cli to work on Linux using Lima with QEMU.

Currently, trellis-cli relies on vmType: vz and macOS-specific networking, which makes VMs inaccessible on Linux (cannot route to the VM's IP).

Changes Implemented

1. Dynamic VM Type

  • Updated pkg/lima/instance.go and config.yml to switch between vz (macOS) and qemu (Linux).

2. Bridged Networking (The "TAP" Solution)

Since Lima on Linux (QEMU) implies user-mode networking by default, I implemented a bridged network approach:

  • Host Side: The CLI automatically checks for and creates a tap0 interface (assigned 192.168.56.1) on the host using sudo.
  • VM Side: A provision script creates a corresponding interface inside the VM assigned to 192.168.56.5.

3. QEMU Wrapper

Lima does not currently expose a way to inject specific -netdev tap arguments.

  • Implemented a temporary qemu-system-x86_64 wrapper script in pkg/lima/manager.go.
  • This script injects the TAP network device arguments before passing control to the real QEMU binary.

4. IP Detection

  • Updated Instance.IP() to prioritize the custom bridged subnet (192.168.56.x) on Linux.
  • Falls back to the default NAT IP if the bridge is missing or if running on macOS.

Verification

  • Tested on Ubuntu 22.04.
  • Confirmed macOS logic remains untouched via runtime.GOOS checks.

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.

1 participant