qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, berto@igalia.com, qemu-devel@nongnu.org,
	jcody@redhat.com, armbru@redhat.com, mreitz@redhat.com,
	stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v2 03/16] blkverify: Convert s->test_file to BdrvChild
Date: Thu,  1 Oct 2015 15:13:21 +0200	[thread overview]
Message-ID: <1443705214-9304-4-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1443705214-9304-1-git-send-email-kwolf@redhat.com>

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/blkverify.c | 41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/block/blkverify.c b/block/blkverify.c
index d277e63..6b71622 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -14,7 +14,7 @@
 #include "qapi/qmp/qstring.h"
 
 typedef struct {
-    BlockDriverState *test_file;
+    BdrvChild *test_file;
 } BDRVBlkverifyState;
 
 typedef struct BlkverifyAIOCB BlkverifyAIOCB;
@@ -132,12 +132,12 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
     }
 
     /* Open the test file */
-    assert(s->test_file == NULL);
-    ret = bdrv_open_image(&s->test_file, qemu_opt_get(opts, "x-image"), options,
-                          "test", bs, &child_format, false, &local_err);
-    if (ret < 0) {
+    s->test_file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options,
+                                   "test", bs, &child_format, false,
+                                   &local_err);
+    if (local_err) {
+        ret = -EINVAL;
         error_propagate(errp, local_err);
-        s->test_file = NULL;
         goto fail;
     }
 
@@ -151,7 +151,7 @@ static void blkverify_close(BlockDriverState *bs)
 {
     BDRVBlkverifyState *s = bs->opaque;
 
-    bdrv_unref(s->test_file);
+    bdrv_unref_child(bs, s->test_file);
     s->test_file = NULL;
 }
 
