yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
958e1b
From e2fd1947f5c17139ab279ff155f31f1a74d8d3e0 Mon Sep 17 00:00:00 2001
958e1b
From: Kevin Wolf <kwolf@redhat.com>
958e1b
Date: Thu, 20 Nov 2014 13:47:23 +0100
958e1b
Subject: [PATCH 4/5] Revert "rbd: link and load librbd dynamically"
958e1b
958e1b
Message-id: <1416491244-20209-4-git-send-email-kwolf@redhat.com>
958e1b
Patchwork-id: 62493
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH v2 3/4] Revert "rbd: link and load librbd dynamically"
958e1b
Bugzilla: 1140742
958e1b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
RH-Acked-by: Max Reitz <mreitz@redhat.com>
958e1b
958e1b
This reverts commit 64d9964fc97fc525b86e12c5f385dea7e646a3b0.
958e1b
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
958e1b
Conflicts:
958e1b
	configure
958e1b
958e1b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
958e1b
---
958e1b
 block/Makefile.objs |   2 +-
958e1b
 block/rbd.c         | 218 ++++++++++++----------------------------------------
958e1b
 block/rbd_types.h   |  91 ----------------------
958e1b
 configure           |  41 +++++++++-
958e1b
 4 files changed, 89 insertions(+), 263 deletions(-)
958e1b
 delete mode 100644 block/rbd_types.h
958e1b
958e1b
diff --git a/block/Makefile.objs b/block/Makefile.objs
958e1b
index 6b578d9..0be180f 100644
958e1b
--- a/block/Makefile.objs
958e1b
+++ b/block/Makefile.objs
958e1b
@@ -13,7 +13,7 @@ ifeq ($(CONFIG_POSIX),y)
958e1b
 block-obj-y += nbd.o sheepdog.o
958e1b
 block-obj-$(CONFIG_LIBISCSI) += iscsi.o
958e1b
 block-obj-$(CONFIG_CURL) += curl.o
958e1b
-block-obj-y += rbd.o
958e1b
+block-obj-$(CONFIG_RBD) += rbd.o
958e1b
 block-obj-$(CONFIG_GLUSTERFS) += gluster.o
958e1b
 block-obj-$(CONFIG_LIBSSH2) += ssh.o
958e1b
 endif
958e1b
diff --git a/block/rbd.c b/block/rbd.c
958e1b
index 89319dc..4eea455 100644
958e1b
--- a/block/rbd.c
958e1b
+++ b/block/rbd.c
958e1b
@@ -11,14 +11,13 @@
958e1b
  * GNU GPL, version 2 or (at your option) any later version.
958e1b
  */
958e1b
 
958e1b
-#include <gmodule.h>
958e1b
 #include <inttypes.h>
958e1b
 
958e1b
 #include "qemu-common.h"
958e1b
 #include "qemu/error-report.h"
958e1b
 #include "block/block_int.h"
958e1b
 
958e1b
-#include "rbd_types.h"
958e1b
+#include <rbd/librbd.h>
958e1b
 
958e1b
 /*
958e1b
  * When specifying the image filename use:
958e1b
@@ -45,6 +44,13 @@
958e1b
  * leading "\".
958e1b
  */
958e1b
 
958e1b
+/* rbd_aio_discard added in 0.1.2 */
958e1b
+#if LIBRBD_VERSION_CODE >= LIBRBD_VERSION(0, 1, 2)
958e1b
+#define LIBRBD_SUPPORTS_DISCARD
958e1b
+#else
958e1b
+#undef LIBRBD_SUPPORTS_DISCARD
958e1b
+#endif
958e1b
+
958e1b
 #define OBJ_MAX_SIZE (1UL << OBJ_DEFAULT_OBJ_ORDER)
958e1b
 
958e1b
 #define RBD_MAX_CONF_NAME_SIZE 128
958e1b
@@ -100,10 +106,6 @@ typedef struct BDRVRBDState {
958e1b
     RADOSCB *event_rcb;
958e1b
 } BDRVRBDState;
958e1b
 
