From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq3Qw-0005qP-Mk for qemu-devel@nongnu.org; Mon, 09 Dec 2013 11:11:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vq3Qr-0000im-Ke for qemu-devel@nongnu.org; Mon, 09 Dec 2013 11:11:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60651) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vq3Qr-0000ig-Bz for qemu-devel@nongnu.org; Mon, 09 Dec 2013 11:11:41 -0500 Date: Mon, 9 Dec 2013 17:11:38 +0100 From: Kevin Wolf Message-ID: <20131209161138.GH3549@dhcp-200-207.str.redhat.com> References: <1386263703-19292-1-git-send-email-benoit@irqsave.net> <1386263703-19292-2-git-send-email-benoit@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1386263703-19292-2-git-send-email-benoit@irqsave.net> Content-Transfer-Encoding: quoted-printable 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. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?Beno=EEt?= Canet Cc: famz@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com Am 05.12.2013 um 18:14 hat Beno=EEt Canet geschrieben: > Add the minimum of code to prepare for the following patches. >=20 > Signed-off-by: Benoit Canet > Reviewed-by: Eric Blake > --- > 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(-) >=20 > 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(Block= DriverState *bs, > static QTAILQ_HEAD(, BlockDriverState) bdrv_states =3D > QTAILQ_HEAD_INITIALIZER(bdrv_states); > =20 > +static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =3D > + QTAILQ_HEAD_INITIALIZER(graph_bdrv_states); > + > static QLIST_HEAD(, BlockDriver) bdrv_drivers =3D > QLIST_HEAD_INITIALIZER(bdrv_drivers); > =20 > @@ -318,15 +321,21 @@ void bdrv_register(BlockDriver *bdrv) > } > =20 > /* 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_n= ame) > { > BlockDriverState *bs; > =20 > + assert(node_name); > + > bs =3D g_malloc0(sizeof(BlockDriverState)); > QLIST_INIT(&bs->dirty_bitmaps); > pstrcpy(bs->device_name, sizeof(bs->device_name), device_name); > if (device_name[0] !=3D '\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] !=3D '\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 ch= ar *filename, > options =3D qdict_new(); > } > =20 > - bs =3D bdrv_new(""); > + bs =3D bdrv_new("", ""); > bs->options =3D options; > options =3D qdict_clone_shallow(options); > =20 > @@ -993,7 +1002,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, Q= Dict *options, Error **errp) > sizeof(backing_filename)); > } > =20 > - bs->backing_hd =3D bdrv_new(""); > + bs->backing_hd =3D bdrv_new("", ""); > =20 > if (bs->backing_format[0] !=3D '\0') { > back_drv =3D bdrv_find_format(bs->backing_format); > @@ -1059,7 +1068,7 @@ int bdrv_open(BlockDriverState *bs, const char *f= ilename, QDict *options, > instead of opening 'filename' directly */ > =20 > /* Get the required size from the image */ > - bs1 =3D bdrv_new(""); > + bs1 =3D bdrv_new("", ""); > QINCREF(options); > ret =3D bdrv_open(bs1, filename, options, BDRV_O_NO_BACKING, > drv, &local_err); > @@ -1500,7 +1509,7 @@ void bdrv_close_all(void) > { > BlockDriverState *bs; > =20 > - 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(BlockDriverStat= e *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 effect= ively > * a busy wait. > */ > - QTAILQ_FOREACH(bs, &bdrv_states, list) { > + QTAILQ_FOREACH(bs, &bdrv_states, device_list) { > if (bdrv_start_throttled_reqs(bs)) { > busy =3D true; > } > @@ -1570,14 +1579,18 @@ void bdrv_drain_all(void) > } > } > =20 > -/* 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] !=3D '\0') { > - QTAILQ_REMOVE(&bdrv_states, bs, list); > + QTAILQ_REMOVE(&bdrv_states, bs, device_list); > } > bs->device_name[0] =3D '\0'; > + if (bs->node_name[0] !=3D '\0') { > + QTAILQ_REMOVE(&graph_bdrv_states, bs, node_list); > + } > } Should we also set bs->node_name[0] =3D '\0'? Kevin