diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d2a57fc18..ff9e07fae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -182,7 +182,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | set -euo pipefail - for version in v49.0 v51.1; do + for version in v51.2; do for architecture in x86_64 aarch64; do if [ "$architecture" = "x86_64" ]; then asset="cloud-hypervisor-static" diff --git a/Makefile b/Makefile index 54f0ef92d..4fd351623 100644 --- a/Makefile +++ b/Makefile @@ -34,21 +34,16 @@ $(XCADDY): | $(BIN_DIR) install-tools: $(OAPI_CODEGEN) $(AIR) $(WIRE) $(XCADDY) -# Download Cloud Hypervisor binaries (both v49.0 and v51.1 for backwards-compatible upgrades) +# Download Cloud Hypervisor binaries. Older releases are no longer shipped: +# CVE-2026-45782 is fixed in v51.2. download-ch-binaries: @echo "Downloading Cloud Hypervisor binaries..." - @mkdir -p lib/vmm/binaries/cloud-hypervisor/v49.0/{x86_64,aarch64} - @mkdir -p lib/vmm/binaries/cloud-hypervisor/v51.1/{x86_64,aarch64} - @echo "Downloading v49.0..." - @curl -L -o lib/vmm/binaries/cloud-hypervisor/v49.0/x86_64/cloud-hypervisor \ - https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v49.0/cloud-hypervisor-static - @curl -L -o lib/vmm/binaries/cloud-hypervisor/v49.0/aarch64/cloud-hypervisor \ - https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v49.0/cloud-hypervisor-static-aarch64 - @echo "Downloading v51.1..." - @curl -L -o lib/vmm/binaries/cloud-hypervisor/v51.1/x86_64/cloud-hypervisor \ - https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v51.1/cloud-hypervisor-static - @curl -L -o lib/vmm/binaries/cloud-hypervisor/v51.1/aarch64/cloud-hypervisor \ - https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v51.1/cloud-hypervisor-static-aarch64 + @mkdir -p lib/vmm/binaries/cloud-hypervisor/v51.2/{x86_64,aarch64} + @echo "Downloading v51.2..." + @curl -L -o lib/vmm/binaries/cloud-hypervisor/v51.2/x86_64/cloud-hypervisor \ + https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v51.2/cloud-hypervisor-static + @curl -L -o lib/vmm/binaries/cloud-hypervisor/v51.2/aarch64/cloud-hypervisor \ + https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v51.2/cloud-hypervisor-static-aarch64 @chmod +x lib/vmm/binaries/cloud-hypervisor/v*/*/cloud-hypervisor @echo "Binaries downloaded successfully" @@ -132,7 +127,7 @@ download-ch-spec: @echo "Downloading Cloud Hypervisor API spec..." @mkdir -p specs/cloud-hypervisor/api-v0.3.0 @curl -L -o specs/cloud-hypervisor/api-v0.3.0/cloud-hypervisor.yaml \ - https://raw.githubusercontent.com/cloud-hypervisor/cloud-hypervisor/refs/tags/v51.1/vmm/src/api/openapi/cloud-hypervisor.yaml + https://raw.githubusercontent.com/cloud-hypervisor/cloud-hypervisor/refs/tags/v51.2/vmm/src/api/openapi/cloud-hypervisor.yaml @echo "API spec downloaded" # Generate Go code from OpenAPI spec @@ -187,7 +182,7 @@ ensure-ch-binaries: echo "Unsupported architecture: $$ARCH"; exit 1; \ fi; \ NEEDS_DOWNLOAD=0; \ - for CH_VERSION in v49.0 v51.1; do \ + for CH_VERSION in v51.2; do \ CH_BIN=lib/vmm/binaries/cloud-hypervisor/$$CH_VERSION/$$CH_ARCH/cloud-hypervisor; \ if [ ! -f "$$CH_BIN" ]; then \ echo "Cloud Hypervisor binary not found: $$CH_BIN"; \ diff --git a/lib/hypervisor/cloudhypervisor/cloudhypervisor.go b/lib/hypervisor/cloudhypervisor/cloudhypervisor.go index 6b3b4a781..a70a98607 100644 --- a/lib/hypervisor/cloudhypervisor/cloudhypervisor.go +++ b/lib/hypervisor/cloudhypervisor/cloudhypervisor.go @@ -73,7 +73,7 @@ func CapabilitiesForVersion(v vmm.CHVersion) hypervisor.Capabilities { SupportsSnapshotBaseReuse: false, } switch v { - case vmm.V51_1: + case vmm.V51_2: caps.SupportsDiskResize = true } return caps diff --git a/lib/hypervisor/cloudhypervisor/register_linux.go b/lib/hypervisor/cloudhypervisor/register_linux.go index fe03fbac6..2785198f8 100644 --- a/lib/hypervisor/cloudhypervisor/register_linux.go +++ b/lib/hypervisor/cloudhypervisor/register_linux.go @@ -7,8 +7,8 @@ import "github.com/kernel/hypeman/lib/hypervisor" // Cloud Hypervisor requires KVM, so registration — and therefore its // presence in hypervisor.RegisteredRuntimes — is Linux-only. Capabilities // are resolved per registry read from the configured default version (which -// SetDefaultVersion may change after init, e.g. pinning v49.0 without -// disk-resize) rather than frozen from the compile-time default. No +// SetDefaultVersion may change after init, e.g. legacy v49.0 instances +// without disk-resize) rather than frozen from the compile-time default. No // LaunchCheck: the binaries for every supported version ship embedded in // hypeman. func init() { diff --git a/lib/hypervisor/cloudhypervisor/register_linux_test.go b/lib/hypervisor/cloudhypervisor/register_linux_test.go index 6d2189588..fde6cb0f2 100644 --- a/lib/hypervisor/cloudhypervisor/register_linux_test.go +++ b/lib/hypervisor/cloudhypervisor/register_linux_test.go @@ -14,24 +14,22 @@ import ( // boundary: the capability registry must resolve cloud-hypervisor // capabilities from the configured default version at read time, not from a // value frozen at package init. v49.0 lacks live disk resize; advertising it -// would misreport what ordinary configured launches can do. +// would misreport what ordinary configured launches can do. v49.0 is no +// longer shipped, but legacy instances keep its capabilities. // // Not parallel: it mutates the process-wide configured default version. func TestRegisteredCapabilitiesTrackConfiguredDefaultVersion(t *testing.T) { t.Cleanup(func() { require.NoError(t, SetDefaultVersion("")) }) - require.NoError(t, SetDefaultVersion(string(vmm.V49_0))) + require.NoError(t, SetDefaultVersion(string(vmm.V51_2))) caps, ok := hypervisor.CapabilitiesForType(hypervisor.TypeCloudHypervisor) require.True(t, ok, "cloud-hypervisor must be registered on Linux") - require.False(t, caps.SupportsDiskResize, "a v49.0 default must not advertise disk-resize") - require.NotContains(t, caps.FeatureIDs(), hypervisor.FeatureDiskResize) - - require.NoError(t, SetDefaultVersion(string(vmm.V51_1))) - caps, ok = hypervisor.CapabilitiesForType(hypervisor.TypeCloudHypervisor) - require.True(t, ok) - require.True(t, caps.SupportsDiskResize, "a v51.1 default must advertise disk-resize") + require.True(t, caps.SupportsDiskResize, "a v51.2 default must advertise disk-resize") require.Contains(t, caps.FeatureIDs(), hypervisor.FeatureDiskResize) + require.False(t, CapabilitiesForVersion(vmm.CHVersion("v49.0")).SupportsDiskResize, + "a legacy v49.0 instance must not advertise disk-resize") + // The registry enumeration used by the capabilities endpoint must agree // with the per-type lookup. for _, rt := range hypervisor.RegisteredRuntimes() { diff --git a/lib/instances/create.go b/lib/instances/create.go index 2bae403f4..cecfda6b4 100644 --- a/lib/instances/create.go +++ b/lib/instances/create.go @@ -807,6 +807,26 @@ func isSystemDirectory(path string) bool { return false } +// resolveStartVersion maps the version stored in instance metadata onto one the +// starter can still launch. An upgrade can drop a build from the supported set +// (a vulnerable one, say), but a stopped instance keeps its pinned version, so a +// cold start falls back to the starter's default instead of failing forever. +// fellBack reports whether the requested version was unusable. +func resolveStartVersion(requested string, resolve func(requested string) (string, error)) (string, bool, error) { + version, err := resolve(requested) + if err == nil { + return version, false, nil + } + if requested == "" { + return "", false, err + } + fallback, fallbackErr := resolve("") + if fallbackErr != nil { + return "", false, err + } + return fallback, true, nil +} + // startAndBootVM starts the VMM and boots the VM func (m *manager) startAndBootVM( ctx context.Context, @@ -838,6 +858,21 @@ func (m *manager) startAndBootVM( stored.HypervisorVersion = resolvedVersion } + // A stored version may no longer be supported (for example a dropped + // vulnerable build); boot on the starter default instead of failing. + resolvedVersion, fellBack, err := resolveStartVersion(stored.HypervisorVersion, func(requested string) (string, error) { + return starter.ResolveVersion(m.paths, requested) + }) + if err != nil { + return fmt.Errorf("resolve version for hypervisor %s start: %w", stored.HypervisorType, err) + } + if fellBack { + log.WarnContext(ctx, "stored hypervisor version unsupported, using default", + "instance_id", stored.Id, "hypervisor", stored.HypervisorType, + "stored_version", stored.HypervisorVersion, "version", resolvedVersion) + } + stored.HypervisorVersion = resolvedVersion + // Build VM configuration inst := &Instance{StoredMetadata: *stored} vmConfig, err := m.buildHypervisorConfig(ctx, inst, imageInfo, netConfig) diff --git a/lib/instances/hypervisor_version_fallback_test.go b/lib/instances/hypervisor_version_fallback_test.go new file mode 100644 index 000000000..771e4db04 --- /dev/null +++ b/lib/instances/hypervisor_version_fallback_test.go @@ -0,0 +1,117 @@ +package instances + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/kernel/hypeman/lib/hypervisor" + "github.com/kernel/hypeman/lib/images" + "github.com/kernel/hypeman/lib/paths" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestResolveStartVersion(t *testing.T) { + unsupported := errors.New("unsupported cloud-hypervisor version: v51.1") + + resolver := func(requested string) (string, error) { + if requested == "" { + return "v51.2", nil + } + if requested != "v51.2" { + return "", unsupported + } + return requested, nil + } + + t.Run("supported version is kept", func(t *testing.T) { + version, fellBack, err := resolveStartVersion("v51.2", resolver) + require.NoError(t, err) + assert.Equal(t, "v51.2", version) + assert.False(t, fellBack) + }) + + t.Run("removed version falls back to default", func(t *testing.T) { + version, fellBack, err := resolveStartVersion("v51.1", resolver) + require.NoError(t, err) + assert.Equal(t, "v51.2", version) + assert.True(t, fellBack) + }) + + t.Run("both resolutions failing returns the error", func(t *testing.T) { + _, _, err := resolveStartVersion("v51.1", func(string) (string, error) { + return "", unsupported + }) + require.ErrorIs(t, err, unsupported) + }) +} + +// versionFallbackStarter mimics a host where only the default version exists. +type versionFallbackStarter struct { + startedVersion string +} + +func (s *versionFallbackStarter) ValidateConfig(hypervisor.VMConfig) error { return nil } +func (s *versionFallbackStarter) SocketName() string { return "version-fallback.sock" } +func (s *versionFallbackStarter) GetBinaryPath(*paths.Paths, string) (string, error) { + return "", nil +} +func (s *versionFallbackStarter) GetVersion(*paths.Paths) (string, error) { return "v51.2", nil } +func (s *versionFallbackStarter) ResolveVersion(_ *paths.Paths, requested string) (string, error) { + if requested == "" || requested == "v51.2" { + return "v51.2", nil + } + return "", fmt.Errorf("unsupported cloud-hypervisor version: %s", requested) +} +func (s *versionFallbackStarter) StartVM(_ context.Context, _ *paths.Paths, version, _ string, _ hypervisor.VMConfig) (int, hypervisor.Hypervisor, error) { + s.startedVersion = version + return 0, lifecycleNoopHypervisor{state: hypervisor.StateRunning}, nil +} +func (s *versionFallbackStarter) RestoreVM(context.Context, *paths.Paths, string, string, string) (int, hypervisor.Hypervisor, error) { + return 0, nil, fmt.Errorf("restore must not be attempted") +} +func (s *versionFallbackStarter) PrepareFork(context.Context, hypervisor.ForkPrepareRequest) (hypervisor.ForkPrepareResult, error) { + return hypervisor.ForkPrepareResult{}, nil +} + +// TestStartAndBootVMFallsBackForRemovedVersion drives a cold start whose +// on-disk metadata pins a version the starter no longer supports. +func TestStartAndBootVMFallsBackForRemovedVersion(t *testing.T) { + mgr, dataDir := setupTestManager(t) + hvType := hypervisor.Type("version-fallback-test") + starter := &versionFallbackStarter{} + mgr.vmStarters[hvType] = starter + + id := "version-fallback" + dir := filepath.Join(dataDir, "guests", id) + require.NoError(t, os.MkdirAll(dir, 0o755)) + seed := StoredMetadata{ + Id: id, + Name: id, + HypervisorType: hvType, + HypervisorVersion: "v51.1", + KernelVersion: "ch-v6.12.9", + SocketPath: filepath.Join(dir, "version-fallback.sock"), + } + raw, err := json.Marshal(&seed) + require.NoError(t, err) + require.NoError(t, os.WriteFile(filepath.Join(dir, "metadata.json"), raw, 0o644)) + + loaded, err := mgr.loadMetadata(id) + require.NoError(t, err) + require.Equal(t, "v51.1", loaded.HypervisorVersion) + + img := &images.Image{Name: "proof", Digest: "sha256:" + strings.Repeat("0", 64)} + err = mgr.startAndBootVM(context.Background(), &loaded.StoredMetadata, img, nil, true) + t.Logf("startAndBootVM: %v, StartVM version: %q, stored version: %q", + err, starter.startedVersion, loaded.HypervisorVersion) + require.NoError(t, err) + assert.Equal(t, "v51.2", starter.startedVersion) + assert.Equal(t, "v51.2", loaded.HypervisorVersion) +} diff --git a/lib/instances/manager_test.go b/lib/instances/manager_test.go index c85a7f72c..341a059aa 100644 --- a/lib/instances/manager_test.go +++ b/lib/instances/manager_test.go @@ -1422,7 +1422,7 @@ func TestStorageOperations(t *testing.T) { Env: map[string]string{"TEST": "value"}, CreatedAt: time.Now(), HypervisorType: hypervisor.TypeCloudHypervisor, - HypervisorVersion: string(vmm.V51_1), + HypervisorVersion: string(vmm.V51_2), SocketPath: "/tmp/test.sock", DataDir: paths.New(tmpDir).InstanceDir("test-123"), } diff --git a/lib/instances/restore_image_missing_test.go b/lib/instances/restore_image_missing_test.go index 8d102966c..fdaecca84 100644 --- a/lib/instances/restore_image_missing_test.go +++ b/lib/instances/restore_image_missing_test.go @@ -28,7 +28,7 @@ func TestRestoreInstanceMissingImageReturnsNotFoundFast(t *testing.T) { Vcpus: 1, CreatedAt: time.Now(), HypervisorType: hypervisor.TypeCloudHypervisor, - HypervisorVersion: string(vmm.V51_1), + HypervisorVersion: string(vmm.V51_2), // A socket path that does not exist forces deriveState down the // no-socket branch, where a present snapshot dir yields Standby. SocketPath: filepath.Join(tmpDir, id, "nonexistent.sock"), diff --git a/lib/instances/types.go b/lib/instances/types.go index db171e488..629326b32 100644 --- a/lib/instances/types.go +++ b/lib/instances/types.go @@ -144,7 +144,7 @@ type StoredMetadata struct { // Hypervisor configuration HypervisorType hypervisor.Type // Hypervisor type (e.g., "cloud-hypervisor") - HypervisorVersion string // Hypervisor version (e.g., "v51.1") + HypervisorVersion string // Hypervisor version (e.g., "v51.2") // Embedded so its fields keep their flat JSON keys in persisted metadata. HypervisorProcessIdentity diff --git a/lib/instances/version_upgrade_test.go b/lib/instances/version_upgrade_test.go index 3b93eb54f..ab255cc3d 100644 --- a/lib/instances/version_upgrade_test.go +++ b/lib/instances/version_upgrade_test.go @@ -18,11 +18,9 @@ import ( "github.com/stretchr/testify/require" ) -// TestCloudHypervisorVersionUpgradeRestore verifies that instances created on -// one CH version can be put in standby and restored after the default version -// changes. This tests the backwards-compatible upgrade path: deploy new binary -// with both versions embedded, flip the flag, and existing standbys still -// restore using their original version. +// TestCloudHypervisorVersionUpgradeRestore verifies that a standby instance is +// restored with the CH version stored in its metadata, while new instances +// follow the configured default version. func TestCloudHypervisorVersionUpgradeRestore(t *testing.T) { t.Parallel() if _, err := os.Stat("/dev/kvm"); os.IsNotExist(err) { @@ -64,8 +62,8 @@ func TestCloudHypervisorVersionUpgradeRestore(t *testing.T) { _ = cloudhypervisor.SetDefaultVersion("") }) - // Phase 1: Create instance with explicit v49.0 version - t.Log("Creating instance with CH v49.0...") + // Phase 1: Create instance with an explicit version + t.Log("Creating instance with an explicit CH version...") inst, err := mgr.CreateInstance(ctx, CreateInstanceRequest{ Name: "version-upgrade-test", Image: integrationTestImageRef(t, "docker.io/library/alpine:latest"), @@ -74,11 +72,11 @@ func TestCloudHypervisorVersionUpgradeRestore(t *testing.T) { Vcpus: 1, NetworkEnabled: false, Hypervisor: hypervisor.TypeCloudHypervisor, - HypervisorVersion: string(vmm.V49_0), + HypervisorVersion: string(vmm.V51_2), Cmd: []string{"sleep", "infinity"}, }) require.NoError(t, err) - assert.Equal(t, string(vmm.V49_0), inst.HypervisorVersion) + assert.Equal(t, string(vmm.V51_2), inst.HypervisorVersion) t.Logf("Instance created: %s (version: %s)", inst.Id, inst.HypervisorVersion) inst, err = waitForInstanceState(ctx, mgr, inst.Id, StateRunning, integrationTestTimeout(20*time.Second)) @@ -94,25 +92,25 @@ func TestCloudHypervisorVersionUpgradeRestore(t *testing.T) { require.NoError(t, err) assert.Equal(t, StateStandby, inst.State) assert.True(t, inst.HasSnapshot) - assert.Equal(t, string(vmm.V49_0), inst.HypervisorVersion) + assert.Equal(t, string(vmm.V51_2), inst.HypervisorVersion) - // Phase 3: Change default version to v51.1 (simulates a deploy with new config) - t.Log("Switching default CH version to v51.1...") - require.NoError(t, cloudhypervisor.SetDefaultVersion(string(vmm.V51_1))) + // Phase 3: Set the default version (simulates a deploy with new config) + t.Log("Setting default CH version...") + require.NoError(t, cloudhypervisor.SetDefaultVersion(string(vmm.V51_2))) - // Phase 4: Restore -- must use the stored v49.0, not the new default - t.Log("Restoring instance (should use stored v49.0)...") + // Phase 4: Restore -- must use the stored version + t.Log("Restoring instance (should use stored version)...") inst, err = mgr.RestoreInstance(ctx, inst.Id) require.NoError(t, err) inst, err = waitForInstanceState(ctx, mgr, inst.Id, StateRunning, integrationTestTimeout(20*time.Second)) require.NoError(t, err) assert.Equal(t, StateRunning, inst.State) - assert.Equal(t, string(vmm.V49_0), inst.HypervisorVersion, - "Restored instance must use original version, not the new default") + assert.Equal(t, string(vmm.V51_2), inst.HypervisorVersion, + "Restored instance must use its stored version") t.Logf("Instance restored with version: %s", inst.HypervisorVersion) - // Phase 5: Verify a NEW instance picks up the v51.1 default - t.Log("Creating second instance (should use v51.1 via default)...") + // Phase 5: Verify a NEW instance picks up the configured default + t.Log("Creating second instance (should use the default version)...") inst2, err := mgr.CreateInstance(ctx, CreateInstanceRequest{ Name: "version-upgrade-new", Image: integrationTestImageRef(t, "docker.io/library/alpine:latest"), @@ -124,7 +122,7 @@ func TestCloudHypervisorVersionUpgradeRestore(t *testing.T) { Cmd: []string{"sleep", "infinity"}, }) require.NoError(t, err) - assert.Equal(t, string(vmm.V51_1), inst2.HypervisorVersion, + assert.Equal(t, string(vmm.V51_2), inst2.HypervisorVersion, "New instance should use the updated default version") t.Logf("New instance created: %s (version: %s)", inst2.Id, inst2.HypervisorVersion) diff --git a/lib/system/README.md b/lib/system/README.md index 119363edb..780b4be37 100644 --- a/lib/system/README.md +++ b/lib/system/README.md @@ -37,8 +37,8 @@ Manages versioned kernel and initrd files for Cloud Hypervisor VMs. **Snapshots require exact matches:** ``` -Standby: kernel ch-6.12.8-kernel-1.2-20251213, CH v51.1 -Restore: kernel ch-6.12.8-kernel-1.2-20251213, CH v51.1 (MUST match) +Standby: kernel ch-6.12.8-kernel-1.2-20251213, CH v51.2 +Restore: kernel ch-6.12.8-kernel-1.2-20251213, CH v51.2 (MUST match) ``` **Maintenance upgrades (shutdown → boot):** diff --git a/lib/vmm/README.md b/lib/vmm/README.md index f8b7e23c8..b92ca61f9 100644 --- a/lib/vmm/README.md +++ b/lib/vmm/README.md @@ -38,7 +38,7 @@ dataDir := "/var/lib/hypeman" socketPath := "/tmp/vmm.sock" // Start Cloud Hypervisor VMM (extracts binary if needed) -err := vmm.StartProcess(ctx, dataDir, vmm.V51_1, socketPath) +err := vmm.StartProcess(ctx, dataDir, vmm.V51_2, socketPath) if err != nil { log.Fatal(err) } @@ -60,9 +60,9 @@ resp, err := client.GetVmmPingWithResponse(ctx) ### Check Binary Version ```go -binaryPath, _ := vmm.GetBinaryPath(dataDir, vmm.V51_1) +binaryPath, _ := vmm.GetBinaryPath(dataDir, vmm.V51_2) version, err := vmm.ParseVersion(binaryPath) -fmt.Println(version) // "v51.1" +fmt.Println(version) // "v51.2" ``` ## Architecture @@ -75,10 +75,7 @@ lib/vmm/ ├── version.go # Version parsing utilities ├── binaries/ # Embedded Cloud Hypervisor binaries │ └── cloud-hypervisor/ -│ ├── v49.0/ -│ │ ├── x86_64/cloud-hypervisor -│ │ └── aarch64/cloud-hypervisor -│ └── v51.1/ +│ └── v51.2/ │ ├── x86_64/cloud-hypervisor │ └── aarch64/cloud-hypervisor └── client_test.go # Tests with real Cloud Hypervisor @@ -86,14 +83,13 @@ lib/vmm/ ## Supported Versions -- Cloud Hypervisor v49.0 (API v0.3.0) -- Cloud Hypervisor v51.1 (API v0.3.0) +- Cloud Hypervisor v51.2 (API v0.3.0) Cloud Hypervisor versions may update frequently while the API updates less frequently. All embedded versions currently share the same API spec. ## Multi-Version Support -Multiple CH versions are embedded to support zero-downtime upgrades. Snapshot restore requires the exact CH binary version that created the snapshot, so both old and new binaries must be available during the migration window. +Only v51.2 is embedded; earlier releases were removed because of CVE-2026-45782. Snapshot restore requires the exact CH binary version that created the snapshot, so instances snapshotted on a removed version must be shut down and recreated before upgrading. `DefaultVersion` in `binaries.go` controls which version is used for new instances. Operators can override it via the `hypervisor.cloud_hypervisor_default_version` config field. Existing instances always restore using the version stored in their metadata. diff --git a/lib/vmm/binaries_darwin.go b/lib/vmm/binaries_darwin.go index 5c46eaf52..aac3df490 100644 --- a/lib/vmm/binaries_darwin.go +++ b/lib/vmm/binaries_darwin.go @@ -12,11 +12,10 @@ import ( type CHVersion string const ( - V49_0 CHVersion = "v49.0" - V51_1 CHVersion = "v51.1" + V51_2 CHVersion = "v51.2" ) -const DefaultVersion = V51_1 +const DefaultVersion = V51_2 // SupportedVersions lists supported Cloud Hypervisor versions. // On macOS, Cloud Hypervisor is not supported (use vz instead). diff --git a/lib/vmm/binaries_linux.go b/lib/vmm/binaries_linux.go index 6856b7898..8dafde1a8 100644 --- a/lib/vmm/binaries_linux.go +++ b/lib/vmm/binaries_linux.go @@ -13,22 +13,21 @@ import ( "github.com/kernel/hypeman/lib/paths" ) -//go:embed binaries/cloud-hypervisor/v49.0/x86_64/cloud-hypervisor -//go:embed binaries/cloud-hypervisor/v49.0/aarch64/cloud-hypervisor -//go:embed binaries/cloud-hypervisor/v51.1/x86_64/cloud-hypervisor -//go:embed binaries/cloud-hypervisor/v51.1/aarch64/cloud-hypervisor +// Older releases were dropped: CVE-2026-45782 affects every release before 51.2. +// +//go:embed binaries/cloud-hypervisor/v51.2/x86_64/cloud-hypervisor +//go:embed binaries/cloud-hypervisor/v51.2/aarch64/cloud-hypervisor var binaryFS embed.FS type CHVersion string const ( - V49_0 CHVersion = "v49.0" - V51_1 CHVersion = "v51.1" + V51_2 CHVersion = "v51.2" ) -const DefaultVersion = V51_1 +const DefaultVersion = V51_2 -var SupportedVersions = []CHVersion{V49_0, V51_1} +var SupportedVersions = []CHVersion{V51_2} // ExtractBinary extracts the embedded Cloud Hypervisor binary to the data directory func ExtractBinary(p *paths.Paths, version CHVersion) (string, error) { diff --git a/lib/vmm/client_test.go b/lib/vmm/client_test.go index 483ffc4fb..891797822 100644 --- a/lib/vmm/client_test.go +++ b/lib/vmm/client_test.go @@ -17,8 +17,8 @@ import ( func TestExtractBinary(t *testing.T) { tmpDir := t.TempDir() - // Test extraction for v51.1 - binaryPath, err := ExtractBinary(paths.New(tmpDir), V51_1) + // Test extraction for v51.2 + binaryPath, err := ExtractBinary(paths.New(tmpDir), V51_2) require.NoError(t, err) // Verify file exists @@ -31,14 +31,13 @@ func TestExtractBinary(t *testing.T) { assert.Equal(t, os.FileMode(0755), info.Mode().Perm()) // Test idempotency - second extraction should succeed and return same path - binaryPath2, err := ExtractBinary(paths.New(tmpDir), V51_1) + binaryPath2, err := ExtractBinary(paths.New(tmpDir), V51_2) require.NoError(t, err) assert.Equal(t, binaryPath, binaryPath2) } func TestIsVersionSupported(t *testing.T) { - assert.True(t, IsVersionSupported(V49_0)) - assert.True(t, IsVersionSupported(V51_1)) + assert.True(t, IsVersionSupported(V51_2)) assert.False(t, IsVersionSupported("v1.0")) } @@ -46,13 +45,13 @@ func TestParseVersion(t *testing.T) { tmpDir := t.TempDir() // Extract binary - binaryPath, err := ExtractBinary(paths.New(tmpDir), V51_1) + binaryPath, err := ExtractBinary(paths.New(tmpDir), V51_2) require.NoError(t, err) // Parse version version, err := ParseVersion(binaryPath) require.NoError(t, err) - assert.Equal(t, V51_1, version) + assert.Equal(t, V51_2, version) } func TestStartProcessAndShutdown(t *testing.T) { @@ -61,7 +60,7 @@ func TestStartProcessAndShutdown(t *testing.T) { ctx := context.Background() // Start VMM process - pid, err := StartProcess(ctx, paths.New(tmpDir), V51_1, socketPath) + pid, err := StartProcess(ctx, paths.New(tmpDir), V51_2, socketPath) require.NoError(t, err) assert.Greater(t, pid, 0, "PID should be positive") @@ -96,12 +95,12 @@ func TestStartProcessSocketInUse(t *testing.T) { ctx := context.Background() // Start first VMM - pid, err := StartProcess(ctx, paths.New(tmpDir), V51_1, socketPath) + pid, err := StartProcess(ctx, paths.New(tmpDir), V51_2, socketPath) require.NoError(t, err) assert.Greater(t, pid, 0) // Try to start second VMM on same socket - should fail - _, err = StartProcess(ctx, paths.New(tmpDir), V51_1, socketPath) + _, err = StartProcess(ctx, paths.New(tmpDir), V51_2, socketPath) require.Error(t, err) assert.Contains(t, err.Error(), "socket already in use") @@ -119,8 +118,7 @@ func TestMultipleVersions(t *testing.T) { name string version CHVersion }{ - {"v49.0", V49_0}, - {"v51.1", V51_1}, + {"v51.2", V51_2}, } for _, tt := range tests { @@ -160,7 +158,7 @@ func TestStartProcessCreatesLogFiles(t *testing.T) { ctx := context.Background() // Start VMM process with verbose logging to ensure output is written - pid, err := StartProcessWithArgs(ctx, paths.New(tmpDir), V51_1, socketPath, []string{"-v"}) + pid, err := StartProcessWithArgs(ctx, paths.New(tmpDir), V51_2, socketPath, []string{"-v"}) require.NoError(t, err) assert.Greater(t, pid, 0) @@ -200,7 +198,7 @@ func TestStartProcessDoesNotInheritEnvironment(t *testing.T) { socketPath := filepath.Join(tmpDir, "test.sock") ctx := context.Background() - pid, err := StartProcess(ctx, paths.New(tmpDir), V51_1, socketPath) + pid, err := StartProcess(ctx, paths.New(tmpDir), V51_2, socketPath) require.NoError(t, err) client, err := NewVMM(socketPath) diff --git a/lib/vmm/version.go b/lib/vmm/version.go index 5f723255f..073f3bae4 100644 --- a/lib/vmm/version.go +++ b/lib/vmm/version.go @@ -8,7 +8,7 @@ import ( // ParseVersion extracts version from cloud-hypervisor --version output // and matches it against SupportedVersions. Checks longer version strings -// first so "v49.0.1" doesn't falsely match "v49.0". +// first so "v51.2.1" doesn't falsely match "v51.2". func ParseVersion(binaryPath string) (CHVersion, error) { cmd := exec.Command(binaryPath, "--version") output, err := cmd.Output() @@ -19,7 +19,7 @@ func ParseVersion(binaryPath string) (CHVersion, error) { versionStr := strings.TrimSpace(string(output)) // Match against supported versions, longest first to avoid - // "v49.0" matching inside "v49.0.1". + // "v51.2" matching inside "v51.2.1". for _, v := range sortedByLengthDesc(SupportedVersions) { if strings.Contains(versionStr, string(v)) { return v, nil