Skip to content

Cloud Hypervisor BuildExecCmd should not add two --initramfs flags #679

@mdryaan

Description

@mdryaan

Description

BuildExecCmd in pkg/unikontainers/hypervisors/cloud_hypervisor.go adds --initramfs unconditionally when args.InitrdPath is non-empty, then adds --initramfs again if extraMonArgs.ExtraInitrd is also non-empty. Cloud Hypervisor does not accept multiple --initramfs flags and rejects the command. The Firecracker implementation in the same codebase handles this correctly by preferring args.InitrdPath and falling back to extraMonArgs.ExtraInitrd only when the former is empty.

Steps to reproduce

Add a test that builds a Cloud Hypervisor exec command with both args.InitrdPath and extraMonArgs.ExtraInitrd set:

go test ./pkg/unikontainers/hypervisors/ -v -run TestCloudHypervisorSingleInitrd
Image

The test asserts that the resulting argument slice contains exactly one --initramfs flag. Before the fix, the slice contains two and the assertion fails.

Expected behavior: The Cloud Hypervisor command line contains at most one --initramfs flag. When both paths are set, args.InitrdPath takes precedence.

Current behavior: When both args.InitrdPath and extraMonArgs.ExtraInitrd are set, the command line contains two --initramfs flags and Cloud Hypervisor rejects it.

Proposed solution: Apply the same priority logic used in the Firecracker implementation: resolve the initrd path to args.InitrdPath if set, otherwise fall back to extraMonArgs.ExtraInitrd. Pass the single resolved path to --initramfs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions