diff mbox

[24/26] vvfat: migrate vvfat driver QemuOptionParameter usage

Message ID 1395360813-2833-25-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
vvfat block driver.

Signed-off-by: Leandro Dorileo <l@dorileo.org>
---
 block/vvfat.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/block/vvfat.c b/block/vvfat.c
index f966ea5..7aefba3 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -2907,7 +2907,7 @@  static BlockDriver vvfat_write_target = {
 static int enable_write_target(BDRVVVFATState *s)
 {
     BlockDriver *bdrv_qcow;
-    QEMUOptionParameter *options;
+    QemuOpts *options;
     Error *local_err = NULL;
     int ret;
     int size = sector2cluster(s, s->sector_count);
@@ -2918,13 +2918,26 @@  static int enable_write_target(BDRVVVFATState *s)
     s->qcow_filename = g_malloc(1024);
     ret = get_tmp_filename(s->qcow_filename, 1024);
     if (ret < 0) {
-        goto err;
+        goto err_opt;
     }
 
     bdrv_qcow = bdrv_find_format("qcow");
-    options = parse_option_parameters("", bdrv_qcow->create_options, NULL);
-    set_option_parameter_int(options, BLOCK_OPT_SIZE, s->sector_count * 512);
-    set_option_parameter(options, BLOCK_OPT_BACKING_FILE, "fat:");
+
+    options = qemu_opts_create(bdrv_qcow->create_options, NULL, 0,
+                               &error_abort);
+    if (!options) {
+        goto err_opt;
+    }
+
+    ret = qemu_opt_set_number(options, BLOCK_OPT_SIZE, s->sector_count * 512);
+    if (ret < 0) {
+        goto err;
+    }
+
+    ret = qemu_opt_set(options, BLOCK_OPT_BACKING_FILE, "fat:");
+    if (ret < 0) {
+        goto err;
+    }
 
     ret = bdrv_create(bdrv_qcow, s->qcow_filename, options, &local_err);
     if (ret < 0) {
@@ -2951,10 +2964,13 @@  static int enable_write_target(BDRVVVFATState *s)
     s->bs->backing_hd->drv = &vvfat_write_target;
     s->bs->backing_hd->opaque = g_malloc(sizeof(void*));
     *(void**)s->bs->backing_hd->opaque = s;
+    qemu_opts_del(options);
 
     return 0;
 
 err:
+    qemu_opts_del(options);
+err_opt:
     g_free(s->qcow_filename);
     s->qcow_filename = NULL;
     return ret;