qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>
Subject: [Qemu-devel] [PATCH] Drop bdrv_create2
Date: Wed, 27 May 2009 14:48:06 +0200	[thread overview]
Message-ID: <1243428486-9020-1-git-send-email-kwolf@redhat.com> (raw)

This patch converts the remaining users of bdrv_create2 to bdrv_create and
removes the now unused function.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c       |   55 +++++++++++++++----------------------------------------
 block/vvfat.c |   11 +++++++++--
 2 files changed, 24 insertions(+), 42 deletions(-)

diff --git a/block.c b/block.c
index c80d4b9..6e4d910 100644
--- a/block.c
+++ b/block.c
@@ -184,42 +184,6 @@ BlockDriver *bdrv_find_format(const char *format_name)
     return NULL;
 }
 
-int bdrv_create2(BlockDriver *drv,
-                const char *filename, int64_t size_in_sectors,
-                const char *backing_file, const char *backing_format,
-                int flags)
-{
-    QEMUOptionParameter *options;
-
-    options = parse_option_parameters("", drv->create_options, NULL);
-
-    // Process flags
-    if (flags & ~(BLOCK_FLAG_ENCRYPT | BLOCK_FLAG_COMPAT6 | BLOCK_FLAG_COMPRESS)) {
-        return -ENOTSUP;
-    }
-
-    if (flags & BLOCK_FLAG_ENCRYPT) {
-        set_option_parameter_int(options, BLOCK_OPT_ENCRYPT, 1);
-    }
-    if (flags & BLOCK_FLAG_COMPAT6) {
-        set_option_parameter_int(options, BLOCK_OPT_COMPAT6, 1);
-    }
-
-    // Add size to options
-    set_option_parameter_int(options, BLOCK_OPT_SIZE, size_in_sectors * 512);
-
-    // Backing files
-    if ((backing_file != NULL && set_option_parameter(options,
-            BLOCK_OPT_BACKING_FILE, backing_file))
-        || (backing_format != NULL && set_option_parameter(options,
-            BLOCK_OPT_BACKING_FMT, backing_format)))
-    {
-        return -ENOTSUP;
-    }
-
-    return bdrv_create(drv, filename, options);
-}
-
 int bdrv_create(BlockDriver *drv, const char* filename,
     QEMUOptionParameter *options)
 {
@@ -392,6 +356,8 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
         BlockDriverState *bs1;
         int64_t total_size;
         int is_protocol = 0;
+        BlockDriver *bdrv_qcow2;
+        QEMUOptionParameter *options;
 
         /* if snapshot, we create a temporary backing file and open it
            instead of opening 'filename' directly */
@@ -419,14 +385,23 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
         else
             realpath(filename, backing_filename);
 
-        ret = bdrv_create2(bdrv_find_format("qcow2"), tmp_filename,
-                           total_size, backing_filename, 
-                           (drv ? drv->format_name : NULL), 0);
+        bdrv_qcow2 = bdrv_find_format("qcow2");
+        options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
+
+        set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size * 512);
+        set_option_parameter(options, BLOCK_OPT_BACKING_FILE, backing_filename);
+        if (drv) {
+            set_option_parameter(options, BLOCK_OPT_BACKING_FMT,
+                drv->format_name);
+        }
+
+        ret = bdrv_create(bdrv_qcow2, tmp_filename, options);
         if (ret < 0) {
             return ret;
         }
+
         filename = tmp_filename;
-        drv = bdrv_find_format("qcow2");
+        drv = bdrv_qcow2;
         bs->is_temporary = 1;
     }
 
diff --git a/block/vvfat.c b/block/vvfat.c
index 13960e9..6c29f48 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -2770,6 +2770,8 @@ static BlockDriver vvfat_write_target = {
 
 static int enable_write_target(BDRVVVFATState *s)
 {
+    BlockDriver *bdrv_qcow;
+    QEMUOptionParameter *options;
     int size = sector2cluster(s, s->sector_count);
     s->used_clusters = calloc(size, 1);
 
@@ -2777,8 +2779,13 @@ static int enable_write_target(BDRVVVFATState *s)
 
     s->qcow_filename = qemu_malloc(1024);
     get_tmp_filename(s->qcow_filename, 1024);
-    if (bdrv_create2(bdrv_find_format("qcow"),
-		s->qcow_filename, s->sector_count, "fat:", NULL, 0) < 0)
+
+    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:");
+
+    if (bdrv_create(bdrv_qcow, s->qcow_filename, options) < 0)
 	return -1;
     s->qcow = bdrv_new("");
     if (s->qcow == NULL || bdrv_open(s->qcow, s->qcow_filename, 0) < 0)
-- 
1.6.0.6

                 reply	other threads:[~2009-05-27 12:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1243428486-9020-1-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).