[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 1/6] block-backend: Refactor inactivate check
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PULL 1/6] block-backend: Refactor inactivate check |
Date: |
Wed, 23 Aug 2017 11:33:44 -0500 |
From: Fam Zheng <address@hidden>
The logic will be fixed (extended), move it to a separate function.
Signed-off-by: Fam Zheng <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Eric Blake <address@hidden>
---
block/block-backend.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index e9798e897d..a3984d2bec 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -192,19 +192,28 @@ static void blk_root_activate(BdrvChild *child, Error
**errp)
}
}
-static int blk_root_inactivate(BdrvChild *child)
+static bool blk_can_inactivate(BlockBackend *blk)
{
- BlockBackend *blk = child->opaque;
-
- if (blk->disable_perm) {
- return 0;
- }
-
/* Only inactivate BlockBackends for guest devices (which are inactive at
* this point because the VM is stopped) and unattached monitor-owned
* BlockBackends. If there is still any other user like a block job, then
* we simply can't inactivate the image. */
- if (!blk->dev && !blk_name(blk)[0]) {
+ if (blk->dev || blk_name(blk)[0]) {
+ return true;
+ }
+
+ return false;
+}
+
+static int blk_root_inactivate(BdrvChild *child)
+{
+ BlockBackend *blk = child->opaque;
+
+ if (blk->disable_perm) {
+ return 0;
+ }
+
+ if (!blk_can_inactivate(blk)) {
return -EPERM;
}
--
2.13.5
- [Qemu-devel] [PULL 0/6] NBD pull request for 2.10-rc4, Eric Blake, 2017/08/23
- [Qemu-devel] [PULL 1/6] block-backend: Refactor inactivate check,
Eric Blake <=
- [Qemu-devel] [PULL 2/6] block-backend: Allow more "can inactivate" cases, Eric Blake, 2017/08/23
- [Qemu-devel] [PULL 3/6] mirror: Mark target BB as "force allow inactivate", Eric Blake, 2017/08/23
- [Qemu-devel] [PULL 4/6] block: Update open_flags after ->inactivate() callback, Eric Blake, 2017/08/23
- [Qemu-devel] [PULL 5/6] qemu-iotests: add 194 non-shared storage migration test, Eric Blake, 2017/08/23
- [Qemu-devel] [PULL 6/6] nbd-client: avoid spurious qio_channel_yield() re-entry, Eric Blake, 2017/08/23
- Re: [Qemu-devel] [PULL 0/6] NBD pull request for 2.10-rc4, Peter Maydell, 2017/08/23
- Re: [Qemu-devel] [PULL 0/6] NBD pull request for 2.10-rc4, Christian Ehrhardt, 2017/08/23