Do the directly migration from QemuOptionParameter to QemuOpts on
raw-posix block driver.

Signed-off-by: Leandro Dorileo <l...@dorileo.org>
---
 block/raw-posix.c | 50 +++++++++++++++++++++++---------------------------
 1 file changed, 23 insertions(+), 27 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index 1688e16..ddeafa7 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1234,8 +1234,7 @@ static int64_t 
raw_get_allocated_file_size(BlockDriverState *bs)
     return (int64_t)st.st_blocks * 512;
 }
 
-static int raw_create(const char *filename, QEMUOptionParameter *options,
-                      Error **errp)
+static int raw_create(const char *filename, QemuOpts *options, Error **errp)
 {
     int fd;
     int result = 0;
@@ -1243,12 +1242,9 @@ static int raw_create(const char *filename, 
QEMUOptionParameter *options,
 
     strstart(filename, "file:", &filename);
 
-    /* Read out options */
-    while (options && options->name) {
-        if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
-            total_size = options->value.n / BDRV_SECTOR_SIZE;
-        }
-        options++;
+    total_size = qemu_opt_get_size(options, BLOCK_OPT_SIZE, 0);
+    if (total_size) {
+        total_size = total_size / BDRV_SECTOR_SIZE;
     }
 
     fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
@@ -1410,13 +1406,17 @@ static int raw_get_info(BlockDriverState *bs, 
BlockDriverInfo *bdi)
     return 0;
 }
 
-static QEMUOptionParameter raw_create_options[] = {
-    {
-        .name = BLOCK_OPT_SIZE,
-        .type = OPT_SIZE,
-        .help = "Virtual disk size"
+static QemuOptsList raw_create_options = {
+    .name = "raw_create_options",
+    .head = QTAILQ_HEAD_INITIALIZER(raw_create_options.head),
+    .desc = {
+        {
+            .name = BLOCK_OPT_SIZE,
+            .type = QEMU_OPT_SIZE,
+            .help = "Virtual disk size"
+        },
+        { NULL }
     },
-    { NULL }
 };
 
 static BlockDriver bdrv_file = {
@@ -1448,7 +1448,7 @@ static BlockDriver bdrv_file = {
     .bdrv_get_allocated_file_size
                         = raw_get_allocated_file_size,
 
-    .create_options = raw_create_options,
+    .create_options = &raw_create_options,
 };
 
 /***********************************************/
@@ -1769,8 +1769,7 @@ static coroutine_fn int 
hdev_co_write_zeroes(BlockDriverState *bs,
     return -ENOTSUP;
 }
 
-static int hdev_create(const char *filename, QEMUOptionParameter *options,
-                       Error **errp)
+static int hdev_create(const char *filename, QemuOpts *options, Error **errp)
 {
     int fd;
     int ret = 0;
@@ -1789,12 +1788,9 @@ static int hdev_create(const char *filename, 
QEMUOptionParameter *options,
 
     (void)has_prefix;
 
-    /* Read out options */
-    while (options && options->name) {
-        if (!strcmp(options->name, "size")) {
-            total_size = options->value.n / BDRV_SECTOR_SIZE;
-        }
-        options++;
+    total_size = qemu_opt_get_size(options, BLOCK_OPT_SIZE, 0);
+    if (total_size) {
+        total_size = total_size / BDRV_SECTOR_SIZE;
     }
 
     fd = qemu_open(filename, O_WRONLY | O_BINARY);
@@ -1833,7 +1829,7 @@ static BlockDriver bdrv_host_device = {
     .bdrv_reopen_commit  = raw_reopen_commit,
     .bdrv_reopen_abort   = raw_reopen_abort,
     .bdrv_create        = hdev_create,
-    .create_options     = raw_create_options,
+    .create_options     = &raw_create_options,
     .bdrv_co_write_zeroes = hdev_co_write_zeroes,
 
     .bdrv_aio_readv    = raw_aio_readv,
@@ -1977,7 +1973,7 @@ static BlockDriver bdrv_host_floppy = {
     .bdrv_reopen_commit  = raw_reopen_commit,
     .bdrv_reopen_abort   = raw_reopen_abort,
     .bdrv_create        = hdev_create,
-    .create_options     = raw_create_options,
+    .create_options     = &raw_create_options,
 
     .bdrv_aio_readv     = raw_aio_readv,
     .bdrv_aio_writev    = raw_aio_writev,
@@ -2102,7 +2098,7 @@ static BlockDriver bdrv_host_cdrom = {
     .bdrv_reopen_commit  = raw_reopen_commit,
     .bdrv_reopen_abort   = raw_reopen_abort,
     .bdrv_create        = hdev_create,
-    .create_options     = raw_create_options,
+    .create_options     = &raw_create_options,
 
     .bdrv_aio_readv     = raw_aio_readv,
     .bdrv_aio_writev    = raw_aio_writev,
@@ -2233,7 +2229,7 @@ static BlockDriver bdrv_host_cdrom = {
     .bdrv_reopen_commit  = raw_reopen_commit,
     .bdrv_reopen_abort   = raw_reopen_abort,
     .bdrv_create        = hdev_create,
-    .create_options     = raw_create_options,
+    .create_options     = &raw_create_options,
 
     .bdrv_aio_readv     = raw_aio_readv,
     .bdrv_aio_writev    = raw_aio_writev,
-- 
1.9.0


Reply via email to