qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, benoit.canet@irqsave.net, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 2/4] block: Keep DriveInfo alive until BlockDriverState dies
Date: Sat, 13 Sep 2014 21:32:26 +0200	[thread overview]
Message-ID: <54149BCA.9090808@redhat.com> (raw)
In-Reply-To: <1410549984-16110-3-git-send-email-armbru@redhat.com>

On 12.09.2014 21:26, Markus Armbruster wrote:
> If the BDS's refcnt > 0, drive_del() destroys the DriveInfo, but not
> the BDS.  This can happen in three places:
>
> * Device model destruction during unplug: blockdev_auto_del()
>
> * Xen IDE unplug: pci_piix3_xen_ide_unplug()
>
> * drive_del command when no device model is attached: do_drive_del()
>
> The other callers of drive_del are on error paths where refcnt == 1.
>
> If the user somehow manages to plug in a device model using a BDS that
> has gone through drive_del(), the legacy configuration passed in
> DriveInfo doesn't reach the device model, and automatic deletion on
> unplug doesn't work.  Worse, some device models such as scsi-disk
> crash when DriveInfo doesn't exist.
>
> This is theoretical; I didn't research an actual reproducer.
>
> Fix by keeping DriveInfo alive until its BDS dies.
>
> This affects qemu_drive_opts: now you can't reuse the same ID for new
> drive options until the BDS dies.  Before, you could, but since the
> code always attempts to create a BDS with the same ID next, the
> enclosing operation "create a new drive" failed anyway.  Different
> error path, same result.
>
> Unfortunately, the fix involves use of blockdev.c stuff from block.c,
> which is a layering violation.  Fortunately, my forthcoming
> BlockBackend work will get rid of it again.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>   block.c                   |  2 ++
>   blockdev.c                | 13 ++++++++-----
>   include/sysemu/blockdev.h |  1 +
>   stubs/Makefile.objs       |  1 +
>   stubs/blockdev.c          | 12 ++++++++++++
>   5 files changed, 24 insertions(+), 5 deletions(-)
>   create mode 100644 stubs/blockdev.c

Seems reasonable.

Reviewed-by: Max Reitz <mreitz@redhat.com>

  reply	other threads:[~2014-09-13 19:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-12 19:26 [Qemu-devel] [PATCH 0/4] Miscellaneous block fixes Markus Armbruster
2014-09-12 19:26 ` [Qemu-devel] [PATCH 1/4] blockdev: Disentangle BlockDriverState and DriveInfo creation Markus Armbruster
2014-09-13 18:36   ` Max Reitz
2014-09-15  6:35     ` Markus Armbruster
2014-09-15 11:17   ` Benoît Canet
2014-09-15 11:52     ` Markus Armbruster
2014-09-12 19:26 ` [Qemu-devel] [PATCH 2/4] block: Keep DriveInfo alive until BlockDriverState dies Markus Armbruster
2014-09-13 19:32   ` Max Reitz [this message]
2014-09-15  6:23   ` Markus Armbruster
2014-09-15 11:38   ` Benoît Canet
2014-09-12 19:26 ` [Qemu-devel] [PATCH 3/4] qemu-nbd: Destroy the BlockDriverState properly Markus Armbruster
2014-09-13 12:49   ` Paolo Bonzini
2014-09-12 19:26 ` [Qemu-devel] [PATCH 4/4] block: Improve message for device name clashing with node name Markus Armbruster
2014-09-13 15:47   ` Eric Blake
2014-09-13 18:52   ` Benoît Canet
2014-09-22 16:31 ` [Qemu-devel] [PATCH 0/4] Miscellaneous block fixes Kevin Wolf

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=54149BCA.9090808@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=benoit.canet@irqsave.net \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).