[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH V4 1/7] block: Add bs->node_name to hold the nam
From: |
Kevin Wolf |
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 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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 <address@hidden>
> Reviewed-by: Eric Blake <address@hidden>
> ---
> 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