10254c4d1SDavid Woodhouse /* 20254c4d1SDavid Woodhouse * QEMU Xen emulation: The actual implementation of XenStore 30254c4d1SDavid Woodhouse * 40254c4d1SDavid Woodhouse * Copyright © 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. 50254c4d1SDavid Woodhouse * 60254c4d1SDavid Woodhouse * Authors: David Woodhouse <dwmw2@infradead.org> 70254c4d1SDavid Woodhouse * 80254c4d1SDavid Woodhouse * This work is licensed under the terms of the GNU GPL, version 2 or later. 90254c4d1SDavid Woodhouse * See the COPYING file in the top-level directory. 100254c4d1SDavid Woodhouse */ 110254c4d1SDavid Woodhouse 120254c4d1SDavid Woodhouse #ifndef QEMU_XENSTORE_IMPL_H 130254c4d1SDavid Woodhouse #define QEMU_XENSTORE_IMPL_H 140254c4d1SDavid Woodhouse 15*ba2a92dbSPaul Durrant #include "hw/xen/xen_backend_ops.h" 16be1934dfSPaul Durrant 170254c4d1SDavid Woodhouse typedef struct XenstoreImplState XenstoreImplState; 180254c4d1SDavid Woodhouse 19be1934dfSPaul Durrant XenstoreImplState *xs_impl_create(unsigned int dom_id); 20be1934dfSPaul Durrant 21be1934dfSPaul Durrant char *xs_perm_as_string(unsigned int perm, unsigned int domid); 220254c4d1SDavid Woodhouse 230254c4d1SDavid Woodhouse /* 240254c4d1SDavid Woodhouse * These functions return *positive* error numbers. This is a little 250254c4d1SDavid Woodhouse * unconventional but it helps to keep us honest because there is 260254c4d1SDavid Woodhouse * also a very limited set of error numbers that they are permitted 270254c4d1SDavid Woodhouse * to return (those in xsd_errors). 280254c4d1SDavid Woodhouse */ 290254c4d1SDavid Woodhouse 300254c4d1SDavid Woodhouse int xs_impl_read(XenstoreImplState *s, unsigned int dom_id, 310254c4d1SDavid Woodhouse xs_transaction_t tx_id, const char *path, GByteArray *data); 320254c4d1SDavid Woodhouse int xs_impl_write(XenstoreImplState *s, unsigned int dom_id, 330254c4d1SDavid Woodhouse xs_transaction_t tx_id, const char *path, GByteArray *data); 340254c4d1SDavid Woodhouse int xs_impl_directory(XenstoreImplState *s, unsigned int dom_id, 350254c4d1SDavid Woodhouse xs_transaction_t tx_id, const char *path, 360254c4d1SDavid Woodhouse uint64_t *gencnt, GList **items); 370254c4d1SDavid Woodhouse int xs_impl_transaction_start(XenstoreImplState *s, unsigned int dom_id, 380254c4d1SDavid Woodhouse xs_transaction_t *tx_id); 390254c4d1SDavid Woodhouse int xs_impl_transaction_end(XenstoreImplState *s, unsigned int dom_id, 400254c4d1SDavid Woodhouse xs_transaction_t tx_id, bool commit); 410254c4d1SDavid Woodhouse int xs_impl_rm(XenstoreImplState *s, unsigned int dom_id, 420254c4d1SDavid Woodhouse xs_transaction_t tx_id, const char *path); 430254c4d1SDavid Woodhouse int xs_impl_get_perms(XenstoreImplState *s, unsigned int dom_id, 440254c4d1SDavid Woodhouse xs_transaction_t tx_id, const char *path, GList **perms); 450254c4d1SDavid Woodhouse int xs_impl_set_perms(XenstoreImplState *s, unsigned int dom_id, 460254c4d1SDavid Woodhouse xs_transaction_t tx_id, const char *path, GList *perms); 470254c4d1SDavid Woodhouse 480254c4d1SDavid Woodhouse /* This differs from xs_watch_fn because it has the token */ 490254c4d1SDavid Woodhouse typedef void(xs_impl_watch_fn)(void *opaque, const char *path, 500254c4d1SDavid Woodhouse const char *token); 510254c4d1SDavid Woodhouse int xs_impl_watch(XenstoreImplState *s, unsigned int dom_id, const char *path, 520254c4d1SDavid Woodhouse const char *token, xs_impl_watch_fn fn, void *opaque); 530254c4d1SDavid Woodhouse int xs_impl_unwatch(XenstoreImplState *s, unsigned int dom_id, 540254c4d1SDavid Woodhouse const char *path, const char *token, xs_impl_watch_fn fn, 550254c4d1SDavid Woodhouse void *opaque); 560254c4d1SDavid Woodhouse int xs_impl_reset_watches(XenstoreImplState *s, unsigned int dom_id); 570254c4d1SDavid Woodhouse 58766804b1SDavid Woodhouse GByteArray *xs_impl_serialize(XenstoreImplState *s); 59766804b1SDavid Woodhouse int xs_impl_deserialize(XenstoreImplState *s, GByteArray *bytes, 60766804b1SDavid Woodhouse unsigned int dom_id, xs_impl_watch_fn watch_fn, 61766804b1SDavid Woodhouse void *watch_opaque); 62766804b1SDavid Woodhouse 630254c4d1SDavid Woodhouse #endif /* QEMU_XENSTORE_IMPL_H */ 64