qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: "Benoît Canet" <benoit@irqsave.net>
Cc: famz@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org,
	armbru@redhat.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH V4 1/7] block: Add bs->node_name to hold the name of a bs node of the bs graph.
Date: Mon, 9 Dec 2013 17:11:38 +0100	[thread overview]
Message-ID: <20131209161138.GH3549@dhcp-200-207.str.redhat.com> (raw)
In-Reply-To: <1386263703-19292-2-git-send-email-benoit@irqsave.net>

Am 05.12.2013 um 18:14 hat Benoît Canet geschrieben:
> Add the minimum of code to prepare for the following patches.
> 
> Signed-off-by: Benoit Canet <benoit@irqsave.net>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>  block.c                   | 72 ++++++++++++++++++++++++++++++++++-------------
>  block/blkverify.c         |  2 +-
>  block/iscsi.c             |  2 +-
>  block/vmdk.c              |  2 +-
>  block/vvfat.c             |  4 +--
>  blockdev.c                |  8 +++---
>  hw/block/xen_disk.c       |  2 +-
>  include/block/block.h     |  3 +-
>  include/block/block_int.h |  9 +++++-
>  qemu-img.c                |  6 ++--
>  qemu-io.c                 |  2 +-
>  qemu-nbd.c                |  2 +-
>  12 files changed, 78 insertions(+), 36 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 3d78581..4f6b36a 100644
> --- a/block.c
> +++ b/block.c
> @@ -89,6 +89,9 @@ static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs,
>  static QTAILQ_HEAD(, BlockDriverState) bdrv_states =
>      QTAILQ_HEAD_INITIALIZER(bdrv_states);
>  
> +static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
> +    QTAILQ_HEAD_INITIALIZER(graph_bdrv_states);
> +
>  static QLIST_HEAD(, BlockDriver) bdrv_drivers =
>      QLIST_HEAD_INITIALIZER(bdrv_drivers);
>  
> @@ -318,15 +321,21 @@ void bdrv_register(BlockDriver *bdrv)
>  }
>  
>  /* create a new block device (by default it is empty) */
> -BlockDriverState *bdrv_new(const char *device_name)
> +BlockDriverState *bdrv_new(const char *device_name, const char *node_name)
>  {
>      BlockDriverState *bs;
>  
> +    assert(node_name);
> +
>      bs = g_malloc0(sizeof(BlockDriverState));
>      QLIST_INIT(&bs->dirty_bitmaps);
>      pstrcpy(bs->device_name, sizeof(bs->device_name), device_name);
>      if (device_name[0] != '\0') {
> -        QTAILQ_INSERT_TAIL(&bdrv_states, bs, list);
> +        QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list);
> +    }
> +    pstrcpy(bs->node_name, sizeof(bs->node_name), node_name);
> +    if (node_name[0] != '\0') {
> +        QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list);
>      }
>      bdrv_iostatus_disable(bs);
>      notifier_list_init(&bs->close_notifiers);
> @@ -871,7 +880,7 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename,
>          options = qdict_new();
>      }
>  
> -    bs = bdrv_new("");
> +    bs = bdrv_new("", "");
>      bs->options = options;
>      options = qdict_clone_shallow(options);
>  
> @@ -993,7 +1002,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
>                                         sizeof(backing_filename));
>      }
>  
> -    bs->backing_hd = bdrv_new("");
> +    bs->backing_hd = bdrv_new("", "");
>  
>      if (bs->backing_format[0] != '\0') {
>          back_drv = bdrv_find_format(bs->backing_format);
> @@ -1059,7 +1068,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
>             instead of opening 'filename' directly */
>  
>          /* Get the required size from the image */
> -        bs1 = bdrv_new("");
> +        bs1 = bdrv_new("", "");
>          QINCREF(options);
>          ret = bdrv_open(bs1, filename, options, BDRV_O_NO_BACKING,
>                          drv, &local_err);
> @@ -1500,7 +1509,7 @@ void bdrv_close_all(void)
>  {
>      BlockDriverState *bs;
>  
> -    QTAILQ_FOREACH(bs, &bdrv_states, list) {
> +    QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
>          bdrv_close(bs);
>      }
>  }
> @@ -1529,7 +1538,7 @@ static bool bdrv_requests_pending(BlockDriverState *bs)
>  static bool bdrv_requests_pending_all(void)
>  {
>      BlockDriverState *bs;
> -    QTAILQ_FOREACH(bs, &bdrv_states, list) {
> +    QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
>          if (bdrv_requests_pending(bs)) {
>              return true;
>          }
> @@ -1559,7 +1568,7 @@ void bdrv_drain_all(void)
>          /* FIXME: We do not have timer support here, so this is effectively
>           * a busy wait.
>           */
> -        QTAILQ_FOREACH(bs, &bdrv_states, list) {
> +        QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
>              if (bdrv_start_throttled_reqs(bs)) {
>                  busy = true;
>              }
> @@ -1570,14 +1579,18 @@ void bdrv_drain_all(void)
>      }
>  }
>  
> -/* make a BlockDriverState anonymous by removing from bdrv_state list.
> +/* make a BlockDriverState anonymous by removing from bdrv_state and
> + * graph_bdrv_state list.
>     Also, NULL terminate the device_name to prevent double remove */
>  void bdrv_make_anon(BlockDriverState *bs)
>  {
>      if (bs->device_name[0] != '\0') {
> -        QTAILQ_REMOVE(&bdrv_states, bs, list);
> +        QTAILQ_REMOVE(&bdrv_states, bs, device_list);
>      }
>      bs->device_name[0] = '\0';
> +    if (bs->node_name[0] != '\0') {
> +        QTAILQ_REMOVE(&graph_bdrv_states, bs, node_list);
> +    }
>  }

Should we also set bs->node_name[0] = '\0'?

Kevin

  parent reply	other threads:[~2013-12-09 16:11 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-05 17:14 [Qemu-devel] [PATCH V4 0/7] Giving names to BlockDriverState graph nodes Benoît Canet
2013-12-05 17:14 ` [Qemu-devel] [PATCH V4 1/7] block: Add bs->node_name to hold the name of a bs node of the bs graph Benoît Canet
2013-12-09 16:04   ` Kevin Wolf
2013-12-09 16:11   ` Kevin Wolf [this message]
2013-12-05 17:14 ` [Qemu-devel] [PATCH V4 2/7] block: Allow the user to define "node-name" option Benoît Canet
2013-12-06 15:35   ` Eric Blake
2013-12-09 16:15   ` Kevin Wolf
2013-12-11 14:42     ` Benoît Canet
2013-12-05 17:14 ` [Qemu-devel] [PATCH V4 3/7] qmp: Add a command to list the named BlockDriverState nodes Benoît Canet
2013-12-06 15:59   ` Eric Blake
2013-12-09 15:46     ` Benoît Canet
2013-12-10 15:22       ` Eric Blake
2013-12-05 17:15 ` [Qemu-devel] [PATCH V4 4/7] qmp: Allow to change password on names block driver states Benoît Canet
2013-12-06 14:27   ` Luiz Capitulino
2013-12-06 15:24     ` Eric Blake
2013-12-06 16:52       ` Luiz Capitulino
2013-12-09 13:35         ` Benoît Canet
2013-12-09 16:23         ` Kevin Wolf
2013-12-09 16:41           ` Luiz Capitulino
2013-12-09 16:48             ` Benoît Canet
2013-12-09 17:03               ` Luiz Capitulino
2013-12-09 17:16                 ` Benoît Canet
2013-12-10  9:57             ` Kevin Wolf
2013-12-10 14:06               ` Luiz Capitulino
2013-12-10 14:25                 ` Kevin Wolf
2013-12-10 15:16                   ` Luiz Capitulino
2013-12-10 15:54                     ` Kevin Wolf
2013-12-10 16:15                     ` Eric Blake
2013-12-11  3:52                     ` Fam Zheng
2013-12-11 13:20                       ` Luiz Capitulino
2013-12-05 17:15 ` [Qemu-devel] [PATCH V4 5/7] qmp: Allow block_resize to manipulate bs graph nodes Benoît Canet
2013-12-09 16:24   ` Kevin Wolf
2013-12-09 16:41     ` Benoît Canet
2013-12-10  9:59       ` Kevin Wolf
2013-12-05 17:15 ` [Qemu-devel] [PATCH V4 6/7] block: Create authorizations mechanism for external snapshots Benoît Canet
2013-12-05 17:15 ` [Qemu-devel] [PATCH V4 7/7] qmp: Allow to take external snapshots on bs graphs node Benoît Canet
2013-12-09 15:32 ` [Qemu-devel] [PATCH V4 0/7] Giving names to BlockDriverState graph nodes Kevin Wolf
2013-12-09 15:52   ` Benoît Canet

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=20131209161138.GH3549@dhcp-200-207.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=benoit@irqsave.net \
    --cc=famz@redhat.com \
    --cc=jcody@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).