ia64/xen-unstable

view tools/blktap2/include/tapdisk-message.h @ 19647:1c627434605e

blktap2: a completely rewritten blktap implementation

Benefits to blktap2 over the old version of blktap:

* Isolation from xenstore - Blktap devices are now created directly on
the linux dom0 command line, rather than being spawned in response
to XenStore events. This is handy for debugging, makes blktap
generally easier to work with, and is a step toward a generic
user-level block device implementation that is not Xen-specific.

* Improved tapdisk infrastructure: simpler request forwarding, new
request scheduler, request merging, more efficient use of AIO.

* Improved tapdisk error handling and memory management. No
allocations on the block data path, IO retry logic to protect
guests
transient block device failures. This has been tested and is known
to work on weird environments such as NFS soft mounts.

* Pause and snapshot of live virtual disks (see xmsnap script).

* VHD support. The VHD code in this release has been rigorously
tested, and represents a very mature implementation of the VHD
image
format.

* No more duplication of mechanism with blkback. The blktap kernel
module has changed dramatically from the original blktap. Blkback
is now always used to talk to Xen guests, blktap just presents a
Linux gendisk that blkback can export. This is done while
preserving the zero-copy data path from domU to physical device.

These patches deprecate the old blktap code, which can hopefully be
removed from the tree completely at some point in the future.

Signed-off-by: Jake Wires <jake.wires@citrix.com>
Signed-off-by: Dutch Meyer <dmeyer@cs.ubc.ca>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 26 11:52:31 2009 +0100 (2009-05-26)
parents
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>
32 #define TAPDISK_MESSAGE_MAX_PATH_LENGTH 256
33 #define TAPDISK_MESSAGE_STRING_LENGTH 256
35 #define TAPDISK_MESSAGE_FLAG_SHARED 0x01
36 #define TAPDISK_MESSAGE_FLAG_RDONLY 0x02
37 #define TAPDISK_MESSAGE_FLAG_ADD_CACHE 0x04
38 #define TAPDISK_MESSAGE_FLAG_VHD_INDEX 0x08
39 #define TAPDISK_MESSAGE_FLAG_LOG_DIRTY 0x10
41 typedef struct tapdisk_message tapdisk_message_t;
42 typedef uint8_t tapdisk_message_flag_t;
43 typedef struct tapdisk_message_image tapdisk_message_image_t;
44 typedef struct tapdisk_message_params tapdisk_message_params_t;
45 typedef struct tapdisk_message_string tapdisk_message_string_t;
47 struct tapdisk_message_params {
48 tapdisk_message_flag_t flags;
50 uint8_t storage;
51 uint32_t devnum;
52 uint32_t domid;
53 uint16_t path_len;
54 char path[TAPDISK_MESSAGE_MAX_PATH_LENGTH];
55 };
57 struct tapdisk_message_image {
58 uint64_t sectors;
59 uint32_t sector_size;
60 uint32_t info;
61 };
63 struct tapdisk_message_string {
64 char text[TAPDISK_MESSAGE_STRING_LENGTH];
65 };
67 struct tapdisk_message {
68 uint16_t type;
69 uint16_t cookie;
70 uint16_t drivertype;
72 union {
73 pid_t tapdisk_pid;
74 tapdisk_message_image_t image;
75 tapdisk_message_params_t params;
76 tapdisk_message_string_t string;
77 } u;
78 };
80 enum tapdisk_message_id {
81 TAPDISK_MESSAGE_ERROR = 1,
82 TAPDISK_MESSAGE_RUNTIME_ERROR,
83 TAPDISK_MESSAGE_PID,
84 TAPDISK_MESSAGE_PID_RSP,
85 TAPDISK_MESSAGE_OPEN,
86 TAPDISK_MESSAGE_OPEN_RSP,
87 TAPDISK_MESSAGE_PAUSE,
88 TAPDISK_MESSAGE_PAUSE_RSP,
89 TAPDISK_MESSAGE_RESUME,
90 TAPDISK_MESSAGE_RESUME_RSP,
91 TAPDISK_MESSAGE_CLOSE,
92 TAPDISK_MESSAGE_CLOSE_RSP,
93 TAPDISK_MESSAGE_EXIT,
94 };
96 static inline char *
97 tapdisk_message_name(enum tapdisk_message_id id)
98 {
99 switch (id) {
100 case TAPDISK_MESSAGE_ERROR:
101 return "error";
103 case TAPDISK_MESSAGE_PID:
104 return "pid";
106 case TAPDISK_MESSAGE_PID_RSP:
107 return "pid response";
109 case TAPDISK_MESSAGE_OPEN:
110 return "open";
112 case TAPDISK_MESSAGE_OPEN_RSP:
113 return "open response";
115 case TAPDISK_MESSAGE_PAUSE:
116 return "pause";
118 case TAPDISK_MESSAGE_PAUSE_RSP:
119 return "pause response";
121 case TAPDISK_MESSAGE_RESUME:
122 return "resume";
124 case TAPDISK_MESSAGE_RESUME_RSP:
125 return "resume response";
127 case TAPDISK_MESSAGE_CLOSE:
128 return "close";
130 case TAPDISK_MESSAGE_CLOSE_RSP:
131 return "close response";
133 case TAPDISK_MESSAGE_EXIT:
134 return "exit";
136 default:
137 return "unknown";
138 }
139 }
141 #endif