diff mbox

[07/26] cow: migrate cow driver QemuOptionParameter usage

Message ID 1395360813-2833-8-git-send-email-l@dorileo.org
State New
Headers show

Commit Message

Leandro Dorileo March 21, 2014, 12:13 a.m. UTC
Do the directly migration from QemuOptionParameter to QemuOpts on
cow block driver.

Signed-off-by: Leandro Dorileo <l@dorileo.org>
---
 block/cow.c | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)
diff mbox

Patch

diff --git a/block/cow.c b/block/cow.c
index 30deb88..811f7f7 100644
--- a/block/cow.c
+++ b/block/cow.c
@@ -324,8 +324,7 @@  static void cow_close(BlockDriverState *bs)
 {
 }
 
-static int cow_create(const char *filename, QEMUOptionParameter *options,
-                      Error **errp)
+static int cow_create(const char *filename, QemuOpts *options, Error **errp)
 {
     struct cow_header_v2 cow_header;
     struct stat st;
@@ -335,16 +334,13 @@  static int cow_create(const char *filename, QEMUOptionParameter *options,
     int ret;
     BlockDriverState *cow_bs;
 
-    /* Read out options */
-    while (options && options->name) {
-        if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
-            image_sectors = options->value.n / 512;
-        } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) {
-            image_filename = options->value.s;
-        }
-        options++;
+    image_sectors = qemu_opt_get_size(options, BLOCK_OPT_SIZE, 0);
+    if (image_sectors) {
+        image_sectors = image_sectors / 512;
     }
 
+    image_filename = qemu_opt_get(options, BLOCK_OPT_BACKING_FILE);
+
     ret = bdrv_create_file(filename, options, &local_err);
     if (ret < 0) {
         error_propagate(errp, local_err);
@@ -393,18 +389,22 @@  exit:
     return ret;
 }
 
-static QEMUOptionParameter cow_create_options[] = {
-    {
-        .name = BLOCK_OPT_SIZE,
-        .type = OPT_SIZE,
-        .help = "Virtual disk size"
-    },
-    {
-        .name = BLOCK_OPT_BACKING_FILE,
-        .type = OPT_STRING,
-        .help = "File name of a base image"
+static QemuOptsList cow_create_options = {
+    .name = "cow_create_options",
+    .head = QTAILQ_HEAD_INITIALIZER(cow_create_options.head),
+    .desc = {
+        {
+            .name = BLOCK_OPT_SIZE,
+            .type = QEMU_OPT_SIZE,
+            .help = "Virtual disk size"
+        },
+        {
+            .name = BLOCK_OPT_BACKING_FILE,
+            .type = QEMU_OPT_STRING,
+            .help = "File name of a base image"
+        },
+        { NULL }
     },
-    { NULL }
 };
 
 static BlockDriver bdrv_cow = {
@@ -421,7 +421,7 @@  static BlockDriver bdrv_cow = {
     .bdrv_write             = cow_co_write,
     .bdrv_co_get_block_status   = cow_co_get_block_status,
 
-    .create_options = cow_create_options,
+    .create_options = &cow_create_options,
 };
 
 static void bdrv_cow_init(void)