Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A Xenstore protocol implementation in pure OCaml. This code works in both regular Unix and in MirageOS applications.
OCaml Other

Merge pull request #12 from samoht/master

Update the opam file
latest commit 296ba15023
@samoht samoht authored
Failed to load latest commit information.
bench Rename xs_bench to bench
core Regenerate OASIS
core_test Improve the README example by making 'read' return an option
doc Make the xs_client_unix look more like the lwt one, renamed xs_client…
examples Add a LowLevel watch interface and use it to build an @introduceDomai…
kernelspace We need xenctrl.h to compile the domaininfolist-based domain watcher
unix Regenerate OASIS
userspace Split into 'unix' and 'xenctrl' subpackages, add configure script
xenctrl Regenerate OASIS
xs xs: add a 'watch' subcommand
.gitignore Split into 'unix' and 'xenctrl' subpackages, add configure script
.travis-ci.sh travis: add a test case without the Xen headers
.travis.yml travis: add a test case without the Xen headers
CHANGES Improve the README example by making 'read' return an option
Makefile Split into 'unix' and 'xenctrl' subpackages, add configure script
README.md README: formatting
_oasis Split into 'unix' and 'xenctrl' subpackages, add configure script
_tags Regenerate OASIS
configure Split into 'unix' and 'xenctrl' subpackages, add configure script
configure.ml Split into 'unix' and 'xenctrl' subpackages, add configure script
myocamlbuild.ml Regenerate OASIS
opam Update the opam file
setup.ml Regenerate OASIS

README.md

XenStore protocol in OCaml

Layout of this project:

  core/        : protocol parser/printer, Lwt-based client
  core_test/   : unit tests for the protocol parser/printer
  unix/        : userspace 'transport' over sockets and xenbus mmap
  mirage/      : kernelspace 'transport' for Mirage
  xs/          : example userspace CLI

This code is all available under the standard Mirage license (ISC).

How to use the client

For Unix userspace, add the ocamlfind package 'xenstore.userspace' and create a 'Client':

#use "topfind";;
#require "lwt.syntax";;
#require "xenstore.userspace";;

open Lwt
module Client = Xenstore.Client.Make(Userspace)

To perform a single non-transactional read or wrote:

lwt my_domid = Client.(immediate (read_exn "domid"));;

To perform a transactional update:

Client.(transaction (
  let open M in
  write "a" "b" >>= fun () ->
  write "c" "d" >>= fun () ->
  return ()
))

To wait for a condition to be met:

Client.(wait (
  let open M in
  read "hotplug-status" >>= fun status ->
  read "hotplug-error" >>= fun error ->
  match status, error with
  | None, None -> return `Retry
  | _, Some error -> return (`Error error)
  | Some status, _ -> return (`Ok status)
))

Open issues

  1. Xenstore.Client.Make is a nice name. Global 'Userspace' and 'Kernelspace' are a bit rude. Can these be made part of the Xenstore.* space somehow, even through they are optional?
Something went wrong with that request. Please try again.