958e1b
-static bool librbd_loaded;
958e1b
-static GModule *librbd_handle;
958e1b
-
958e1b
-static int qemu_rbd_load_libs(void);
958e1b
 static void rbd_aio_bh_cb(void *opaque);
958e1b
 
958e1b
 static int qemu_rbd_next_tok(char *dst, int dst_len,
958e1b
@@ -309,10 +311,6 @@ static int qemu_rbd_create(const char *filename, QEMUOptionParameter *options,
958e1b
         return -EINVAL;
958e1b
     }
958e1b
 
958e1b
-    if (qemu_rbd_load_libs() < 0) {
958e1b
-        return -EIO;
958e1b
-    }
958e1b
-
958e1b
     /* Read out options */
958e1b
     while (options && options->name) {
958e1b
         if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
958e1b
@@ -491,10 +489,6 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
958e1b
         goto failed_opts;
958e1b
     }
958e1b
 
958e1b
-    if (qemu_rbd_load_libs() < 0) {
958e1b
-        return -EIO;
958e1b
-    }
958e1b
-
958e1b
     clientname = qemu_rbd_parse_clientname(conf, clientname_buf);
958e1b
     r = rados_create(&s->cluster, clientname);
958e1b
     if (r < 0) {
958e1b
@@ -686,6 +680,28 @@ static void rbd_aio_bh_cb(void *opaque)
958e1b
     }
958e1b
 }
958e1b
 
958e1b
+static int rbd_aio_discard_wrapper(rbd_image_t image,
958e1b
+                                   uint64_t off,
958e1b
+                                   uint64_t len,
958e1b
+                                   rbd_completion_t comp)
958e1b
+{
958e1b
+#ifdef LIBRBD_SUPPORTS_DISCARD
958e1b
+    return rbd_aio_discard(image, off, len, comp);
958e1b
+#else
958e1b
+    return -ENOTSUP;
958e1b
+#endif
958e1b
+}
958e1b
+
958e1b
+static int rbd_aio_flush_wrapper(rbd_image_t image,
958e1b
+                                 rbd_completion_t comp)
958e1b
+{
958e1b
+#ifdef LIBRBD_SUPPORTS_AIO_FLUSH
958e1b
+    return rbd_aio_flush(image, comp);
958e1b
+#else
958e1b
+    return -ENOTSUP;
958e1b
+#endif
958e1b
+}
958e1b
+
958e1b
 static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
958e1b
                                        int64_t sector_num,
958e1b
                                        QEMUIOVector *qiov,
958e1b
@@ -748,10 +764,10 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
958e1b
         r = rbd_aio_read(s->image, off, size, buf, c);
958e1b
         break;
958e1b
     case RBD_AIO_DISCARD:
958e1b
-        r = rbd_aio_discard(s->image, off, size, c);
958e1b
+        r = rbd_aio_discard_wrapper(s->image, off, size, c);
958e1b
         break;
958e1b
     case RBD_AIO_FLUSH:
958e1b
-        r = rbd_aio_flush(s->image, c);
958e1b
+        r = rbd_aio_flush_wrapper(s->image, c);
958e1b
         break;
958e1b
     default:
958e1b
         r = -EINVAL;
958e1b
@@ -792,6 +808,7 @@ static BlockDriverAIOCB *qemu_rbd_aio_writev(BlockDriverState *bs,
958e1b
                          RBD_AIO_WRITE);
958e1b
 }
958e1b
 
958e1b
+#ifdef LIBRBD_SUPPORTS_AIO_FLUSH
958e1b
 static BlockDriverAIOCB *qemu_rbd_aio_flush(BlockDriverState *bs,
958e1b
                                             BlockDriverCompletionFunc *cb,
958e1b
                                             void *opaque)
958e1b
@@ -799,14 +816,19 @@ static BlockDriverAIOCB *qemu_rbd_aio_flush(BlockDriverState *bs,
958e1b
     return rbd_start_aio(bs, 0, NULL, 0, cb, opaque, RBD_AIO_FLUSH);
958e1b
 }
958e1b
 
958e1b
+#else
958e1b
+
958e1b
 static int qemu_rbd_co_flush(BlockDriverState *bs)
