Skip to content

xen-store: support XenStore access through /dev/xen/xenbus - #20

Open
lkpdn wants to merge 3 commits into
rust-vmm:mainfrom
lkpdn:pr-xenstore-device-transport
Open

xen-store: support XenStore access through /dev/xen/xenbus#20
lkpdn wants to merge 3 commits into
rust-vmm:mainfrom
lkpdn:pr-xenstore-device-transport

Conversation

@lkpdn

@lkpdn lkpdn commented Aug 24, 2026

Copy link
Copy Markdown

Summary of the PR

XenStoreHandle::new() currently connects only through the Unix domain socket, which is normally unavailable in a driver domain. Linux exposes XenStore through /dev/xen/xenbus.

First abstract the transport I/O without changing the socket path, then add the device fallback. Open the device with O_NONBLOCK and poll it with a shutdown eventfd so partial reads remain interruptible.

Dependency

Depends-on: #18
(This branch is stacked on #18. The last two commits are new here.)

Requirements

  • All commits in this PR have Signed-Off-By trailers (with
    git commit -s), and the commit message has max 60 characters for the
    summary and max 75 characters for each description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

@lkpdn
lkpdn force-pushed the pr-xenstore-device-transport branch from 2d77dae to 1622572 Compare August 27, 2026 14:49
lkpdn added 3 commits August 27, 2026 23:57
xs_transaction() writes the request header with write_all(), then sends
the payload with one writev(). A short write leaves XenStore waiting for
the rest while the client waits for a reply. EINTR leaves the header
stranded on the stream.

Build each payload as one byte buffer and use write_all() for both
parts. This retries short writes and EINTR, and removes the raw iovec
handling and nix dependency.

Add deterministic coverage for both cases.

Fixes: 43a2751 ("Add support for Xen store API")
Signed-off-by: Koichiro Den <den@valinux.co.jp>
The XenStore client stores and operates directly on UnixStream objects.
This ties protocol handling to the XenStore Unix domain socket
transport.

Introduce XenStoreTransport and route cloning, reads, writes, and
shutdown through it. Keep UnixStream as the only transport in this
patch.

Add a socket-pair test covering the refactored protocol path and idle
reader shutdown.

No functional change intended.

Signed-off-by: Koichiro Den <den@valinux.co.jp>
XenStoreHandle::new() connects only through a Unix domain socket,
which is normally unavailable in a driver domain. On Linux,
/dev/xen/xenbus exposes the kernel's XenStore connection to user space
as a character device. Follow xs_open() in libxenstore by trying this
interface when the socket connection fails.

Unlike a socket, this character device cannot use shutdown(2) to wake
a blocked reader, and std::thread has no equivalent to libxenstore's
use of pthread_cancel(). Do a simple cooperative shutdown instead:
open the device with O_NONBLOCK and poll it together with a shutdown
eventfd before each read. This keeps partial reads interruptible without
relying on Linux to make complete XenStore messages available before
waking readers.

Add tests for fallback and shutdown of the character device reader,
including shutdown after partial data and while input is ready.

Signed-off-by: Koichiro Den <den@valinux.co.jp>
@lkpdn
lkpdn force-pushed the pr-xenstore-device-transport branch from 1622572 to 21d85ad Compare August 27, 2026 14:59
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