1 /* 2 * QEMU Xen emulation: The actual implementation of XenStore 3 * 4 * Copyright © 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. 5 * 6 * Authors: David Woodhouse <dwmw2@infradead.org> 7 * 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. 10 */ 11 12 #ifndef QEMU_XENSTORE_IMPL_H 13 #define QEMU_XENSTORE_IMPL_H 14 15 typedef uint32_t xs_transaction_t; 16 17 #define XBT_NULL 0 18 19 #define XS_PERM_NONE 0x00 20 #define XS_PERM_READ 0x01 21 #define XS_PERM_WRITE 0x02 22 23 typedef struct XenstoreImplState XenstoreImplState; 24 25 XenstoreImplState *xs_impl_create(unsigned int dom_id); 26 27 char *xs_perm_as_string(unsigned int perm, unsigned int domid); 28 29 /* 30 * These functions return *positive* error numbers. This is a little 31 * unconventional but it helps to keep us honest because there is 32 * also a very limited set of error numbers that they are permitted 33 * to return (those in xsd_errors). 34 */ 35 36 int xs_impl_read(XenstoreImplState *s, unsigned int dom_id, 37 xs_transaction_t tx_id, const char *path, GByteArray *data); 38 int xs_impl_write(XenstoreImplState *s, unsigned int dom_id, 39 xs_transaction_t tx_id, const char *path, GByteArray *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); 43 int xs_impl_transaction_start(XenstoreImplState *s, unsigned int dom_id, 44 xs_transaction_t *tx_id); 45 int xs_impl_transaction_end(XenstoreImplState *s, unsigned int dom_id, 46 xs_transaction_t tx_id, bool commit); 47 int xs_impl_rm(XenstoreImplState *s, unsigned int dom_id, 48 xs_transaction_t tx_id, const char *path); 49 int xs_impl_get_perms(XenstoreImplState *s, unsigned int dom_id, 50 xs_transaction_t tx_id, const char *path, GList **perms); 51 int xs_impl_set_perms(XenstoreImplState *s, unsigned int dom_id, 52 xs_transaction_t tx_id, const char *path, GList *perms); 53 54 /* This differs from xs_watch_fn because it has the token */ 55 typedef void(xs_impl_watch_fn)(void *opaque, const char *path, 56 const char *token); 57 int xs_impl_watch(XenstoreImplState *s, unsigned int dom_id, const char *path, 58 const char *token, xs_impl_watch_fn fn, void *opaque); 59 int xs_impl_unwatch(XenstoreImplState *s, unsigned int dom_id, 60 const char *path, const char *token, xs_impl_watch_fn fn, 61 void *opaque); 62 int xs_impl_reset_watches(XenstoreImplState *s, unsigned int dom_id); 63 64 #endif /* QEMU_XENSTORE_IMPL_H */ 65