From patchwork Fri Mar 21 00:13:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leandro Dorileo X-Patchwork-Id: 332444 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7CE592C00A2 for ; Fri, 21 Mar 2014 11:19:15 +1100 (EST) Received: from localhost ([::1]:50147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQnB3-00062M-AH for incoming@patchwork.ozlabs.org; Thu, 20 Mar 2014 20:19:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQn6F-0000sW-Ln for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:14:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQn69-0007ac-8m for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:14:15 -0400 Received: from mail-yk0-f169.google.com ([209.85.160.169]:62810) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQn68-0007aW-Uv for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:14:09 -0400 Received: by mail-yk0-f169.google.com with SMTP id 142so4367617ykq.0 for ; Thu, 20 Mar 2014 17:14:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=T2FNH2OyPg1wyZS4REdJH6D1SBJOItlyHLZ6L6nmfFo=; b=dpp0EDVTOJr4wvcH18q2Peq7oTpH033+hUti6r8CvCx1RU3pDIH//mgN3KTvBkeFAM +c7Cy2/RoCGRAQrK9CJUBSEh9bMM9RlBRLiCQCRvnEky2moFW8+wryHqO5CILmND08ZM 6hZd0k7mKE/K+HK9DY4MXGs566gN2sYK+vqVV18Q+cZ4kWaVvQiUF17QNVNT5A5KyHLz GZ3tiRsHEzFX4M6GOduaY+e2exbhoSp4CIfzL9NdNtbVPOudtAocruH9uEABct0aSgGE Awkx1460pKRId70fcewzpJVzJtE9PCvykMA9PoVXNqaAowr9RQU/sM1/o+F0gGcFxgUx S/fw== X-Gm-Message-State: ALoCoQkM18qLwycxQbgkllT6XBHaa+sRziOHRRE8R1PArnhImqKSS76OkwQdU8Wu+cnoM2aKnhFK X-Received: by 10.236.126.162 with SMTP id b22mr38346738yhi.72.1395360848643; Thu, 20 Mar 2014 17:14:08 -0700 (PDT) Received: from dorilex-lnv.MultilaserAP ([177.194.92.107]) by mx.google.com with ESMTPSA id k63sm5501231yhg.37.2014.03.20.17.14.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Mar 2014 17:14:08 -0700 (PDT) From: Leandro Dorileo To: qemu-devel@nongnu.org Date: Thu, 20 Mar 2014 21:13:14 -0300 Message-Id: <1395360813-2833-8-git-send-email-l@dorileo.org> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1395360813-2833-1-git-send-email-l@dorileo.org> References: <1395360813-2833-1-git-send-email-l@dorileo.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.160.169 Cc: Kevin Wolf , Fam Zheng , Stefan Hajnoczi , Liu Yuan , Jeff Cody , Markus Armbruster , Peter Lieven , "Richard W.M. Jones" , Luiz Capitulino , Leandro Dorileo , Ronnie Sahlberg , Josh Durgin , Anthony Liguori , Paolo Bonzini , Stefan Weil , Max Reitz , MORITA Kazutaka , Benoit Canet Subject: [Qemu-devel] [PATCH 07/26] cow: migrate cow driver QemuOptionParameter usage 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 Do the directly migration from QemuOptionParameter to QemuOpts on cow block driver. Signed-off-by: Leandro Dorileo --- block/cow.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) 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)