qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH V2] qemu-img: use QemuOpts instead of QEMUOptionParameter in resize function
@ 2012-08-06  2:18 Dong Xu Wang
  2012-08-06 10:14 ` Stefan Hajnoczi
  0 siblings, 1 reply; 3+ messages in thread
From: Dong Xu Wang @ 2012-08-06  2:18 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Dong Xu Wang


Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
---
v1->v2: fix param leak.

 qemu-img.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 80cfb9b..36e1c77 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1567,14 +1567,19 @@ static int img_resize(int argc, char **argv)
     const char *filename, *fmt, *size;
     int64_t n, total_size;
     BlockDriverState *bs = NULL;
-    QEMUOptionParameter *param;
-    QEMUOptionParameter resize_options[] = {
-        {
-            .name = BLOCK_OPT_SIZE,
-            .type = OPT_SIZE,
-            .help = "Virtual disk size"
+    QemuOpts *param;
+    static QemuOptsList resize_options = {
+        .name = "resize_options",
+        .head = QTAILQ_HEAD_INITIALIZER(resize_options.head),
+        .desc = {
+            {
+                .name = BLOCK_OPT_SIZE,
+                .type = QEMU_OPT_SIZE,
+                .help = "Virtual disk size"
+            }, {
+                /* end of list */
+            }
         },
-        { NULL }
     };
 
     /* Remove size from argv manually so that negative numbers are not treated
@@ -1624,14 +1629,15 @@ static int img_resize(int argc, char **argv)
     }
 
     /* Parse size */
-    param = parse_option_parameters("", resize_options, NULL);
-    if (set_option_parameter(param, BLOCK_OPT_SIZE, size)) {
+    param = qemu_opts_create(&resize_options, NULL, 0, NULL);
+    if (qemu_opt_set(param, BLOCK_OPT_SIZE, size)) {
         /* Error message already printed when size parsing fails */
         ret = -1;
+        qemu_opts_del(param);
         goto out;
     }
-    n = get_option_parameter(param, BLOCK_OPT_SIZE)->value.n;
-    free_option_parameters(param);
+    n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0);
+    qemu_opts_del(param);
 
     bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR);
     if (!bs) {
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH V2] qemu-img: use QemuOpts instead of QEMUOptionParameter in resize function
  2012-08-06  2:18 [Qemu-devel] [PATCH V2] qemu-img: use QemuOpts instead of QEMUOptionParameter in resize function Dong Xu Wang
@ 2012-08-06 10:14 ` Stefan Hajnoczi
  2012-08-06 11:23   ` Kevin Wolf
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2012-08-06 10:14 UTC (permalink / raw)
  To: Dong Xu Wang; +Cc: kwolf, qemu-devel

On Mon, Aug 6, 2012 at 3:18 AM, Dong Xu Wang <wdongxu@linux.vnet.ibm.com> wrote:
>
> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
> ---
> v1->v2: fix param leak.
>
>  qemu-img.c |   28 +++++++++++++++++-----------
>  1 files changed, 17 insertions(+), 11 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH V2] qemu-img: use QemuOpts instead of QEMUOptionParameter in resize function
  2012-08-06 10:14 ` Stefan Hajnoczi
@ 2012-08-06 11:23   ` Kevin Wolf
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2012-08-06 11:23 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Dong Xu Wang, qemu-devel

Am 06.08.2012 12:14, schrieb Stefan Hajnoczi:
> On Mon, Aug 6, 2012 at 3:18 AM, Dong Xu Wang <wdongxu@linux.vnet.ibm.com> wrote:
>>
>> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
>> ---
>> v1->v2: fix param leak.
>>
>>  qemu-img.c |   28 +++++++++++++++++-----------
>>  1 files changed, 17 insertions(+), 11 deletions(-)
> 
> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

Thanks, applied to the block branch.

(But why do we even use any of the option functions instead of calling
strtosz_suffix?)

Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-08-06 11:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-06  2:18 [Qemu-devel] [PATCH V2] qemu-img: use QemuOpts instead of QEMUOptionParameter in resize function Dong Xu Wang
2012-08-06 10:14 ` Stefan Hajnoczi
2012-08-06 11:23   ` Kevin Wolf

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).