ia64/xen-unstable

view tools/blktap2/include/blktaplib.h @ 19835:edfdeb150f27

Fix buildsystem to detect udev > version 124

udev removed the udevinfo symlink from versions higher than 123 and
xen's build-system could not detect if udev is in place and has the
required version.

Signed-off-by: Marc-A. Dahlhaus <mad@wol.de>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 25 13:02:37 2009 +0100 (2009-06-25)
parents 1c627434605e
children
line source
1 /* blktaplib.h
2 *
3 * Blktap library userspace code.
4 *
5 * Copyright (c) 2007, XenSource Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * * Neither the name of XenSource Inc. nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
23 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
32 #ifndef __BLKTAPLIB_H__
33 #define __BLKTAPLIB_H__
35 #include <syslog.h>
36 #include <xenctrl.h>
37 #include <xen/io/blkif.h>
39 #if 1
40 #define DPRINTF(_f, _a...) syslog(LOG_INFO, _f, ##_a)
41 #else
42 #define DPRINTF(_f, _a...) ((void)0)
43 #endif
45 #define EPRINTF(_f, _a...) syslog(LOG_ERR, "tap-err:%s: " _f, __func__, ##_a)
47 #define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, XC_PAGE_SIZE)
49 /* size of the extra VMA area to map in attached pages. */
50 #define BLKTAP_VMA_PAGES BLK_RING_SIZE
52 /* blktap IOCTLs: These must correspond with the blktap driver ioctls */
53 #define BLKTAP_IOCTL_KICK_FE 1
54 #define BLKTAP_IOCTL_KICK_BE 2
55 #define BLKTAP_IOCTL_SETMODE 3
56 #define BLKTAP_IOCTL_SENDPID 4
57 #define BLKTAP_IOCTL_NEWINTF 5
58 #define BLKTAP_IOCTL_MINOR 6
59 #define BLKTAP_IOCTL_MAJOR 7
60 #define BLKTAP_QUERY_ALLOC_REQS 8
61 #define BLKTAP_IOCTL_FREEINTF 9
62 #define BLKTAP_IOCTL_PRINT_IDXS 100
63 #define BLKTAP_IOCTL_BACKDEV_SETUP 200
65 #define PRIO_SPECIAL_IO -9999
67 /* blktap switching modes: (Set with BLKTAP_IOCTL_SETMODE) */
68 #define BLKTAP_MODE_PASSTHROUGH 0x00000000 /* default */
69 #define BLKTAP_MODE_INTERCEPT_FE 0x00000001
70 #define BLKTAP_MODE_INTERCEPT_BE 0x00000002
72 #define BLKTAP_MODE_INTERPOSE \
73 (BLKTAP_MODE_INTERCEPT_FE | BLKTAP_MODE_INTERCEPT_BE)
75 static inline int BLKTAP_MODE_VALID(unsigned long arg)
76 {
77 return (
78 ( arg == BLKTAP_MODE_PASSTHROUGH ) ||
79 ( arg == BLKTAP_MODE_INTERCEPT_FE ) ||
80 ( arg == BLKTAP_MODE_INTERPOSE ) );
81 }
83 #define MAX_REQUESTS BLK_RING_SIZE
85 #define BLKTAP_IOCTL_KICK 1
86 #define MAX_PENDING_REQS BLK_RING_SIZE
87 #define BLKTAP_DEV_DIR "/dev/xen"
88 #define BLKTAP_DEV_NAME "blktap"
89 #define BACKDEV_NAME "backdev"
90 #define BLKTAP_DEV_MINOR 0
91 #define BLKTAP_CTRL_DIR "/var/run/tap"
93 extern int blktap_major;
95 #define BLKTAP_RING_PAGES 1 /* Front */
96 #define BLKTAP_MMAP_REGION_SIZE (BLKTAP_RING_PAGES + MMAP_PAGES)
98 struct blkif;
99 struct blkif_info;
101 typedef struct {
102 blkif_request_t req;
103 int submitting;
104 int secs_pending;
105 int16_t status;
106 int num_retries;
107 struct timeval last_try;
108 } pending_req_t;
110 typedef struct blkif {
111 domid_t domid;
112 long int handle;
114 long int pdev;
115 long int readonly;
117 enum { DISCONNECTED, DISCONNECTING, CONNECTED } state;
119 struct blkif_ops *ops;
120 struct blkif *hash_next;
122 void *prv; /* device-specific data */
123 struct blkif_info *info; /*Image parameter passing */
124 pending_req_t pending_list[MAX_REQUESTS];
125 int devnum;
126 int fds[2];
127 int be_id;
128 char *backend_path;
129 int major;
130 int minor;
131 pid_t tappid;
132 int drivertype;
133 uint16_t cookie;
134 int err;
135 } blkif_t;
137 typedef struct blkif_info {
138 char *params;
139 int readonly;
140 int storage;
141 } blkif_info_t;
143 typedef struct tapdev_info {
144 int fd;
145 char *mem;
146 blkif_sring_t *sring;
147 blkif_back_ring_t fe_ring;
148 unsigned long vstart;
149 blkif_t *blkif;
150 } tapdev_info_t;
152 typedef struct domid_translate {
153 unsigned short domid;
154 unsigned short busid;
155 } domid_translate_t ;
157 typedef struct image {
158 unsigned long long size;
159 unsigned long secsize;
160 unsigned int info;
161 } image_t;
163 typedef struct msg_hdr {
164 uint16_t type;
165 uint16_t len;
166 uint16_t drivertype;
167 uint16_t cookie;
168 } msg_hdr_t;
170 typedef struct msg_params {
171 uint8_t readonly;
172 int path_off;
173 int path_len;
174 int storage;
175 } msg_params_t;
177 typedef struct msg_newdev {
178 uint8_t devnum;
179 uint16_t domid;
180 } msg_newdev_t;
182 typedef struct msg_pid {
183 pid_t pid;
184 } msg_pid_t;
186 typedef struct msg_cp {
187 int cp_uuid_off;
188 int cp_uuid_len;
189 int cp_drivertype;
190 } msg_cp_t;
192 typedef struct msg_lock {
193 int ro;
194 int enforce;
195 int uuid_off;
196 int uuid_len;
197 } msg_lock_t;
199 #define READ 0
200 #define WRITE 1
202 /*Control Messages between manager and tapdev*/
203 #define CTLMSG_PARAMS 1
204 #define CTLMSG_IMG 2
205 #define CTLMSG_IMG_FAIL 3
206 #define CTLMSG_NEWDEV 4
207 #define CTLMSG_NEWDEV_RSP 5
208 #define CTLMSG_NEWDEV_FAIL 6
209 #define CTLMSG_CLOSE 7
210 #define CTLMSG_CLOSE_RSP 8
211 #define CTLMSG_PID 9
212 #define CTLMSG_PID_RSP 10
213 #define CTLMSG_CHECKPOINT 11
214 #define CTLMSG_CHECKPOINT_RSP 12
215 #define CTLMSG_LOCK 13
216 #define CTLMSG_LOCK_RSP 14
217 #define CTLMSG_PAUSE 15
218 #define CTLMSG_PAUSE_RSP 16
219 #define CTLMSG_RESUME 17
220 #define CTLMSG_RESUME_RSP 18
222 #define TAPDISK_STORAGE_TYPE_NFS 1
223 #define TAPDISK_STORAGE_TYPE_EXT 2
224 #define TAPDISK_STORAGE_TYPE_LVM 3
225 #define TAPDISK_STORAGE_TYPE_DEFAULT TAPDISK_STORAGE_TYPE_EXT
227 /* Abitrary values, must match the underlying driver... */
228 #define MAX_TAP_DEV 256
230 /* Accessing attached data page mappings */
231 #define MMAP_PAGES \
232 (MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
233 #define MMAP_VADDR(_vstart,_req,_seg) \
234 ((_vstart) + \
235 ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * getpagesize()) + \
236 ((_seg) * getpagesize()))
238 /* Defines that are only used by library clients */
240 #ifndef __COMPILING_BLKTAP_LIB
242 static char *blkif_op_name[] = {
243 [BLKIF_OP_READ] = "READ",
244 [BLKIF_OP_WRITE] = "WRITE",
245 };
247 #endif /* __COMPILING_BLKTAP_LIB */
249 #endif /* __BLKTAPLIB_H__ */