2 * QEMU Block driver for RADOS (Ceph)
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 <rbd/librbd.h>
17 #include "qapi/error.h"
18 #include "qemu/error-report.h"
19 #include "block/block_int.h"
20 #include "crypto/secret.h"
21 #include "qemu/cutils.h"
22 #include "qapi/qmp/qstring.h"
23 #include "qapi/qmp/qjson.h"
26 * When specifying the image filename use:
28 * rbd:poolname/devicename[@snapshotname][:option1=value1[:option2=value2...]]
30 * poolname must be the name of an existing rados pool.
32 * devicename is the name of the rbd image.
34 * Each option given is used to configure rados, and may be any valid
35 * Ceph option, "id", or "conf".
37 * The "id" option indicates what user we should authenticate as to
38 * the Ceph cluster. If it is excluded we will use the Ceph default
41 * The "conf" option specifies a Ceph configuration file to read. If
42 * it is not specified, we will read from the default Ceph locations
43 * (e.g., /etc/ceph/ceph.conf). To avoid reading _any_ configuration
44 * file, specify conf=/dev/null.
46 * Configuration values containing :, @, or = can be escaped with a
50 /* rbd_aio_discard added in 0.1.2 */
51 #if LIBRBD_VERSION_CODE >= LIBRBD_VERSION(0, 1, 2)
52 #define LIBRBD_SUPPORTS_DISCARD
54 #undef LIBRBD_SUPPORTS_DISCARD
57 #define OBJ_MAX_SIZE (1UL << OBJ_DEFAULT_OBJ_ORDER)
59 #define RBD_MAX_SNAPS 100
61 /* The LIBRBD_SUPPORTS_IOVEC is defined in librbd.h */
62 #ifdef LIBRBD_SUPPORTS_IOVEC
63 #define LIBRBD_USE_IOVEC 1
65 #define LIBRBD_USE_IOVEC 0
75 typedef struct RBDAIOCB {
82 struct BDRVRBDState *s;
85 typedef struct RADOSCB {
87 struct BDRVRBDState *s;
93 typedef struct BDRVRBDState {
101 static char *qemu_rbd_next_tok(char *src, char delim, char **p)
107 for (end = src; *end; ++end) {
111 if (*end == '\\' && end[1] != '\0') {
122 static void qemu_rbd_unescape(char *src)
126 for (p = src; *src; ++src, ++p) {
127 if (*src == '\\' && src[1] != '\0') {
135 static void qemu_rbd_parse_filename(const char *filename, QDict *options,
140 QList *keypairs = NULL;
143 if (!strstart(filename, "rbd:", &start)) {
144 error_setg(errp, "File name must start with 'rbd:'");
148 buf = g_strdup(start);
151 found_str = qemu_rbd_next_tok(p, '/', &p);
153 error_setg(errp, "Pool name is required");
156 qemu_rbd_unescape(found_str);
157 qdict_put(options, "pool", qstring_from_str(found_str));
159 if (strchr(p, '@')) {
160 found_str = qemu_rbd_next_tok(p, '@', &p);
161 qemu_rbd_unescape(found_str);
162 qdict_put(options, "image", qstring_from_str(found_str));
164 found_str = qemu_rbd_next_tok(p, ':', &p);
165 qemu_rbd_unescape(found_str);
166 qdict_put(options, "snapshot", qstring_from_str(found_str));
168 found_str = qemu_rbd_next_tok(p, ':', &p);
169 qemu_rbd_unescape(found_str);
170 qdict_put(options, "image", qstring_from_str(found_str));
176 /* The following are essentially all key/value pairs, and we treat
177 * 'id' and 'conf' a bit special. Key/value pairs may be in any order. */
180 name = qemu_rbd_next_tok(p, '=', &p);
182 error_setg(errp, "conf option %s has no value", name);
186 qemu_rbd_unescape(name);
188 value = qemu_rbd_next_tok(p, ':', &p);
189 qemu_rbd_unescape(value);
191 if (!strcmp(name, "conf")) {
192 qdict_put(options, "conf", qstring_from_str(value));
193 } else if (!strcmp(name, "id")) {
194 qdict_put(options, "user" , qstring_from_str(value));
197 * We pass these internally to qemu_rbd_set_keypairs(), so
198 * we can get away with the simpler list of [ "key1",
199 * "value1", "key2", "value2" ] rather than a raw dict
200 * { "key1": "value1", "key2": "value2" } where we can't
201 * guarantee order, or even a more correct but complex
202 * [ { "key1": "value1" }, { "key2": "value2" } ]
205 keypairs = qlist_new();
207 qlist_append(keypairs, qstring_from_str(name));
208 qlist_append(keypairs, qstring_from_str(value));
213 qdict_put(options, "=keyvalue-pairs",
214 qobject_to_json(QOBJECT(keypairs)));
224 static int qemu_rbd_set_auth(rados_t cluster, const char *secretid,
231 gchar *secret = qcrypto_secret_lookup_as_base64(secretid,
237 rados_conf_set(cluster, "key", secret);
243 static int qemu_rbd_set_keypairs(rados_t cluster, const char *keypairs_json,
253 if (!keypairs_json) {
256 keypairs = qobject_to_qlist(qobject_from_json(keypairs_json,
258 remaining = qlist_size(keypairs) / 2;
261 while (remaining--) {
262 name = qobject_to_qstring(qlist_pop(keypairs));
263 value = qobject_to_qstring(qlist_pop(keypairs));
264 assert(name && value);
265 key = qstring_get_str(name);
267 ret = rados_conf_set(cluster, key, qstring_get_str(value));
271 error_setg_errno(errp, -ret, "invalid conf option %s", key);
281 static void qemu_rbd_memset(RADOSCB *rcb, int64_t offs)
283 if (LIBRBD_USE_IOVEC) {
284 RBDAIOCB *acb = rcb->acb;
285 iov_memset(acb->qiov->iov, acb->qiov->niov, offs, 0,
286 acb->qiov->size - offs);
288 memset(rcb->buf + offs, 0, rcb->size - offs);
292 static QemuOptsList runtime_opts = {
294 .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
298 .type = QEMU_OPT_STRING,
299 .help = "Rados pool name",
303 .type = QEMU_OPT_STRING,
304 .help = "Image name in the pool",
308 .type = QEMU_OPT_STRING,
309 .help = "Rados config file location",
313 .type = QEMU_OPT_STRING,
314 .help = "Ceph snapshot name",
317 /* maps to 'id' in rados_create() */
319 .type = QEMU_OPT_STRING,
320 .help = "Rados id name",
323 * server.* extracted manually, see qemu_rbd_mon_host()
326 .name = "password-secret",
327 .type = QEMU_OPT_STRING,
328 .help = "ID of secret providing the password",
332 * Keys for qemu_rbd_parse_filename(), not in the QAPI schema
336 * HACK: name starts with '=' so that qemu_opts_parse()
339 .name = "=keyvalue-pairs",
340 .type = QEMU_OPT_STRING,
341 .help = "Legacy rados key/value option parameters",
343 { /* end of list */ }
347 static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
349 Error *local_err = NULL;
353 const char *pool, *name, *conf, *clientname, *keypairs;
354 const char *secretid;
356 rados_ioctx_t io_ctx;
357 QDict *options = NULL;
360 secretid = qemu_opt_get(opts, "password-secret");
362 /* Read out options */
363 bytes = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
365 objsize = qemu_opt_get_size_del(opts, BLOCK_OPT_CLUSTER_SIZE, 0);
367 if ((objsize - 1) & objsize) { /* not a power of 2? */
368 error_setg(errp, "obj size needs to be power of 2");
372 if (objsize < 4096) {
373 error_setg(errp, "obj size too small");
377 obj_order = ctz32(objsize);
380 options = qdict_new();
381 qemu_rbd_parse_filename(filename, options, &local_err);
384 error_propagate(errp, local_err);
389 * Caution: while qdict_get_try_str() is fine, getting non-string
390 * types would require more care. When @options come from -blockdev
391 * or blockdev_add, its members are typed according to the QAPI
392 * schema, but when they come from -drive, they're all QString.
394 pool = qdict_get_try_str(options, "pool");
395 conf = qdict_get_try_str(options, "conf");
396 clientname = qdict_get_try_str(options, "user");
397 name = qdict_get_try_str(options, "image");
398 keypairs = qdict_get_try_str(options, "=keyvalue-pairs");
400 ret = rados_create(&cluster, clientname);
402 error_setg_errno(errp, -ret, "error initializing");
406 /* try default location when conf=NULL, but ignore failure */
407 ret = rados_conf_read_file(cluster, conf);
408 if (conf && ret < 0) {
409 error_setg_errno(errp, -ret, "error reading conf file %s", conf);
414 ret = qemu_rbd_set_keypairs(cluster, keypairs, errp);
420 if (qemu_rbd_set_auth(cluster, secretid, errp) < 0) {
425 ret = rados_connect(cluster);
427 error_setg_errno(errp, -ret, "error connecting");
431 ret = rados_ioctx_create(cluster, pool, &io_ctx);
433 error_setg_errno(errp, -ret, "error opening pool %s", pool);
437 ret = rbd_create(io_ctx, name, bytes, &obj_order);
439 error_setg_errno(errp, -ret, "error rbd create");
442 rados_ioctx_destroy(io_ctx);
445 rados_shutdown(cluster);
453 * This aio completion is being called from rbd_finish_bh() and runs in qemu
456 static void qemu_rbd_complete_aio(RADOSCB *rcb)
458 RBDAIOCB *acb = rcb->acb;
463 if (acb->cmd != RBD_AIO_READ) {
467 } else if (!acb->error) {
468 acb->ret = rcb->size;
472 qemu_rbd_memset(rcb, 0);
475 } else if (r < rcb->size) {
476 qemu_rbd_memset(rcb, r);
478 acb->ret = rcb->size;
480 } else if (!acb->error) {
487 if (!LIBRBD_USE_IOVEC) {
488 if (acb->cmd == RBD_AIO_READ) {
489 qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size);
491 qemu_vfree(acb->bounce);
494 acb->common.cb(acb->common.opaque, (acb->ret > 0 ? 0 : acb->ret));
499 static char *qemu_rbd_mon_host(QDict *options, Error **errp)
501 const char **vals = g_new(const char *, qdict_size(options) + 1);
503 const char *host, *port;
508 sprintf(keybuf, "server.%d.host", i);
509 host = qdict_get_try_str(options, keybuf);
510 qdict_del(options, keybuf);
511 sprintf(keybuf, "server.%d.port", i);
512 port = qdict_get_try_str(options, keybuf);
513 qdict_del(options, keybuf);
514 if (!host && !port) {
518 error_setg(errp, "Parameter server.%d.host is missing", i);
523 if (strchr(host, ':')) {
524 vals[i] = port ? g_strdup_printf("[%s]:%s", host, port)
525 : g_strdup_printf("[%s]", host);
527 vals[i] = port ? g_strdup_printf("%s:%s", host, port)
533 rados_str = i ? g_strjoinv(";", (char **)vals) : NULL;
535 g_strfreev((char **)vals);
539 static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
542 BDRVRBDState *s = bs->opaque;
543 const char *pool, *snap, *conf, *clientname, *name, *keypairs;
544 const char *secretid;
546 Error *local_err = NULL;
547 char *mon_host = NULL;
550 opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
551 qemu_opts_absorb_qdict(opts, options, &local_err);
553 error_propagate(errp, local_err);
558 mon_host = qemu_rbd_mon_host(options, &local_err);
560 error_propagate(errp, local_err);
565 secretid = qemu_opt_get(opts, "password-secret");
567 pool = qemu_opt_get(opts, "pool");
568 conf = qemu_opt_get(opts, "conf");
569 snap = qemu_opt_get(opts, "snapshot");
570 clientname = qemu_opt_get(opts, "user");
571 name = qemu_opt_get(opts, "image");
572 keypairs = qemu_opt_get(opts, "=keyvalue-pairs");
574 if (!pool || !name) {
575 error_setg(errp, "Parameters 'pool' and 'image' are required");
580 r = rados_create(&s->cluster, clientname);
582 error_setg_errno(errp, -r, "error initializing");
586 s->snap = g_strdup(snap);
587 s->name = g_strdup(name);
589 /* try default location when conf=NULL, but ignore failure */
590 r = rados_conf_read_file(s->cluster, conf);
592 error_setg_errno(errp, -r, "error reading conf file %s", conf);
593 goto failed_shutdown;
596 r = qemu_rbd_set_keypairs(s->cluster, keypairs, errp);
598 goto failed_shutdown;
602 r = rados_conf_set(s->cluster, "mon_host", mon_host);
604 goto failed_shutdown;
608 if (qemu_rbd_set_auth(s->cluster, secretid, errp) < 0) {
610 goto failed_shutdown;
614 * Fallback to more conservative semantics if setting cache
615 * options fails. Ignore errors from setting rbd_cache because the
616 * only possible error is that the option does not exist, and
617 * librbd defaults to no caching. If write through caching cannot
618 * be set up, fall back to no caching.
620 if (flags & BDRV_O_NOCACHE) {
621 rados_conf_set(s->cluster, "rbd_cache", "false");
623 rados_conf_set(s->cluster, "rbd_cache", "true");
626 r = rados_connect(s->cluster);
628 error_setg_errno(errp, -r, "error connecting");
629 goto failed_shutdown;
632 r = rados_ioctx_create(s->cluster, pool, &s->io_ctx);
634 error_setg_errno(errp, -r, "error opening pool %s", pool);
635 goto failed_shutdown;
638 r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
640 error_setg_errno(errp, -r, "error reading header from %s", s->name);
644 bs->read_only = (s->snap != NULL);
650 rados_ioctx_destroy(s->io_ctx);
652 rados_shutdown(s->cluster);
661 static void qemu_rbd_close(BlockDriverState *bs)
663 BDRVRBDState *s = bs->opaque;
666 rados_ioctx_destroy(s->io_ctx);
669 rados_shutdown(s->cluster);
672 static const AIOCBInfo rbd_aiocb_info = {
673 .aiocb_size = sizeof(RBDAIOCB),
676 static void rbd_finish_bh(void *opaque)
678 RADOSCB *rcb = opaque;
679 qemu_rbd_complete_aio(rcb);
683 * This is the callback function for rbd_aio_read and _write
685 * Note: this function is being called from a non qemu thread so
686 * we need to be careful about what we do here. Generally we only
687 * schedule a BH, and do the rest of the io completion handling
688 * from rbd_finish_bh() which runs in a qemu context.
690 static void rbd_finish_aiocb(rbd_completion_t c, RADOSCB *rcb)
692 RBDAIOCB *acb = rcb->acb;
694 rcb->ret = rbd_aio_get_return_value(c);
697 aio_bh_schedule_oneshot(bdrv_get_aio_context(acb->common.bs),
701 static int rbd_aio_discard_wrapper(rbd_image_t image,
704 rbd_completion_t comp)
706 #ifdef LIBRBD_SUPPORTS_DISCARD
707 return rbd_aio_discard(image, off, len, comp);
713 static int rbd_aio_flush_wrapper(rbd_image_t image,
714 rbd_completion_t comp)
716 #ifdef LIBRBD_SUPPORTS_AIO_FLUSH
717 return rbd_aio_flush(image, comp);
723 static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
727 BlockCompletionFunc *cb,
736 BDRVRBDState *s = bs->opaque;
738 acb = qemu_aio_get(&rbd_aiocb_info, bs, cb, opaque);
741 assert(!qiov || qiov->size == size);
743 rcb = g_new(RADOSCB, 1);
745 if (!LIBRBD_USE_IOVEC) {
746 if (cmd == RBD_AIO_DISCARD || cmd == RBD_AIO_FLUSH) {
749 acb->bounce = qemu_try_blockalign(bs, qiov->size);
750 if (acb->bounce == NULL) {
754 if (cmd == RBD_AIO_WRITE) {
755 qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size);
757 rcb->buf = acb->bounce;
767 r = rbd_aio_create_completion(rcb, (rbd_callback_t) rbd_finish_aiocb, &c);
774 #ifdef LIBRBD_SUPPORTS_IOVEC
775 r = rbd_aio_writev(s->image, qiov->iov, qiov->niov, off, c);
777 r = rbd_aio_write(s->image, off, size, rcb->buf, c);
781 #ifdef LIBRBD_SUPPORTS_IOVEC
782 r = rbd_aio_readv(s->image, qiov->iov, qiov->niov, off, c);
784 r = rbd_aio_read(s->image, off, size, rcb->buf, c);
787 case RBD_AIO_DISCARD:
788 r = rbd_aio_discard_wrapper(s->image, off, size, c);
791 r = rbd_aio_flush_wrapper(s->image, c);
798 goto failed_completion;
806 if (!LIBRBD_USE_IOVEC) {
807 qemu_vfree(acb->bounce);
814 static BlockAIOCB *qemu_rbd_aio_readv(BlockDriverState *bs,
818 BlockCompletionFunc *cb,
821 return rbd_start_aio(bs, sector_num << BDRV_SECTOR_BITS, qiov,
822 (int64_t) nb_sectors << BDRV_SECTOR_BITS, cb, opaque,
826 static BlockAIOCB *qemu_rbd_aio_writev(BlockDriverState *bs,
830 BlockCompletionFunc *cb,
833 return rbd_start_aio(bs, sector_num << BDRV_SECTOR_BITS, qiov,
834 (int64_t) nb_sectors << BDRV_SECTOR_BITS, cb, opaque,
838 #ifdef LIBRBD_SUPPORTS_AIO_FLUSH
839 static BlockAIOCB *qemu_rbd_aio_flush(BlockDriverState *bs,
840 BlockCompletionFunc *cb,
843 return rbd_start_aio(bs, 0, NULL, 0, cb, opaque, RBD_AIO_FLUSH);
848 static int qemu_rbd_co_flush(BlockDriverState *bs)
850 #if LIBRBD_VERSION_CODE >= LIBRBD_VERSION(0, 1, 1)
851 /* rbd_flush added in 0.1.1 */
852 BDRVRBDState *s = bs->opaque;
853 return rbd_flush(s->image);
860 static int qemu_rbd_getinfo(BlockDriverState *bs, BlockDriverInfo *bdi)
862 BDRVRBDState *s = bs->opaque;
863 rbd_image_info_t info;
866 r = rbd_stat(s->image, &info, sizeof(info));
871 bdi->cluster_size = info.obj_size;
875 static int64_t qemu_rbd_getlength(BlockDriverState *bs)
877 BDRVRBDState *s = bs->opaque;
878 rbd_image_info_t info;
881 r = rbd_stat(s->image, &info, sizeof(info));
889 static int qemu_rbd_truncate(BlockDriverState *bs, int64_t offset)
891 BDRVRBDState *s = bs->opaque;
894 r = rbd_resize(s->image, offset);
902 static int qemu_rbd_snap_create(BlockDriverState *bs,
903 QEMUSnapshotInfo *sn_info)
905 BDRVRBDState *s = bs->opaque;
908 if (sn_info->name[0] == '\0') {
909 return -EINVAL; /* we need a name for rbd snapshots */
913 * rbd snapshots are using the name as the user controlled unique identifier
914 * we can't use the rbd snapid for that purpose, as it can't be set
916 if (sn_info->id_str[0] != '\0' &&
917 strcmp(sn_info->id_str, sn_info->name) != 0) {
921 if (strlen(sn_info->name) >= sizeof(sn_info->id_str)) {
925 r = rbd_snap_create(s->image, sn_info->name);
927 error_report("failed to create snap: %s", strerror(-r));
934 static int qemu_rbd_snap_remove(BlockDriverState *bs,
935 const char *snapshot_id,
936 const char *snapshot_name,
939 BDRVRBDState *s = bs->opaque;
942 if (!snapshot_name) {
943 error_setg(errp, "rbd need a valid snapshot name");
947 /* If snapshot_id is specified, it must be equal to name, see
948 qemu_rbd_snap_list() */
949 if (snapshot_id && strcmp(snapshot_id, snapshot_name)) {
951 "rbd do not support snapshot id, it should be NULL or "
952 "equal to snapshot name");
956 r = rbd_snap_remove(s->image, snapshot_name);
958 error_setg_errno(errp, -r, "Failed to remove the snapshot");
963 static int qemu_rbd_snap_rollback(BlockDriverState *bs,
964 const char *snapshot_name)
966 BDRVRBDState *s = bs->opaque;
968 return rbd_snap_rollback(s->image, snapshot_name);
971 static int qemu_rbd_snap_list(BlockDriverState *bs,
972 QEMUSnapshotInfo **psn_tab)
974 BDRVRBDState *s = bs->opaque;
975 QEMUSnapshotInfo *sn_info, *sn_tab = NULL;
977 rbd_snap_info_t *snaps;
978 int max_snaps = RBD_MAX_SNAPS;
981 snaps = g_new(rbd_snap_info_t, max_snaps);
982 snap_count = rbd_snap_list(s->image, snaps, &max_snaps);
983 if (snap_count <= 0) {
986 } while (snap_count == -ERANGE);
988 if (snap_count <= 0) {
992 sn_tab = g_new0(QEMUSnapshotInfo, snap_count);
994 for (i = 0; i < snap_count; i++) {
995 const char *snap_name = snaps[i].name;
997 sn_info = sn_tab + i;
998 pstrcpy(sn_info->id_str, sizeof(sn_info->id_str), snap_name);
999 pstrcpy(sn_info->name, sizeof(sn_info->name), snap_name);
1001 sn_info->vm_state_size = snaps[i].size;
1002 sn_info->date_sec = 0;
1003 sn_info->date_nsec = 0;
1004 sn_info->vm_clock_nsec = 0;
1006 rbd_snap_list_end(snaps);
1014 #ifdef LIBRBD_SUPPORTS_DISCARD
1015 static BlockAIOCB *qemu_rbd_aio_pdiscard(BlockDriverState *bs,
1018 BlockCompletionFunc *cb,
1021 return rbd_start_aio(bs, offset, NULL, count, cb, opaque,
1026 #ifdef LIBRBD_SUPPORTS_INVALIDATE
1027 static void qemu_rbd_invalidate_cache(BlockDriverState *bs,
1030 BDRVRBDState *s = bs->opaque;
1031 int r = rbd_invalidate_cache(s->image);
1033 error_setg_errno(errp, -r, "Failed to invalidate the cache");
1038 static QemuOptsList qemu_rbd_create_opts = {
1039 .name = "rbd-create-opts",
1040 .head = QTAILQ_HEAD_INITIALIZER(qemu_rbd_create_opts.head),
1043 .name = BLOCK_OPT_SIZE,
1044 .type = QEMU_OPT_SIZE,
1045 .help = "Virtual disk size"
1048 .name = BLOCK_OPT_CLUSTER_SIZE,
1049 .type = QEMU_OPT_SIZE,
1050 .help = "RBD object size"
1053 .name = "password-secret",
1054 .type = QEMU_OPT_STRING,
1055 .help = "ID of secret providing the password",
1057 { /* end of list */ }
1061 static BlockDriver bdrv_rbd = {
1062 .format_name = "rbd",
1063 .instance_size = sizeof(BDRVRBDState),
1064 .bdrv_parse_filename = qemu_rbd_parse_filename,
1065 .bdrv_file_open = qemu_rbd_open,
1066 .bdrv_close = qemu_rbd_close,
1067 .bdrv_create = qemu_rbd_create,
1068 .bdrv_has_zero_init = bdrv_has_zero_init_1,
1069 .bdrv_get_info = qemu_rbd_getinfo,
1070 .create_opts = &qemu_rbd_create_opts,
1071 .bdrv_getlength = qemu_rbd_getlength,
1072 .bdrv_truncate = qemu_rbd_truncate,
1073 .protocol_name = "rbd",
1075 .bdrv_aio_readv = qemu_rbd_aio_readv,
1076 .bdrv_aio_writev = qemu_rbd_aio_writev,
1078 #ifdef LIBRBD_SUPPORTS_AIO_FLUSH
1079 .bdrv_aio_flush = qemu_rbd_aio_flush,
1081 .bdrv_co_flush_to_disk = qemu_rbd_co_flush,
1084 #ifdef LIBRBD_SUPPORTS_DISCARD
1085 .bdrv_aio_pdiscard = qemu_rbd_aio_pdiscard,
1088 .bdrv_snapshot_create = qemu_rbd_snap_create,
1089 .bdrv_snapshot_delete = qemu_rbd_snap_remove,
1090 .bdrv_snapshot_list = qemu_rbd_snap_list,
1091 .bdrv_snapshot_goto = qemu_rbd_snap_rollback,
1092 #ifdef LIBRBD_SUPPORTS_INVALIDATE
1093 .bdrv_invalidate_cache = qemu_rbd_invalidate_cache,
1097 static void bdrv_rbd_init(void)
1099 bdrv_register(&bdrv_rbd);
1102 block_init(bdrv_rbd_init);