summaryrefslogtreecommitdiffstats
path: root/blockdev.c
diff options
context:
space:
mode:
authorJeff Cody <jcody@redhat.com>2016-02-01 20:33:10 -0500
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 19:30:23 -0600
commit00244f40c3b3433ec479699b3cfc28505d36078a (patch)
treed296dc6679a02b997eb4edacc316bebeb78e9f9b /blockdev.c
parent625051a1baf38dc365a6ec9188747791aaa790c6 (diff)
downloadhqemu-00244f40c3b3433ec479699b3cfc28505d36078a.zip
hqemu-00244f40c3b3433ec479699b3cfc28505d36078a.tar.gz
block: set device_list.tqe_prev to NULL on BDS removal
This fixes a regression introduced with commit 3f09bfbc7. Multiple bugs arise in conjunction with live snapshots and mirroring operations (which include active layer commit). After a live snapshot occurs, the active layer and the base layer both have a non-NULL tqe_prev field in the device_list, although the base node's tqe_prev field points to a NULL entry. This non-NULL tqe_prev field occurs after the bdrv_append() in the external snapshot calls change_parent_backing_link(). In change_parent_backing_link(), when the previous active layer is removed from device_list, the device_list.tqe_prev pointer is not set to NULL. The operating scheme in the block layer is to indicate that a BDS belongs in the bdrv_states device_list iff the device_list.tqe_prev pointer is non-NULL. This patch does two things: 1.) Introduces a new block layer helper bdrv_device_remove() to remove a BDS from the device_list, and 2.) uses that new API, which also fixes the regression once used in change_parent_backing_link(). Signed-off-by: Jeff Cody <jcody@redhat.com> Message-id: 0cd51e11c0666c04ddb7c05293fe94afeb551e89.1454376655.git.jcody@redhat.com Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/blockdev.c b/blockdev.c
index 35e1e5c..be4ca44 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2408,8 +2408,7 @@ void qmp_x_blockdev_remove_medium(const char *device, Error **errp)
/* This follows the convention established by bdrv_make_anon() */
if (bs->device_list.tqe_prev) {
- QTAILQ_REMOVE(&bdrv_states, bs, device_list);
- bs->device_list.tqe_prev = NULL;
+ bdrv_device_remove(bs);
}
blk_remove_bs(blk);
OpenPOWER on IntegriCloud