root / include / tapdisk-message.h @ abdb293f
History | View | Annotate | Download (6.6 kB)
1 |
/* Copyright (c) 2008, XenSource Inc.
|
---|---|
2 |
* All rights reserved.
|
3 |
*
|
4 |
* Redistribution and use in source and binary forms, with or without
|
5 |
* modification, are permitted provided that the following conditions are met:
|
6 |
* * Redistributions of source code must retain the above copyright
|
7 |
* notice, this list of conditions and the following disclaimer.
|
8 |
* * Redistributions in binary form must reproduce the above copyright
|
9 |
* notice, this list of conditions and the following disclaimer in the
|
10 |
* documentation and/or other materials provided with the distribution.
|
11 |
* * Neither the name of XenSource Inc. nor the names of its contributors
|
12 |
* may be used to endorse or promote products derived from this software
|
13 |
* without specific prior written permission.
|
14 |
*
|
15 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
16 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
17 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
18 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
19 |
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
20 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
21 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
22 |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
23 |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
24 |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
25 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26 |
*/
|
27 |
#ifndef _TAPDISK_MESSAGE_H_
|
28 |
#define _TAPDISK_MESSAGE_H_
|
29 |
|
30 |
#include <inttypes.h> |
31 |
#include <sys/types.h> |
32 |
|
33 |
#define TAPDISK_MESSAGE_MAX_PATH_LENGTH 256 |
34 |
#define TAPDISK_MESSAGE_STRING_LENGTH 256 |
35 |
|
36 |
#define TAPDISK_MESSAGE_MAX_MINORS \
|
37 |
((TAPDISK_MESSAGE_MAX_PATH_LENGTH / sizeof(int)) - 1) |
38 |
|
39 |
#define TAPDISK_MESSAGE_FLAG_SHARED 0x001 |
40 |
#define TAPDISK_MESSAGE_FLAG_RDONLY 0x002 |
41 |
#define TAPDISK_MESSAGE_FLAG_ADD_CACHE 0x004 |
42 |
#define TAPDISK_MESSAGE_FLAG_VHD_INDEX 0x008 |
43 |
#define TAPDISK_MESSAGE_FLAG_LOG_DIRTY 0x010 |
44 |
#define TAPDISK_MESSAGE_FLAG_ADD_LCACHE 0x020 |
45 |
#define TAPDISK_MESSAGE_FLAG_REUSE_PRT 0x040 |
46 |
#define TAPDISK_MESSAGE_FLAG_SECONDARY 0x080 |
47 |
#define TAPDISK_MESSAGE_FLAG_STANDBY 0x100 |
48 |
|
49 |
typedef struct tapdisk_message tapdisk_message_t; |
50 |
typedef uint32_t tapdisk_message_flag_t;
|
51 |
typedef struct tapdisk_message_image tapdisk_message_image_t; |
52 |
typedef struct tapdisk_message_params tapdisk_message_params_t; |
53 |
typedef struct tapdisk_message_string tapdisk_message_string_t; |
54 |
typedef struct tapdisk_message_response tapdisk_message_response_t; |
55 |
typedef struct tapdisk_message_minors tapdisk_message_minors_t; |
56 |
typedef struct tapdisk_message_list tapdisk_message_list_t; |
57 |
typedef struct tapdisk_message_stat tapdisk_message_stat_t; |
58 |
|
59 |
struct tapdisk_message_params {
|
60 |
tapdisk_message_flag_t flags; |
61 |
|
62 |
uint32_t devnum; |
63 |
uint32_t domid; |
64 |
char path[TAPDISK_MESSAGE_MAX_PATH_LENGTH];
|
65 |
uint32_t prt_devnum; |
66 |
char secondary[TAPDISK_MESSAGE_MAX_PATH_LENGTH];
|
67 |
}; |
68 |
|
69 |
struct tapdisk_message_image {
|
70 |
uint64_t sectors; |
71 |
uint32_t sector_size; |
72 |
uint32_t info; |
73 |
}; |
74 |
|
75 |
struct tapdisk_message_string {
|
76 |
char text[TAPDISK_MESSAGE_STRING_LENGTH];
|
77 |
}; |
78 |
|
79 |
struct tapdisk_message_response {
|
80 |
int error;
|
81 |
char message[TAPDISK_MESSAGE_STRING_LENGTH];
|
82 |
}; |
83 |
|
84 |
struct tapdisk_message_minors {
|
85 |
int count;
|
86 |
int list[TAPDISK_MESSAGE_MAX_MINORS];
|
87 |
}; |
88 |
|
89 |
struct tapdisk_message_list {
|
90 |
int count;
|
91 |
int minor;
|
92 |
int state;
|
93 |
char path[TAPDISK_MESSAGE_MAX_PATH_LENGTH];
|
94 |
}; |
95 |
|
96 |
struct tapdisk_message_stat {
|
97 |
uint16_t type; |
98 |
uint16_t cookie; |
99 |
size_t length; |
100 |
}; |
101 |
|
102 |
|
103 |
struct tapdisk_message {
|
104 |
uint16_t type; |
105 |
uint16_t cookie; |
106 |
|
107 |
union {
|
108 |
pid_t tapdisk_pid; |
109 |
tapdisk_message_image_t image; |
110 |
tapdisk_message_params_t params; |
111 |
tapdisk_message_string_t string; |
112 |
tapdisk_message_minors_t minors; |
113 |
tapdisk_message_response_t response; |
114 |
tapdisk_message_list_t list; |
115 |
tapdisk_message_stat_t info; |
116 |
} u; |
117 |
}; |
118 |
|
119 |
enum tapdisk_message_id {
|
120 |
TAPDISK_MESSAGE_ERROR = 1,
|
121 |
TAPDISK_MESSAGE_RUNTIME_ERROR, |
122 |
TAPDISK_MESSAGE_PID, |
123 |
TAPDISK_MESSAGE_PID_RSP, |
124 |
TAPDISK_MESSAGE_ATTACH, |
125 |
TAPDISK_MESSAGE_ATTACH_RSP, |
126 |
TAPDISK_MESSAGE_OPEN, |
127 |
TAPDISK_MESSAGE_OPEN_RSP, |
128 |
TAPDISK_MESSAGE_PAUSE, |
129 |
TAPDISK_MESSAGE_PAUSE_RSP, |
130 |
TAPDISK_MESSAGE_RESUME, |
131 |
TAPDISK_MESSAGE_RESUME_RSP, |
132 |
TAPDISK_MESSAGE_CLOSE, |
133 |
TAPDISK_MESSAGE_CLOSE_RSP, |
134 |
TAPDISK_MESSAGE_DETACH, |
135 |
TAPDISK_MESSAGE_DETACH_RSP, |
136 |
TAPDISK_MESSAGE_LIST_MINORS, |
137 |
TAPDISK_MESSAGE_LIST_MINORS_RSP, |
138 |
TAPDISK_MESSAGE_LIST, |
139 |
TAPDISK_MESSAGE_LIST_RSP, |
140 |
TAPDISK_MESSAGE_STATS, |
141 |
TAPDISK_MESSAGE_STATS_RSP, |
142 |
TAPDISK_MESSAGE_FORCE_SHUTDOWN, |
143 |
TAPDISK_MESSAGE_EXIT, |
144 |
}; |
145 |
|
146 |
#define TAPDISK_MESSAGE_MAX TAPDISK_MESSAGE_EXIT
|
147 |
|
148 |
static inline char * |
149 |
tapdisk_message_name(enum tapdisk_message_id id)
|
150 |
{ |
151 |
switch (id) {
|
152 |
case TAPDISK_MESSAGE_ERROR:
|
153 |
return "error"; |
154 |
|
155 |
case TAPDISK_MESSAGE_PID:
|
156 |
return "pid"; |
157 |
|
158 |
case TAPDISK_MESSAGE_PID_RSP:
|
159 |
return "pid response"; |
160 |
|
161 |
case TAPDISK_MESSAGE_OPEN:
|
162 |
return "open"; |
163 |
|
164 |
case TAPDISK_MESSAGE_OPEN_RSP:
|
165 |
return "open response"; |
166 |
|
167 |
case TAPDISK_MESSAGE_PAUSE:
|
168 |
return "pause"; |
169 |
|
170 |
case TAPDISK_MESSAGE_PAUSE_RSP:
|
171 |
return "pause response"; |
172 |
|
173 |
case TAPDISK_MESSAGE_RESUME:
|
174 |
return "resume"; |
175 |
|
176 |
case TAPDISK_MESSAGE_RESUME_RSP:
|
177 |
return "resume response"; |
178 |
|
179 |
case TAPDISK_MESSAGE_CLOSE:
|
180 |
return "close"; |
181 |
|
182 |
case TAPDISK_MESSAGE_FORCE_SHUTDOWN:
|
183 |
return "force shutdown"; |
184 |
|
185 |
case TAPDISK_MESSAGE_CLOSE_RSP:
|
186 |
return "close response"; |
187 |
|
188 |
case TAPDISK_MESSAGE_ATTACH:
|
189 |
return "attach"; |
190 |
|
191 |
case TAPDISK_MESSAGE_ATTACH_RSP:
|
192 |
return "attach response"; |
193 |
|
194 |
case TAPDISK_MESSAGE_DETACH:
|
195 |
return "detach"; |
196 |
|
197 |
case TAPDISK_MESSAGE_DETACH_RSP:
|
198 |
return "detach response"; |
199 |
|
200 |
case TAPDISK_MESSAGE_LIST_MINORS:
|
201 |
return "list minors"; |
202 |
|
203 |
case TAPDISK_MESSAGE_LIST_MINORS_RSP:
|
204 |
return "list minors response"; |
205 |
|
206 |
case TAPDISK_MESSAGE_LIST:
|
207 |
return "list"; |
208 |
|
209 |
case TAPDISK_MESSAGE_LIST_RSP:
|
210 |
return "list response"; |
211 |
|
212 |
case TAPDISK_MESSAGE_STATS:
|
213 |
return "stats"; |
214 |
|
215 |
case TAPDISK_MESSAGE_STATS_RSP:
|
216 |
return "stats response"; |
217 |
|
218 |
case TAPDISK_MESSAGE_EXIT:
|
219 |
return "exit"; |
220 |
|
221 |
default:
|
222 |
return "unknown"; |
223 |
} |
224 |
} |
225 |
|
226 |
#endif
|