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:
@@ -14,7 +14,7 @@ func TestPurgeComponentRemoved(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
// Set up a service with a stale component.
|
||||
if err := registry.CreateService(a.DB, "mcns", true); err != nil {
|
||||
if err := registry.CreateService(a.DB, "mcns", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
if err := registry.CreateComponent(a.DB, ®istry.Component{
|
||||
@@ -69,7 +69,7 @@ func TestPurgeRefusesRunning(t *testing.T) {
|
||||
a := newTestAgent(t, rt)
|
||||
ctx := context.Background()
|
||||
|
||||
if err := registry.CreateService(a.DB, "mcr", true); err != nil {
|
||||
if err := registry.CreateService(a.DB, "mcr", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
if err := registry.CreateComponent(a.DB, ®istry.Component{
|
||||
@@ -109,7 +109,7 @@ func TestPurgeRefusesStopped(t *testing.T) {
|
||||
a := newTestAgent(t, rt)
|
||||
ctx := context.Background()
|
||||
|
||||
if err := registry.CreateService(a.DB, "mcr", true); err != nil {
|
||||
if err := registry.CreateService(a.DB, "mcr", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
if err := registry.CreateComponent(a.DB, ®istry.Component{
|
||||
@@ -140,7 +140,7 @@ func TestPurgeSkipsDefinedComponent(t *testing.T) {
|
||||
a := newTestAgent(t, rt)
|
||||
ctx := context.Background()
|
||||
|
||||
if err := registry.CreateService(a.DB, "mcns", true); err != nil {
|
||||
if err := registry.CreateService(a.DB, "mcns", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
if err := registry.CreateComponent(a.DB, ®istry.Component{
|
||||
@@ -176,7 +176,7 @@ func TestPurgeDryRun(t *testing.T) {
|
||||
a := newTestAgent(t, rt)
|
||||
ctx := context.Background()
|
||||
|
||||
if err := registry.CreateService(a.DB, "mcns", true); err != nil {
|
||||
if err := registry.CreateService(a.DB, "mcns", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
if err := registry.CreateComponent(a.DB, ®istry.Component{
|
||||
@@ -217,7 +217,7 @@ func TestPurgeServiceFilter(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
// Create two services.
|
||||
if err := registry.CreateService(a.DB, "mcns", true); err != nil {
|
||||
if err := registry.CreateService(a.DB, "mcns", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
if err := registry.CreateComponent(a.DB, ®istry.Component{
|
||||
@@ -226,7 +226,7 @@ func TestPurgeServiceFilter(t *testing.T) {
|
||||
}); err != nil {
|
||||
t.Fatalf("create component: %v", err)
|
||||
}
|
||||
if err := registry.CreateService(a.DB, "mcr", true); err != nil {
|
||||
if err := registry.CreateService(a.DB, "mcr", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
if err := registry.CreateComponent(a.DB, ®istry.Component{
|
||||
@@ -263,7 +263,7 @@ func TestPurgeServiceDeletedWhenEmpty(t *testing.T) {
|
||||
a := newTestAgent(t, rt)
|
||||
ctx := context.Background()
|
||||
|
||||
if err := registry.CreateService(a.DB, "mcns", true); err != nil {
|
||||
if err := registry.CreateService(a.DB, "mcns", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
if err := registry.CreateComponent(a.DB, ®istry.Component{
|
||||
@@ -306,7 +306,7 @@ func TestPurgeServiceKeptWhenComponentsRemain(t *testing.T) {
|
||||
a := newTestAgent(t, rt)
|
||||
ctx := context.Background()
|
||||
|
||||
if err := registry.CreateService(a.DB, "mcns", true); err != nil {
|
||||
if err := registry.CreateService(a.DB, "mcns", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
// Stale component (will be purged).
|
||||
@@ -359,7 +359,7 @@ func TestPurgeExitedState(t *testing.T) {
|
||||
a := newTestAgent(t, rt)
|
||||
ctx := context.Background()
|
||||
|
||||
if err := registry.CreateService(a.DB, "test", true); err != nil {
|
||||
if err := registry.CreateService(a.DB, "test", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
if err := registry.CreateComponent(a.DB, ®istry.Component{
|
||||
@@ -384,7 +384,7 @@ func TestPurgeUnknownState(t *testing.T) {
|
||||
a := newTestAgent(t, rt)
|
||||
ctx := context.Background()
|
||||
|
||||
if err := registry.CreateService(a.DB, "test", true); err != nil {
|
||||
if err := registry.CreateService(a.DB, "test", true, ""); err != nil {
|
||||
t.Fatalf("create service: %v", err)
|
||||
}
|
||||
if err := registry.CreateComponent(a.DB, ®istry.Component{
|
||||
|
||||
Reference in New Issue
Block a user