From e1544e53c01f61392e4afb2e05354e429fc8c32b Mon Sep 17 00:00:00 2001
Message-Id: <e1544e53c01f61392e4afb2e05354e429fc8c32b.1378813438.git.minovotn@redhat.com>
In-Reply-To: <b80f97e724da8388b544413d6a3dcac35d347d9b.1378813438.git.minovotn@redhat.com>
References: <b80f97e724da8388b544413d6a3dcac35d347d9b.1378813438.git.minovotn@redhat.com>
From: Jeffrey Cody <jcody@redhat.com>
Date: Wed, 28 Aug 2013 13:14:47 +0200
Subject: [PATCH 05/13] vpc.c: Use get_option_parameter() does the search

RH-Author: Jeffrey Cody <jcody@redhat.com>
Message-id: <ffa4b5a97d85c9b8fe46ebf858d279d4a1e7b8fc.1377694139.git.jcody@redhat.com>
Patchwork-id: 53840
O-Subject: [RHEL6.5 qemu-kvm PATCH 05/13] vpc.c: Use get_option_parameter() does the search
Bugzilla: 999779
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
RH-Acked-by: Fam Zheng <famz@redhat.com>

From: Mitnick Lyu <mitnick.lyu@gmail.com>

Use get_option_parameter() to instead of duplicating the loop, and
use BDRV_SECTOR_SIZE to instead of 512

Signed-off-by: Mitnick Lyu <mitnick.lyu@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 2d56a546a73ca3f588196f4065621ff5f11f50e4)
Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 block/vpc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 block/vpc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/block/vpc.c b/block/vpc.c
index 5203039..a1e6142 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -538,12 +538,8 @@ static int vpc_create(const char *filename, QEMUOptionParameter *options)
     int ret = -EIO;
 
     // Read out options
-    while (options && options->name) {
-        if (!strcmp(options->name, "size")) {
-            total_sectors = options->value.n / 512;
-        }
-        options++;
-    }
+    total_sectors = get_option_parameter(options, BLOCK_OPT_SIZE)->value.n /
+                    BDRV_SECTOR_SIZE;
 
     // Create the file
     fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
-- 
1.7.11.7