958e1b
 {
958e1b
+#if LIBRBD_VERSION_CODE >= LIBRBD_VERSION(0, 1, 1)
958e1b
+    /* rbd_flush added in 0.1.1 */
958e1b
     BDRVRBDState *s = bs->opaque;
958e1b
-    if (rbd_flush) {
958e1b
-        return rbd_flush(s->image);
958e1b
-    }
958e1b
+    return rbd_flush(s->image);
958e1b
+#else
958e1b
     return 0;
958e1b
+#endif
958e1b
 }
958e1b
+#endif
958e1b
 
958e1b
 static int qemu_rbd_getinfo(BlockDriverState *bs, BlockDriverInfo *bdi)
958e1b
 {
958e1b
@@ -944,6 +966,7 @@ static int qemu_rbd_snap_list(BlockDriverState *bs,
958e1b
     return snap_count;
958e1b
 }
958e1b
 
958e1b
+#ifdef LIBRBD_SUPPORTS_DISCARD
958e1b
 static BlockDriverAIOCB* qemu_rbd_aio_discard(BlockDriverState *bs,
958e1b
                                               int64_t sector_num,
958e1b
                                               int nb_sectors,
958e1b
@@ -953,6 +976,7 @@ static BlockDriverAIOCB* qemu_rbd_aio_discard(BlockDriverState *bs,
958e1b
     return rbd_start_aio(bs, sector_num, NULL, nb_sectors, cb, opaque,
958e1b
                          RBD_AIO_DISCARD);
958e1b
 }
958e1b
+#endif
958e1b
 
958e1b
 static QEMUOptionParameter qemu_rbd_create_options[] = {
958e1b
     {
958e1b
@@ -983,9 +1007,16 @@ static BlockDriver bdrv_rbd = {
958e1b
 
958e1b
     .bdrv_aio_readv         = qemu_rbd_aio_readv,
958e1b
     .bdrv_aio_writev        = qemu_rbd_aio_writev,
958e1b
+
958e1b
+#ifdef LIBRBD_SUPPORTS_AIO_FLUSH
958e1b
     .bdrv_aio_flush         = qemu_rbd_aio_flush,
958e1b
+#else
958e1b
     .bdrv_co_flush_to_disk  = qemu_rbd_co_flush,
958e1b
+#endif
958e1b
+
958e1b
+#ifdef LIBRBD_SUPPORTS_DISCARD
958e1b
     .bdrv_aio_discard       = qemu_rbd_aio_discard,
958e1b
+#endif
958e1b
 
958e1b
     .bdrv_snapshot_create   = qemu_rbd_snap_create,
958e1b
     .bdrv_snapshot_delete   = qemu_rbd_snap_remove,
958e1b
@@ -998,153 +1029,4 @@ static void bdrv_rbd_init(void)
958e1b
     bdrv_register(&bdrv_rbd);
958e1b
 }
958e1b
 
958e1b
-typedef struct LibSymbol {
958e1b
-    const char *name;
958e1b
-    gpointer *addr;
958e1b
-} LibSymbol;
958e1b
-
958e1b
-static int qemu_rbd_set_functions(GModule *lib, const LibSymbol *funcs)
958e1b
-{
958e1b
-    int i = 0;
958e1b
-    while (funcs[i].name) {
958e1b
-        const char *name = funcs[i].name;
958e1b
-        if (!g_module_symbol(lib, name, funcs[i].addr)) {
958e1b
-            error_report("%s could not be loaded from librbd or librados: %s",
958e1b
-                         name, g_module_error());
958e1b
-            return -1;
958e1b
-        }
958e1b
-        ++i;
958e1b
-    }
958e1b
-    return 0;
958e1b
-}
958e1b
-
958e1b
-/*
958e1b
- * Set function pointers for basic librados and librbd
958e1b
- * functions that have always been present in these libraries.
958e1b
- */
958e1b
-static int qemu_rbd_set_mandatory_functions(void)
958e1b
-{
958e1b
-    LibSymbol symbols[] = {
958e1b
-        {"rados_create",
958e1b
-         (gpointer *) &rados_create},
958e1b
-        {"rados_connect",
958e1b
-         (gpointer *) &rados_connect},
958e1b
-        {"rados_shutdown",
958e1b
-         (gpointer *) &rados_shutdown},
958e1b
-        {"rados_conf_read_file",
958e1b
-         (gpointer *) &rados_conf_read_file},
958e1b
-        {"rados_conf_set",
958e1b
-         (gpointer *) &rados_conf_set},
958e1b
-        {"rados_ioctx_create",
958e1b
-         (gpointer *) &rados_ioctx_create},
958e1b
-        {"rados_ioctx_destroy",
958e1b
-         (gpointer *) &rados_ioctx_destroy},
958e1b
-        {"rbd_create",
958e1b
-         (gpointer *) &rbd_create},
958e1b
-        {"rbd_open",
958e1b
-         (gpointer *) &rbd_open},
958e1b
-        {"rbd_close",
958e1b
-         (gpointer *) &rbd_close},
958e1b
-        {"rbd_resize",
958e1b
-         (gpointer *) &rbd_resize},
958e1b
-        {"rbd_stat",
958e1b
-         (gpointer *) &rbd_stat},
958e1b
-        {"rbd_snap_list",
958e1b
-         (gpointer *) &rbd_snap_list},
958e1b
-        {"rbd_snap_list_end",
958e1b
-         (gpointer *) &rbd_snap_list_end},
958e1b
-        {"rbd_snap_create",
958e1b
-         (gpointer *) &rbd_snap_create},
958e1b
-        {"rbd_snap_remove",
958e1b
-         (gpointer *) &rbd_snap_remove},
958e1b
-        {"rbd_snap_rollback",
958e1b
-         (gpointer *) &rbd_snap_rollback},
958e1b
-        {"rbd_aio_write",
958e1b
-         (gpointer *) &rbd_aio_write},
958e1b
-        {"rbd_aio_read",
958e1b
-         (gpointer *) &rbd_aio_read},
958e1b
-        {"rbd_aio_create_completion",
958e1b
-         (gpointer *) &rbd_aio_create_completion},
958e1b
-        {"rbd_aio_get_return_value",
958e1b
-         (gpointer *) &rbd_aio_get_return_value},
958e1b
-        {"rbd_aio_release",
958e1b
-         (gpointer *) &rbd_aio_release},
958e1b
-        {NULL}
958e1b
-    };
958e1b
-
958e1b
-    if (qemu_rbd_set_functions(librbd_handle, symbols) < 0) {
958e1b
-        return -1;
958e1b
-    }
958e1b
-
958e1b
-    return 0;
958e1b
-}
958e1b
-
958e1b
-/*
958e1b
- * Detect whether the installed version of librbd
958e1b
- * supports newer functionality, and enable or disable
958e1b
- * it appropriately in bdrv_rbd.
958e1b
- */
958e1b
-static void qemu_rbd_set_optional_functions(void)
958e1b
-{
958e1b
-    if (g_module_symbol(librbd_handle, "rbd_flush",
958e1b
-                         (gpointer *) &rbd_flush)) {
958e1b
-        bdrv_rbd.bdrv_aio_flush = NULL;
958e1b
-        bdrv_rbd.bdrv_co_flush_to_disk = qemu_rbd_co_flush;
958e1b
-    } else {
958e1b
-        rbd_flush = NULL;
958e1b
-        bdrv_rbd.bdrv_co_flush_to_disk = NULL;
958e1b
-    }
958e1b
-
958e1b
-    if (g_module_symbol(librbd_handle, "rbd_aio_flush",
958e1b
-                        (gpointer *) &rbd_aio_flush)) {
958e1b
-        bdrv_rbd.bdrv_co_flush_to_disk = NULL;
958e1b
-        bdrv_rbd.bdrv_aio_flush = qemu_rbd_aio_flush;
958e1b
-    } else {
958e1b
-        rbd_aio_flush = NULL;
958e1b
-        bdrv_rbd.bdrv_aio_flush = NULL;
958e1b
-    }
958e1b
-
958e1b
-    if (g_module_symbol(librbd_handle, "rbd_aio_discard",
958e1b
-                        (gpointer *) &rbd_aio_discard)) {
958e1b
-        bdrv_rbd.bdrv_aio_discard = qemu_rbd_aio_discard;
958e1b
-    } else {
958e1b
-        rbd_aio_discard = NULL;
958e1b
-        bdrv_rbd.bdrv_aio_discard = NULL;
958e1b
-    }
958e1b
-}
958e1b
-
958e1b
-static int qemu_rbd_load_libs(void)
958e1b
-{
958e1b
-    if (librbd_loaded) {
958e1b
-        return 0;
958e1b
-    }
958e1b
-
958e1b
-    if (!g_module_supported()) {
958e1b
-        error_report("modules are not supported on this platform: %s",
958e1b
-                     g_module_error());
958e1b
-        return -1;
958e1b
-    }
958e1b
-
958e1b
-    librbd_handle = g_module_open("librbd.so.1", 0);
958e1b
-    if (!librbd_handle) {
958e1b
-        error_report("error loading librbd: %s", g_module_error());
958e1b
-        return -1;
958e1b
-    }
958e1b
-
958e1b
-    /*
958e1b
-     * Due to c++ templates used in librbd/librados and their
958e1b
-     * dependencies, and linker duplicate trimming rules, closing
958e1b
-     * librbd would leave it mapped. Make this explicit.
958e1b
-     */
958e1b
-    g_module_make_resident(librbd_handle);
958e1b
-
958e1b
-    if (qemu_rbd_set_mandatory_functions() < 0) {
958e1b
-        return -1;
958e1b
-    }
958e1b
-    qemu_rbd_set_optional_functions();
958e1b
-    librbd_loaded = true;
958e1b
-
958e1b
-    return 0;
958e1b
-}
958e1b
-
958e1b
 block_init(bdrv_rbd_init);
958e1b
diff --git a/block/rbd_types.h b/block/rbd_types.h
958e1b
deleted file mode 100644
958e1b
index f327cb4..0000000
958e1b
--- a/block/rbd_types.h
958e1b
+++ /dev/null
958e1b
@@ -1,91 +0,0 @@
958e1b
-/*
958e1b
- * Types and signatures for librados and librbd
958e1b
- *
958e1b
- * Copyright (C) 2013 Inktank Storage Inc.
958e1b
- *
958e1b
- * This library is free software; you can redistribute it and/or
958e1b
- * modify it under the terms of the GNU Lesser General Public
958e1b
- * License as published by the Free Software Foundation; either
958e1b
- * version 2 of the License, or (at your option) any later version.
958e1b
- *
958e1b
- * This library is distributed in the hope that it will be useful,
958e1b
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
958e1b
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
958e1b
- * Lesser General Public License for more details.
958e1b
- *
958e1b
- * You should have received a copy of the GNU Lesser General Public
958e1b
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
958e1b
- */
958e1b
-
958e1b
-#ifndef QEMU_BLOCK_RBD_TYPES_H
958e1b
-#define QEMU_BLOCK_RBD_TYPES_H
958e1b
-
958e1b
-/* types from librados used by the rbd block driver */
958e1b
-
958e1b
-typedef void *rados_t;
958e1b
-typedef void *rados_ioctx_t;
958e1b
-
958e1b
-static int   (*rados_create)(rados_t *cluster, const char * const id);
958e1b
-static int   (*rados_connect)(rados_t cluster);
958e1b
-static void  (*rados_shutdown)(rados_t cluster);
958e1b
-static int   (*rados_conf_read_file)(rados_t cluster, const char *path);
958e1b
-static int   (*rados_conf_set)(rados_t cluster, const char *option,
958e1b
-                               const char *value);
958e1b
-static int   (*rados_ioctx_create)(rados_t cluster, const char *pool_name,
958e1b
-                                   rados_ioctx_t *ioctx);
958e1b
-static void  (*rados_ioctx_destroy)(rados_ioctx_t io);
958e1b
-
958e1b
-/* types from librbd used by the rbd block driver*/
958e1b
-
958e1b
-typedef void *rbd_image_t;
958e1b
-typedef void *rbd_completion_t;
958e1b
-typedef void (*rbd_callback_t)(rbd_completion_t cb, void *arg);
958e1b
-
958e1b
-typedef struct {
958e1b
-    uint64_t id;
958e1b
-    uint64_t size;
958e1b
-    const char *name;
958e1b
-} rbd_snap_info_t;
958e1b
-
958e1b
-#define RBD_MAX_IMAGE_NAME_SIZE 96
958e1b
-#define RBD_MAX_BLOCK_NAME_SIZE 24
958e1b
-
958e1b
-typedef struct {
958e1b
-    uint64_t size;
958e1b
-    uint64_t obj_size;
958e1b
-    uint64_t num_objs;
958e1b
-    int order;
958e1b
-    char block_name_prefix[RBD_MAX_BLOCK_NAME_SIZE];
958e1b
-    int64_t parent_pool;
958e1b
-    char parent_name[RBD_MAX_IMAGE_NAME_SIZE];
958e1b
-} rbd_image_info_t;
958e1b
-
958e1b
-static int      (*rbd_create)(rados_ioctx_t io, const char *name, uint64_t size,
958e1b
-                              int *order);
958e1b
-static int      (*rbd_open)(rados_ioctx_t io, const char *name, rbd_image_t *image,
958e1b
-                            const char *snap_name);
958e1b
-static int      (*rbd_close)(rbd_image_t image);
958e1b
-static int      (*rbd_resize)(rbd_image_t image, uint64_t size);
958e1b
-static int      (*rbd_stat)(rbd_image_t image, rbd_image_info_t *info,
958e1b
-                            size_t infosize);
958e1b
-static int      (*rbd_snap_list)(rbd_image_t image, rbd_snap_info_t *snaps,
958e1b
-                                 int *max_snaps);
958e1b
-static void     (*rbd_snap_list_end)(rbd_snap_info_t *snaps);
958e1b
-static int      (*rbd_snap_create)(rbd_image_t image, const char *snapname);
958e1b
-static int      (*rbd_snap_remove)(rbd_image_t image, const char *snapname);
958e1b
-static int      (*rbd_snap_rollback)(rbd_image_t image, const char *snapname);
958e1b
-static int      (*rbd_aio_write)(rbd_image_t image, uint64_t off, size_t len,
958e1b
-                                 const char *buf, rbd_completion_t c);
958e1b
-static int      (*rbd_aio_read)(rbd_image_t image, uint64_t off, size_t len,
958e1b
-                                char *buf, rbd_completion_t c);
958e1b
-static int      (*rbd_aio_discard)(rbd_image_t image, uint64_t off, uint64_t len,
958e1b
-                                   rbd_completion_t c);
958e1b
-static int      (*rbd_aio_create_completion)(void *cb_arg,
958e1b
-                                             rbd_callback_t complete_cb,
958e1b
-                                             rbd_completion_t *c);
958e1b
-static ssize_t  (*rbd_aio_get_return_value)(rbd_completion_t c);
958e1b
-static void     (*rbd_aio_release)(rbd_completion_t c);
958e1b
-static int      (*rbd_flush)(rbd_image_t image);
958e1b
-static int      (*rbd_aio_flush)(rbd_image_t image, rbd_completion_t c);
958e1b
-
958e1b
-#endif
958e1b
diff --git a/configure b/configure
958e1b
index 8db9dbe..1583359 100755
958e1b
--- a/configure
958e1b
+++ b/configure
958e1b
@@ -227,6 +227,7 @@ qom_cast_debug="yes"
958e1b
 trace_backend="nop"
958e1b
 trace_file="trace"
958e1b
 spice=""
958e1b
+rbd=""
958e1b
 smartcard_nss=""
958e1b
 libusb=""
958e1b
 usb_redir=""
958e1b
@@ -892,6 +893,10 @@ for opt do
958e1b
   ;;
958e1b
   --enable-glx) glx="yes"
958e1b
   ;;
958e1b
+  --disable-rbd) rbd="no"
958e1b
+  ;;
958e1b
+  --enable-rbd) rbd="yes"
958e1b
+  ;;
958e1b
   --disable-xfsctl) xfs="no"
