diff mbox

[19/26] ssh: migrate ssh driver QemuOptionParameter usage

Message ID 1395360813-2833-20-git-send-email-l@dorileo.org
State New
Headers show

Commit Message

Leandro Dorileo March 21, 2014, 12:13 a.m. UTC
Do the directly migration from QemuOptionParameter to QemuOpts on
ssh block driver.

Signed-off-by: Leandro Dorileo <l@dorileo.org>
---
 block/ssh.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

Comments

Richard W.M. Jones March 21, 2014, 8:32 a.m. UTC | #1
On Thu, Mar 20, 2014 at 09:13:26PM -0300, Leandro Dorileo wrote:
> Do the directly migration from QemuOptionParameter to QemuOpts on
> ssh block driver.
> 
> Signed-off-by: Leandro Dorileo <l@dorileo.org>
> ---
>  block/ssh.c | 29 +++++++++++++----------------
>  1 file changed, 13 insertions(+), 16 deletions(-)
> 
> diff --git a/block/ssh.c b/block/ssh.c
> index aa63c9d..b55c518 100644
> --- a/block/ssh.c
> +++ b/block/ssh.c
> @@ -642,17 +642,20 @@ static int ssh_file_open(BlockDriverState *bs, QDict *options, int bdrv_flags,
>      return ret;
>  }
>  
> -static QEMUOptionParameter ssh_create_options[] = {
> -    {
> -        .name = BLOCK_OPT_SIZE,
> -        .type = OPT_SIZE,
> -        .help = "Virtual disk size"
> +static QemuOptsList ssh_create_options = {
> +    .name = "ssh_create_options",
> +    .head = QTAILQ_HEAD_INITIALIZER(ssh_create_options.head),
> +    .desc = {
> +        {
> +            .name = BLOCK_OPT_SIZE,
> +            .type = QEMU_OPT_SIZE,
> +            .help = "Virtual disk size"
> +        },
> +        { NULL }
>      },
> -    { NULL }
>  };
>  
> -static int ssh_create(const char *filename, QEMUOptionParameter *options,
> -                      Error **errp)
> +static int ssh_create(const char *filename, QemuOpts *options, Error **errp)
>  {
>      int r, ret;
>      Error *local_err = NULL;
> @@ -664,13 +667,7 @@ static int ssh_create(const char *filename, QEMUOptionParameter *options,
>  
>      ssh_state_init(&s);
>  
> -    /* Get desired file size. */
> -    while (options && options->name) {
> -        if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
> -            total_size = options->value.n;
> -        }
> -        options++;
> -    }
> +    total_size = qemu_opt_get_size(options, BLOCK_OPT_SIZE, 0);
>      DPRINTF("total_size=%" PRIi64, total_size);
>  
>      uri_options = qdict_new();
> @@ -1051,7 +1048,7 @@ static BlockDriver bdrv_ssh = {
>      .bdrv_co_writev               = ssh_co_writev,
>      .bdrv_getlength               = ssh_getlength,
>      .bdrv_co_flush_to_disk        = ssh_co_flush,
> -    .create_options               = ssh_create_options,
> +    .create_options               = &ssh_create_options,
>  };
>  
>  static void bdrv_ssh_init(void)
> -- 
> 1.9.0

Looks good to me, ACK.

Rich.
diff mbox

Patch

diff --git a/block/ssh.c b/block/ssh.c
index aa63c9d..b55c518 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -642,17 +642,20 @@  static int ssh_file_open(BlockDriverState *bs, QDict *options, int bdrv_flags,
     return ret;
 }
 
-static QEMUOptionParameter ssh_create_options[] = {
-    {
-        .name = BLOCK_OPT_SIZE,
-        .type = OPT_SIZE,
-        .help = "Virtual disk size"
+static QemuOptsList ssh_create_options = {
+    .name = "ssh_create_options",
+    .head = QTAILQ_HEAD_INITIALIZER(ssh_create_options.head),
+    .desc = {
+        {
+            .name = BLOCK_OPT_SIZE,
+            .type = QEMU_OPT_SIZE,
+            .help = "Virtual disk size"
+        },
+        { NULL }
     },
-    { NULL }
 };
 
-static int ssh_create(const char *filename, QEMUOptionParameter *options,
-                      Error **errp)
+static int ssh_create(const char *filename, QemuOpts *options, Error **errp)
 {
     int r, ret;
     Error *local_err = NULL;
@@ -664,13 +667,7 @@  static int ssh_create(const char *filename, QEMUOptionParameter *options,
 
     ssh_state_init(&s);
 
-    /* Get desired file size. */
-    while (options && options->name) {
-        if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
-            total_size = options->value.n;
-        }
-        options++;
-    }
+    total_size = qemu_opt_get_size(options, BLOCK_OPT_SIZE, 0);
     DPRINTF("total_size=%" PRIi64, total_size);
 
     uri_options = qdict_new();
@@ -1051,7 +1048,7 @@  static BlockDriver bdrv_ssh = {
     .bdrv_co_writev               = ssh_co_writev,
     .bdrv_getlength               = ssh_getlength,
     .bdrv_co_flush_to_disk        = ssh_co_flush,
-    .create_options               = ssh_create_options,
+    .create_options               = &ssh_create_options,
 };
 
 static void bdrv_ssh_init(void)