summaryrefslogtreecommitdiff
path: root/block/rbd.c
diff options
context:
space:
mode:
authorChunyan Liu <cyliu@suse.com>2014-06-05 17:21:04 +0800
committerStefan Hajnoczi <stefanha@redhat.com>2014-06-16 17:23:21 +0800
commitbd0cf596fd1200d162e5655adff9c06d40dbdd14 (patch)
tree470dc080806766e2274b19a13dfcc6fc607ed36b /block/rbd.c
parentcd3a4cf631644636b098243fd118980100efbe01 (diff)
downloadqemu-bd0cf596fd1200d162e5655adff9c06d40dbdd14.zip
rbd.c: replace QEMUOptionParameter with QemuOpts
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Chunyan Liu <cyliu@suse.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/rbd.c')
-rw-r--r--block/rbd.c63
1 files changed, 30 insertions, 33 deletions
diff --git a/block/rbd.c b/block/rbd.c
index 93639f783c..e15d3129a5 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -289,8 +289,7 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf, Error **errp)
return ret;
}
-static int qemu_rbd_create(const char *filename, QEMUOptionParameter *options,
- Error **errp)
+static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
{
Error *local_err = NULL;
int64_t bytes = 0;
@@ -315,24 +314,18 @@ static int qemu_rbd_create(const char *filename, QEMUOptionParameter *options,
}
/* Read out options */
- while (options && options->name) {
- if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
- bytes = options->value.n;
- } else if (!strcmp(options->name, BLOCK_OPT_CLUSTER_SIZE)) {
- if (options->value.n) {
- objsize = options->value.n;
- if ((objsize - 1) & objsize) { /* not a power of 2? */
- error_setg(errp, "obj size needs to be power of 2");
- return -EINVAL;
- }
- if (objsize < 4096) {
- error_setg(errp, "obj size too small");
- return -EINVAL;
- }
- obj_order = ffs(objsize) - 1;
- }
+ bytes = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0);
+ objsize = qemu_opt_get_size_del(opts, BLOCK_OPT_CLUSTER_SIZE, 0);
+ if (objsize) {
+ if ((objsize - 1) & objsize) { /* not a power of 2? */
+ error_setg(errp, "obj size needs to be power of 2");
+ return -EINVAL;
+ }
+ if (objsize < 4096) {
+ error_setg(errp, "obj size too small");
+ return -EINVAL;
}
- options++;
+ obj_order = ffs(objsize) - 1;
}
clientname = qemu_rbd_parse_clientname(conf, clientname_buf);
@@ -911,18 +904,22 @@ static BlockDriverAIOCB* qemu_rbd_aio_discard(BlockDriverState *bs,
}
#endif
-static QEMUOptionParameter qemu_rbd_create_options[] = {
- {
- .name = BLOCK_OPT_SIZE,
- .type = OPT_SIZE,
- .help = "Virtual disk size"
- },
- {
- .name = BLOCK_OPT_CLUSTER_SIZE,
- .type = OPT_SIZE,
- .help = "RBD object size"
- },
- {NULL}
+static QemuOptsList qemu_rbd_create_opts = {
+ .name = "rbd-create-opts",
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_rbd_create_opts.head),
+ .desc = {
+ {
+ .name = BLOCK_OPT_SIZE,
+ .type = QEMU_OPT_SIZE,
+ .help = "Virtual disk size"
+ },
+ {
+ .name = BLOCK_OPT_CLUSTER_SIZE,
+ .type = QEMU_OPT_SIZE,
+ .help = "RBD object size"
+ },
+ { /* end of list */ }
+ }
};
static BlockDriver bdrv_rbd = {
@@ -931,10 +928,10 @@ static BlockDriver bdrv_rbd = {
.bdrv_needs_filename = true,
.bdrv_file_open = qemu_rbd_open,
.bdrv_close = qemu_rbd_close,
- .bdrv_create = qemu_rbd_create,
+ .bdrv_create2 = qemu_rbd_create,
.bdrv_has_zero_init = bdrv_has_zero_init_1,
.bdrv_get_info = qemu_rbd_getinfo,
- .create_options = qemu_rbd_create_options,
+ .create_opts = &qemu_rbd_create_opts,
.bdrv_getlength = qemu_rbd_getlength,
.bdrv_truncate = qemu_rbd_truncate,
.protocol_name = "rbd",