@@ -159,7 +159,7 @@ static int64_t blkverify_getlength(BlockDriverState *bs)
 {
     BDRVBlkverifyState *s = bs->opaque;
 
-    return bdrv_getlength(s->test_file);
+    return bdrv_getlength(s->test_file->bs);
 }
 
 static BlkverifyAIOCB *blkverify_aio_get(BlockDriverState *bs, bool is_write,
@@ -242,7 +242,7 @@ static BlockAIOCB *blkverify_aio_readv(BlockDriverState *bs,
     qemu_iovec_init(&acb->raw_qiov, acb->qiov->niov);
     qemu_iovec_clone(&acb->raw_qiov, qiov, acb->buf);
 
-    bdrv_aio_readv(s->test_file, sector_num, qiov, nb_sectors,
+    bdrv_aio_readv(s->test_file->bs, sector_num, qiov, nb_sectors,
                    blkverify_aio_cb, acb);
     bdrv_aio_readv(bs->file, sector_num, &acb->raw_qiov, nb_sectors,
                    blkverify_aio_cb, acb);
@@ -257,7 +257,7 @@ static BlockAIOCB *blkverify_aio_writev(BlockDriverState *bs,
     BlkverifyAIOCB *acb = blkverify_aio_get(bs, true, sector_num, qiov,
                                             nb_sectors, cb, opaque);
 
-    bdrv_aio_writev(s->test_file, sector_num, qiov, nb_sectors,
+    bdrv_aio_writev(s->test_file->bs, sector_num, qiov, nb_sectors,
                     blkverify_aio_cb, acb);
     bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors,
                     blkverify_aio_cb, acb);
@@ -271,7 +271,7 @@ static BlockAIOCB *blkverify_aio_flush(BlockDriverState *bs,
     BDRVBlkverifyState *s = bs->opaque;
 
     /* Only flush test file, the raw file is not important */
-    return bdrv_aio_flush(s->test_file, cb, opaque);
+    return bdrv_aio_flush(s->test_file->bs, cb, opaque);
 }
 
 static bool blkverify_recurse_is_first_non_filter(BlockDriverState *bs,
@@ -285,7 +285,7 @@ static bool blkverify_recurse_is_first_non_filter(BlockDriverState *bs,
         return true;
     }
 
-    return bdrv_recurse_is_first_non_filter(s->test_file, candidate);
+    return bdrv_recurse_is_first_non_filter(s->test_file->bs, candidate);
 }
 
 /* Propagate AioContext changes to ->test_file */
@@ -293,7 +293,7 @@ static void blkverify_detach_aio_context(BlockDriverState *bs)
 {
     BDRVBlkverifyState *s = bs->opaque;
 
-    bdrv_detach_aio_context(s->test_file);
+    bdrv_detach_aio_context(s->test_file->bs);
 }
 
 static void blkverify_attach_aio_context(BlockDriverState *bs,
@@ -301,7 +301,7 @@ static void blkverify_attach_aio_context(BlockDriverState *bs,
 {
     BDRVBlkverifyState *s = bs->opaque;
 
-    bdrv_attach_aio_context(s->test_file, new_context);
+    bdrv_attach_aio_context(s->test_file->bs, new_context);
 }
 
 static void blkverify_refresh_filename(BlockDriverState *bs)
@@ -309,24 +309,25 @@ static void blkverify_refresh_filename(BlockDriverState *bs)
     BDRVBlkverifyState *s = bs->opaque;
 
     /* bs->file has already been refreshed */
-    bdrv_refresh_filename(s->test_file);
+    bdrv_refresh_filename(s->test_file->bs);
 
-    if (bs->file->full_open_options && s->test_file->full_open_options) {
+    if (bs->file->full_open_options && s->test_file->bs->full_open_options) {
         QDict *opts = qdict_new();
         qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("blkverify")));
 
         QINCREF(bs->file->full_open_options);
         qdict_put_obj(opts, "raw", QOBJECT(bs->file->full_open_options));
-        QINCREF(s->test_file->full_open_options);
-        qdict_put_obj(opts, "test", QOBJECT(s->test_file->full_open_options));
+        QINCREF(s->test_file->bs->full_open_options);
+        qdict_put_obj(opts, "test",
+                      QOBJECT(s->test_file->bs->full_open_options));
 
         bs->full_open_options = opts;
     }
 
-    if (bs->file->exact_filename[0] && s->test_file->exact_filename[0]) {
+    if (bs->file->exact_filename[0] && s->test_file->bs->exact_filename[0]) {
         snprintf(bs->exact_filename, sizeof(bs->exact_filename),
                  "blkverify:%s:%s",
-                 bs->file->exact_filename, s->test_file->exact_filename);
+                 bs->file->exact_filename, s->test_file->bs->exact_filename);
     }
 }
 
-- 
1.8.3.1

  parent reply	other threads:[~2015-10-01 13:14 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-01 13:13 [Qemu-devel] [PATCH v2 00/16] block: Get rid of bdrv_swap() Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 01/16] block: Introduce BDS.file_child Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 02/16] vmdk: Use BdrvChild instead of BDS for references to extents Kevin Wolf
2015-10-01 13:13 ` Kevin Wolf [this message]
2015-10-05 12:07   ` [Qemu-devel] [PATCH v2 03/16] blkverify: Convert s->test_file to BdrvChild Alberto Garcia
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 04/16] quorum: Convert " Kevin Wolf
2015-10-07 18:16   ` Max Reitz
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 05/16] block: Convert bs->file " Kevin Wolf
2015-10-02 17:06   ` Max Reitz
2015-10-05 12:31   ` Alberto Garcia
2015-10-08 10:23   ` Fam Zheng
2015-10-09 11:34     ` Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 06/16] block: Remove bdrv_open_image() Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 07/16] block: Convert bs->backing_hd to BdrvChild Kevin Wolf
2015-10-02 17:14   ` Max Reitz
2015-10-05 12:59   ` Alberto Garcia
2015-10-09  1:39   ` Fam Zheng
2015-10-09 11:36     ` Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 08/16] block: Manage backing file references in bdrv_set_backing_hd() Kevin Wolf
2015-10-02 17:18   ` Max Reitz
2015-10-05 13:31   ` Alberto Garcia
2015-10-09  1:49   ` Fam Zheng
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 09/16] block: Split bdrv_move_feature_fields() Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 10/16] block/io: Make bdrv_requests_pending() public Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 11/16] block-backend: Add blk_set_bs() Kevin Wolf
2015-10-02 17:21   ` Max Reitz
2015-10-05 13:33   ` Alberto Garcia
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 12/16] block: Introduce parents list Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 13/16] block: Implement bdrv_append() without bdrv_swap() Kevin Wolf
2015-10-02 17:32   ` Max Reitz
2015-10-09 14:54   ` Stefan Hajnoczi
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 14/16] blockjob: Store device name at job creation Kevin Wolf
2015-10-02 17:44   ` Max Reitz
2015-10-06 13:10   ` Alberto Garcia
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 15/16] block: Add and use bdrv_replace_in_backing_chain() Kevin Wolf
2015-10-01 13:13 ` [Qemu-devel] [PATCH v2 16/16] block: Remove bdrv_swap() Kevin Wolf
2015-10-09  2:10 ` [Qemu-devel] [PATCH v2 00/16] block: Get rid of bdrv_swap() Fam Zheng
2015-10-09 14:56 ` Stefan Hajnoczi

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=1443705214-9304-4-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berto@igalia.com \
    --cc=jcody@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).