[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] block: Close a BlockDriverState completely even
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] block: Close a BlockDriverState completely even when bs->drv is NULL |
Date: |
Tue, 7 Nov 2017 16:29:49 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 |
On 11/06/2017 08:53 AM, Alberto Garcia wrote:
> bdrv_close() skips much of its logic when bs->drv is NULL. This is
> fine when we're closing a BlockDriverState that has just been created
> (because e.g the initialization process failed), but it's not enough
> in other cases.
>
> For example, when a valid qcow2 image is found to be corrupted then
> QEMU marks it as such in the file header and then sets bs->drv to
> NULL in order to make the BlockDriverState unusable. When that BDS is
> later closed then many of its data structures are not freed (leaking
> their memory) and none of its children are detached. This results in
> bdrv_close_all() failing to close all BDSs and making this assertion
> fail when QEMU is being shut down:
>
> bdrv_close_all: Assertion `QTAILQ_EMPTY(&all_bdrv_states)' failed.
>
> This patch makes bdrv_close() do the full uninitialization process
> in all cases. This fixes the problem with corrupted images and still
> works fine with freshly created BDSs.
>
> Signed-off-by: Alberto Garcia <address@hidden>
> ---
> block.c | 57
> +++++++++++++++++++++++-----------------------
> tests/qemu-iotests/060 | 13 +++++++++++
> tests/qemu-iotests/060.out | 12 ++++++++++
> 3 files changed, 53 insertions(+), 29 deletions(-)
>
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature