]>
Commit | Line | Data |
---|---|---|
f27aaf4b CB |
1 | /* |
2 | * QEMU Block driver for RADOS (Ceph) | |
3 | * | |
ad32e9c0 JD |
4 | * Copyright (C) 2010-2011 Christian Brunner <[email protected]>, |
5 | * Josh Durgin <[email protected]> | |
f27aaf4b CB |
6 | * |
7 | * This work is licensed under the terms of the GNU GPL, version 2. See | |
8 | * the COPYING file in the top-level directory. | |
9 | * | |
6b620ca3 PB |
10 | * Contributions after 2012-01-13 are licensed under the terms of the |
11 | * GNU GPL, version 2 or (at your option) any later version. | |
f27aaf4b CB |
12 | */ |
13 | ||
80c71a24 | 14 | #include "qemu/osdep.h" |
ad32e9c0 | 15 | |
da34e65c | 16 | #include "qapi/error.h" |
1de7afc9 | 17 | #include "qemu/error-report.h" |
737e150e | 18 | #include "block/block_int.h" |
60390a21 | 19 | #include "crypto/secret.h" |
f348b6d1 | 20 | #include "qemu/cutils.h" |
f27aaf4b | 21 | |
ad32e9c0 | 22 | #include <rbd/librbd.h> |
f27aaf4b | 23 | |
f27aaf4b CB |
24 | /* |
25 | * When specifying the image filename use: | |
26 | * | |
fab5cf59 | 27 | * rbd:poolname/devicename[@snapshotname][:option1=value1[:option2=value2...]] |
f27aaf4b | 28 | * |
9e1fbcde | 29 | * poolname must be the name of an existing rados pool. |
f27aaf4b | 30 | * |
9e1fbcde | 31 | * devicename is the name of the rbd image. |
f27aaf4b | 32 | * |
9e1fbcde SW |
33 | * Each option given is used to configure rados, and may be any valid |
34 | * Ceph option, "id", or "conf". | |
fab5cf59 | 35 | * |
9e1fbcde SW |
36 | * The "id" option indicates what user we should authenticate as to |
37 | * the Ceph cluster. If it is excluded we will use the Ceph default | |
38 | * (normally 'admin'). | |
f27aaf4b | 39 | * |
9e1fbcde SW |
40 | * The "conf" option specifies a Ceph configuration file to read. If |
41 | * it is not specified, we will read from the default Ceph locations | |
42 | * (e.g., /etc/ceph/ceph.conf). To avoid reading _any_ configuration | |
43 | * file, specify conf=/dev/null. | |
f27aaf4b | 44 | * |
9e1fbcde SW |
45 | * Configuration values containing :, @, or = can be escaped with a |
46 | * leading "\". | |
f27aaf4b CB |
47 | */ |
48 | ||
787f3133 JD |
49 | /* rbd_aio_discard added in 0.1.2 */ |
50 | #if LIBRBD_VERSION_CODE >= LIBRBD_VERSION(0, 1, 2) | |
51 | #define LIBRBD_SUPPORTS_DISCARD | |
52 | #else | |
53 | #undef LIBRBD_SUPPORTS_DISCARD | |
54 | #endif | |
55 | ||
f27aaf4b CB |
56 | #define OBJ_MAX_SIZE (1UL << OBJ_DEFAULT_OBJ_ORDER) |
57 | ||
ad32e9c0 JD |
58 | #define RBD_MAX_CONF_NAME_SIZE 128 |
59 | #define RBD_MAX_CONF_VAL_SIZE 512 | |
60 | #define RBD_MAX_CONF_SIZE 1024 | |
61 | #define RBD_MAX_POOL_NAME_SIZE 128 | |
62 | #define RBD_MAX_SNAP_NAME_SIZE 128 | |
63 | #define RBD_MAX_SNAPS 100 | |
64 | ||
787f3133 JD |
65 | typedef enum { |
66 | RBD_AIO_READ, | |
67 | RBD_AIO_WRITE, | |
dc7588c1 JD |
68 | RBD_AIO_DISCARD, |
69 | RBD_AIO_FLUSH | |
787f3133 JD |
70 | } RBDAIOCmd; |
71 | ||
f27aaf4b | 72 | typedef struct RBDAIOCB { |
7c84b1b8 | 73 | BlockAIOCB common; |
f27aaf4b | 74 | QEMUBH *bh; |
08448d51 | 75 | int64_t ret; |
f27aaf4b CB |
76 | QEMUIOVector *qiov; |
77 | char *bounce; | |
787f3133 | 78 | RBDAIOCmd cmd; |
f27aaf4b CB |
79 | int error; |
80 | struct BDRVRBDState *s; | |
f27aaf4b CB |
81 | } RBDAIOCB; |
82 | ||
83 | typedef struct RADOSCB { | |
f27aaf4b CB |
84 | RBDAIOCB *acb; |
85 | struct BDRVRBDState *s; | |
ad32e9c0 | 86 | int64_t size; |
f27aaf4b | 87 | char *buf; |
08448d51 | 88 | int64_t ret; |
f27aaf4b CB |
89 | } RADOSCB; |
90 | ||
f27aaf4b | 91 | typedef struct BDRVRBDState { |
ad32e9c0 JD |
92 | rados_t cluster; |
93 | rados_ioctx_t io_ctx; | |
94 | rbd_image_t image; | |
95 | char name[RBD_MAX_IMAGE_NAME_SIZE]; | |
ad32e9c0 | 96 | char *snap; |
f27aaf4b CB |
97 | } BDRVRBDState; |
98 | ||
ad32e9c0 JD |
99 | static int qemu_rbd_next_tok(char *dst, int dst_len, |
100 | char *src, char delim, | |
101 | const char *name, | |
d61563b2 | 102 | char **p, Error **errp) |
f27aaf4b CB |
103 | { |
104 | int l; | |
105 | char *end; | |
106 | ||
107 | *p = NULL; | |
108 | ||
109 | if (delim != '\0') { | |
16a06b24 SW |
110 | for (end = src; *end; ++end) { |
111 | if (*end == delim) { | |
112 | break; | |
113 | } | |
114 | if (*end == '\\' && end[1] != '\0') { | |
115 | end++; | |
116 | } | |
117 | } | |
118 | if (*end == delim) { | |
f27aaf4b CB |
119 | *p = end + 1; |
120 | *end = '\0'; | |
121 | } | |
122 | } | |
123 | l = strlen(src); | |
124 | if (l >= dst_len) { | |
d61563b2 | 125 | error_setg(errp, "%s too long", name); |
f27aaf4b CB |
126 | return -EINVAL; |
127 | } else if (l == 0) { | |
d61563b2 | 128 | error_setg(errp, "%s too short", name); |
f27aaf4b CB |
129 | return -EINVAL; |
130 | } | |
131 | ||
132 | pstrcpy(dst, dst_len, src); | |
133 | ||
134 | return 0; | |
135 | } | |
136 | ||
16a06b24 SW |
137 | static void qemu_rbd_unescape(char *src) |
138 | { | |
139 | char *p; | |
140 | ||
141 | for (p = src; *src; ++src, ++p) { | |
142 | if (*src == '\\' && src[1] != '\0') { | |
143 | src++; | |
144 | } | |
145 | *p = *src; | |
146 | } | |
147 | *p = '\0'; | |
148 | } | |
149 | ||
ad32e9c0 JD |
150 | static int qemu_rbd_parsename(const char *filename, |
151 | char *pool, int pool_len, | |
152 | char *snap, int snap_len, | |
fab5cf59 | 153 | char *name, int name_len, |
d61563b2 MA |
154 | char *conf, int conf_len, |
155 | Error **errp) | |
f27aaf4b CB |
156 | { |
157 | const char *start; | |
158 | char *p, *buf; | |
159 | int ret; | |
160 | ||
161 | if (!strstart(filename, "rbd:", &start)) { | |
d61563b2 | 162 | error_setg(errp, "File name must start with 'rbd:'"); |
f27aaf4b CB |
163 | return -EINVAL; |
164 | } | |
165 | ||
7267c094 | 166 | buf = g_strdup(start); |
f27aaf4b | 167 | p = buf; |
fab5cf59 JD |
168 | *snap = '\0'; |
169 | *conf = '\0'; | |
f27aaf4b | 170 | |
d61563b2 MA |
171 | ret = qemu_rbd_next_tok(pool, pool_len, p, |
172 | '/', "pool name", &p, errp); | |
f27aaf4b CB |
173 | if (ret < 0 || !p) { |
174 | ret = -EINVAL; | |
175 | goto done; | |
176 | } | |
16a06b24 | 177 | qemu_rbd_unescape(pool); |
fab5cf59 JD |
178 | |
179 | if (strchr(p, '@')) { | |
d61563b2 MA |
180 | ret = qemu_rbd_next_tok(name, name_len, p, |
181 | '@', "object name", &p, errp); | |
fab5cf59 JD |
182 | if (ret < 0) { |
183 | goto done; | |
184 | } | |
d61563b2 MA |
185 | ret = qemu_rbd_next_tok(snap, snap_len, p, |
186 | ':', "snap name", &p, errp); | |
16a06b24 | 187 | qemu_rbd_unescape(snap); |
fab5cf59 | 188 | } else { |
d61563b2 MA |
189 | ret = qemu_rbd_next_tok(name, name_len, p, |
190 | ':', "object name", &p, errp); | |
f27aaf4b | 191 | } |
16a06b24 | 192 | qemu_rbd_unescape(name); |
fab5cf59 | 193 | if (ret < 0 || !p) { |
f27aaf4b CB |
194 | goto done; |
195 | } | |
196 | ||
d61563b2 MA |
197 | ret = qemu_rbd_next_tok(conf, conf_len, p, |
198 | '\0', "configuration", &p, errp); | |
f27aaf4b CB |
199 | |
200 | done: | |
7267c094 | 201 | g_free(buf); |
f27aaf4b CB |
202 | return ret; |
203 | } | |
204 | ||
7c7e9df0 SW |
205 | static char *qemu_rbd_parse_clientname(const char *conf, char *clientname) |
206 | { | |
207 | const char *p = conf; | |
208 | ||
209 | while (*p) { | |
210 | int len; | |
211 | const char *end = strchr(p, ':'); | |
212 | ||
213 | if (end) { | |
214 | len = end - p; | |
215 | } else { | |
216 | len = strlen(p); | |
217 | } | |
218 | ||
219 | if (strncmp(p, "id=", 3) == 0) { | |
220 | len -= 3; | |
221 | strncpy(clientname, p + 3, len); | |
222 | clientname[len] = '\0'; | |
223 | return clientname; | |
224 | } | |
225 | if (end == NULL) { | |
226 | break; | |
227 | } | |
228 | p = end + 1; | |
229 | } | |
230 | return NULL; | |
231 | } | |
232 | ||
60390a21 DB |
233 | |
234 | static int qemu_rbd_set_auth(rados_t cluster, const char *secretid, | |
235 | Error **errp) | |
236 | { | |
237 | if (secretid == 0) { | |
238 | return 0; | |
239 | } | |
240 | ||
241 | gchar *secret = qcrypto_secret_lookup_as_base64(secretid, | |
242 | errp); | |
243 | if (!secret) { | |
244 | return -1; | |
245 | } | |
246 | ||
247 | rados_conf_set(cluster, "key", secret); | |
248 | g_free(secret); | |
249 | ||
250 | return 0; | |
251 | } | |
252 | ||
253 | ||
e34d8f29 JD |
254 | static int qemu_rbd_set_conf(rados_t cluster, const char *conf, |
255 | bool only_read_conf_file, | |
256 | Error **errp) | |
fab5cf59 JD |
257 | { |
258 | char *p, *buf; | |
259 | char name[RBD_MAX_CONF_NAME_SIZE]; | |
260 | char value[RBD_MAX_CONF_VAL_SIZE]; | |
261 | int ret = 0; | |
262 | ||
7267c094 | 263 | buf = g_strdup(conf); |
fab5cf59 JD |
264 | p = buf; |
265 | ||
266 | while (p) { | |
267 | ret = qemu_rbd_next_tok(name, sizeof(name), p, | |
d61563b2 | 268 | '=', "conf option name", &p, errp); |
fab5cf59 JD |
269 | if (ret < 0) { |
270 | break; | |
271 | } | |
16a06b24 | 272 | qemu_rbd_unescape(name); |
fab5cf59 JD |
273 | |
274 | if (!p) { | |
d61563b2 | 275 | error_setg(errp, "conf option %s has no value", name); |
fab5cf59 JD |
276 | ret = -EINVAL; |
277 | break; | |
278 | } | |
279 | ||
280 | ret = qemu_rbd_next_tok(value, sizeof(value), p, | |
d61563b2 | 281 | ':', "conf option value", &p, errp); |
fab5cf59 JD |
282 | if (ret < 0) { |
283 | break; | |
284 | } | |
16a06b24 | 285 | qemu_rbd_unescape(value); |
fab5cf59 | 286 | |
7c7e9df0 | 287 | if (strcmp(name, "conf") == 0) { |
e34d8f29 JD |
288 | /* read the conf file alone, so it doesn't override more |
289 | specific settings for a particular device */ | |
290 | if (only_read_conf_file) { | |
291 | ret = rados_conf_read_file(cluster, value); | |
292 | if (ret < 0) { | |
87cd3d20 VU |
293 | error_setg_errno(errp, -ret, "error reading conf file %s", |
294 | value); | |
e34d8f29 JD |
295 | break; |
296 | } | |
fab5cf59 | 297 | } |
7c7e9df0 SW |
298 | } else if (strcmp(name, "id") == 0) { |
299 | /* ignore, this is parsed by qemu_rbd_parse_clientname() */ | |
e34d8f29 | 300 | } else if (!only_read_conf_file) { |
7c7e9df0 | 301 | ret = rados_conf_set(cluster, name, value); |
fab5cf59 | 302 | if (ret < 0) { |
87cd3d20 | 303 | error_setg_errno(errp, -ret, "invalid conf option %s", name); |
7c7e9df0 | 304 | ret = -EINVAL; |
fab5cf59 JD |
305 | break; |
306 | } | |
307 | } | |
308 | } | |
309 | ||
7267c094 | 310 | g_free(buf); |
fab5cf59 JD |
311 | return ret; |
312 | } | |
313 | ||
bd0cf596 | 314 | static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp) |
f27aaf4b | 315 | { |
d61563b2 | 316 | Error *local_err = NULL; |
f27aaf4b CB |
317 | int64_t bytes = 0; |
318 | int64_t objsize; | |
ad32e9c0 JD |
319 | int obj_order = 0; |
320 | char pool[RBD_MAX_POOL_NAME_SIZE]; | |
321 | char name[RBD_MAX_IMAGE_NAME_SIZE]; | |
322 | char snap_buf[RBD_MAX_SNAP_NAME_SIZE]; | |
fab5cf59 | 323 | char conf[RBD_MAX_CONF_SIZE]; |
7c7e9df0 SW |
324 | char clientname_buf[RBD_MAX_CONF_SIZE]; |
325 | char *clientname; | |
60390a21 | 326 | const char *secretid; |
ad32e9c0 JD |
327 | rados_t cluster; |
328 | rados_ioctx_t io_ctx; | |
f27aaf4b CB |
329 | int ret; |
330 | ||
60390a21 DB |
331 | secretid = qemu_opt_get(opts, "password-secret"); |
332 | ||
ad32e9c0 JD |
333 | if (qemu_rbd_parsename(filename, pool, sizeof(pool), |
334 | snap_buf, sizeof(snap_buf), | |
fab5cf59 | 335 | name, sizeof(name), |
d61563b2 MA |
336 | conf, sizeof(conf), &local_err) < 0) { |
337 | error_propagate(errp, local_err); | |
f27aaf4b CB |
338 | return -EINVAL; |
339 | } | |
f27aaf4b | 340 | |
f27aaf4b | 341 | /* Read out options */ |
c2eb918e HT |
342 | bytes = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), |
343 | BDRV_SECTOR_SIZE); | |
bd0cf596 CL |
344 | objsize = qemu_opt_get_size_del(opts, BLOCK_OPT_CLUSTER_SIZE, 0); |
345 | if (objsize) { | |
346 | if ((objsize - 1) & objsize) { /* not a power of 2? */ | |
347 | error_setg(errp, "obj size needs to be power of 2"); | |
348 | return -EINVAL; | |
349 | } | |
350 | if (objsize < 4096) { | |
351 | error_setg(errp, "obj size too small"); | |
352 | return -EINVAL; | |
f27aaf4b | 353 | } |
786a4ea8 | 354 | obj_order = ctz32(objsize); |
f27aaf4b CB |
355 | } |
356 | ||
7c7e9df0 | 357 | clientname = qemu_rbd_parse_clientname(conf, clientname_buf); |
87cd3d20 VU |
358 | ret = rados_create(&cluster, clientname); |
359 | if (ret < 0) { | |
360 | error_setg_errno(errp, -ret, "error initializing"); | |
361 | return ret; | |
f27aaf4b CB |
362 | } |
363 | ||
fab5cf59 | 364 | if (strstr(conf, "conf=") == NULL) { |
f9fe18ec SW |
365 | /* try default location, but ignore failure */ |
366 | rados_conf_read_file(cluster, NULL); | |
e34d8f29 JD |
367 | } else if (conf[0] != '\0' && |
368 | qemu_rbd_set_conf(cluster, conf, true, &local_err) < 0) { | |
369 | rados_shutdown(cluster); | |
370 | error_propagate(errp, local_err); | |
371 | return -EIO; | |
fab5cf59 JD |
372 | } |
373 | ||
374 | if (conf[0] != '\0' && | |
e34d8f29 | 375 | qemu_rbd_set_conf(cluster, conf, false, &local_err) < 0) { |
ad32e9c0 | 376 | rados_shutdown(cluster); |
d61563b2 | 377 | error_propagate(errp, local_err); |
f27aaf4b CB |
378 | return -EIO; |
379 | } | |
380 | ||
60390a21 DB |
381 | if (qemu_rbd_set_auth(cluster, secretid, errp) < 0) { |
382 | rados_shutdown(cluster); | |
383 | return -EIO; | |
384 | } | |
385 | ||
87cd3d20 VU |
386 | ret = rados_connect(cluster); |
387 | if (ret < 0) { | |
388 | error_setg_errno(errp, -ret, "error connecting"); | |
ad32e9c0 | 389 | rados_shutdown(cluster); |
87cd3d20 | 390 | return ret; |
f27aaf4b | 391 | } |
f27aaf4b | 392 | |
87cd3d20 VU |
393 | ret = rados_ioctx_create(cluster, pool, &io_ctx); |
394 | if (ret < 0) { | |
395 | error_setg_errno(errp, -ret, "error opening pool %s", pool); | |
ad32e9c0 | 396 | rados_shutdown(cluster); |
87cd3d20 | 397 | return ret; |
f27aaf4b CB |
398 | } |
399 | ||
ad32e9c0 JD |
400 | ret = rbd_create(io_ctx, name, bytes, &obj_order); |
401 | rados_ioctx_destroy(io_ctx); | |
402 | rados_shutdown(cluster); | |
87cd3d20 VU |
403 | if (ret < 0) { |
404 | error_setg_errno(errp, -ret, "error rbd create"); | |
405 | return ret; | |
406 | } | |
f27aaf4b CB |
407 | |
408 | return ret; | |
409 | } | |
410 | ||
411 | /* | |
e04fb07f SH |
412 | * This aio completion is being called from rbd_finish_bh() and runs in qemu |
413 | * BH context. | |
f27aaf4b | 414 | */ |
ad32e9c0 | 415 | static void qemu_rbd_complete_aio(RADOSCB *rcb) |
f27aaf4b CB |
416 | { |
417 | RBDAIOCB *acb = rcb->acb; | |
418 | int64_t r; | |
419 | ||
f27aaf4b CB |
420 | r = rcb->ret; |
421 | ||
dc7588c1 | 422 | if (acb->cmd != RBD_AIO_READ) { |
f27aaf4b CB |
423 | if (r < 0) { |
424 | acb->ret = r; | |
425 | acb->error = 1; | |
426 | } else if (!acb->error) { | |
ad32e9c0 | 427 | acb->ret = rcb->size; |
f27aaf4b CB |
428 | } |
429 | } else { | |
ad32e9c0 JD |
430 | if (r < 0) { |
431 | memset(rcb->buf, 0, rcb->size); | |
f27aaf4b CB |
432 | acb->ret = r; |
433 | acb->error = 1; | |
ad32e9c0 JD |
434 | } else if (r < rcb->size) { |
435 | memset(rcb->buf + r, 0, rcb->size - r); | |
f27aaf4b | 436 | if (!acb->error) { |
ad32e9c0 | 437 | acb->ret = rcb->size; |
f27aaf4b CB |
438 | } |
439 | } else if (!acb->error) { | |
ad32e9c0 | 440 | acb->ret = r; |
f27aaf4b CB |
441 | } |
442 | } | |
f27aaf4b | 443 | |
e04fb07f | 444 | g_free(rcb); |
f27aaf4b | 445 | |
e04fb07f SH |
446 | if (acb->cmd == RBD_AIO_READ) { |
447 | qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size); | |
448 | } | |
449 | qemu_vfree(acb->bounce); | |
450 | acb->common.cb(acb->common.opaque, (acb->ret > 0 ? 0 : acb->ret)); | |
f27aaf4b | 451 | |
8007429a | 452 | qemu_aio_unref(acb); |
f27aaf4b CB |
453 | } |
454 | ||
a9ccedc3 KW |
455 | /* TODO Convert to fine grained options */ |
456 | static QemuOptsList runtime_opts = { | |
457 | .name = "rbd", | |
458 | .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), | |
459 | .desc = { | |
460 | { | |
461 | .name = "filename", | |
462 | .type = QEMU_OPT_STRING, | |
463 | .help = "Specification of the rbd image", | |
464 | }, | |
60390a21 DB |
465 | { |
466 | .name = "password-secret", | |
467 | .type = QEMU_OPT_STRING, | |
468 | .help = "ID of secret providing the password", | |
469 | }, | |
a9ccedc3 KW |
470 | { /* end of list */ } |
471 | }, | |
472 | }; | |
473 | ||
015a1036 HR |
474 | static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, |
475 | Error **errp) | |
f27aaf4b CB |
476 | { |
477 | BDRVRBDState *s = bs->opaque; | |
ad32e9c0 JD |
478 | char pool[RBD_MAX_POOL_NAME_SIZE]; |
479 | char snap_buf[RBD_MAX_SNAP_NAME_SIZE]; | |
fab5cf59 | 480 | char conf[RBD_MAX_CONF_SIZE]; |
7c7e9df0 SW |
481 | char clientname_buf[RBD_MAX_CONF_SIZE]; |
482 | char *clientname; | |
60390a21 | 483 | const char *secretid; |
a9ccedc3 KW |
484 | QemuOpts *opts; |
485 | Error *local_err = NULL; | |
486 | const char *filename; | |
f27aaf4b CB |
487 | int r; |
488 | ||
87ea75d5 | 489 | opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); |
a9ccedc3 | 490 | qemu_opts_absorb_qdict(opts, options, &local_err); |
84d18f06 | 491 | if (local_err) { |
d61563b2 | 492 | error_propagate(errp, local_err); |
a9ccedc3 KW |
493 | qemu_opts_del(opts); |
494 | return -EINVAL; | |
495 | } | |
496 | ||
497 | filename = qemu_opt_get(opts, "filename"); | |
60390a21 | 498 | secretid = qemu_opt_get(opts, "password-secret"); |
a9ccedc3 | 499 | |
ad32e9c0 JD |
500 | if (qemu_rbd_parsename(filename, pool, sizeof(pool), |
501 | snap_buf, sizeof(snap_buf), | |
fab5cf59 | 502 | s->name, sizeof(s->name), |
d61563b2 | 503 | conf, sizeof(conf), errp) < 0) { |
c3ca988d KW |
504 | r = -EINVAL; |
505 | goto failed_opts; | |
f27aaf4b | 506 | } |
f27aaf4b | 507 | |
7c7e9df0 SW |
508 | clientname = qemu_rbd_parse_clientname(conf, clientname_buf); |
509 | r = rados_create(&s->cluster, clientname); | |
ad32e9c0 | 510 | if (r < 0) { |
87cd3d20 | 511 | error_setg_errno(errp, -r, "error initializing"); |
c3ca988d | 512 | goto failed_opts; |
f27aaf4b CB |
513 | } |
514 | ||
eb93d5d9 SW |
515 | s->snap = NULL; |
516 | if (snap_buf[0] != '\0') { | |
517 | s->snap = g_strdup(snap_buf); | |
518 | } | |
519 | ||
99a3c89d JD |
520 | if (strstr(conf, "conf=") == NULL) { |
521 | /* try default location, but ignore failure */ | |
522 | rados_conf_read_file(s->cluster, NULL); | |
e34d8f29 JD |
523 | } else if (conf[0] != '\0') { |
524 | r = qemu_rbd_set_conf(s->cluster, conf, true, errp); | |
525 | if (r < 0) { | |
526 | goto failed_shutdown; | |
527 | } | |
99a3c89d JD |
528 | } |
529 | ||
530 | if (conf[0] != '\0') { | |
e34d8f29 | 531 | r = qemu_rbd_set_conf(s->cluster, conf, false, errp); |
99a3c89d JD |
532 | if (r < 0) { |
533 | goto failed_shutdown; | |
534 | } | |
535 | } | |
536 | ||
60390a21 DB |
537 | if (qemu_rbd_set_auth(s->cluster, secretid, errp) < 0) { |
538 | r = -EIO; | |
539 | goto failed_shutdown; | |
540 | } | |
541 | ||
b11f38fc JD |
542 | /* |
543 | * Fallback to more conservative semantics if setting cache | |
544 | * options fails. Ignore errors from setting rbd_cache because the | |
545 | * only possible error is that the option does not exist, and | |
546 | * librbd defaults to no caching. If write through caching cannot | |
547 | * be set up, fall back to no caching. | |
548 | */ | |
549 | if (flags & BDRV_O_NOCACHE) { | |
550 | rados_conf_set(s->cluster, "rbd_cache", "false"); | |
551 | } else { | |
552 | rados_conf_set(s->cluster, "rbd_cache", "true"); | |
b11f38fc JD |
553 | } |
554 | ||
ad32e9c0 JD |
555 | r = rados_connect(s->cluster); |
556 | if (r < 0) { | |
87cd3d20 | 557 | error_setg_errno(errp, -r, "error connecting"); |
eb93d5d9 | 558 | goto failed_shutdown; |
f27aaf4b CB |
559 | } |
560 | ||
ad32e9c0 JD |
561 | r = rados_ioctx_create(s->cluster, pool, &s->io_ctx); |
562 | if (r < 0) { | |
87cd3d20 | 563 | error_setg_errno(errp, -r, "error opening pool %s", pool); |
eb93d5d9 | 564 | goto failed_shutdown; |
f27aaf4b CB |
565 | } |
566 | ||
ad32e9c0 | 567 | r = rbd_open(s->io_ctx, s->name, &s->image, s->snap); |
f27aaf4b | 568 | if (r < 0) { |
87cd3d20 | 569 | error_setg_errno(errp, -r, "error reading header from %s", s->name); |
eb93d5d9 | 570 | goto failed_open; |
f27aaf4b CB |
571 | } |
572 | ||
ad32e9c0 | 573 | bs->read_only = (s->snap != NULL); |
f27aaf4b | 574 | |
c3ca988d | 575 | qemu_opts_del(opts); |
f27aaf4b CB |
576 | return 0; |
577 | ||
eb93d5d9 | 578 | failed_open: |
ad32e9c0 | 579 | rados_ioctx_destroy(s->io_ctx); |
eb93d5d9 | 580 | failed_shutdown: |
ad32e9c0 | 581 | rados_shutdown(s->cluster); |
eb93d5d9 | 582 | g_free(s->snap); |
c3ca988d KW |
583 | failed_opts: |
584 | qemu_opts_del(opts); | |
f27aaf4b CB |
585 | return r; |
586 | } | |
587 | ||
ad32e9c0 | 588 | static void qemu_rbd_close(BlockDriverState *bs) |
f27aaf4b CB |
589 | { |
590 | BDRVRBDState *s = bs->opaque; | |
591 | ||
ad32e9c0 JD |
592 | rbd_close(s->image); |
593 | rados_ioctx_destroy(s->io_ctx); | |
7267c094 | 594 | g_free(s->snap); |
ad32e9c0 | 595 | rados_shutdown(s->cluster); |
f27aaf4b CB |
596 | } |
597 | ||
d7331bed | 598 | static const AIOCBInfo rbd_aiocb_info = { |
f27aaf4b | 599 | .aiocb_size = sizeof(RBDAIOCB), |
f27aaf4b CB |
600 | }; |
601 | ||
e04fb07f | 602 | static void rbd_finish_bh(void *opaque) |
f27aaf4b | 603 | { |
e04fb07f SH |
604 | RADOSCB *rcb = opaque; |
605 | qemu_bh_delete(rcb->acb->bh); | |
606 | qemu_rbd_complete_aio(rcb); | |
ad32e9c0 JD |
607 | } |
608 | ||
609 | /* | |
610 | * This is the callback function for rbd_aio_read and _write | |
611 | * | |
612 | * Note: this function is being called from a non qemu thread so | |
613 | * we need to be careful about what we do here. Generally we only | |
e04fb07f SH |
614 | * schedule a BH, and do the rest of the io completion handling |
615 | * from rbd_finish_bh() which runs in a qemu context. | |
ad32e9c0 JD |
616 | */ |
617 | static void rbd_finish_aiocb(rbd_completion_t c, RADOSCB *rcb) | |
618 | { | |
e04fb07f SH |
619 | RBDAIOCB *acb = rcb->acb; |
620 | ||
ad32e9c0 JD |
621 | rcb->ret = rbd_aio_get_return_value(c); |
622 | rbd_aio_release(c); | |
f27aaf4b | 623 | |
ea800191 SH |
624 | acb->bh = aio_bh_new(bdrv_get_aio_context(acb->common.bs), |
625 | rbd_finish_bh, rcb); | |
e04fb07f | 626 | qemu_bh_schedule(acb->bh); |
f27aaf4b CB |
627 | } |
628 | ||
787f3133 JD |
629 | static int rbd_aio_discard_wrapper(rbd_image_t image, |
630 | uint64_t off, | |
631 | uint64_t len, | |
632 | rbd_completion_t comp) | |
633 | { | |
634 | #ifdef LIBRBD_SUPPORTS_DISCARD | |
635 | return rbd_aio_discard(image, off, len, comp); | |
636 | #else | |
637 | return -ENOTSUP; | |
638 | #endif | |
639 | } | |
640 | ||
dc7588c1 JD |
641 | static int rbd_aio_flush_wrapper(rbd_image_t image, |
642 | rbd_completion_t comp) | |
643 | { | |
644 | #ifdef LIBRBD_SUPPORTS_AIO_FLUSH | |
645 | return rbd_aio_flush(image, comp); | |
646 | #else | |
647 | return -ENOTSUP; | |
648 | #endif | |
649 | } | |
650 | ||
7c84b1b8 MA |
651 | static BlockAIOCB *rbd_start_aio(BlockDriverState *bs, |
652 | int64_t sector_num, | |
653 | QEMUIOVector *qiov, | |
654 | int nb_sectors, | |
097310b5 | 655 | BlockCompletionFunc *cb, |
7c84b1b8 MA |
656 | void *opaque, |
657 | RBDAIOCmd cmd) | |
f27aaf4b CB |
658 | { |
659 | RBDAIOCB *acb; | |
0f7a0237 | 660 | RADOSCB *rcb = NULL; |
ad32e9c0 | 661 | rbd_completion_t c; |
f27aaf4b CB |
662 | int64_t off, size; |
663 | char *buf; | |
51a13528 | 664 | int r; |
f27aaf4b CB |
665 | |
666 | BDRVRBDState *s = bs->opaque; | |
667 | ||
d7331bed | 668 | acb = qemu_aio_get(&rbd_aiocb_info, bs, cb, opaque); |
787f3133 | 669 | acb->cmd = cmd; |
f27aaf4b | 670 | acb->qiov = qiov; |
dc7588c1 | 671 | if (cmd == RBD_AIO_DISCARD || cmd == RBD_AIO_FLUSH) { |
787f3133 JD |
672 | acb->bounce = NULL; |
673 | } else { | |
0f7a0237 KW |
674 | acb->bounce = qemu_try_blockalign(bs, qiov->size); |
675 | if (acb->bounce == NULL) { | |
676 | goto failed; | |
677 | } | |
787f3133 | 678 | } |
f27aaf4b CB |
679 | acb->ret = 0; |
680 | acb->error = 0; | |
681 | acb->s = s; | |
f27aaf4b CB |
682 | acb->bh = NULL; |
683 | ||
787f3133 | 684 | if (cmd == RBD_AIO_WRITE) { |
d5e6b161 | 685 | qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size); |
f27aaf4b CB |
686 | } |
687 | ||
688 | buf = acb->bounce; | |
689 | ||
690 | off = sector_num * BDRV_SECTOR_SIZE; | |
691 | size = nb_sectors * BDRV_SECTOR_SIZE; | |
f27aaf4b | 692 | |
5839e53b | 693 | rcb = g_new(RADOSCB, 1); |
ad32e9c0 JD |
694 | rcb->acb = acb; |
695 | rcb->buf = buf; | |
696 | rcb->s = acb->s; | |
697 | rcb->size = size; | |
51a13528 JD |
698 | r = rbd_aio_create_completion(rcb, (rbd_callback_t) rbd_finish_aiocb, &c); |
699 | if (r < 0) { | |
700 | goto failed; | |
701 | } | |
f27aaf4b | 702 | |
787f3133 JD |
703 | switch (cmd) { |
704 | case RBD_AIO_WRITE: | |
51a13528 | 705 | r = rbd_aio_write(s->image, off, size, buf, c); |
787f3133 JD |
706 | break; |
707 | case RBD_AIO_READ: | |
51a13528 | 708 | r = rbd_aio_read(s->image, off, size, buf, c); |
787f3133 JD |
709 | break; |
710 | case RBD_AIO_DISCARD: | |
711 | r = rbd_aio_discard_wrapper(s->image, off, size, c); | |
712 | break; | |
dc7588c1 JD |
713 | case RBD_AIO_FLUSH: |
714 | r = rbd_aio_flush_wrapper(s->image, c); | |
715 | break; | |
787f3133 JD |
716 | default: |
717 | r = -EINVAL; | |
51a13528 JD |
718 | } |
719 | ||
720 | if (r < 0) { | |
405a2764 | 721 | goto failed_completion; |
f27aaf4b CB |
722 | } |
723 | ||
724 | return &acb->common; | |
51a13528 | 725 | |
405a2764 KW |
726 | failed_completion: |
727 | rbd_aio_release(c); | |
51a13528 | 728 | failed: |
7267c094 | 729 | g_free(rcb); |
405a2764 | 730 | qemu_vfree(acb->bounce); |
8007429a | 731 | qemu_aio_unref(acb); |
51a13528 | 732 | return NULL; |
f27aaf4b CB |
733 | } |
734 | ||
7c84b1b8 MA |
735 | static BlockAIOCB *qemu_rbd_aio_readv(BlockDriverState *bs, |
736 | int64_t sector_num, | |
737 | QEMUIOVector *qiov, | |
738 | int nb_sectors, | |
097310b5 | 739 | BlockCompletionFunc *cb, |
7c84b1b8 | 740 | void *opaque) |
f27aaf4b | 741 | { |
787f3133 JD |
742 | return rbd_start_aio(bs, sector_num, qiov, nb_sectors, cb, opaque, |
743 | RBD_AIO_READ); | |
f27aaf4b CB |
744 | } |
745 | ||
7c84b1b8 MA |
746 | static BlockAIOCB *qemu_rbd_aio_writev(BlockDriverState *bs, |
747 | int64_t sector_num, | |
748 | QEMUIOVector *qiov, | |
749 | int nb_sectors, | |
097310b5 | 750 | BlockCompletionFunc *cb, |
7c84b1b8 | 751 | void *opaque) |
f27aaf4b | 752 | { |
787f3133 JD |
753 | return rbd_start_aio(bs, sector_num, qiov, nb_sectors, cb, opaque, |
754 | RBD_AIO_WRITE); | |
f27aaf4b CB |
755 | } |
756 | ||
dc7588c1 | 757 | #ifdef LIBRBD_SUPPORTS_AIO_FLUSH |
7c84b1b8 | 758 | static BlockAIOCB *qemu_rbd_aio_flush(BlockDriverState *bs, |
097310b5 | 759 | BlockCompletionFunc *cb, |
7c84b1b8 | 760 | void *opaque) |
dc7588c1 JD |
761 | { |
762 | return rbd_start_aio(bs, 0, NULL, 0, cb, opaque, RBD_AIO_FLUSH); | |
763 | } | |
764 | ||
765 | #else | |
766 | ||
8b94ff85 | 767 | static int qemu_rbd_co_flush(BlockDriverState *bs) |
7a3f5fe9 SW |
768 | { |
769 | #if LIBRBD_VERSION_CODE >= LIBRBD_VERSION(0, 1, 1) | |
770 | /* rbd_flush added in 0.1.1 */ | |
771 | BDRVRBDState *s = bs->opaque; | |
772 | return rbd_flush(s->image); | |
773 | #else | |
774 | return 0; | |
775 | #endif | |
776 | } | |
dc7588c1 | 777 | #endif |
7a3f5fe9 | 778 | |
ad32e9c0 | 779 | static int qemu_rbd_getinfo(BlockDriverState *bs, BlockDriverInfo *bdi) |
f27aaf4b CB |
780 | { |
781 | BDRVRBDState *s = bs->opaque; | |
ad32e9c0 JD |
782 | rbd_image_info_t info; |
783 | int r; | |
784 | ||
785 | r = rbd_stat(s->image, &info, sizeof(info)); | |
786 | if (r < 0) { | |
787 | return r; | |
788 | } | |
789 | ||
790 | bdi->cluster_size = info.obj_size; | |
f27aaf4b CB |
791 | return 0; |
792 | } | |
793 | ||
ad32e9c0 | 794 | static int64_t qemu_rbd_getlength(BlockDriverState *bs) |
f27aaf4b CB |
795 | { |
796 | BDRVRBDState *s = bs->opaque; | |
ad32e9c0 JD |
797 | rbd_image_info_t info; |
798 | int r; | |
f27aaf4b | 799 | |
ad32e9c0 JD |
800 | r = rbd_stat(s->image, &info, sizeof(info)); |
801 | if (r < 0) { | |
802 | return r; | |
803 | } | |
804 | ||
805 | return info.size; | |
f27aaf4b CB |
806 | } |
807 | ||
30cdc48c JD |
808 | static int qemu_rbd_truncate(BlockDriverState *bs, int64_t offset) |
809 | { | |
810 | BDRVRBDState *s = bs->opaque; | |
811 | int r; | |
812 | ||
813 | r = rbd_resize(s->image, offset); | |
814 | if (r < 0) { | |
815 | return r; | |
816 | } | |
817 | ||
818 | return 0; | |
819 | } | |
820 | ||
ad32e9c0 JD |
821 | static int qemu_rbd_snap_create(BlockDriverState *bs, |
822 | QEMUSnapshotInfo *sn_info) | |
f27aaf4b CB |
823 | { |
824 | BDRVRBDState *s = bs->opaque; | |
f27aaf4b | 825 | int r; |
f27aaf4b CB |
826 | |
827 | if (sn_info->name[0] == '\0') { | |
828 | return -EINVAL; /* we need a name for rbd snapshots */ | |
829 | } | |
830 | ||
831 | /* | |
832 | * rbd snapshots are using the name as the user controlled unique identifier | |
833 | * we can't use the rbd snapid for that purpose, as it can't be set | |
834 | */ | |
835 | if (sn_info->id_str[0] != '\0' && | |
836 | strcmp(sn_info->id_str, sn_info->name) != 0) { | |
837 | return -EINVAL; | |
838 | } | |
839 | ||
840 | if (strlen(sn_info->name) >= sizeof(sn_info->id_str)) { | |
841 | return -ERANGE; | |
842 | } | |
843 | ||
ad32e9c0 | 844 | r = rbd_snap_create(s->image, sn_info->name); |
f27aaf4b | 845 | if (r < 0) { |
ad32e9c0 | 846 | error_report("failed to create snap: %s", strerror(-r)); |
f27aaf4b CB |
847 | return r; |
848 | } | |
849 | ||
f27aaf4b CB |
850 | return 0; |
851 | } | |
852 | ||
bd603247 | 853 | static int qemu_rbd_snap_remove(BlockDriverState *bs, |
a89d89d3 WX |
854 | const char *snapshot_id, |
855 | const char *snapshot_name, | |
856 | Error **errp) | |
bd603247 GF |
857 | { |
858 | BDRVRBDState *s = bs->opaque; | |
859 | int r; | |
860 | ||
a89d89d3 WX |
861 | if (!snapshot_name) { |
862 | error_setg(errp, "rbd need a valid snapshot name"); | |
863 | return -EINVAL; | |
864 | } | |
865 | ||
866 | /* If snapshot_id is specified, it must be equal to name, see | |
867 | qemu_rbd_snap_list() */ | |
868 | if (snapshot_id && strcmp(snapshot_id, snapshot_name)) { | |
869 | error_setg(errp, | |
870 | "rbd do not support snapshot id, it should be NULL or " | |
871 | "equal to snapshot name"); | |
872 | return -EINVAL; | |
873 | } | |
874 | ||
bd603247 | 875 | r = rbd_snap_remove(s->image, snapshot_name); |
a89d89d3 WX |
876 | if (r < 0) { |
877 | error_setg_errno(errp, -r, "Failed to remove the snapshot"); | |
878 | } | |
bd603247 GF |
879 | return r; |
880 | } | |
881 | ||
882 | static int qemu_rbd_snap_rollback(BlockDriverState *bs, | |
883 | const char *snapshot_name) | |
884 | { | |
885 | BDRVRBDState *s = bs->opaque; | |
886 | int r; | |
887 | ||
888 | r = rbd_snap_rollback(s->image, snapshot_name); | |
889 | return r; | |
890 | } | |
891 | ||
ad32e9c0 JD |
892 | static int qemu_rbd_snap_list(BlockDriverState *bs, |
893 | QEMUSnapshotInfo **psn_tab) | |
f27aaf4b CB |
894 | { |
895 | BDRVRBDState *s = bs->opaque; | |
f27aaf4b | 896 | QEMUSnapshotInfo *sn_info, *sn_tab = NULL; |
ad32e9c0 JD |
897 | int i, snap_count; |
898 | rbd_snap_info_t *snaps; | |
899 | int max_snaps = RBD_MAX_SNAPS; | |
f27aaf4b | 900 | |
ad32e9c0 | 901 | do { |
02c4f26b | 902 | snaps = g_new(rbd_snap_info_t, max_snaps); |
ad32e9c0 | 903 | snap_count = rbd_snap_list(s->image, snaps, &max_snaps); |
9e6337d0 | 904 | if (snap_count <= 0) { |
7267c094 | 905 | g_free(snaps); |
f27aaf4b | 906 | } |
ad32e9c0 | 907 | } while (snap_count == -ERANGE); |
f27aaf4b | 908 | |
ad32e9c0 | 909 | if (snap_count <= 0) { |
b9c53290 | 910 | goto done; |
f27aaf4b CB |
911 | } |
912 | ||
5839e53b | 913 | sn_tab = g_new0(QEMUSnapshotInfo, snap_count); |
f27aaf4b | 914 | |
ad32e9c0 JD |
915 | for (i = 0; i < snap_count; i++) { |
916 | const char *snap_name = snaps[i].name; | |
f27aaf4b CB |
917 | |
918 | sn_info = sn_tab + i; | |
919 | pstrcpy(sn_info->id_str, sizeof(sn_info->id_str), snap_name); | |
920 | pstrcpy(sn_info->name, sizeof(sn_info->name), snap_name); | |
f27aaf4b | 921 | |
ad32e9c0 | 922 | sn_info->vm_state_size = snaps[i].size; |
f27aaf4b CB |
923 | sn_info->date_sec = 0; |
924 | sn_info->date_nsec = 0; | |
925 | sn_info->vm_clock_nsec = 0; | |
926 | } | |
ad32e9c0 | 927 | rbd_snap_list_end(snaps); |
9e6337d0 | 928 | g_free(snaps); |
ad32e9c0 | 929 | |
b9c53290 | 930 | done: |
f27aaf4b | 931 | *psn_tab = sn_tab; |
f27aaf4b | 932 | return snap_count; |
f27aaf4b CB |
933 | } |
934 | ||
787f3133 | 935 | #ifdef LIBRBD_SUPPORTS_DISCARD |
7c84b1b8 MA |
936 | static BlockAIOCB* qemu_rbd_aio_discard(BlockDriverState *bs, |
937 | int64_t sector_num, | |
938 | int nb_sectors, | |
097310b5 | 939 | BlockCompletionFunc *cb, |
7c84b1b8 | 940 | void *opaque) |
787f3133 JD |
941 | { |
942 | return rbd_start_aio(bs, sector_num, NULL, nb_sectors, cb, opaque, | |
943 | RBD_AIO_DISCARD); | |
944 | } | |
945 | #endif | |
946 | ||
be217884 AC |
947 | #ifdef LIBRBD_SUPPORTS_INVALIDATE |
948 | static void qemu_rbd_invalidate_cache(BlockDriverState *bs, | |
949 | Error **errp) | |
950 | { | |
951 | BDRVRBDState *s = bs->opaque; | |
952 | int r = rbd_invalidate_cache(s->image); | |
953 | if (r < 0) { | |
954 | error_setg_errno(errp, -r, "Failed to invalidate the cache"); | |
955 | } | |
956 | } | |
957 | #endif | |
958 | ||
bd0cf596 CL |
959 | static QemuOptsList qemu_rbd_create_opts = { |
960 | .name = "rbd-create-opts", | |
961 | .head = QTAILQ_HEAD_INITIALIZER(qemu_rbd_create_opts.head), | |
962 | .desc = { | |
963 | { | |
964 | .name = BLOCK_OPT_SIZE, | |
965 | .type = QEMU_OPT_SIZE, | |
966 | .help = "Virtual disk size" | |
967 | }, | |
968 | { | |
969 | .name = BLOCK_OPT_CLUSTER_SIZE, | |
970 | .type = QEMU_OPT_SIZE, | |
971 | .help = "RBD object size" | |
972 | }, | |
60390a21 DB |
973 | { |
974 | .name = "password-secret", | |
975 | .type = QEMU_OPT_STRING, | |
976 | .help = "ID of secret providing the password", | |
977 | }, | |
bd0cf596 CL |
978 | { /* end of list */ } |
979 | } | |
f27aaf4b CB |
980 | }; |
981 | ||
982 | static BlockDriver bdrv_rbd = { | |
983 | .format_name = "rbd", | |
984 | .instance_size = sizeof(BDRVRBDState), | |
030be321 | 985 | .bdrv_needs_filename = true, |
ad32e9c0 JD |
986 | .bdrv_file_open = qemu_rbd_open, |
987 | .bdrv_close = qemu_rbd_close, | |
c282e1fd | 988 | .bdrv_create = qemu_rbd_create, |
3ac21627 | 989 | .bdrv_has_zero_init = bdrv_has_zero_init_1, |
ad32e9c0 | 990 | .bdrv_get_info = qemu_rbd_getinfo, |
bd0cf596 | 991 | .create_opts = &qemu_rbd_create_opts, |
ad32e9c0 | 992 | .bdrv_getlength = qemu_rbd_getlength, |
30cdc48c | 993 | .bdrv_truncate = qemu_rbd_truncate, |
f27aaf4b CB |
994 | .protocol_name = "rbd", |
995 | ||
c68b89ac KW |
996 | .bdrv_aio_readv = qemu_rbd_aio_readv, |
997 | .bdrv_aio_writev = qemu_rbd_aio_writev, | |
dc7588c1 JD |
998 | |
999 | #ifdef LIBRBD_SUPPORTS_AIO_FLUSH | |
1000 | .bdrv_aio_flush = qemu_rbd_aio_flush, | |
1001 | #else | |
c68b89ac | 1002 | .bdrv_co_flush_to_disk = qemu_rbd_co_flush, |
dc7588c1 | 1003 | #endif |
f27aaf4b | 1004 | |
787f3133 JD |
1005 | #ifdef LIBRBD_SUPPORTS_DISCARD |
1006 | .bdrv_aio_discard = qemu_rbd_aio_discard, | |
1007 | #endif | |
1008 | ||
c68b89ac | 1009 | .bdrv_snapshot_create = qemu_rbd_snap_create, |
bd603247 | 1010 | .bdrv_snapshot_delete = qemu_rbd_snap_remove, |
c68b89ac | 1011 | .bdrv_snapshot_list = qemu_rbd_snap_list, |
bd603247 | 1012 | .bdrv_snapshot_goto = qemu_rbd_snap_rollback, |
be217884 AC |
1013 | #ifdef LIBRBD_SUPPORTS_INVALIDATE |
1014 | .bdrv_invalidate_cache = qemu_rbd_invalidate_cache, | |
1015 | #endif | |
f27aaf4b CB |
1016 | }; |
1017 | ||
1018 | static void bdrv_rbd_init(void) | |
1019 | { | |
1020 | bdrv_register(&bdrv_rbd); | |
1021 | } | |
1022 | ||
1023 | block_init(bdrv_rbd_init); |