qcow2: Don't try to check tables that couldn't be loaded
[qemu.git] / hw / virtio-9p.h
blobb95dbe48afc0b0c01046a0040a968e79105b7e93
1 #ifndef _QEMU_VIRTIO_9P_H
2 #define _QEMU_VIRTIO_9P_H
4 #include <sys/types.h>
5 #include <dirent.h>
6 #include <sys/time.h>
7 #include <utime.h>
9 #include "file-op-9p.h"
11 /* The feature bitmap for virtio 9P */
12 /* The mount point is specified in a config variable */
13 #define VIRTIO_9P_MOUNT_TAG 0
15 enum {
16 P9_TVERSION = 100,
17 P9_RVERSION,
18 P9_TAUTH = 102,
19 P9_RAUTH,
20 P9_TATTACH = 104,
21 P9_RATTACH,
22 P9_TERROR = 106,
23 P9_RERROR,
24 P9_TFLUSH = 108,
25 P9_RFLUSH,
26 P9_TWALK = 110,
27 P9_RWALK,
28 P9_TOPEN = 112,
29 P9_ROPEN,
30 P9_TCREATE = 114,
31 P9_RCREATE,
32 P9_TREAD = 116,
33 P9_RREAD,
34 P9_TWRITE = 118,
35 P9_RWRITE,
36 P9_TCLUNK = 120,
37 P9_RCLUNK,
38 P9_TREMOVE = 122,
39 P9_RREMOVE,
40 P9_TSTAT = 124,
41 P9_RSTAT,
42 P9_TWSTAT = 126,
43 P9_RWSTAT,
47 /* qid.types */
48 enum {
49 P9_QTDIR = 0x80,
50 P9_QTAPPEND = 0x40,
51 P9_QTEXCL = 0x20,
52 P9_QTMOUNT = 0x10,
53 P9_QTAUTH = 0x08,
54 P9_QTTMP = 0x04,
55 P9_QTSYMLINK = 0x02,
56 P9_QTLINK = 0x01,
57 P9_QTFILE = 0x00,
60 #define P9_NOTAG (u16)(~0)
61 #define P9_NOFID (u32)(~0)
62 #define P9_MAXWELEM 16
64 typedef struct V9fsPDU V9fsPDU;
66 struct V9fsPDU
68 uint32_t size;
69 uint16_t tag;
70 uint8_t id;
71 VirtQueueElement elem;
72 QLIST_ENTRY(V9fsPDU) next;
76 /* FIXME
77 * 1) change user needs to set groups and stuff
80 /* from Linux's linux/virtio_9p.h */
82 /* The ID for virtio console */
83 #define VIRTIO_ID_9P 9
84 #define MAX_REQ 128
85 #define MAX_TAG_LEN 32
87 #define BUG_ON(cond) assert(!(cond))
89 typedef struct V9fsFidState V9fsFidState;
91 typedef struct V9fsString
93 int16_t size;
94 char *data;
95 } V9fsString;
97 typedef struct V9fsQID
99 int8_t type;
100 int32_t version;
101 int64_t path;
102 } V9fsQID;
104 typedef struct V9fsStat
106 int16_t size;
107 int16_t type;
108 int32_t dev;
109 V9fsQID qid;
110 int32_t mode;
111 int32_t atime;
112 int32_t mtime;
113 int64_t length;
114 V9fsString name;
115 V9fsString uid;
116 V9fsString gid;
117 V9fsString muid;
118 /* 9p2000.u */
119 V9fsString extension;
120 int32_t n_uid;
121 int32_t n_gid;
122 int32_t n_muid;
123 } V9fsStat;
125 struct V9fsFidState
127 int32_t fid;
128 V9fsString path;
129 int fd;
130 DIR *dir;
131 uid_t uid;
132 V9fsFidState *next;
135 typedef struct V9fsState
137 VirtIODevice vdev;
138 VirtQueue *vq;
139 V9fsPDU pdus[MAX_REQ];
140 QLIST_HEAD(, V9fsPDU) free_list;
141 V9fsFidState *fid_list;
142 FileOperations *ops;
143 FsContext ctx;
144 uint16_t tag_len;
145 uint8_t *tag;
146 size_t config_size;
147 } V9fsState;
149 struct virtio_9p_config
151 /* number of characters in tag */
152 uint16_t tag_len;
153 /* Variable size tag name */
154 uint8_t tag[0];
155 } __attribute__((packed));
157 extern size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count,
158 size_t offset, size_t size, int pack);
160 static inline size_t do_pdu_unpack(void *dst, struct iovec *sg, int sg_count,
161 size_t offset, size_t size)
163 return pdu_packunpack(dst, sg, sg_count, offset, size, 0);
166 #endif