[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 39/56] rbd: Use qemu_rbd_connect() in qemu_rbd_do_cre
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 39/56] rbd: Use qemu_rbd_connect() in qemu_rbd_do_create() |
Date: |
Fri, 9 Mar 2018 17:19:16 +0100 |
This is almost exactly the same code. The differences are that
qemu_rbd_connect() supports BlockdevOptionsRbd.server and that the cache
mode is set explicitly.
Supporting 'server' is a welcome new feature for image creation.
Caching is disabled by default, so leave it that way.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block/rbd.c | 54 ++++++++++--------------------------------------------
1 file changed, 10 insertions(+), 44 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
index 2ac7ffca42..294ed07ac4 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -103,6 +103,11 @@ typedef struct BDRVRBDState {
char *snap;
} BDRVRBDState;
+static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
+ BlockdevOptionsRbd *opts, bool cache,
+ const char *keypairs, const char *secretid,
+ Error **errp);
+
static char *qemu_rbd_next_tok(char *src, char delim, char **p)
{
char *end;
@@ -351,12 +356,6 @@ static int qemu_rbd_do_create(BlockdevCreateOptions
*options,
return -EINVAL;
}
- /* TODO Remove the limitation */
- if (opts->location->has_server) {
- error_setg(errp, "Can't specify server for image creation");
- return -EINVAL;
- }
-
if (opts->has_cluster_size) {
int64_t objsize = opts->cluster_size;
if ((objsize - 1) & objsize) { /* not a power of 2? */
@@ -370,54 +369,21 @@ static int qemu_rbd_do_create(BlockdevCreateOptions
*options,
obj_order = ctz32(objsize);
}
- ret = rados_create(&cluster, opts->location->user);
+ ret = qemu_rbd_connect(&cluster, &io_ctx, opts->location, false, keypairs,
+ password_secret, errp);
if (ret < 0) {
- error_setg_errno(errp, -ret, "error initializing");
return ret;
}
- /* try default location when conf=NULL, but ignore failure */
- ret = rados_conf_read_file(cluster, opts->location->conf);
- if (opts->location->conf && ret < 0) {
- error_setg_errno(errp, -ret, "error reading conf file %s",
- opts->location->conf);
- ret = -EIO;
- goto shutdown;
- }
-
- ret = qemu_rbd_set_keypairs(cluster, keypairs, errp);
- if (ret < 0) {
- ret = -EIO;
- goto shutdown;
- }
-
- if (qemu_rbd_set_auth(cluster, password_secret, errp) < 0) {
- ret = -EIO;
- goto shutdown;
- }
-
- ret = rados_connect(cluster);
- if (ret < 0) {
- error_setg_errno(errp, -ret, "error connecting");
- goto shutdown;
- }
-
- ret = rados_ioctx_create(cluster, opts->location->pool, &io_ctx);
- if (ret < 0) {
- error_setg_errno(errp, -ret, "error opening pool %s",
- opts->location->pool);
- goto shutdown;
- }
-
ret = rbd_create(io_ctx, opts->location->image, opts->size, &obj_order);
if (ret < 0) {
error_setg_errno(errp, -ret, "error rbd create");
+ goto out;
}
- rados_ioctx_destroy(io_ctx);
-
ret = 0;
-shutdown:
+out:
+ rados_ioctx_destroy(io_ctx);
rados_shutdown(cluster);
return ret;
}
--
2.13.6
- [Qemu-devel] [PULL 23/56] util: Add qemu_opts_to_qdict_filtered(), (continued)
- [Qemu-devel] [PULL 23/56] util: Add qemu_opts_to_qdict_filtered(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 31/56] file-win32: Support .bdrv_co_create, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 33/56] rbd: Fix use after free in qemu_rbd_set_keypairs() error path, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 37/56] rbd: Support .bdrv_co_create, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 40/56] nfs: Use QAPI options in nfs_client_open(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 48/56] file-posix: Fix no-op bdrv_truncate() with falloc preallocation, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 41/56] nfs: Support .bdrv_co_create, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 46/56] ssh: Pass BlockdevOptionsSsh to connect_to_ssh(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 49/56] block: Fail bdrv_truncate() with negative size, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 44/56] ssh: Use QAPI BlockdevOptionsSsh object, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 39/56] rbd: Use qemu_rbd_connect() in qemu_rbd_do_create(),
Kevin Wolf <=
- [Qemu-devel] [PULL 35/56] rbd: Remove non-schema options from runtime_opts, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 43/56] sheepdog: Support .bdrv_co_create, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 51/56] qemu-iotests: Test ssh image creation over QMP, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 38/56] rbd: Assign s->snap/image_name in qemu_rbd_open(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 42/56] sheepdog: QAPIfy "redundancy" create option, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 47/56] ssh: Support .bdrv_co_create, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 45/56] ssh: QAPIfy host-key-check option, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 52/56] iotests: Test creating overlay when guest running, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 54/56] iotests: Skip test for ENOMEM error, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 53/56] iotests: Mark all tests executable, Kevin Wolf, 2018/03/09