qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 03/23] block: Connect BlockBackend to BlockDr


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH v3 03/23] block: Connect BlockBackend to BlockDriverState
Date: Sat, 20 Sep 2014 21:08:06 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1

On 16.09.2014 20:12, Markus Armbruster wrote:
The pointer from BlockBackend to BlockDriverState is a strong
reference, managed with bdrv_ref() / bdrv_unref(), the back-pointer is
a weak one.

Convenience function blk_new_with_bs() creates a BlockBackend with its
BlockDriverState.  Callers have to unref both.  The commit after next
will relieve them of the need to unref the BlockDriverState.

Complication: due to the silly way drive_del works, we need a way to
hide a BlockBackend, just like bdrv_make_anon().  To emphasize its
"special" status, give the function a suitably off-putting name:
blk_hide_on_behalf_of_do_drive_del().  Unfortunately, hiding turns the
BlockBackend's name into the empty string.  Can't avoid that without
breaking the blk->bs->device_name equals blk->name invariant.

The patch adds a memory leak: drive_del while a device model is
connected leaks the BlockBackend.  Avoiding the leak here is rather
hairy, but it'll become straightforward in a few commits, so I mark it
FIXME in the code now, and plug it when it's easy.

Good.

Signed-off-by: Markus Armbruster <address@hidden>
---
  block.c                        |  10 ++--
  block/block-backend.c          |  71 ++++++++++++++++++++++-
  blockdev.c                     |  21 ++++---
  hw/block/xen_disk.c            |   8 +--
  include/block/block_int.h      |   2 +
  include/sysemu/block-backend.h |   5 ++
  qemu-img.c                     | 125 +++++++++++++++++++----------------------
  qemu-io.c                      |   4 +-
  qemu-nbd.c                     |   4 +-
  9 files changed, 156 insertions(+), 94 deletions(-)

Reviewed-by: Max Reitz <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]