Oleksandr Andrushchenko | 7fd47cc | 2020-08-06 12:42:46 +0300 | [diff] [blame] | 1 | /* SPDX-License-Identifier: MIT |
| 2 | * |
| 3 | * Details of the "wire" protocol between Xen Store Daemon and client |
| 4 | * library or guest kernel. |
| 5 | * |
| 6 | * Copyright (C) 2005 Rusty Russell IBM Corporation |
| 7 | */ |
| 8 | |
| 9 | #ifndef _XS_WIRE_H |
| 10 | #define _XS_WIRE_H |
| 11 | |
| 12 | enum xsd_sockmsg_type { |
| 13 | XS_CONTROL, |
| 14 | #define XS_DEBUG XS_CONTROL |
| 15 | XS_DIRECTORY, |
| 16 | XS_READ, |
| 17 | XS_GET_PERMS, |
| 18 | XS_WATCH, |
| 19 | XS_UNWATCH, |
| 20 | XS_TRANSACTION_START, |
| 21 | XS_TRANSACTION_END, |
| 22 | XS_INTRODUCE, |
| 23 | XS_RELEASE, |
| 24 | XS_GET_DOMAIN_PATH, |
| 25 | XS_WRITE, |
| 26 | XS_MKDIR, |
| 27 | XS_RM, |
| 28 | XS_SET_PERMS, |
| 29 | XS_WATCH_EVENT, |
| 30 | XS_ERROR, |
| 31 | XS_IS_DOMAIN_INTRODUCED, |
| 32 | XS_RESUME, |
| 33 | XS_SET_TARGET, |
| 34 | /* XS_RESTRICT has been removed */ |
| 35 | XS_RESET_WATCHES = XS_SET_TARGET + 2, |
| 36 | XS_DIRECTORY_PART, |
| 37 | |
| 38 | XS_TYPE_COUNT, /* Number of valid types. */ |
| 39 | |
| 40 | XS_INVALID = 0xffff /* Guaranteed to remain an invalid type */ |
| 41 | }; |
| 42 | |
| 43 | #define XS_WRITE_NONE "NONE" |
| 44 | #define XS_WRITE_CREATE "CREATE" |
| 45 | #define XS_WRITE_CREATE_EXCL "CREATE|EXCL" |
| 46 | |
| 47 | /* We hand errors as strings, for portability. */ |
| 48 | struct xsd_errors { |
| 49 | int errnum; |
| 50 | const char *errstring; |
| 51 | }; |
| 52 | |
| 53 | #ifdef EINVAL |
| 54 | #define XSD_ERROR(x) { x, #x } |
| 55 | /* LINTED: static unused */ |
| 56 | static struct xsd_errors xsd_errors[] |
| 57 | #if defined(__GNUC__) |
| 58 | __attribute__((unused)) |
| 59 | #endif |
| 60 | = { |
| 61 | XSD_ERROR(EINVAL), |
| 62 | XSD_ERROR(EACCES), |
| 63 | XSD_ERROR(EEXIST), |
| 64 | XSD_ERROR(EISDIR), |
| 65 | XSD_ERROR(ENOENT), |
| 66 | XSD_ERROR(ENOMEM), |
| 67 | XSD_ERROR(ENOSPC), |
| 68 | XSD_ERROR(EIO), |
| 69 | XSD_ERROR(ENOTEMPTY), |
| 70 | XSD_ERROR(ENOSYS), |
| 71 | XSD_ERROR(EROFS), |
| 72 | XSD_ERROR(EBUSY), |
| 73 | XSD_ERROR(EAGAIN), |
| 74 | XSD_ERROR(EISCONN), |
| 75 | XSD_ERROR(E2BIG) |
| 76 | }; |
| 77 | #endif |
| 78 | |
| 79 | struct xsd_sockmsg { |
| 80 | u32 type; /* XS_??? */ |
| 81 | u32 req_id;/* Request identifier, echoed in daemon's response. */ |
| 82 | u32 tx_id; /* Transaction id (0 if not related to a transaction). */ |
| 83 | u32 len; /* Length of data following this. */ |
| 84 | |
| 85 | /* Generally followed by nul-terminated string(s). */ |
| 86 | }; |
| 87 | |
| 88 | enum xs_watch_type { |
| 89 | XS_WATCH_PATH = 0, |
| 90 | XS_WATCH_TOKEN |
| 91 | }; |
| 92 | |
| 93 | /* |
| 94 | * `incontents 150 xenstore_struct XenStore wire protocol. |
| 95 | * |
| 96 | * Inter-domain shared memory communications. |
| 97 | */ |
| 98 | #define XENSTORE_RING_SIZE 1024 |
| 99 | typedef u32 XENSTORE_RING_IDX; |
| 100 | #define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE - 1)) |
| 101 | struct xenstore_domain_interface { |
| 102 | char req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */ |
| 103 | char rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */ |
| 104 | XENSTORE_RING_IDX req_cons, req_prod; |
| 105 | XENSTORE_RING_IDX rsp_cons, rsp_prod; |
| 106 | u32 server_features; /* Bitmap of features supported by the server */ |
| 107 | u32 connection; |
| 108 | }; |
| 109 | |
| 110 | /* Violating this is very bad. See docs/misc/xenstore.txt. */ |
| 111 | #define XENSTORE_PAYLOAD_MAX 4096 |
| 112 | |
| 113 | /* Violating these just gets you an error back */ |
| 114 | #define XENSTORE_ABS_PATH_MAX 3072 |
| 115 | #define XENSTORE_REL_PATH_MAX 2048 |
| 116 | |
| 117 | /* The ability to reconnect a ring */ |
| 118 | #define XENSTORE_SERVER_FEATURE_RECONNECTION 1 |
| 119 | |
| 120 | /* Valid values for the connection field */ |
| 121 | #define XENSTORE_CONNECTED 0 /* the steady-state */ |
| 122 | #define XENSTORE_RECONNECT 1 /* guest has initiated a reconnect */ |
| 123 | |
| 124 | #endif /* _XS_WIRE_H */ |
| 125 | |
| 126 | /* |
| 127 | * Local variables: |
| 128 | * mode: C |
| 129 | * c-file-style: "BSD" |
| 130 | * c-basic-offset: 4 |
| 131 | * tab-width: 8 |
| 132 | * indent-tabs-mode: nil |
| 133 | * End: |
| 134 | */ |