Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit d7d9ddf

Browse files
committed
feat: add VM console access commands and documentation
- Add 'make console' command for text-based VM console access - Add 'make vm-console' command for graphical VM console access via virt-viewer - Update install-deps to include virt-viewer package - Document virt-viewer usage in integration testing guide - Update local testing setup documentation with console access options - Add console commands to main commands table in copilot instructions These commands provide easy access to VM console for debugging when SSH fails during cloud-init or boot processes. Users can now use: - virt-viewer spice://127.0.0.1:5900 for graphical console - virsh console for text-based console access
1 parent 94d01d4 commit d7d9ddf

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

.github/copilot-instructions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,13 @@ make test-syntax # Syntax validation only
121121
| Command | Purpose |
122122
| ------------------------- | --------------------------------- |
123123
| `make help` | Show all available commands |
124-
| `make install-deps` | Install OpenTofu, libvirt, KVM |
124+
| `make install-deps` | Install OpenTofu, libvirt, KVM, virt-viewer |
125125
| `make test` | Run complete infrastructure tests |
126126
| `make apply` | Deploy VM with full configuration |
127127
| `make apply-minimal` | Deploy VM with minimal config |
128128
| `make ssh` | Connect to deployed VM |
129+
| `make console` | Access VM console (text-based) |
130+
| `make vm-console` | Access VM graphical console (GUI) |
129131
| `make destroy` | Remove deployed VM |
130132
| `make monitor-cloud-init` | Watch VM provisioning progress |
131133

Makefile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Makefile for Torrust Tracker Local Testing Infrastructure
2-
.PHONY: help init plan apply destroy test clean status ssh install-deps
2+
.PHONY: help init plan apply destroy test clean status ssh install-deps console vm-console
33

44
# Default variables
55
VM_NAME ?= torrust-tracker-demo
@@ -16,7 +16,7 @@ help: ## Show this help message
1616
install-deps: ## Install required dependencies (Ubuntu/Debian)
1717
@echo "Installing dependencies..."
1818
sudo apt update
19-
sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager genisoimage
19+
sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager virt-viewer genisoimage
2020
sudo usermod -aG libvirt $$USER
2121
sudo usermod -aG kvm $$USER
2222
sudo systemctl enable libvirtd
@@ -306,3 +306,17 @@ vm-info: ## Show detailed VM network information
306306
@echo ""
307307
@echo "DHCP leases:"
308308
@virsh net-dhcp-leases default 2>/dev/null | grep $(VM_NAME) || echo "No DHCP lease found"
309+
310+
console: ## Access VM console (text-based)
311+
@echo "Connecting to VM console..."
312+
@echo "Use Ctrl+] to exit console"
313+
@virsh console $(VM_NAME)
314+
315+
vm-console: ## Access VM graphical console (GUI)
316+
@echo "Opening VM graphical console..."
317+
@if command -v virt-viewer >/dev/null 2>&1; then \
318+
virt-viewer $(VM_NAME) || virt-viewer spice://127.0.0.1:5900; \
319+
else \
320+
echo "virt-viewer not found. Please install it:"; \
321+
echo " sudo apt install virt-viewer"; \
322+
fi

docs/guides/integration-testing-guide.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ techniques based on [cloud-init debugging documentation](https://cloudinit.readt
316316
#### Access VM Console
317317

318318
```bash
319-
# Connect to VM console (bypass SSH)
319+
# Method 1: Connect to VM console via virsh (text-based)
320320
virsh console torrust-tracker-demo
321321

322322
# Login as 'ubuntu' (default user) with no password, then:
@@ -328,6 +328,18 @@ sudo systemctl status cloud-init-local cloud-init cloud-config cloud-final
328328
# Exit console: Ctrl+]
329329
```
330330

331+
**Method 2: Use virt-viewer for graphical console access**
332+
333+
```bash
334+
# Connect to VM graphical console (shows login prompt)
335+
virt-viewer spice://127.0.0.1:5900
336+
337+
# Alternative using VM name
338+
virt-viewer torrust-tracker-demo
339+
```
340+
341+
**Note**: The virt-viewer method provides a graphical console where you should see a login prompt. This is particularly useful when the text-based virsh console doesn't work or when you need to see the full boot process.
342+
331343
#### Check from Host System
332344

333345
```bash

infrastructure/docs/local-testing-setup.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ tofu refresh
306306
5. **SSH connection refused**
307307
308308
- VM might still be booting/configuring
309-
- Check VM console: `virsh console torrust-tracker-demo`
309+
- Check VM console: `virsh console torrust-tracker-demo` or `virt-viewer spice://127.0.0.1:5900`
310310
- Verify firewall rules
311311
312312
6. **VM deployment timeout (can't get IP address)**
@@ -315,6 +315,6 @@ tofu refresh
315315
configuration, reboot)
316316
- **Solution**: This is normal; VM will get IP after cloud-init completes
317317
(~5-10 minutes)
318-
- **Check**: Use `virsh console torrust-tracker-demo` to monitor boot progress
318+
- **Check**: Use `virsh console torrust-tracker-demo` or `virt-viewer spice://127.0.0.1:5900` to monitor boot progress
319319
320320
### Logs and Debugging

0 commit comments

Comments
 (0)