Skip to content

fix(cloud-hypervisor): pass block devices in a single --disk flag - #990

Open
CapThunder19 wants to merge 1 commit into
urunc-dev:mainfrom
CapThunder19:fix/ch-single-disk-flag
Open

fix(cloud-hypervisor): pass block devices in a single --disk flag#990
CapThunder19 wants to merge 1 commit into
urunc-dev:mainfrom
CapThunder19:fix/ch-single-disk-flag

Conversation

@CapThunder19

Copy link
Copy Markdown

Description

CloudHypervisor.BuildExecCmd appended a separate --disk flag for each block
device. Cloud Hypervisor expects every disk as its own value after a single
--disk flag, and rejects the flag outright if it appears more than once:

error: the argument '--disk <disk>...' cannot be used multiple times

So any Linux container on cloud-hypervisor with more than one block device failed at argument
parsing and the VM was never created. A single disk worked, which is why the
existing e2e cases, all single-disk, never caught it.

This collects the generated disk specs and appends them behind one --disk.

Before:

--disk path=/rootfs.img,id=rootfs --disk path=/dev/loop0,id=vol0

After:

--disk path=/rootfs.img,id=rootfs path=/dev/loop0,id=vol0

Related issues

Fixes #988

How was this tested?

Reproduced and verified end-to-end on urunc 3395292, cloud-hypervisor v50.0.0
(the version pinned in ci.yml), x86_64. No containerd or devmapper needed: a
hand-written OCI bundle using a com.urunc.unikernel.block rootfs plus one
loop-backed ext4 volume bind-mounted in.

Before the fix, that 2-disk container:

--disk path=/rootfs.img,id=rootfs --disk path=/dev/loop0,id=vol0
error: the argument '--disk <disk>...' cannot be used multiple times

After the fix, same container:

--disk path=/rootfs.img,id=rootfs path=/dev/loop0,id=vol0

No argument error. Cloud Hypervisor proceeds to kernel loading and stops only on
the placeholder kernel I used (KernelLoad(Bzimage(InvalidBzImage))), matching
what a single-disk container did before the change.

Also ran go build ./..., go vet ./pkg/unikontainers/hypervisors/..., gofmt
and the ./pkg/unikontainers/... unit tests. All pass.

  • I have read the contribution guide.
  • The linter passes locally (make lint). golangci-lint v2.9 reports no new issues from this change; the 4 it flags (1 ineffassign in cmd/urunc/create.go, 3 unused in pkg/containerd-shim/guest_rootfs.go) are pre-existing on main.
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).

@netlify

netlify Bot commented Aug 24, 2026

Copy link
Copy Markdown

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit 059b4b2
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a8c4af54651af00089d7539

@CapThunder19

Copy link
Copy Markdown
Author

pls review it and tell me if any change needed

@Anand-240

Copy link
Copy Markdown
Contributor

I was going through this PR and the change looks correct to me. On main the block loop adds a --disk for every device, so once there's more than one disk you get multiple --disk flags and cloud-hypervisor just refuses to start. Collecting them under a single --disk is the right fix.
While I was in that folder I noticed cloud-hypervisor doesn't have a test file yet. qemu and hyperlight both have one, so I followed that same pattern.
So I tried writing a small regression test for BuildExecCmd that checks multiple block devices end up under exactly one --disk flag. It fails on main (two flags) and passes with your change, and gofmt and go vet are both clean.
If it's useful, I can send it over. Do you want me to open a PR against your fix/ch-single-disk-flag branch so the fix and the test land together, or should I add it as a follow-up once this merges? Either works for me.

@cmainas cmainas added invalid This doesn't seem right do-not-merge labels Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cloud-hypervisor: container with more than one block device fails to start (repeated --disk flags)

3 participants