[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH 1/3] block: Allow x-blockdev-del on
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [Qemu-devel] [PATCH 1/3] block: Allow x-blockdev-del on a BB with a monitor-owned BDS |
Date: |
Tue, 9 Feb 2016 08:34:09 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
On 02/08/2016 07:14 AM, Alberto Garcia wrote:
When sending a multi-patch series, you should always include a 0/3 cover
letter. The cover letter is optional only for a lone patch.
> When x-blockdev-del is performed on a BlockBackend that has inserted
> media it will only succeed if the BDS doesn't have any additional
> references.
>
> The only problem with this is that if the BDS was created separately
> using blockdev-add then the backend won't be able to be destroyed
> unless the BDS is ejected first. This is an unnecessary restriction.
>
> Now that we have a list of monitor-owned BDSs we can allow
> x-blockdev-del to work in this scenario if the BDS has exactly one
> extra reference and that reference is from the monitor.
>
> Signed-off-by: Alberto Garcia <address@hidden>
> ---
> blockdev.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/blockdev.c b/blockdev.c
> index e1b6b0f..847058d 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -3966,9 +3966,16 @@ void qmp_x_blockdev_del(bool has_id, const char *id,
> }
>
> if (bs->refcnt > 1) {
> - error_setg(errp, "Block device %s is in use",
> - bdrv_get_device_or_node_name(bs));
> - goto out;
> + /* We allow deleting a BlockBackend that has a BDS with an
> + * extra reference if that extra reference is from the
> + * monitor. */
> + bool bs_has_only_monitor_ref =
> + blk && bs->monitor_list.tqe_prev && bs->refcnt == 2;
> + if (!bs_has_only_monitor_ref) {
I don't think the temporary bool or nested 'if' are necessary; but at
the same time, I don't think the following is any more legible:
/* Prohibit deleting a BlockBackend whose BDS is in use by any more than
a single monitor */
if (bs->refcnt > 1 + (blk && bs->monitor_list.tqe_prev)) {
error_setg(...
so I could live with your patch as-is:
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature