debuggers.hg

view tools/blktap2/include/tapdisk-message.h @ 22848:6341fe0f4e5a

Added tag 4.1.0-rc2 for changeset 9dca60d88c63
author Keir Fraser <keir@xen.org>
date Tue Jan 25 14:06:55 2011 +0000 (2011-01-25)
parents 63d0f5348af2
children
line source
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_
30 #include <inttypes.h>
31 #include <sys/types.h>
33 #define TAPDISK_MESSAGE_MAX_PATH_LENGTH 256
34 #define TAPDISK_MESSAGE_STRING_LENGTH 256
36 #define TAPDISK_MESSAGE_MAX_MINORS \
37 ((TAPDISK_MESSAGE_MAX_PATH_LENGTH / sizeof(int)) - 1)
39 #define TAPDISK_MESSAGE_FLAG_SHARED 0x01
40 #define TAPDISK_MESSAGE_FLAG_RDONLY 0x02
41 #define TAPDISK_MESSAGE_FLAG_ADD_CACHE 0x04
42 #define TAPDISK_MESSAGE_FLAG_VHD_INDEX 0x08
43 #define TAPDISK_MESSAGE_FLAG_LOG_DIRTY 0x10
45 typedef struct tapdisk_message tapdisk_message_t;
46 typedef uint8_t tapdisk_message_flag_t;
47 typedef struct tapdisk_message_image tapdisk_message_image_t;
48 typedef struct tapdisk_message_params tapdisk_message_params_t;
49 typedef struct tapdisk_message_string tapdisk_message_string_t;
50 typedef struct tapdisk_message_response tapdisk_message_response_t;
51 typedef struct tapdisk_message_minors tapdisk_message_minors_t;
52 typedef struct tapdisk_message_list tapdisk_message_list_t;
54 struct tapdisk_message_params {
55 tapdisk_message_flag_t flags;
57 uint8_t storage;
58 uint32_t devnum;
59 uint32_t domid;
60 uint16_t path_len;
61 char path[TAPDISK_MESSAGE_MAX_PATH_LENGTH];
62 };
64 struct tapdisk_message_image {
65 uint64_t sectors;
66 uint32_t sector_size;
67 uint32_t info;
68 };
70 struct tapdisk_message_string {
71 char text[TAPDISK_MESSAGE_STRING_LENGTH];
72 };
74 struct tapdisk_message_response {
75 int error;
76 char message[TAPDISK_MESSAGE_STRING_LENGTH];
77 };
79 struct tapdisk_message_minors {
80 int count;
81 int list[TAPDISK_MESSAGE_MAX_MINORS];
82 };
84 struct tapdisk_message_list {
85 int count;
86 int minor;
87 int state;
88 char path[TAPDISK_MESSAGE_MAX_PATH_LENGTH];
89 };
91 struct tapdisk_message {
92 uint16_t type;
93 uint16_t cookie;
95 union {
96 pid_t tapdisk_pid;
97 tapdisk_message_image_t image;
98 tapdisk_message_params_t params;
99 tapdisk_message_string_t string;
100 tapdisk_message_minors_t minors;
101 tapdisk_message_response_t response;
102 tapdisk_message_list_t list;
103 } u;
104 };
106 enum tapdisk_message_id {
107 TAPDISK_MESSAGE_ERROR = 1,
108 TAPDISK_MESSAGE_RUNTIME_ERROR,
109 TAPDISK_MESSAGE_PID,
110 TAPDISK_MESSAGE_PID_RSP,
111 TAPDISK_MESSAGE_ATTACH,
112 TAPDISK_MESSAGE_ATTACH_RSP,
113 TAPDISK_MESSAGE_OPEN,
114 TAPDISK_MESSAGE_OPEN_RSP,
115 TAPDISK_MESSAGE_PAUSE,
116 TAPDISK_MESSAGE_PAUSE_RSP,
117 TAPDISK_MESSAGE_RESUME,
118 TAPDISK_MESSAGE_RESUME_RSP,
119 TAPDISK_MESSAGE_CLOSE,
120 TAPDISK_MESSAGE_CLOSE_RSP,
121 TAPDISK_MESSAGE_DETACH,
122 TAPDISK_MESSAGE_DETACH_RSP,
123 TAPDISK_MESSAGE_LIST_MINORS,
124 TAPDISK_MESSAGE_LIST_MINORS_RSP,
125 TAPDISK_MESSAGE_LIST,
126 TAPDISK_MESSAGE_LIST_RSP,
127 TAPDISK_MESSAGE_FORCE_SHUTDOWN,
128 TAPDISK_MESSAGE_EXIT,
129 };
131 static inline char *
132 tapdisk_message_name(enum tapdisk_message_id id)
133 {
134 switch (id) {
135 case TAPDISK_MESSAGE_ERROR:
136 return "error";
138 case TAPDISK_MESSAGE_PID:
139 return "pid";
141 case TAPDISK_MESSAGE_PID_RSP:
142 return "pid response";
144 case TAPDISK_MESSAGE_OPEN:
145 return "open";
147 case TAPDISK_MESSAGE_OPEN_RSP:
148 return "open response";
150 case TAPDISK_MESSAGE_PAUSE:
151 return "pause";
153 case TAPDISK_MESSAGE_PAUSE_RSP:
154 return "pause response";
156 case TAPDISK_MESSAGE_RESUME:
157 return "resume";
159 case TAPDISK_MESSAGE_RESUME_RSP:
160 return "resume response";
162 case TAPDISK_MESSAGE_CLOSE:
163 return "close";
165 case TAPDISK_MESSAGE_FORCE_SHUTDOWN:
166 return "force shutdown";
168 case TAPDISK_MESSAGE_CLOSE_RSP:
169 return "close response";
171 case TAPDISK_MESSAGE_ATTACH:
172 return "attach";
174 case TAPDISK_MESSAGE_ATTACH_RSP:
175 return "attach response";
177 case TAPDISK_MESSAGE_DETACH:
178 return "detach";
180 case TAPDISK_MESSAGE_DETACH_RSP:
181 return "detach response";
183 case TAPDISK_MESSAGE_LIST_MINORS:
184 return "list minors";
186 case TAPDISK_MESSAGE_LIST_MINORS_RSP:
187 return "list minors response";
189 case TAPDISK_MESSAGE_LIST:
190 return "list";
192 case TAPDISK_MESSAGE_LIST_RSP:
193 return "list response";
195 case TAPDISK_MESSAGE_EXIT:
196 return "exit";
198 default:
199 return "unknown";
200 }
201 }
203 #endif