Do the directly migration from QemuOptionParameter to QemuOpts on
rbd block driver.

Signed-off-by: Leandro Dorileo <l...@dorileo.org>
---
 block/rbd.c | 60 +++++++++++++++++++++++++++++-------------------------------
 1 file changed, 29 insertions(+), 31 deletions(-)

diff --git a/block/rbd.c b/block/rbd.c
index dbc79f4..ae8c471 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -282,7 +282,7 @@ static int qemu_rbd_set_conf(rados_t cluster, const char 
*conf)
     return ret;
 }
 
-static int qemu_rbd_create(const char *filename, QEMUOptionParameter *options,
+static int qemu_rbd_create(const char *filename, QemuOpts *options,
                            Error **errp)
 {
     int64_t bytes = 0;
@@ -305,25 +305,19 @@ static int qemu_rbd_create(const char *filename, 
QEMUOptionParameter *options,
         return -EINVAL;
     }
 
-    /* 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_report("obj size needs to be power of 2");
-                    return -EINVAL;
-                }
-                if (objsize < 4096) {
-                    error_report("obj size too small");
-                    return -EINVAL;
-                }
-                obj_order = ffs(objsize) - 1;
-            }
+    bytes = qemu_opt_get_size(options, BLOCK_OPT_SIZE, 0);
+    objsize = qemu_opt_get_size(options, BLOCK_OPT_CLUSTER_SIZE, 0);
+
+    if (objsize != 0) {
+        if ((objsize - 1) & objsize) {  /* not a power of 2? */
+            error_report("obj size needs to be power of 2");
+            return -EINVAL;
+        }
+        if (objsize < 4096) {
+            error_report("obj size too small");
+            return -EINVAL;
         }
-        options++;
+        obj_order = ffs(objsize) - 1;
     }
 
     clientname = qemu_rbd_parse_clientname(conf, clientname_buf);
@@ -900,18 +894,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"
+static QemuOptsList qemu_rbd_create_options = {
+    .name = "qemu_rbd_create_options",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_rbd_create_options.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"
+        },
+        {NULL}
     },
-    {NULL}
 };
 
 static BlockDriver bdrv_rbd = {
@@ -923,7 +921,7 @@ static BlockDriver bdrv_rbd = {
     .bdrv_create        = 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_options     = &qemu_rbd_create_options,
     .bdrv_getlength     = qemu_rbd_getlength,
     .bdrv_truncate      = qemu_rbd_truncate,
     .protocol_name      = "rbd",
-- 
1.9.0


Reply via email to