2 * QEMU Block driver for RADOS (Ceph)
4 * Copyright (C) 2010-2011 Christian Brunner <chb@muc.de>,
5 * Josh Durgin <josh.durgin@dreamhost.com>
7 * This work is licensed under the terms of the GNU GPL, version 2. See
8 * the COPYING file in the top-level directory.
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.
14 #include "qemu/osdep.h"
16 #include "qapi/error.h"
17 #include "qemu/error-report.h"
18 #include "block/block_int.h"
19 #include "crypto/secret.h"
20 #include "qemu/cutils.h"
22 #include <rbd/librbd.h>
25 * When specifying the image filename use:
27 * rbd:poolname/devicename[@snapshotname][:option1=value1[:option2=value2...]]
29 * poolname must be the name of an existing rados pool.
31 * devicename is the name of the rbd image.
33 * Each option given is used to configure rados, and may be any valid
34 * Ceph option, "id", or "conf".
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
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.
45 * Configuration values containing :, @, or = can be escaped with a
49 /* rbd_aio_discard added in 0.1.2 */
50 #if LIBRBD_VERSION_CODE >= LIBRBD_VERSION(0, 1, 2)
51 #define LIBRBD_SUPPORTS_DISCARD
53 #undef LIBRBD_SUPPORTS_DISCARD
56 #define OBJ_MAX_SIZE (1UL << OBJ_DEFAULT_OBJ_ORDER)
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
65 /* The LIBRBD_SUPPORTS_IOVEC is defined in librbd.h */
66 #ifdef LIBRBD_SUPPORTS_IOVEC
67 #define LIBRBD_USE_IOVEC 1
69 #define LIBRBD_USE_IOVEC 0
79 typedef struct RBDAIOCB
{
86 struct BDRVRBDState
*s
;
89 typedef struct RADOSCB
{
91 struct BDRVRBDState
*s
;
97 typedef struct BDRVRBDState
{
101 char name
[RBD_MAX_IMAGE_NAME_SIZE
];
105 static int qemu_rbd_next_tok(char *dst
, int dst_len
,
106 char *src
, char delim
,
108 char **p
, Error
**errp
)
116 for (end
= src
; *end
; ++end
) {
120 if (*end
== '\\' && end
[1] != '\0') {
131 error_setg(errp
, "%s too long", name
);
134 error_setg(errp
, "%s too short", name
);
138 pstrcpy(dst
, dst_len
, src
);
143 static void qemu_rbd_unescape(char *src
)
147 for (p
= src
; *src
; ++src
, ++p
) {
148 if (*src
== '\\' && src
[1] != '\0') {
156 static int qemu_rbd_parsename(const char *filename
,
157 char *pool
, int pool_len
,
158 char *snap
, int snap_len
,
159 char *name
, int name_len
,
160 char *conf
, int conf_len
,
167 if (!strstart(filename
, "rbd:", &start
)) {
168 error_setg(errp
, "File name must start with 'rbd:'");
172 buf
= g_strdup(start
);
177 ret
= qemu_rbd_next_tok(pool
, pool_len
, p
,
178 '/', "pool name", &p
, errp
);
183 qemu_rbd_unescape(pool
);
185 if (strchr(p
, '@')) {
186 ret
= qemu_rbd_next_tok(name
, name_len
, p
,
187 '@', "object name", &p
, errp
);
191 ret
= qemu_rbd_next_tok(snap
, snap_len
, p
,
192 ':', "snap name", &p
, errp
);
193 qemu_rbd_unescape(snap
);
195 ret
= qemu_rbd_next_tok(name
, name_len
, p
,
196 ':', "object name", &p
, errp
);
198 qemu_rbd_unescape(name
);
203 ret
= qemu_rbd_next_tok(conf
, conf_len
, p
,
204 '\0', "configuration", &p
, errp
);
211 static char *qemu_rbd_parse_clientname(const char *conf
, char *clientname
)
213 const char *p
= conf
;
217 const char *end
= strchr(p
, ':');
225 if (strncmp(p
, "id=", 3) == 0) {
227 strncpy(clientname
, p
+ 3, len
);
228 clientname
[len
] = '\0';
240 static int qemu_rbd_set_auth(rados_t cluster
, const char *secretid
,
247 gchar
*secret
= qcrypto_secret_lookup_as_base64(secretid
,
253 rados_conf_set(cluster
, "key", secret
);
260 static int qemu_rbd_set_conf(rados_t cluster
, const char *conf
,
261 bool only_read_conf_file
,
265 char name
[RBD_MAX_CONF_NAME_SIZE
];
266 char value
[RBD_MAX_CONF_VAL_SIZE
];
269 buf
= g_strdup(conf
);
273 ret
= qemu_rbd_next_tok(name
, sizeof(name
), p
,
274 '=', "conf option name", &p
, errp
);
278 qemu_rbd_unescape(name
);
281 error_setg(errp
, "conf option %s has no value", name
);
286 ret
= qemu_rbd_next_tok(value
, sizeof(value
), p
,
287 ':', "conf option value", &p
, errp
);
291 qemu_rbd_unescape(value
);
293 if (strcmp(name
, "conf") == 0) {
294 /* read the conf file alone, so it doesn't override more
295 specific settings for a particular device */
296 if (only_read_conf_file
) {
297 ret
= rados_conf_read_file(cluster
, value
);
299 error_setg_errno(errp
, -ret
, "error reading conf file %s",
304 } else if (strcmp(name
, "id") == 0) {
305 /* ignore, this is parsed by qemu_rbd_parse_clientname() */
306 } else if (!only_read_conf_file
) {
307 ret
= rados_conf_set(cluster
, name
, value
);
309 error_setg_errno(errp
, -ret
, "invalid conf option %s", name
);
320 static void qemu_rbd_memset(RADOSCB
*rcb
, int64_t offs
)
322 if (LIBRBD_USE_IOVEC
) {
323 RBDAIOCB
*acb
= rcb
->acb
;
324 iov_memset(acb
->qiov
->iov
, acb
->qiov
->niov
, offs
, 0,
325 acb
->qiov
->size
- offs
);
327 memset(rcb
->buf
+ offs
, 0, rcb
->size
- offs
);
331 static int qemu_rbd_create(const char *filename
, QemuOpts
*opts
, Error
**errp
)
333 Error
*local_err
= NULL
;
337 char pool
[RBD_MAX_POOL_NAME_SIZE
];
338 char name
[RBD_MAX_IMAGE_NAME_SIZE
];
339 char snap_buf
[RBD_MAX_SNAP_NAME_SIZE
];
340 char conf
[RBD_MAX_CONF_SIZE
];
341 char clientname_buf
[RBD_MAX_CONF_SIZE
];
343 const char *secretid
;
345 rados_ioctx_t io_ctx
;
348 secretid
= qemu_opt_get(opts
, "password-secret");
350 if (qemu_rbd_parsename(filename
, pool
, sizeof(pool
),
351 snap_buf
, sizeof(snap_buf
),
353 conf
, sizeof(conf
), &local_err
) < 0) {
354 error_propagate(errp
, local_err
);
358 /* Read out options */
359 bytes
= ROUND_UP(qemu_opt_get_size_del(opts
, BLOCK_OPT_SIZE
, 0),
361 objsize
= qemu_opt_get_size_del(opts
, BLOCK_OPT_CLUSTER_SIZE
, 0);
363 if ((objsize
- 1) & objsize
) { /* not a power of 2? */
364 error_setg(errp
, "obj size needs to be power of 2");
367 if (objsize
< 4096) {
368 error_setg(errp
, "obj size too small");
371 obj_order
= ctz32(objsize
);
374 clientname
= qemu_rbd_parse_clientname(conf
, clientname_buf
);
375 ret
= rados_create(&cluster
, clientname
);
377 error_setg_errno(errp
, -ret
, "error initializing");
381 if (strstr(conf
, "conf=") == NULL
) {
382 /* try default location, but ignore failure */
383 rados_conf_read_file(cluster
, NULL
);
384 } else if (conf
[0] != '\0' &&
385 qemu_rbd_set_conf(cluster
, conf
, true, &local_err
) < 0) {
386 error_propagate(errp
, local_err
);
391 if (conf
[0] != '\0' &&
392 qemu_rbd_set_conf(cluster
, conf
, false, &local_err
) < 0) {
393 error_propagate(errp
, local_err
);
398 if (qemu_rbd_set_auth(cluster
, secretid
, errp
) < 0) {
403 ret
= rados_connect(cluster
);
405 error_setg_errno(errp
, -ret
, "error connecting");
409 ret
= rados_ioctx_create(cluster
, pool
, &io_ctx
);
411 error_setg_errno(errp
, -ret
, "error opening pool %s", pool
);
415 ret
= rbd_create(io_ctx
, name
, bytes
, &obj_order
);
417 error_setg_errno(errp
, -ret
, "error rbd create");
420 rados_ioctx_destroy(io_ctx
);
423 rados_shutdown(cluster
);
428 * This aio completion is being called from rbd_finish_bh() and runs in qemu
431 static void qemu_rbd_complete_aio(RADOSCB
*rcb
)
433 RBDAIOCB
*acb
= rcb
->acb
;
438 if (acb
->cmd
!= RBD_AIO_READ
) {
442 } else if (!acb
->error
) {
443 acb
->ret
= rcb
->size
;
447 qemu_rbd_memset(rcb
, 0);
450 } else if (r
< rcb
->size
) {
451 qemu_rbd_memset(rcb
, r
);
453 acb
->ret
= rcb
->size
;
455 } else if (!acb
->error
) {
462 if (!LIBRBD_USE_IOVEC
) {
463 if (acb
->cmd
== RBD_AIO_READ
) {
464 qemu_iovec_from_buf(acb
->qiov
, 0, acb
->bounce
, acb
->qiov
->size
);
466 qemu_vfree(acb
->bounce
);
469 acb
->common
.cb(acb
->common
.opaque
, (acb
->ret
> 0 ? 0 : acb
->ret
));
474 /* TODO Convert to fine grained options */
475 static QemuOptsList runtime_opts
= {
477 .head
= QTAILQ_HEAD_INITIALIZER(runtime_opts
.head
),
481 .type
= QEMU_OPT_STRING
,
482 .help
= "Specification of the rbd image",
485 .name
= "password-secret",
486 .type
= QEMU_OPT_STRING
,
487 .help
= "ID of secret providing the password",
489 { /* end of list */ }
493 static int qemu_rbd_open(BlockDriverState
*bs
, QDict
*options
, int flags
,
496 BDRVRBDState
*s
= bs
->opaque
;
497 char pool
[RBD_MAX_POOL_NAME_SIZE
];
498 char snap_buf
[RBD_MAX_SNAP_NAME_SIZE
];
499 char conf
[RBD_MAX_CONF_SIZE
];
500 char clientname_buf
[RBD_MAX_CONF_SIZE
];
502 const char *secretid
;
504 Error
*local_err
= NULL
;
505 const char *filename
;
508 opts
= qemu_opts_create(&runtime_opts
, NULL
, 0, &error_abort
);
509 qemu_opts_absorb_qdict(opts
, options
, &local_err
);
511 error_propagate(errp
, local_err
);
516 filename
= qemu_opt_get(opts
, "filename");
517 secretid
= qemu_opt_get(opts
, "password-secret");
519 if (qemu_rbd_parsename(filename
, pool
, sizeof(pool
),
520 snap_buf
, sizeof(snap_buf
),
521 s
->name
, sizeof(s
->name
),
522 conf
, sizeof(conf
), errp
) < 0) {
527 clientname
= qemu_rbd_parse_clientname(conf
, clientname_buf
);
528 r
= rados_create(&s
->cluster
, clientname
);
530 error_setg_errno(errp
, -r
, "error initializing");
535 if (snap_buf
[0] != '\0') {
536 s
->snap
= g_strdup(snap_buf
);
539 if (strstr(conf
, "conf=") == NULL
) {
540 /* try default location, but ignore failure */
541 rados_conf_read_file(s
->cluster
, NULL
);
542 } else if (conf
[0] != '\0') {
543 r
= qemu_rbd_set_conf(s
->cluster
, conf
, true, errp
);
545 goto failed_shutdown
;
549 if (conf
[0] != '\0') {
550 r
= qemu_rbd_set_conf(s
->cluster
, conf
, false, errp
);
552 goto failed_shutdown
;
556 if (qemu_rbd_set_auth(s
->cluster
, secretid
, errp
) < 0) {
558 goto failed_shutdown
;
562 * Fallback to more conservative semantics if setting cache
563 * options fails. Ignore errors from setting rbd_cache because the
564 * only possible error is that the option does not exist, and
565 * librbd defaults to no caching. If write through caching cannot
566 * be set up, fall back to no caching.
568 if (flags
& BDRV_O_NOCACHE
) {
569 rados_conf_set(s
->cluster
, "rbd_cache", "false");
571 rados_conf_set(s
->cluster
, "rbd_cache", "true");
574 r
= rados_connect(s
->cluster
);
576 error_setg_errno(errp
, -r
, "error connecting");
577 goto failed_shutdown
;
580 r
= rados_ioctx_create(s
->cluster
, pool
, &s
->io_ctx
);
582 error_setg_errno(errp
, -r
, "error opening pool %s", pool
);
583 goto failed_shutdown
;
586 r
= rbd_open(s
->io_ctx
, s
->name
, &s
->image
, s
->snap
);
588 error_setg_errno(errp
, -r
, "error reading header from %s", s
->name
);
592 bs
->read_only
= (s
->snap
!= NULL
);
598 rados_ioctx_destroy(s
->io_ctx
);
600 rados_shutdown(s
->cluster
);
607 static void qemu_rbd_close(BlockDriverState
*bs
)
609 BDRVRBDState
*s
= bs
->opaque
;
612 rados_ioctx_destroy(s
->io_ctx
);
614 rados_shutdown(s
->cluster
);
617 static const AIOCBInfo rbd_aiocb_info
= {
618 .aiocb_size
= sizeof(RBDAIOCB
),
621 static void rbd_finish_bh(void *opaque
)
623 RADOSCB
*rcb
= opaque
;
624 qemu_rbd_complete_aio(rcb
);
628 * This is the callback function for rbd_aio_read and _write
630 * Note: this function is being called from a non qemu thread so
631 * we need to be careful about what we do here. Generally we only
632 * schedule a BH, and do the rest of the io completion handling
633 * from rbd_finish_bh() which runs in a qemu context.
635 static void rbd_finish_aiocb(rbd_completion_t c
, RADOSCB
*rcb
)
637 RBDAIOCB
*acb
= rcb
->acb
;
639 rcb
->ret
= rbd_aio_get_return_value(c
);
642 aio_bh_schedule_oneshot(bdrv_get_aio_context(acb
->common
.bs
),
646 static int rbd_aio_discard_wrapper(rbd_image_t image
,
649 rbd_completion_t comp
)
651 #ifdef LIBRBD_SUPPORTS_DISCARD
652 return rbd_aio_discard(image
, off
, len
, comp
);
658 static int rbd_aio_flush_wrapper(rbd_image_t image
,
659 rbd_completion_t comp
)
661 #ifdef LIBRBD_SUPPORTS_AIO_FLUSH
662 return rbd_aio_flush(image
, comp
);
668 static BlockAIOCB
*rbd_start_aio(BlockDriverState
*bs
,
672 BlockCompletionFunc
*cb
,
681 BDRVRBDState
*s
= bs
->opaque
;
683 acb
= qemu_aio_get(&rbd_aiocb_info
, bs
, cb
, opaque
);
686 assert(!qiov
|| qiov
->size
== size
);
688 rcb
= g_new(RADOSCB
, 1);
690 if (!LIBRBD_USE_IOVEC
) {
691 if (cmd
== RBD_AIO_DISCARD
|| cmd
== RBD_AIO_FLUSH
) {
694 acb
->bounce
= qemu_try_blockalign(bs
, qiov
->size
);
695 if (acb
->bounce
== NULL
) {
699 if (cmd
== RBD_AIO_WRITE
) {
700 qemu_iovec_to_buf(acb
->qiov
, 0, acb
->bounce
, qiov
->size
);
702 rcb
->buf
= acb
->bounce
;
712 r
= rbd_aio_create_completion(rcb
, (rbd_callback_t
) rbd_finish_aiocb
, &c
);
719 #ifdef LIBRBD_SUPPORTS_IOVEC
720 r
= rbd_aio_writev(s
->image
, qiov
->iov
, qiov
->niov
, off
, c
);
722 r
= rbd_aio_write(s
->image
, off
, size
, rcb
->buf
, c
);
726 #ifdef LIBRBD_SUPPORTS_IOVEC
727 r
= rbd_aio_readv(s
->image
, qiov
->iov
, qiov
->niov
, off
, c
);
729 r
= rbd_aio_read(s
->image
, off
, size
, rcb
->buf
, c
);
732 case RBD_AIO_DISCARD
:
733 r
= rbd_aio_discard_wrapper(s
->image
, off
, size
, c
);
736 r
= rbd_aio_flush_wrapper(s
->image
, c
);
743 goto failed_completion
;
751 if (!LIBRBD_USE_IOVEC
) {
752 qemu_vfree(acb
->bounce
);
759 static BlockAIOCB
*qemu_rbd_aio_readv(BlockDriverState
*bs
,
763 BlockCompletionFunc
*cb
,
766 return rbd_start_aio(bs
, sector_num
<< BDRV_SECTOR_BITS
, qiov
,
767 (int64_t) nb_sectors
<< BDRV_SECTOR_BITS
, cb
, opaque
,
771 static BlockAIOCB
*qemu_rbd_aio_writev(BlockDriverState
*bs
,
775 BlockCompletionFunc
*cb
,
778 return rbd_start_aio(bs
, sector_num
<< BDRV_SECTOR_BITS
, qiov
,
779 (int64_t) nb_sectors
<< BDRV_SECTOR_BITS
, cb
, opaque
,
783 #ifdef LIBRBD_SUPPORTS_AIO_FLUSH
784 static BlockAIOCB
*qemu_rbd_aio_flush(BlockDriverState
*bs
,
785 BlockCompletionFunc
*cb
,
788 return rbd_start_aio(bs
, 0, NULL
, 0, cb
, opaque
, RBD_AIO_FLUSH
);
793 static int qemu_rbd_co_flush(BlockDriverState
*bs
)
795 #if LIBRBD_VERSION_CODE >= LIBRBD_VERSION(0, 1, 1)
796 /* rbd_flush added in 0.1.1 */
797 BDRVRBDState
*s
= bs
->opaque
;
798 return rbd_flush(s
->image
);
805 static int qemu_rbd_getinfo(BlockDriverState
*bs
, BlockDriverInfo
*bdi
)
807 BDRVRBDState
*s
= bs
->opaque
;
808 rbd_image_info_t info
;
811 r
= rbd_stat(s
->image
, &info
, sizeof(info
));
816 bdi
->cluster_size
= info
.obj_size
;
820 static int64_t qemu_rbd_getlength(BlockDriverState
*bs
)
822 BDRVRBDState
*s
= bs
->opaque
;
823 rbd_image_info_t info
;
826 r
= rbd_stat(s
->image
, &info
, sizeof(info
));
834 static int qemu_rbd_truncate(BlockDriverState
*bs
, int64_t offset
)
836 BDRVRBDState
*s
= bs
->opaque
;
839 r
= rbd_resize(s
->image
, offset
);
847 static int qemu_rbd_snap_create(BlockDriverState
*bs
,
848 QEMUSnapshotInfo
*sn_info
)
850 BDRVRBDState
*s
= bs
->opaque
;
853 if (sn_info
->name
[0] == '\0') {
854 return -EINVAL
; /* we need a name for rbd snapshots */
858 * rbd snapshots are using the name as the user controlled unique identifier
859 * we can't use the rbd snapid for that purpose, as it can't be set
861 if (sn_info
->id_str
[0] != '\0' &&
862 strcmp(sn_info
->id_str
, sn_info
->name
) != 0) {
866 if (strlen(sn_info
->name
) >= sizeof(sn_info
->id_str
)) {
870 r
= rbd_snap_create(s
->image
, sn_info
->name
);
872 error_report("failed to create snap: %s", strerror(-r
));
879 static int qemu_rbd_snap_remove(BlockDriverState
*bs
,
880 const char *snapshot_id
,
881 const char *snapshot_name
,
884 BDRVRBDState
*s
= bs
->opaque
;
887 if (!snapshot_name
) {
888 error_setg(errp
, "rbd need a valid snapshot name");
892 /* If snapshot_id is specified, it must be equal to name, see
893 qemu_rbd_snap_list() */
894 if (snapshot_id
&& strcmp(snapshot_id
, snapshot_name
)) {
896 "rbd do not support snapshot id, it should be NULL or "
897 "equal to snapshot name");
901 r
= rbd_snap_remove(s
->image
, snapshot_name
);
903 error_setg_errno(errp
, -r
, "Failed to remove the snapshot");
908 static int qemu_rbd_snap_rollback(BlockDriverState
*bs
,
909 const char *snapshot_name
)
911 BDRVRBDState
*s
= bs
->opaque
;
913 return rbd_snap_rollback(s
->image
, snapshot_name
);
916 static int qemu_rbd_snap_list(BlockDriverState
*bs
,
917 QEMUSnapshotInfo
**psn_tab
)
919 BDRVRBDState
*s
= bs
->opaque
;
920 QEMUSnapshotInfo
*sn_info
, *sn_tab
= NULL
;
922 rbd_snap_info_t
*snaps
;
923 int max_snaps
= RBD_MAX_SNAPS
;
926 snaps
= g_new(rbd_snap_info_t
, max_snaps
);
927 snap_count
= rbd_snap_list(s
->image
, snaps
, &max_snaps
);
928 if (snap_count
<= 0) {
931 } while (snap_count
== -ERANGE
);
933 if (snap_count
<= 0) {
937 sn_tab
= g_new0(QEMUSnapshotInfo
, snap_count
);
939 for (i
= 0; i
< snap_count
; i
++) {
940 const char *snap_name
= snaps
[i
].name
;
942 sn_info
= sn_tab
+ i
;
943 pstrcpy(sn_info
->id_str
, sizeof(sn_info
->id_str
), snap_name
);
944 pstrcpy(sn_info
->name
, sizeof(sn_info
->name
), snap_name
);
946 sn_info
->vm_state_size
= snaps
[i
].size
;
947 sn_info
->date_sec
= 0;
948 sn_info
->date_nsec
= 0;
949 sn_info
->vm_clock_nsec
= 0;
951 rbd_snap_list_end(snaps
);
959 #ifdef LIBRBD_SUPPORTS_DISCARD
960 static BlockAIOCB
*qemu_rbd_aio_pdiscard(BlockDriverState
*bs
,
963 BlockCompletionFunc
*cb
,
966 return rbd_start_aio(bs
, offset
, NULL
, count
, cb
, opaque
,
971 #ifdef LIBRBD_SUPPORTS_INVALIDATE
972 static void qemu_rbd_invalidate_cache(BlockDriverState
*bs
,
975 BDRVRBDState
*s
= bs
->opaque
;
976 int r
= rbd_invalidate_cache(s
->image
);
978 error_setg_errno(errp
, -r
, "Failed to invalidate the cache");
983 static QemuOptsList qemu_rbd_create_opts
= {
984 .name
= "rbd-create-opts",
985 .head
= QTAILQ_HEAD_INITIALIZER(qemu_rbd_create_opts
.head
),
988 .name
= BLOCK_OPT_SIZE
,
989 .type
= QEMU_OPT_SIZE
,
990 .help
= "Virtual disk size"
993 .name
= BLOCK_OPT_CLUSTER_SIZE
,
994 .type
= QEMU_OPT_SIZE
,
995 .help
= "RBD object size"
998 .name
= "password-secret",
999 .type
= QEMU_OPT_STRING
,
1000 .help
= "ID of secret providing the password",
1002 { /* end of list */ }
1006 static BlockDriver bdrv_rbd
= {
1007 .format_name
= "rbd",
1008 .instance_size
= sizeof(BDRVRBDState
),
1009 .bdrv_needs_filename
= true,
1010 .bdrv_file_open
= qemu_rbd_open
,
1011 .bdrv_close
= qemu_rbd_close
,
1012 .bdrv_create
= qemu_rbd_create
,
1013 .bdrv_has_zero_init
= bdrv_has_zero_init_1
,
1014 .bdrv_get_info
= qemu_rbd_getinfo
,
1015 .create_opts
= &qemu_rbd_create_opts
,
1016 .bdrv_getlength
= qemu_rbd_getlength
,
1017 .bdrv_truncate
= qemu_rbd_truncate
,
1018 .protocol_name
= "rbd",
1020 .bdrv_aio_readv
= qemu_rbd_aio_readv
,
1021 .bdrv_aio_writev
= qemu_rbd_aio_writev
,
1023 #ifdef LIBRBD_SUPPORTS_AIO_FLUSH
1024 .bdrv_aio_flush
= qemu_rbd_aio_flush
,
1026 .bdrv_co_flush_to_disk
= qemu_rbd_co_flush
,
1029 #ifdef LIBRBD_SUPPORTS_DISCARD
1030 .bdrv_aio_pdiscard
= qemu_rbd_aio_pdiscard
,
1033 .bdrv_snapshot_create
= qemu_rbd_snap_create
,
1034 .bdrv_snapshot_delete
= qemu_rbd_snap_remove
,
1035 .bdrv_snapshot_list
= qemu_rbd_snap_list
,
1036 .bdrv_snapshot_goto
= qemu_rbd_snap_rollback
,
1037 #ifdef LIBRBD_SUPPORTS_INVALIDATE
1038 .bdrv_invalidate_cache
= qemu_rbd_invalidate_cache
,
1042 static void bdrv_rbd_init(void)
1044 bdrv_register(&bdrv_rbd
);
1047 block_init(bdrv_rbd_init
);