xref: /illumos-gate/usr/src/uts/common/xen/public/io/xs_wire.h (revision 6a074c93c5dee390d8ca2377f42e55418f0a9eb3)
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 };
50 
51 #define XS_WRITE_NONE "NONE"
52 #define XS_WRITE_CREATE "CREATE"
53 #define XS_WRITE_CREATE_EXCL "CREATE|EXCL"
54 
55 /* We hand errors as strings, for portability. */
56 struct xsd_errors
57 {
58     int errnum;
59     const char *errstring;
60 };
61 #define XSD_ERROR(x) { x, #x }
62 #if !defined(__GNUC__)
63 /* LINTED: static unused */
64 static struct xsd_errors xsd_errors[] = {
65     XSD_ERROR(EINVAL),
66     XSD_ERROR(EACCES),
67     XSD_ERROR(EEXIST),
68     XSD_ERROR(EISDIR),
69     XSD_ERROR(ENOENT),
70     XSD_ERROR(ENOMEM),
71     XSD_ERROR(ENOSPC),
72     XSD_ERROR(EIO),
73     XSD_ERROR(ENOTEMPTY),
74     XSD_ERROR(ENOSYS),
75     XSD_ERROR(EROFS),
76     XSD_ERROR(EBUSY),
77     XSD_ERROR(EAGAIN),
78     XSD_ERROR(EISCONN)
79 };
80 #else
81 static struct xsd_errors xsd_errors[] __attribute__((unused)) = {
82     XSD_ERROR(EINVAL),
83     XSD_ERROR(EACCES),
84     XSD_ERROR(EEXIST),
85     XSD_ERROR(EISDIR),
86     XSD_ERROR(ENOENT),
87     XSD_ERROR(ENOMEM),
88     XSD_ERROR(ENOSPC),
89     XSD_ERROR(EIO),
90     XSD_ERROR(ENOTEMPTY),
91     XSD_ERROR(ENOSYS),
92     XSD_ERROR(EROFS),
93     XSD_ERROR(EBUSY),
94     XSD_ERROR(EAGAIN),
95     XSD_ERROR(EISCONN)
96 };
97 #endif
98 
99 struct xsd_sockmsg
100 {
101     uint32_t type;  /* XS_??? */
102     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
103     uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
104     uint32_t len;   /* Length of data following this. */
105 
106     /* Generally followed by nul-terminated string(s). */
107 };
108 
109 enum xs_watch_type
110 {
111     XS_WATCH_PATH = 0,
112     XS_WATCH_TOKEN
113 };
114 
115 /* Inter-domain shared memory communications. */
116 #define XENSTORE_RING_SIZE 1024
117 typedef uint32_t XENSTORE_RING_IDX;
118 #define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1))
119 struct xenstore_domain_interface {
120     char req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */
121     char rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */
122     XENSTORE_RING_IDX req_cons, req_prod;
123     XENSTORE_RING_IDX rsp_cons, rsp_prod;
124 };
125 
126 #endif /* _XS_WIRE_H */
127 
128 /*
129  * Local variables:
130  * mode: C
131  * c-set-style: "BSD"
132  * c-basic-offset: 4
133  * tab-width: 4
134  * indent-tabs-mode: nil
135  * End:
136  */
137