qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Chunyan Liu <cyliu@suse.com>
To: qemu-devel@nongnu.org, stefanha@redhat.com, kwolf@redhat.com
Cc: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>, Chunyan Liu <cyliu@suse.com>
Subject: [Qemu-devel] [v19 18/25] vdi.c: replace QEMUOptionParameter with QemuOpts
Date: Mon, 20 Jan 2014 22:20:01 +0800	[thread overview]
Message-ID: <1390227608-7225-19-git-send-email-cyliu@suse.com> (raw)
In-Reply-To: <1390227608-7225-1-git-send-email-cyliu@suse.com>

vdi.c: replace QEMUOptionParameter with QemuOpts

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Signed-off-by: Chunyan Liu <cyliu@suse.com>
---
 block/vdi.c |   71 ++++++++++++++++++++++++++++------------------------------
 1 files changed, 34 insertions(+), 37 deletions(-)

diff --git a/block/vdi.c b/block/vdi.c
index 2d7490f..e5494a0 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -646,7 +646,7 @@ static int vdi_co_write(BlockDriverState *bs,
     return ret;
 }
 
-static int vdi_create(const char *filename, QEMUOptionParameter *options,
+static int vdi_create(const char *filename, QemuOpts *opts,
                       Error **errp)
 {
     int fd;
@@ -662,25 +662,17 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options,
     logout("\n");
 
     /* Read out options. */
-    while (options && options->name) {
-        if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
-            bytes = options->value.n;
+    bytes = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0);
 #if defined(CONFIG_VDI_BLOCK_SIZE)
-        } else if (!strcmp(options->name, BLOCK_OPT_CLUSTER_SIZE)) {
-            if (options->value.n) {
-                /* TODO: Additional checks (SECTOR_SIZE * 2^n, ...). */
-                block_size = options->value.n;
-            }
+    block_size = qemu_opt_get_size_del(opts,
+                                       BLOCK_OPT_CLUSTER_SIZE,
+                                       DEFAULT_CLUSTER_SIZE);
 #endif
 #if defined(CONFIG_VDI_STATIC_IMAGE)
-        } else if (!strcmp(options->name, BLOCK_OPT_STATIC)) {
-            if (options->value.n) {
-                image_type = VDI_TYPE_STATIC;
-            }
-#endif
-        }
-        options++;
+    if (qemu_opt_get_bool_del(opts, BLOCK_OPT_STATIC, false)) {
+        image_type = VDI_TYPE_STATIC;
     }
+#endif
 
     fd = qemu_open(filename,
                    O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE,
@@ -760,29 +752,34 @@ static void vdi_close(BlockDriverState *bs)
     error_free(s->migration_blocker);
 }
 
-static QEMUOptionParameter vdi_create_options[] = {
-    {
-        .name = BLOCK_OPT_SIZE,
-        .type = OPT_SIZE,
-        .help = "Virtual disk size"
-    },
+static QemuOptsList vdi_create_opts = {
+    .name = "vdi-create-opts",
+    .head = QTAILQ_HEAD_INITIALIZER(vdi_create_opts.head),
+    .desc = {
+        {
+            .name = BLOCK_OPT_SIZE,
+            .type = QEMU_OPT_SIZE,
+            .help = "Virtual disk size"
+        },
 #if defined(CONFIG_VDI_BLOCK_SIZE)
-    {
-        .name = BLOCK_OPT_CLUSTER_SIZE,
-        .type = OPT_SIZE,
-        .help = "VDI cluster (block) size",
-        .value = { .n = DEFAULT_CLUSTER_SIZE },
-    },
+        {
+            .name = BLOCK_OPT_CLUSTER_SIZE,
+            .type = QEMU_OPT_SIZE,
+            .help = "VDI cluster (block) size",
+            .def_value_str = stringify(DEFAULT_CLUSTER_SIZE)
+        },
 #endif
 #if defined(CONFIG_VDI_STATIC_IMAGE)
-    {
-        .name = BLOCK_OPT_STATIC,
-        .type = OPT_FLAG,
-        .help = "VDI static (pre-allocated) image"
-    },
+        {
+            .name = BLOCK_OPT_STATIC,
+            .type = QEMU_OPT_BOOL,
+            .help = "VDI static (pre-allocated) image",
+            .def_value_str = "off"
+        },
 #endif
-    /* TODO: An additional option to set UUID values might be useful. */
-    { NULL }
+        /* TODO: An additional option to set UUID values might be useful. */
+        { /* end of list */ }
+    }
 };
 
 static BlockDriver bdrv_vdi = {
@@ -792,7 +789,7 @@ static BlockDriver bdrv_vdi = {
     .bdrv_open = vdi_open,
     .bdrv_close = vdi_close,
     .bdrv_reopen_prepare = vdi_reopen_prepare,
-    .bdrv_create = vdi_create,
+    .bdrv_create2 = vdi_create,
     .bdrv_has_zero_init = bdrv_has_zero_init_1,
     .bdrv_co_get_block_status = vdi_co_get_block_status,
     .bdrv_make_empty = vdi_make_empty,
@@ -804,7 +801,7 @@ static BlockDriver bdrv_vdi = {
 
     .bdrv_get_info = vdi_get_info,
 
-    .create_options = vdi_create_options,
+    .create_opts = &vdi_create_opts,
     .bdrv_check = vdi_check,
 };
 
-- 
1.6.0.2

  parent reply	other threads:[~2014-01-20 14:21 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-20 14:19 [Qemu-devel] [v19 00/25] replace QEMUOptionParameter with QemuOpts Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 01/25] add def_value_str to QemuOptDesc Chunyan Liu
2014-01-22 13:25   ` Kevin Wolf
2014-01-20 14:19 ` [Qemu-devel] [v19 02/25] qapi: output def_value_str when query command line options Chunyan Liu
2014-01-20 15:53   ` Eric Blake
2014-01-20 14:19 ` [Qemu-devel] [v19 03/25] improve some functions in qemu-option.c Chunyan Liu
2014-01-22 13:33   ` Kevin Wolf
2014-01-20 14:19 ` [Qemu-devel] [v19 04/25] add some QemuOpts functions for replace work Chunyan Liu
2014-01-22 13:57   ` Kevin Wolf
2014-01-20 14:19 ` [Qemu-devel] [v19 05/25] change block layer to support both QemuOpts and QEMUOptionParameter Chunyan Liu
2014-01-22 14:19   ` Kevin Wolf
2014-01-20 14:19 ` [Qemu-devel] [v19 06/25] cow.c: replace QEMUOptionParameter with QemuOpts Chunyan Liu
2014-01-22 14:20   ` Kevin Wolf
2014-01-20 14:19 ` [Qemu-devel] [v19 07/25] gluster.c: " Chunyan Liu
2014-01-22 13:10   ` Kevin Wolf
2014-01-20 14:19 ` [Qemu-devel] [v19 08/25] iscsi.c: replace QEMUOptionParamter " Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 09/25] qcow.c: " Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 10/25] qcow2.c: replace QEMUOptionParameter with QemuOpts in create Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 11/25] qcow2.c: replace QEMUOptionParameter with QemuOpts in amend options Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 12/25] qed.c: replace QEMUOptionParameter with QemuOpts Chunyan Liu
2014-01-22 14:24   ` Kevin Wolf
2014-01-20 14:19 ` [Qemu-devel] [v19 13/25] raw-posix.c: " Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 14/25] raw-win32.c: " Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 15/25] rbd.c: " Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 16/25] sheepdog.c: " Chunyan Liu
2014-01-20 14:20 ` [Qemu-devel] [v19 17/25] ssh.c: " Chunyan Liu
2014-01-20 14:20 ` Chunyan Liu [this message]
2014-01-20 14:20 ` [Qemu-devel] [v19 19/25] vmdk.c: " Chunyan Liu
2014-01-20 14:20 ` [Qemu-devel] [v19 20/25] vpc.c: " Chunyan Liu
2014-01-20 14:20 ` [Qemu-devel] [v19 21/25] raw_bsd.c: " Chunyan Liu
2014-01-20 14:20 ` [Qemu-devel] [v19 22/25] vhdx.c: " Chunyan Liu
2014-01-22 14:26   ` Kevin Wolf
2014-01-20 14:20 ` [Qemu-devel] [v19 23/25] vvfat.c: " Chunyan Liu
2014-01-20 14:20 ` [Qemu-devel] [v19 24/25] cleanup QEMUOptionParameter Chunyan Liu
2014-01-22 14:33   ` Kevin Wolf
2014-01-20 14:20 ` [Qemu-devel] [v19 25/25] change back to original name from bdrv_create2 to bdrv_create Chunyan Liu
2014-01-22 14:35 ` [Qemu-devel] [v19 00/25] replace QEMUOptionParameter with QemuOpts Kevin Wolf
2014-01-22 16:11   ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1390227608-7225-19-git-send-email-cyliu@suse.com \
    --to=cyliu@suse.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=wdongxu@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).