Skip to content

feat(cloud-hypervisor): expose a configurable REST API control socket - #847

Open
Anamika1608 wants to merge 9 commits into
urunc-dev:mainfrom
Anamika1608:cloud-hypervisor-socket
Open

feat(cloud-hypervisor): expose a configurable REST API control socket#847
Anamika1608 wants to merge 9 commits into
urunc-dev:mainfrom
Anamika1608:cloud-hypervisor-socket

Conversation

@Anamika1608

Copy link
Copy Markdown
Contributor

Description

Expose Cloud Hypervisor's REST API over a control socket so the runtime can talk to the monitor after the guest starts (for graceful shutdown, and later snapshots).

  • cloud_hypervisor.go launches with --api-socket path=<socket_path>.
  • The socket path is configurable via a socket_path monitor field; when a custom path is set, urunc creates its parent directory inside the monitor rootfs. Default is a per-container path under /tmp.

This PR is self-contained against main: it carries a small copy of the shared socket infrastructure (socket_path field, ResolveSocketPath, DefaultSocketDir, UsesControlSocket, the socket-directory creation). The same infra also appears in the Firecracker (#809) and QEMU (#841) PRs; whichever merges first lands it, and this PR then rebases to drop the duplicate. This PR does not touch firecracker.go or qemu.go.

Related issues

How was this tested?

  • go build ./..., go test ./pkg/... ./internal/..., gofmt, and cspell pass (Ubuntu 24.04 aarch64 VM, KVM, Cloud Hypervisor v53).
  • Full guest-boot verification on aarch64 is currently blocked: no aarch64 Cloud Hypervisor image is published in the registry (the ubuntu-cloud-hypervisor-linux-raw and chttp-cloud-hypervisor-* variants return 404), and Cloud Hypervisor v53 has a known raw-disk/console issue on aarch64, both unrelated to this change. The --api-socket wiring itself is covered by the unit tests and the shared ResolveSocketPath tests. Once an aarch64 image is available, the socket can be verified answering /api/v1/vm.info, the same way Firecracker (feat(firecracker): launch with control socket instead of config file #809) and QEMU (feat(qemu): expose a configurable QMP control socket #841) were verified.

LLM usage

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
@netlify

netlify Bot commented Jul 25, 2026

Copy link
Copy Markdown

Deploy Preview for urunc ready!

Name Link
🔨 Latest commit ddfc0e3
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a6841c39a27f2000802a7e8
😎 Deploy Preview https://deploy-preview-847--urunc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Add an opt-in boot_mode field to the monitor configuration. It is
inert in this commit; the following commit makes cloud-hypervisor
honor boot_mode=api.

Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
With boot_mode=api, Cloud Hypervisor is spawned after changeRoot as a
supervised child with only its API socket enabled, so the monitor and
the socket are confined inside the monitor rootfs. urunc sends the
whole VM configuration with vm.create and boots the guest with vm.boot
only after the start-success handshake, preserving OCI start ordering,
then supervises the child for its lifetime. Any other boot_mode value
keeps the exec-based boot unchanged.

Unikernel-specific raw CLI argument overrides cannot be expressed in
the REST configuration and yield a clear error in this mode.

Add an HTTP-over-Unix API client and unit tests driving it against a
fake REST server, asserting the full vm.create payload and ordering.

Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
createTapDevice relies on a later syscall.Exec into the monitor to
close the tap device fd that netlink.LinkAdd opened (O_CLOEXEC). In any
flow where urunc keeps running instead of exec-ing away, the fd stays
open and, since the tap device is single-queue, blocks the monitor from
attaching to it ("Resource busy").

Close the fd explicitly after the owner and group are set (handling the
close error), and add the author to contributors.

Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant