feat(qemu): expose a configurable QMP control socket - #841
Conversation
✅ Deploy Preview for urunc ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
74479f7 to
7bc678b
Compare
|
hi @cmainas, a couple of things on this PR i wanted to check with you. 1. socket_path and the /tmp constraint the socket_path field works, but there is a constraint: the monitor creates the socket inside its own pivoted rootfs (after changeRoot), and that rootfs only has a standard set of directories. so a custom socket_path has to be placed under /tmp, which is always present there. i verified this end to end: with is keeping socket_path scoped to /tmp fine for now, or do you want it fully configurable? 2. testing the other monitors i wired the socket for qemu (a QMP socket) and cloud hypervisor (its REST api socket) too, both honoring socket_path. for qemu i was able to test it fully end to end: i found for cloud hypervisor i could only cover it with unit tests (asserting the launch args), because i could not find an aarch64 cloud hypervisor image in the registry. i probed a few names (chttp/busybox/nginx variants of is there an aarch64 cloud hypervisor image i can use to test it end to end, or is x86 only expected there for now? |
|
Hello @Anamika1608 ,
The default location can be
I have created the |
|
hi @cmainas, did both things you mentioned.
default stays
the socket part works: it launches with the guest does not boot though, looks like the aarch64 issue you warned about. so the socket is verified on all three monitors now. |
0647fcb to
2e20d7d
Compare
Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
2e20d7d to
02c0ac8
Compare
Add an opt-in boot_mode field to the monitor configuration. It is inert in this commit; the following commit makes qemu honor boot_mode=api. Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
With boot_mode=api, QEMU is spawned after changeRoot as a supervised child with its CPUs frozen (-S), so the monitor and its QMP socket are confined inside the monitor rootfs. urunc performs the QMP handshake and sends cont only after the start-success handshake, preserving OCI start ordering, then supervises the child for its lifetime. The machine configuration itself stays on the command line: QMP cannot configure a machine, so for QEMU the api mode drives only the guest's start. Any other boot_mode value keeps the exec-based boot unchanged. Add a QMP client implementing the handshake and single commands, and unit tests driving it against a fake QMP server on a Unix socket. 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>
Reject boot_mode=api with virtiofs sharedfs up front, since QMP cannot be sequenced ahead of virtiofsd's own startup. Pass real stdin through to the paused QEMU child, matching the exec path's -serial stdio. Bound every QMP read/write with a deadline instead of only the initial dial, and restore the SIGKILL-cannot-be-caught note on Supervise. Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
Signed-off-by: Anamika Aggarwal <anamikaagg18@gmail.com>
Description
Expose QEMU's QMP control socket so the runtime can talk to the monitor after the guest starts (for graceful shutdown, and later snapshots). QEMU still boots from its CLI arguments as before; this only adds the socket for post-boot control.
qemu.golaunches with-qmp unix:<socket_path>,server,nowaitalongside the existing-monitor null;server,nowaitlets QEMU boot without waiting for a client to connect.socket_pathmonitor 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_pathfield,ResolveSocketPath,DefaultSocketDir,UsesControlSocket, the socket-directory creation). The same infra also appears in the Firecracker PR (#809); whichever merges first lands it, and this PR then rebases to drop the duplicate. This PR does not touchfirecracker.go.Related issues
How was this tested?
go build ./...,go test ./pkg/... ./internal/...,gofmt, and cspell pass;TestQemuBuildExecCmdcovers the-qmpstring for both a configuredsocket_pathand the default path (Ubuntu 24.04 aarch64 VM, KVM, QEMU 10.2.1).chttp-qemu-linux-aarch64boots, the guest serves HTTP 200,qemu-system-aarch64launches with-qmp unix:/tmp/qemu.sock,server,nowait, and the QMP socket negotiates capabilities and answersquery-statuswith"status": "running".LLM usage
Checklist
make lint).make test_ctr,make test_nerdctl,make test_docker,make test_crictl).