From patchwork Thu Aug 2 03:42:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Wang X-Patchwork-Id: 174681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F276E2C0094 for ; Thu, 2 Aug 2012 13:42:50 +1000 (EST) Received: from localhost ([::1]:59442 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwmJE-0002UU-1x for incoming@patchwork.ozlabs.org; Wed, 01 Aug 2012 23:42:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwmJ4-0002UP-Aj for qemu-devel@nongnu.org; Wed, 01 Aug 2012 23:42:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SwmJ3-0008JU-BF for qemu-devel@nongnu.org; Wed, 01 Aug 2012 23:42:38 -0400 Received: from mail-gg0-f173.google.com ([209.85.161.173]:44396) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwmJ3-0008JO-76 for qemu-devel@nongnu.org; Wed, 01 Aug 2012 23:42:37 -0400 Received: by ggnp1 with SMTP id p1so7906137ggn.4 for ; Wed, 01 Aug 2012 20:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer; bh=Ttr8f1kb4bKozFPJzRNHSBAeHZDkpnLswV7lMbReMOY=; b=lMNZiE1tBZhFOhXjhFposooYVc1BQ5f6okwaQOJodF5Gnfomq90OR/83WpM+9muNRz qdcJY76N73QZeJkPYjDNqs1Jlt7MfuijW4UtDhBr2eQltXuZZz6Ywf02zK5A+CZK86dk 6k4DaaMiKEHPvqormJBVYv7qNGNWHMagujywm7Lc1RvxZSRBhW/uPCsb1TcVn9KsHdMU mHQL1Qi8PKfcxjs9k2IIA8RPGv4tqPI1VQNDhOmD9jnMf5v1pmbHZdffB/p56s8WymaM 37G1zPfW0gfm1Holwm8gPtK660e30GmXuxo3slyQnADoRtXqM8dWzKEFFGO8xK77sEaQ 2RyA== Received: by 10.50.220.194 with SMTP id py2mr890960igc.15.1343878956206; Wed, 01 Aug 2012 20:42:36 -0700 (PDT) Received: from localhost.localdomain ([202.108.130.138]) by mx.google.com with ESMTPS id c3sm9832317iga.8.2012.08.01.20.42.32 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 01 Aug 2012 20:42:35 -0700 (PDT) From: Dong Xu Wang To: qemu-devel@nongnu.org Date: Thu, 2 Aug 2012 11:42:18 +0800 Message-Id: <1343878938-23375-1-git-send-email-wdongxu@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.161.173 Cc: kwolf@redhat.com, Dong Xu Wang Subject: [Qemu-devel] [PATCH] qemu-img: use QemuOpts instead of QEMUOptionParameter in resize function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Dong Xu Wang --- qemu-img.c | 27 ++++++++++++++++----------- 1 files changed, 16 insertions(+), 11 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 80cfb9b..13db7a2 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,14 @@ 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; 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) {