958e1b
   ;;
958e1b
   --enable-xfsctl) xfs="yes"
958e1b
@@ -1213,6 +1218,7 @@ echo "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
958e1b
 echo "                           Default:trace-<pid>"
958e1b
 echo "  --disable-spice          disable spice"
958e1b
 echo "  --enable-spice           enable spice"
958e1b
+echo "  --enable-rbd             enable building the rados block device (rbd)"
958e1b
 echo "  --disable-libiscsi       disable iscsi support"
958e1b
 echo "  --enable-libiscsi        enable iscsi support"
958e1b
 echo "  --disable-smartcard-nss  disable smartcard nss support"
958e1b
@@ -2372,10 +2378,10 @@ if test "$mingw32" = yes; then
958e1b
 else
958e1b
     glib_req_ver=2.12
958e1b
 fi
958e1b
-if $pkg_config --atleast-version=$glib_req_ver gthread-2.0 gmodule-2.0 > /dev/null 2>&1
958e1b
+if $pkg_config --atleast-version=$glib_req_ver gthread-2.0 > /dev/null 2>&1
958e1b
 then
958e1b
-    glib_cflags=`$pkg_config --cflags gthread-2.0 gmodule-2.0 2>/dev/null`
958e1b
-    glib_libs=`$pkg_config --libs gthread-2.0 gmodule-2.0 2>/dev/null`
958e1b
+    glib_cflags=`$pkg_config --cflags gthread-2.0 2>/dev/null`
958e1b
+    glib_libs=`$pkg_config --libs gthread-2.0 2>/dev/null`
958e1b
     CFLAGS="$glib_cflags $CFLAGS"
