Add unikernel runtime: run services as Nanos VMs under QEMU/KVM
Implements the hypervisor design's Phase 1: a second runtime.Runtime backend (QEMU) that runs each service component as a Nanos unikernel VM instead of a podman container, selected per-component via a new runtime = "unikernel" service-def field. - internal/runtime/qemu.go: QEMURuntime. Pull extracts the ELF from the OCI image; Run does `ops build` + boots qemu-system-x86_64 with KVM, user-mode net port-forwards, QMP control socket and serial console log; Stop/Remove/Inspect/List/Logs map onto VM lifecycle + state dir. - proto/registry/servicedef: add runtime, memory_mb, vcpus fields (registry migration 5). - agent: holds both runtimes; runtimeFor() selects per component; listAllContainers() merges containers + VMs so drift/status see both. Unikernel runtime auto-enables on nodes with /dev/kvm + ops. Validated end-to-end on straylight: a test service deploys via `mcp deploy --direct`, boots as a Nanos unikernel, serves HTTP through the agent port-forward, and reports running via `mcp status`/`mcp logs`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,7 @@ func TestServiceCRUD(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
|
||||
// Create
|
||||
if err := CreateService(db, "metacrypt", true); err != nil {
|
||||
if err := CreateService(db, "metacrypt", true, ""); err != nil {
|
||||
t.Fatalf("create: %v", err)
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func TestServiceCRUD(t *testing.T) {
|
||||
}
|
||||
|
||||
// Update active
|
||||
if err := UpdateServiceActive(db, "metacrypt", false); err != nil {
|
||||
if err := UpdateServiceActive(db, "metacrypt", false, ""); err != nil {
|
||||
t.Fatalf("update: %v", err)
|
||||
}
|
||||
s, _ = GetService(db, "metacrypt")
|
||||
@@ -80,17 +80,17 @@ func TestServiceCRUD(t *testing.T) {
|
||||
|
||||
func TestServiceDuplicateName(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
if err := CreateService(db, "metacrypt", true); err != nil {
|
||||
if err := CreateService(db, "metacrypt", true, ""); err != nil {
|
||||
t.Fatalf("first create: %v", err)
|
||||
}
|
||||
if err := CreateService(db, "metacrypt", true); err == nil {
|
||||
if err := CreateService(db, "metacrypt", true, ""); err == nil {
|
||||
t.Fatal("expected error on duplicate name")
|
||||
}
|
||||
}
|
||||
|
||||
func TestComponentCRUD(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
if err := CreateService(db, "metacrypt", true); err != nil {
|
||||
if err := CreateService(db, "metacrypt", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ func TestComponentCRUD(t *testing.T) {
|
||||
|
||||
func TestComponentCompositePK(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
if err := CreateService(db, "metacrypt", true); err != nil {
|
||||
if err := CreateService(db, "metacrypt", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ func TestComponentCompositePK(t *testing.T) {
|
||||
|
||||
func TestCascadeDelete(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
if err := CreateService(db, "metacrypt", true); err != nil {
|
||||
if err := CreateService(db, "metacrypt", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ func TestCascadeDelete(t *testing.T) {
|
||||
|
||||
func TestComponentRoutes(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
if err := CreateService(db, "svc", true); err != nil {
|
||||
if err := CreateService(db, "svc", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ func TestComponentRoutes(t *testing.T) {
|
||||
|
||||
func TestRouteHostPort(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
if err := CreateService(db, "svc", true); err != nil {
|
||||
if err := CreateService(db, "svc", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ func TestRouteHostPort(t *testing.T) {
|
||||
|
||||
func TestRouteCascadeDelete(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
if err := CreateService(db, "svc", true); err != nil {
|
||||
if err := CreateService(db, "svc", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user