2 * QEMU Xen emulation: The actual implementation of XenStore
4 * Copyright © 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
6 * Authors: David Woodhouse <dwmw2@infradead.org>, Paul Durrant <paul@xen.org>
8 * This work is licensed under the terms of the GNU GPL, version 2 or later.
9 * See the COPYING file in the top-level directory.
12 #include "qemu/osdep.h"
14 #include "xen_xenstore.h"
15 #include "xenstore_impl.h"
17 struct XenstoreImplState {
20 int xs_impl_read(XenstoreImplState *s, unsigned int dom_id,
21 xs_transaction_t tx_id, const char *path, GByteArray *data)
24 * The data GByteArray shall exist, and will be freed by caller.
25 * Just g_byte_array_append() to it.
30 int xs_impl_write(XenstoreImplState *s, unsigned int dom_id,
31 xs_transaction_t tx_id, const char *path, GByteArray *data)
34 * The data GByteArray shall exist, will be freed by caller. You are
35 * free to use g_byte_array_steal() and keep the data.
40 int xs_impl_directory(XenstoreImplState *s, unsigned int dom_id,
41 xs_transaction_t tx_id, const char *path,
42 uint64_t *gencnt, GList **items)
45 * The items are (char *) to be freed by caller. Although it's consumed
46 * immediately so if you want to change it to (const char *) and keep
47 * them, go ahead and change the caller.
52 int xs_impl_transaction_start(XenstoreImplState *s, unsigned int dom_id,
53 xs_transaction_t *tx_id)
58 int xs_impl_transaction_end(XenstoreImplState *s, unsigned int dom_id,
59 xs_transaction_t tx_id, bool commit)
64 int xs_impl_rm(XenstoreImplState *s, unsigned int dom_id,
65 xs_transaction_t tx_id, const char *path)
70 int xs_impl_get_perms(XenstoreImplState *s, unsigned int dom_id,
71 xs_transaction_t tx_id, const char *path, GList **perms)
74 * The perms are (char *) in the <perm-as-string> wire format to be
75 * freed by the caller.
80 int xs_impl_set_perms(XenstoreImplState *s, unsigned int dom_id,
81 xs_transaction_t tx_id, const char *path, GList *perms)
84 * The perms are (const char *) in the <perm-as-string> wire format.
89 int xs_impl_watch(XenstoreImplState *s, unsigned int dom_id, const char *path,
90 const char *token, xs_impl_watch_fn fn, void *opaque)
93 * When calling the callback @fn, note that the path should
94 * precisely match the relative path that the guest provided, even
95 * if it was a relative path which needed to be prefixed with
96 * /local/domain/${domid}/
101 int xs_impl_unwatch(XenstoreImplState *s, unsigned int dom_id,
102 const char *path, const char *token,
103 xs_impl_watch_fn fn, void *opaque)
105 /* Remove the watch that matches all four criteria */
109 int xs_impl_reset_watches(XenstoreImplState *s, unsigned int dom_id)
114 XenstoreImplState *xs_impl_create(void)
116 return g_new0(XenstoreImplState, 1);