All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Cody <jcody@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, stefanha@redhat.com, kwolf@redhat.com,
	jsnow@redhat.com, eblake@redhat.com
Subject: [Qemu-devel] [PATCH v2 for-2.10 5/8] block: introduce bdrv_can_set_read_only()
Date: Fri,  7 Apr 2017 16:55:29 -0400	[thread overview]
Message-ID: <e2bba34ac3bc76a0c42adc390413f358ae0566e8.1491597120.git.jcody@redhat.com> (raw)
In-Reply-To: <cover.1491597120.git.jcody@redhat.com>
In-Reply-To: <cover.1491597120.git.jcody@redhat.com>

Introduce check function for setting read_only flags.  Will return < 0 on
error, with appropriate Error value set.  Does not alter any flags.

Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 block.c               | 14 +++++++++++++-
 include/block/block.h |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/block.c b/block.c
index a05ad48..1514ae9 100644
--- a/block.c
+++ b/block.c
@@ -197,7 +197,7 @@ bool bdrv_is_read_only(BlockDriverState *bs)
     return bs->read_only;
 }
 
-int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
+int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
 {
     /* Do not set read_only if copy_on_read is enabled */
     if (bs->copy_on_read && read_only) {
@@ -213,6 +213,18 @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
         return -EPERM;
     }
 
+    return 0;
+}
+
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
+{
+    int ret = 0;
+
+    ret = bdrv_can_set_read_only(bs, read_only, errp);
+    if (ret < 0) {
+        return ret;
+    }
+
     bs->read_only = read_only;
     return 0;
 }
diff --git a/include/block/block.h b/include/block/block.h
index beb563a..dfd8694 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -426,6 +426,7 @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
                             int64_t sector_num, int nb_sectors, int *pnum);
 
 bool bdrv_is_read_only(BlockDriverState *bs);
+int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
 int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
 bool bdrv_is_sg(BlockDriverState *bs);
 bool bdrv_is_inserted(BlockDriverState *bs);
-- 
2.9.3

  parent reply	other threads:[~2017-04-07 20:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-07 20:55 [Qemu-devel] [PATCH v2 for-2.10 0/8] RBD reopen, read_only cleanup Jeff Cody
2017-04-07 20:55 ` [Qemu-devel] [PATCH v2 for-2.10 1/8] block: add bdrv_set_read_only() helper function Jeff Cody
2017-04-07 20:55 ` [Qemu-devel] [PATCH v2 for-2.10 2/8] block: do not set BDS read_only if copy_on_read enabled Jeff Cody
2017-04-07 20:55 ` [Qemu-devel] [PATCH v2 for-2.10 3/8] block: honor BDRV_O_ALLOW_RDWR when clearing bs->read_only Jeff Cody
2017-04-07 20:55 ` [Qemu-devel] [PATCH v2 for-2.10 4/8] block: code movement Jeff Cody
2017-04-07 20:55 ` Jeff Cody [this message]
2017-04-07 20:55 ` [Qemu-devel] [PATCH v2 for-2.10 6/8] block: use bdrv_can_set_read_only() during reopen Jeff Cody
2017-04-07 20:55 ` [Qemu-devel] [PATCH v2 for-2.10 7/8] block/rbd - update variable names to more apt names Jeff Cody
2017-04-07 20:55 ` [Qemu-devel] [PATCH v2 for-2.10 8/8] block/rbd: Add support for reopen() Jeff Cody
2017-04-10 15:38 ` [Qemu-devel] [PATCH v2 for-2.10 0/8] RBD reopen, read_only cleanup Stefan Hajnoczi
2017-04-10 16:04 ` John Snow
2017-04-20 15:05 ` Jeff Cody

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=e2bba34ac3bc76a0c42adc390413f358ae0566e8.1491597120.git.jcody@redhat.com \
    --to=jcody@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.