| 1 | /* $NetBSD: xs_wire.h,v 1.2 2011/12/07 15:04:18 cegger Exp $ */ |
| 2 | /* |
| 3 | * Details of the "wire" protocol between Xen Store Daemon and client |
| 4 | * library or guest kernel. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Copyright (C) 2005 Rusty Russell IBM Corporation |
| 25 | */ |
| 26 | |
| 27 | #ifndef _XS_WIRE_H |
| 28 | #define _XS_WIRE_H |
| 29 | |
| 30 | enum xsd_sockmsg_type |
| 31 | { |
| 32 | XS_DEBUG, |
| 33 | XS_DIRECTORY, |
| 34 | XS_READ, |
| 35 | XS_GET_PERMS, |
| 36 | XS_WATCH, |
| 37 | XS_UNWATCH, |
| 38 | XS_TRANSACTION_START, |
| 39 | XS_TRANSACTION_END, |
| 40 | XS_INTRODUCE, |
| 41 | XS_RELEASE, |
| 42 | XS_GET_DOMAIN_PATH, |
| 43 | XS_WRITE, |
| 44 | XS_MKDIR, |
| 45 | XS_RM, |
| 46 | XS_SET_PERMS, |
| 47 | XS_WATCH_EVENT, |
| 48 | XS_ERROR, |
| 49 | XS_IS_DOMAIN_INTRODUCED, |
| 50 | XS_RESUME, |
| 51 | XS_SET_TARGET, |
| 52 | XS_RESTRICT |
| 53 | }; |
| 54 | |
| 55 | #define XS_WRITE_NONE "NONE" |
| 56 | #define XS_WRITE_CREATE "CREATE" |
| 57 | #define XS_WRITE_CREATE_EXCL "CREATE|EXCL" |
| 58 | |
| 59 | /* We hand errors as strings, for portability. */ |
| 60 | struct xsd_errors |
| 61 | { |
| 62 | int errnum; |
| 63 | const char *errstring; |
| 64 | }; |
| 65 | #ifdef EINVAL |
| 66 | #define XSD_ERROR(x) { x, #x } |
| 67 | /* LINTED: static unused */ |
| 68 | static struct xsd_errors xsd_errors[] |
| 69 | #if defined(__GNUC__) |
| 70 | __attribute__((unused)) |
| 71 | #endif |
| 72 | = { |
| 73 | XSD_ERROR(EINVAL), |
| 74 | XSD_ERROR(EACCES), |
| 75 | XSD_ERROR(EEXIST), |
| 76 | XSD_ERROR(EISDIR), |
| 77 | XSD_ERROR(ENOENT), |
| 78 | XSD_ERROR(ENOMEM), |
| 79 | XSD_ERROR(ENOSPC), |
| 80 | XSD_ERROR(EIO), |
| 81 | XSD_ERROR(ENOTEMPTY), |
| 82 | XSD_ERROR(ENOSYS), |
| 83 | XSD_ERROR(EROFS), |
| 84 | XSD_ERROR(EBUSY), |
| 85 | XSD_ERROR(EAGAIN), |
| 86 | XSD_ERROR(EISCONN) |
| 87 | }; |
| 88 | #endif |
| 89 | |
| 90 | struct xsd_sockmsg |
| 91 | { |
| 92 | uint32_t type; /* XS_??? */ |
| 93 | uint32_t req_id;/* Request identifier, echoed in daemon's response. */ |
| 94 | uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */ |
| 95 | uint32_t len; /* Length of data following this. */ |
| 96 | |
| 97 | /* Generally followed by nul-terminated string(s). */ |
| 98 | }; |
| 99 | |
| 100 | enum xs_watch_type |
| 101 | { |
| 102 | XS_WATCH_PATH = 0, |
| 103 | XS_WATCH_TOKEN |
| 104 | }; |
| 105 | |
| 106 | /* Inter-domain shared memory communications. */ |
| 107 | #define XENSTORE_RING_SIZE 1024 |
| 108 | typedef uint32_t XENSTORE_RING_IDX; |
| 109 | #define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1)) |
| 110 | struct xenstore_domain_interface { |
| 111 | char req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */ |
| 112 | char rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */ |
| 113 | volatile XENSTORE_RING_IDX req_cons, req_prod; |
| 114 | volatile XENSTORE_RING_IDX rsp_cons, rsp_prod; |
| 115 | }; |
| 116 | |
| 117 | /* Violating this is very bad. See docs/misc/xenstore.txt. */ |
| 118 | #define XENSTORE_PAYLOAD_MAX 4096 |
| 119 | |
| 120 | /* Violating these just gets you an error back */ |
| 121 | #define XENSTORE_ABS_PATH_MAX 3072 |
| 122 | #define XENSTORE_REL_PATH_MAX 2048 |
| 123 | |
| 124 | #endif /* _XS_WIRE_H */ |
| 125 | |
| 126 | /* |
| 127 | * Local variables: |
| 128 | * mode: C |
| 129 | * c-set-style: "BSD" |
| 130 | * c-basic-offset: 4 |
| 131 | * tab-width: 4 |
| 132 | * indent-tabs-mode: nil |
| 133 | * End: |
| 134 | */ |
| 135 | |