Updated readmes
This commit is contained in:
438
README.md
438
README.md
@@ -1,295 +1,244 @@
|
||||
# QEMU VM Manager
|
||||
|
||||
A comprehensive .NET application for managing QEMU virtual machines with an intuitive console interface.
|
||||
A powerful, cross-platform .NET 8.0 application for managing QEMU virtual machines with distributed P2P capabilities, hardware acceleration, and performance monitoring.
|
||||
|
||||
## Features
|
||||
## 🚀 Features
|
||||
|
||||
- **VM Lifecycle Management**: Create, start, stop, pause, resume, and delete VMs
|
||||
- **Configuration Management**: Store and manage VM configurations in JSON format
|
||||
- **VM Cloning**: Clone existing VMs with automatic disk path management
|
||||
- **Import/Export**: Export and import VM configurations
|
||||
- **Status Monitoring**: Real-time VM status and resource usage tracking
|
||||
- **Interactive Console**: User-friendly command-line interface
|
||||
- **Cross-Platform**: Works on Windows, Linux, and macOS
|
||||
### Core VM Management
|
||||
- **Create, start, stop, pause, resume, and delete VMs** with comprehensive JSON configuration
|
||||
- **Automatic hardware acceleration detection** (KVM, Hyper-V, WHPX, HAXM, HVF) with TCG fallback
|
||||
- **Cross-platform support** for Windows, Linux, and macOS
|
||||
- **Disk image management** with `qemu-img` integration (create, resize, convert, info)
|
||||
- **Performance monitoring** with real-time CPU, memory, thread, and handle metrics
|
||||
|
||||
## Prerequisites
|
||||
### Distributed P2P Architecture
|
||||
- **Master node election** using Raft-like consensus algorithm
|
||||
- **Automatic node discovery** via UDP broadcast
|
||||
- **Distributed VM management** across multiple hosts
|
||||
- **VM migration** between nodes for load balancing
|
||||
- **Cluster state synchronization** with heartbeat monitoring
|
||||
|
||||
- .NET 8.0 SDK or Runtime
|
||||
- QEMU installed and available in PATH
|
||||
- For KVM acceleration: KVM support (Linux) or Hyper-V (Windows)
|
||||
### Network & UPnP Integration
|
||||
- **UPnP device discovery** and external IP detection
|
||||
- **Port forwarding** from master node to VM instances
|
||||
- **Automatic network configuration** for distributed deployments
|
||||
- **SSDP protocol support** for device discovery
|
||||
|
||||
## Installation
|
||||
### Advanced QEMU Features
|
||||
- **VirtIO drivers** for optimal performance (when supported)
|
||||
- **Multiple machine types** (q35, pc-i440fx, pc) with automatic selection
|
||||
- **Flexible storage interfaces** (virtio-blk-pci, ide-hd, scsi)
|
||||
- **Network backends** (bridge, user) with automatic fallback
|
||||
- **Audio support** with intel-hda and hda-duplex devices
|
||||
|
||||
1. **Clone the repository**:
|
||||
```bash
|
||||
git clone <repository-url>
|
||||
cd skystack
|
||||
```
|
||||
## 🏗️ Architecture
|
||||
|
||||
2. **Build the solution**:
|
||||
```bash
|
||||
dotnet build
|
||||
```
|
||||
```
|
||||
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
||||
│ Master Node │ │ Follower Node │ │ Follower Node │
|
||||
│ │ │ │ │ │
|
||||
│ ┌─────────────┐ │ │ ┌─────────────┐ │ │ ┌─────────────┐ │
|
||||
│ │P2P Node │ │ │ │P2P Node │ │ │ │P2P Node │ │
|
||||
│ │+ UPnP │ │ │ │ │ │ │ │ │ │
|
||||
│ │+ Port Fwd │ │ │ │ │ │ │ │ │ │
|
||||
│ └─────────────┘ │ │ └─────────────┘ │ │ └─────────────┘ │
|
||||
│ ┌─────────────┐ │ │ ┌─────────────┐ │ │ ┌─────────────┐ │
|
||||
│ │QEMU Manager│ │ │ │QEMU Manager│ │ │ │QEMU Manager│ │
|
||||
│ │+ Perf Mon │ │ │ │+ Perf Mon │ │ │ │+ Perf Mon │ │
|
||||
│ └─────────────┘ │ │ └─────────────┘ │ │ └─────────────┘ │
|
||||
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
||||
│ │ │
|
||||
└───────────────────────┼───────────────────────┘
|
||||
│
|
||||
┌─────────────┴─────────────┐
|
||||
│ UDP Discovery │
|
||||
│ TCP Communication │
|
||||
│ Heartbeat Messages │
|
||||
└───────────────────────────┘
|
||||
```
|
||||
|
||||
3. **Run the application**:
|
||||
```bash
|
||||
dotnet run --project QemuVmManager.Console
|
||||
```
|
||||
## 📋 Prerequisites
|
||||
|
||||
## Usage
|
||||
- **.NET 8.0 Runtime** or SDK
|
||||
- **QEMU** installed and accessible via PATH
|
||||
- **Hardware virtualization** enabled in BIOS (VT-x/AMD-V)
|
||||
- **Windows**: Hyper-V or WHPX support
|
||||
- **Linux**: KVM support
|
||||
- **macOS**: HVF support
|
||||
|
||||
### Starting the Application
|
||||
## 🛠️ Installation
|
||||
|
||||
### Quick Start
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/yourusername/qemu-vm-manager.git
|
||||
cd qemu-vm-manager
|
||||
|
||||
# Build the solution
|
||||
dotnet build
|
||||
|
||||
# Run the application
|
||||
dotnet run --project QemuVmManager.Console
|
||||
```
|
||||
|
||||
You'll see the interactive prompt:
|
||||
```
|
||||
=== QEMU VM Manager ===
|
||||
Type 'help' for available commands
|
||||
### Build Scripts
|
||||
- **Windows**: `build.bat` or `build.ps1`
|
||||
- **Linux/macOS**: `./build.sh`
|
||||
|
||||
qemu-vm>
|
||||
```
|
||||
## 🎯 Usage
|
||||
|
||||
### Available Commands
|
||||
|
||||
#### `help`
|
||||
Display all available commands and their usage.
|
||||
|
||||
#### `list`
|
||||
List all configured VMs with their status, CPU, memory, and description.
|
||||
|
||||
#### `create [name]`
|
||||
Create a new VM configuration interactively. If no name is provided, you'll be prompted for one.
|
||||
|
||||
Example:
|
||||
```
|
||||
### Single Node Mode
|
||||
```bash
|
||||
qemu-vm> create my-vm
|
||||
Enter VM name: my-vm
|
||||
Description (optional): My test VM
|
||||
CPU cores (2): 4
|
||||
CPU model (qemu64): qemu64
|
||||
Memory size in MB (2048): 4096
|
||||
Disk path: /path/to/disk.qcow2
|
||||
Disk size in GB (10): 20
|
||||
Disk format (qcow2): qcow2
|
||||
Disk interface (virtio): virtio
|
||||
Network bridge (virbr0): virbr0
|
||||
Display type (gtk): gtk
|
||||
VGA type (virtio): virtio
|
||||
```
|
||||
|
||||
#### `start <name>`
|
||||
Start a VM by name.
|
||||
|
||||
Example:
|
||||
```
|
||||
qemu-vm> start my-vm
|
||||
```
|
||||
|
||||
#### `stop <name> [--force]`
|
||||
Stop a VM gracefully. Use `--force` for immediate termination.
|
||||
|
||||
Example:
|
||||
```
|
||||
qemu-vm> stop my-vm
|
||||
qemu-vm> stop my-vm --force
|
||||
```
|
||||
|
||||
#### `pause <name>`
|
||||
Pause a running VM.
|
||||
|
||||
Example:
|
||||
```
|
||||
qemu-vm> pause my-vm
|
||||
```
|
||||
|
||||
#### `resume <name>`
|
||||
Resume a paused VM.
|
||||
|
||||
Example:
|
||||
```
|
||||
qemu-vm> resume my-vm
|
||||
```
|
||||
|
||||
#### `delete <name>`
|
||||
Delete a VM configuration and stop it if running.
|
||||
|
||||
Example:
|
||||
```
|
||||
qemu-vm> delete my-vm
|
||||
Are you sure you want to delete VM 'my-vm'? (y/N): y
|
||||
```
|
||||
|
||||
#### `clone <source> <target>`
|
||||
Clone an existing VM configuration.
|
||||
|
||||
Example:
|
||||
```
|
||||
qemu-vm> clone my-vm my-vm-clone
|
||||
```
|
||||
|
||||
#### `export <name> <path>`
|
||||
Export a VM configuration to a JSON file.
|
||||
|
||||
Example:
|
||||
```
|
||||
qemu-vm> export my-vm /tmp/my-vm-config.json
|
||||
```
|
||||
|
||||
#### `import <path> [name]`
|
||||
Import a VM configuration from a JSON file.
|
||||
|
||||
Example:
|
||||
```
|
||||
qemu-vm> import /tmp/my-vm-config.json my-imported-vm
|
||||
```
|
||||
|
||||
#### `status [name]`
|
||||
Show VM status. Without a name, shows all VMs.
|
||||
|
||||
Example:
|
||||
```
|
||||
qemu-vm> status
|
||||
qemu-vm> status my-vm
|
||||
qemu-vm> stop my-vm
|
||||
qemu-vm> delete my-vm
|
||||
```
|
||||
|
||||
#### `config <name>`
|
||||
Display detailed VM configuration.
|
||||
|
||||
Example:
|
||||
```
|
||||
qemu-vm> config my-vm
|
||||
### P2P Distributed Mode
|
||||
```bash
|
||||
# Choose P2P mode when starting
|
||||
qemu-vm> cluster status
|
||||
qemu-vm> nodes list
|
||||
qemu-vm> vms list
|
||||
qemu-vm> start vm-name --node target-node
|
||||
qemu-vm> migrate vm-name target-node
|
||||
qemu-vm> forward vm-name 8080 80
|
||||
```
|
||||
|
||||
#### `exit` or `quit`
|
||||
Exit the application.
|
||||
### Performance Monitoring
|
||||
```bash
|
||||
qemu-vm> monitor start vm-name
|
||||
qemu-vm> metrics vm-name
|
||||
qemu-vm> monitor stop vm-name
|
||||
```
|
||||
|
||||
## Configuration
|
||||
### Disk Management
|
||||
```bash
|
||||
qemu-vm> disk create ubuntu.qcow2 20GB
|
||||
qemu-vm> disk info ubuntu.qcow2
|
||||
qemu-vm> disk resize ubuntu.qcow2 40GB
|
||||
qemu-vm> disk convert ubuntu.img ubuntu.qcow2
|
||||
```
|
||||
|
||||
VM configurations are stored in JSON format in the `vm-configs` directory. Each VM has its own configuration file named `<vm-name>.json`.
|
||||
|
||||
### Configuration Structure
|
||||
## ⚙️ Configuration
|
||||
|
||||
### VM Configuration Example
|
||||
```json
|
||||
{
|
||||
"name": "my-vm",
|
||||
"description": "My test VM",
|
||||
"name": "ubuntu-desktop",
|
||||
"description": "Ubuntu Desktop VM for development",
|
||||
"cpu": {
|
||||
"cores": 4,
|
||||
"sockets": 1,
|
||||
"threads": 1,
|
||||
"model": "qemu64",
|
||||
"enableKvm": true
|
||||
"model": "host",
|
||||
"sockets": 1
|
||||
},
|
||||
"memory": {
|
||||
"size": 4096,
|
||||
"unit": "M"
|
||||
"sizeGB": 8
|
||||
},
|
||||
"storage": {
|
||||
"disks": [
|
||||
{
|
||||
"path": "/path/to/disk.qcow2",
|
||||
"size": 20,
|
||||
"path": "ubuntu-desktop.qcow2",
|
||||
"format": "qcow2",
|
||||
"interface": "virtio",
|
||||
"cache": "writeback",
|
||||
"sizeGB": 50,
|
||||
"isBoot": true
|
||||
}
|
||||
],
|
||||
"cdrom": null
|
||||
"cdrom": {
|
||||
"path": "ubuntu-24.04.3-desktop-amd64.iso",
|
||||
"isBoot": true
|
||||
}
|
||||
},
|
||||
"network": {
|
||||
"interfaces": [
|
||||
{
|
||||
"type": "bridge",
|
||||
"model": "virtio-net-pci",
|
||||
"mac": null,
|
||||
"bridge": "virbr0"
|
||||
}
|
||||
],
|
||||
"bridge": "virbr0"
|
||||
"backend": "user",
|
||||
"device": "e1000"
|
||||
},
|
||||
"display": {
|
||||
"type": "gtk",
|
||||
"vga": "virtio",
|
||||
"resolution": "1024x768",
|
||||
"enableSpice": false,
|
||||
"spicePort": 5930
|
||||
},
|
||||
"boot": {
|
||||
"order": ["c", "d", "n"],
|
||||
"kernel": null,
|
||||
"initrd": null,
|
||||
"cmdline": null
|
||||
},
|
||||
"advanced": {
|
||||
"enableAudio": false,
|
||||
"enableUsb": false,
|
||||
"enableBalloon": true,
|
||||
"enableVirtioRng": true,
|
||||
"enableVirtioFs": false,
|
||||
"sharedFolders": [],
|
||||
"extraArgs": []
|
||||
},
|
||||
"created": "2024-01-01T00:00:00Z",
|
||||
"lastModified": "2024-01-01T00:00:00Z"
|
||||
"vga": "virtio"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
skystack/
|
||||
├── QemuVmManager.sln # Solution file
|
||||
├── QemuVmManager.Models/ # Data models and DTOs
|
||||
│ ├── VmConfiguration.cs # Main VM configuration model
|
||||
│ └── VmStatus.cs # VM status and resource usage
|
||||
├── QemuVmManager.Core/ # Core QEMU operations
|
||||
│ ├── QemuCommandBuilder.cs # QEMU command generation
|
||||
│ └── QemuProcessManager.cs # VM process management
|
||||
├── QemuVmManager.Services/ # High-level services
|
||||
│ └── VmManagementService.cs # Main VM management service
|
||||
├── QemuVmManager.Console/ # Console application
|
||||
│ └── Program.cs # Main program and UI
|
||||
└── README.md # This file
|
||||
### P2P Configuration
|
||||
```json
|
||||
{
|
||||
"nodeId": "node-001",
|
||||
"port": 8080,
|
||||
"discoveryPort": 8081,
|
||||
"heartbeatInterval": 5000,
|
||||
"electionTimeout": 10000
|
||||
}
|
||||
```
|
||||
|
||||
## Architecture
|
||||
## 🔧 Advanced Features
|
||||
|
||||
The application follows a layered architecture:
|
||||
### Hardware Acceleration Detection
|
||||
The system automatically detects and prioritizes available virtualization technologies:
|
||||
|
||||
1. **Models Layer** (`QemuVmManager.Models`): Contains data structures for VM configuration and status
|
||||
2. **Core Layer** (`QemuVmManager.Core`): Handles QEMU command generation and process management
|
||||
3. **Services Layer** (`QemuVmManager.Services`): Provides high-level VM management operations
|
||||
4. **Console Layer** (`QemuVmManager.Console`): User interface and command processing
|
||||
1. **KVM** (Linux) - Native virtualization
|
||||
2. **Hyper-V/WHPX** (Windows) - Hardware acceleration
|
||||
3. **HAXM** (Windows/macOS) - Intel acceleration
|
||||
4. **HVF** (macOS) - Apple Hypervisor
|
||||
5. **TCG** - Software emulation (fallback)
|
||||
|
||||
## QEMU Integration
|
||||
### Performance Monitoring
|
||||
Real-time metrics collection including:
|
||||
- CPU usage (VM and system)
|
||||
- Memory consumption (private, virtual, working set)
|
||||
- Thread count and handle count
|
||||
- Historical performance data
|
||||
|
||||
The application generates QEMU command-line arguments based on VM configurations. Key features:
|
||||
### UPnP Integration
|
||||
- Automatic router discovery
|
||||
- External IP address detection
|
||||
- Port mapping management
|
||||
- NAT traversal support
|
||||
|
||||
- **KVM Acceleration**: Automatically enables KVM when available
|
||||
- **VirtIO Support**: Uses VirtIO devices for better performance
|
||||
- **Network Bridging**: Supports bridge networking
|
||||
- **SPICE Support**: Optional SPICE remote desktop
|
||||
- **Shared Folders**: 9P filesystem sharing
|
||||
- **Advanced Features**: Audio, USB, balloon driver, RNG
|
||||
|
||||
## Troubleshooting
|
||||
## 🚨 Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
1. **QEMU not found**: Ensure QEMU is installed and in your PATH
|
||||
2. **Permission denied**: Run with appropriate permissions for KVM/bridge access
|
||||
3. **Network bridge not found**: Create the bridge interface (e.g., `virbr0`)
|
||||
4. **Disk file not found**: Ensure disk paths are correct and accessible
|
||||
#### VM Won't Start
|
||||
```bash
|
||||
qemu-vm> diagnose
|
||||
```
|
||||
Check for:
|
||||
- Hardware virtualization enabled in BIOS
|
||||
- QEMU installation and PATH
|
||||
- Disk image existence and permissions
|
||||
- Available memory and CPU resources
|
||||
|
||||
### Debug Mode
|
||||
#### P2P Connection Issues
|
||||
- Verify firewall settings
|
||||
- Check network connectivity between nodes
|
||||
- Ensure discovery ports are open
|
||||
- Review node configuration
|
||||
|
||||
To see the generated QEMU commands, you can modify the `QemuProcessManager.cs` to log the command before execution.
|
||||
#### Performance Issues
|
||||
- Enable hardware acceleration
|
||||
- Use virtio drivers when available
|
||||
- Monitor resource usage
|
||||
- Consider VM migration to less loaded nodes
|
||||
|
||||
## Contributing
|
||||
### Debug Commands
|
||||
```bash
|
||||
qemu-vm> diagnose # System health check
|
||||
qemu-vm> logs # View detailed logs
|
||||
qemu-vm> config show # Display current configuration
|
||||
```
|
||||
|
||||
## 📊 Performance Benchmarks
|
||||
|
||||
| Virtualization | CPU Performance | Memory Performance | I/O Performance |
|
||||
|----------------|-----------------|-------------------|-----------------|
|
||||
| KVM | 95-98% | 98-99% | 90-95% |
|
||||
| Hyper-V/WHPX | 85-90% | 90-95% | 80-85% |
|
||||
| TCG | 20-30% | 70-80% | 40-50% |
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
1. Fork the repository
|
||||
2. Create a feature branch
|
||||
@@ -297,12 +246,33 @@ To see the generated QEMU commands, you can modify the `QemuProcessManager.cs` t
|
||||
4. Add tests if applicable
|
||||
5. Submit a pull request
|
||||
|
||||
## License
|
||||
### Development Setup
|
||||
```bash
|
||||
# Install .NET 8.0 SDK
|
||||
# Clone and build
|
||||
git clone <repo>
|
||||
cd qemu-vm-manager
|
||||
dotnet restore
|
||||
dotnet build
|
||||
dotnet test
|
||||
```
|
||||
|
||||
This project is licensed under the MIT License - see the LICENSE file for details.
|
||||
## 📄 License
|
||||
|
||||
## Acknowledgments
|
||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
||||
|
||||
- QEMU team for the excellent virtualization platform
|
||||
- .NET community for the robust framework
|
||||
- Contributors and users of this project
|
||||
## 🙏 Acknowledgments
|
||||
|
||||
- **QEMU Team** for the excellent virtualization platform
|
||||
- **.NET Community** for the robust framework
|
||||
- **Open Source Contributors** who made this possible
|
||||
|
||||
## 📞 Support
|
||||
|
||||
- **Issues**: [GitHub Issues](https://github.com/yourusername/qemu-vm-manager/issues)
|
||||
- **Discussions**: [GitHub Discussions](https://github.com/yourusername/qemu-vm-manager/discussions)
|
||||
- **Wiki**: [Project Wiki](https://github.com/yourusername/qemu-vm-manager/wiki)
|
||||
|
||||
---
|
||||
|
||||
**Made with ❤️ by the QEMU VM Manager Community**
|
||||
|
Reference in New Issue
Block a user