Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions vagrant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,41 @@ ansible/inventory/

3. **Multiple Networks**: Unlike libvirt, vagrant-qemu doesn't support bridged networking as easily. All VMs use private_network.

4. **Box Compatibility**: Some Vagrant boxes may have boot issues with vagrant-qemu on Apple Silicon. The `generic/debian12` ARM64 box is recommended but may require extended boot timeouts.

## Known Issues

### SSH Timeout During Boot

If VMs show "timeout during server version negotiating" or "Connection reset by peer", the VM may be:
- Still booting (can take 5-10 minutes on first boot)
- Using an incompatible box (ensure ARM64 architecture)

**Solutions:**
1. Increase boot timeout in Vagrantfile (currently set to 1200s)
2. Try a different ARM64-compatible box
3. Verify QEMU supports HVF: `qemu-system-aarch64 -accel help`

### Alternative Approaches

If vagrant-qemu proves unreliable, consider:

1. **VirtualBox 7.1+**: Now supports Apple Silicon (as of September 2024)
```bash
brew install --cask virtualbox
vagrant up --provider=virtualbox
```

2. **UTM with vagrant-utm**: Native macOS virtualization
- Install UTM from App Store
- `vagrant plugin install vagrant_utm`

3. **Lima/Colima**: Lightweight alternative with QEMU backend
```bash
brew install colima
colima start --vm-type=qemu --arch=aarch64
```

## References

- [vagrant-qemu GitHub](https://github.com/ppggff/vagrant-qemu)
Expand Down
21 changes: 12 additions & 9 deletions vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Vagrant.require_version ">= 2.3.0"

# VM Configuration
# Using generic/debian12 ARM64 for vagrant-qemu on Apple Silicon
VM_BOX = "generic/debian12"
VM_BOX_VERSION = "4.3.12"

Expand All @@ -37,11 +38,13 @@ NETWORK_PREFIX = "192.168.64"
GATEWAY = "192.168.64.1"

# VM Definitions
# Each VM needs a unique ssh_port to avoid port collisions with vagrant-qemu
VMS = {
"sip-1" => {
ip: "#{NETWORK_PREFIX}.10",
memory: 2048,
cpus: 2,
ssh_port: 52222,
role: "sip_proxy",
description: "OpenSIPS SIP Proxy",
ansible_groups: ["sip_proxies", "voip"]
Expand All @@ -50,6 +53,7 @@ VMS = {
ip: "#{NETWORK_PREFIX}.20",
memory: 4096,
cpus: 4,
ssh_port: 52223,
role: "media",
description: "RTPEngine Media Proxy",
ansible_groups: ["media_servers", "voip"]
Expand All @@ -58,6 +62,7 @@ VMS = {
ip: "#{NETWORK_PREFIX}.30",
memory: 4096,
cpus: 2,
ssh_port: 52224,
role: "pbx",
description: "Asterisk PBX",
ansible_groups: ["pbx", "voip"]
Expand All @@ -76,6 +81,9 @@ Vagrant.configure("2") do |config|
config.ssh.insert_key = true
config.ssh.forward_agent = true

# Increase boot timeout for QEMU VMs (can be slow on first boot)
config.vm.boot_timeout = 1200

# Disable default synced folder (use Ansible for file transfers)
config.vm.synced_folder ".", "/vagrant", disabled: true

Expand All @@ -90,22 +98,17 @@ Vagrant.configure("2") do |config|
netmask: "255.255.255.0"

# QEMU provider configuration
# Uses recommended settings for Apple Silicon/ARM64 with HVF acceleration
vm.vm.provider "qemu" do |qe|
qe.memory = vm_config[:memory].to_s
qe.smp = vm_config[:cpus].to_s
qe.arch = "aarch64"
qe.machine = "virt,accel=hvf,highmem=on"
qe.machine = "virt,accel=hvf,highmem=off"
qe.cpu = "host"
qe.net_device = "virtio-net-pci"

# Extra QEMU arguments for Apple Silicon optimization
qe.extra_qemu_args = %w(
-cpu host
-smp 2,sockets=1,cores=2,threads=1
)

# Enable serial console for debugging
qe.extra_qemu_args += %w(-serial mon:stdio) if ENV['VAGRANT_DEBUG']
# Unique SSH port for each VM to avoid collisions
qe.ssh_port = vm_config[:ssh_port]
end

# VM-specific provisioning message
Expand Down