qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: armbru@redhat.com, famz@redhat.com, pbonzini@redhat.com,
	eblake@redhat.com, mreitz@redhat.com, kwolf@redhat.com,
	den@openvz.org, vsementsov@virtuozzo.com
Subject: [Qemu-devel] [RFC 1/3] block: add bdrv_reconnect
Date: Tue, 24 Apr 2018 16:08:19 +0300	[thread overview]
Message-ID: <20180424130821.50987-2-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20180424130821.50987-1-vsementsov@virtuozzo.com>

It will be used to reconnect NBD connection.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 include/block/block.h     |  2 ++
 include/block/block_int.h |  3 +++
 block.c                   | 22 ++++++++++++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/include/block/block.h b/include/block/block.h
index cdec3639a3..912e3f3dcc 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -604,4 +604,6 @@ bool bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name,
  */
 void bdrv_register_buf(BlockDriverState *bs, void *host, size_t size);
 void bdrv_unregister_buf(BlockDriverState *bs, void *host);
+
+int bdrv_reconnect(BlockDriverState *bs, Error **errp);
 #endif
diff --git a/include/block/block_int.h b/include/block/block_int.h
index c4dd1d4bb8..ab9018f1c4 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -475,6 +475,9 @@ struct BlockDriver {
      */
     void (*bdrv_register_buf)(BlockDriverState *bs, void *host, size_t size);
     void (*bdrv_unregister_buf)(BlockDriverState *bs, void *host);
+
+    int (*bdrv_reconnect)(BlockDriverState *bs, Error **errp);
+
     QLIST_ENTRY(BlockDriver) list;
 };
 
diff --git a/block.c b/block.c
index a2caadf0a0..fab4413d59 100644
--- a/block.c
+++ b/block.c
@@ -4095,6 +4095,28 @@ int bdrv_has_zero_init(BlockDriverState *bs)
     return 0;
 }
 
+int bdrv_reconnect(BlockDriverState *bs, Error **errp)
+{
+    int ret;
+
+    if (bs->drv && bs->drv->bdrv_reconnect) {
+        return bs->drv->bdrv_reconnect(bs, errp);
+    }
+
+    if (bs->backing) {
+        ret = bdrv_reconnect(bs->backing->bs, errp);
+        if (ret < 0) {
+            return ret;
+        }
+    }
+
+    if (bs->file) {
+        return bdrv_reconnect(bs->file->bs, errp);
+    }
+
+    return 0;
+}
+
 bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs)
 {
     BlockDriverInfo bdi;
-- 
2.11.1

  reply	other threads:[~2018-04-24 13:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-24 13:08 [Qemu-devel] [RFC 0/3] NBD reconnect Vladimir Sementsov-Ogievskiy
2018-04-24 13:08 ` Vladimir Sementsov-Ogievskiy [this message]
2018-04-24 13:08 ` [Qemu-devel] [RFC 2/3] nbd: add .bdrv_reconnect handler Vladimir Sementsov-Ogievskiy
2018-04-24 13:08 ` [Qemu-devel] [RFC 3/3] blk: add 'reconnect' error action Vladimir Sementsov-Ogievskiy
2018-04-26 16:19 ` [Qemu-devel] [RFC 0/3] NBD reconnect Vladimir Sementsov-Ogievskiy

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=20180424130821.50987-2-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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).