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