958e1b
     LIBS="$glib_libs $LIBS"
958e1b
     libs_qga="$glib_libs $libs_qga"
958e1b
@@ -2477,6 +2483,31 @@ if test "$mingw32" != yes -a "$pthread" = no; then
958e1b
 fi
958e1b
 
958e1b
 ##########################################
958e1b
+# rbd probe
958e1b
+if test "$rbd" != "no" ; then
958e1b
+  cat > $TMPC <
958e1b
+#include <stdio.h>
958e1b
+#include <rbd/librbd.h>
958e1b
+int main(void) {
958e1b
+    rados_t cluster;
958e1b
+    rados_create(&cluster, NULL);
958e1b
+    return 0;
958e1b
+}
958e1b
+EOF
958e1b
+  rbd_libs="-lrbd -lrados"
958e1b
+  if compile_prog "" "$rbd_libs" ; then
958e1b
+    rbd=yes
958e1b
+    libs_tools="$rbd_libs $libs_tools"
958e1b
+    libs_softmmu="$rbd_libs $libs_softmmu"
958e1b
+  else
958e1b
+    if test "$rbd" = "yes" ; then
958e1b
+      feature_not_found "rados block device"
958e1b
+    fi
958e1b
+    rbd=no
958e1b
+  fi
958e1b
+fi
958e1b
+
958e1b
+##########################################
958e1b
 # libssh2 probe
958e1b
 min_libssh2_version=1.2.8
958e1b
 if test "$libssh2" != "no" ; then
958e1b
@@ -3665,6 +3696,7 @@ echo "vhost-scsi support $vhost_scsi"
958e1b
 echo "Trace backend     $trace_backend"
958e1b
 echo "Trace output file $trace_file-<pid>"
958e1b
 echo "spice support     $spice ($spice_protocol_version/$spice_server_version)"
958e1b
+echo "rbd support       $rbd"
958e1b
 echo "xfsctl support    $xfs"
958e1b
 echo "nss used          $smartcard_nss"
958e1b
 echo "libusb            $libusb"
958e1b
@@ -4035,6 +4067,9 @@ fi
958e1b
 if test "$qom_cast_debug" = "yes" ; then
958e1b
   echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
958e1b
 fi
958e1b
+if test "$rbd" = "yes" ; then
958e1b
+  echo "CONFIG_RBD=y" >> $config_host_mak
958e1b
+fi
958e1b
 
958e1b
 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
958e1b
 
958e1b
-- 
958e1b
1.8.3.1
958e1b