All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Alberto Garcia <berto@igalia.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [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	[thread overview]
Message-ID: <56BA06F1.20704@redhat.com> (raw)
In-Reply-To: <7bfce913f68d95284746e7cf3693703f5361b26f.1454940776.git.berto@igalia.com>

[-- Attachment #1: Type: text/plain, Size: 2164 bytes --]

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 <berto@igalia.com>
> ---
>  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 <eblake@redhat.com>


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  parent reply	other threads:[~2016-02-09 15:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-08 14:14 [Qemu-devel] [PATCH 1/3] block: Allow x-blockdev-del on a BB with a monitor-owned BDS Alberto Garcia
2016-02-08 14:14 ` [Qemu-devel] [PATCH 2/3] iotests: Update test 139 after the changes in x-blockdev-del Alberto Garcia
2016-02-09 15:36   ` Eric Blake
2016-02-09 15:44     ` Alberto Garcia
2016-02-08 14:14 ` [Qemu-devel] [PATCH 3/3] block: Update the x-blockdev-del documentation Alberto Garcia
2016-02-09 15:38   ` Eric Blake
2016-02-09 10:32 ` [Qemu-devel] [PATCH 1/3] block: Allow x-blockdev-del on a BB with a monitor-owned BDS Kevin Wolf
2016-02-09 10:47   ` Alberto Garcia
2016-02-09 15:34 ` Eric Blake [this message]
2016-02-09 15:39   ` Alberto Garcia

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=56BA06F1.20704@redhat.com \
    --to=eblake@redhat.com \
    --cc=berto@igalia.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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.