Skip to content

Commit 8ec1251

Browse files
committed
Add README
1 parent 52982d0 commit 8ec1251

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

lib/hypervisor/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Hypervisor Abstraction
2+
3+
Provides a common interface for VM management across different hypervisors.
4+
5+
## Purpose
6+
7+
Hypeman originally supported only Cloud Hypervisor. This abstraction layer allows supporting multiple hypervisors (e.g., QEMU) through a unified interface, enabling:
8+
9+
- **Hypervisor choice per instance** - Different instances can use different hypervisors
10+
- **Feature parity where possible** - Common operations work the same way
11+
- **Graceful degradation** - Features unsupported by a hypervisor can be detected and handled
12+
13+
## How It Works
14+
15+
The abstraction defines two key interfaces:
16+
17+
1. **Hypervisor** - VM lifecycle operations (create, boot, pause, resume, snapshot, restore, shutdown)
18+
2. **ProcessManager** - Hypervisor process lifecycle (start binary, get binary path)
19+
20+
Each hypervisor implementation translates the generic configuration and operations to its native format. For example, Cloud Hypervisor uses an HTTP API over a Unix socket, while QEMU would use QMP.
21+
22+
Before using optional features, callers check capabilities:
23+
24+
```go
25+
if hv.Capabilities().SupportsSnapshot {
26+
hv.Snapshot(ctx, path)
27+
}
28+
```
29+
30+
## Hypervisor Switching
31+
32+
Instances store their hypervisor type in metadata. An instance can switch hypervisors only when stopped (no running VM, no snapshot), since:
33+
34+
- Disk images are hypervisor-agnostic
35+
- Snapshots are hypervisor-specific and cannot be restored by a different hypervisor

0 commit comments

Comments
 (0)