From: Stefan Hajnoczi <stefanha@gmail.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/2] block: Convert bdrv_first to QTAILQ
Date: Fri, 9 Apr 2010 19:17:45 +0100 [thread overview]
Message-ID: <r2rfbd9d3991004091117m9d01fc59labc788ca5acd4b3a@mail.gmail.com> (raw)
In-Reply-To: <4BBF5A27.8090701@redhat.com>
On Fri, Apr 9, 2010 at 5:47 PM, Kevin Wolf <kwolf@redhat.com> wrote:
>> @@ -545,13 +542,15 @@ void bdrv_close(BlockDriverState *bs)
>>
>> void bdrv_delete(BlockDriverState *bs)
>> {
>> - BlockDriverState **pbs;
>> + BlockDriverState *bs1;
>>
>> - pbs = &bdrv_first;
>> - while (*pbs != bs && *pbs != NULL)
>> - pbs = &(*pbs)->next;
>> - if (*pbs == bs)
>> - *pbs = bs->next;
>> + /* remove from list, if necessary */
>> + QTAILQ_FOREACH(bs1, &bdrv_states, list) {
>> + if (bs1 == bs) {
>> + QTAILQ_REMOVE(&bdrv_states, bs, list);
>> + break;
>> + }
>> + }
>
> This loop looks strange, what is it used for? We had only a next pointer
> previously, so we needed to search the element. A QTAILQ has both prev
> and next pointers though, so you should be able to directly use
> QTAILQ_REMOVE.
Only named BlockDriverStates are added to the tail queue. Those with
an empty string as their name will not be on the tail queue.
The QTAILQ_REMOVE macro will not work if the element isn't on the tail
queue. I didn't see a clean way to check if an element is on a tail
queue using qemu-queue.h, so I kept the search behavior. The check I
want is tge_prev != NULL, I think.
I see three options:
1. Leave the search.
2. Modify qemu-queue.h to add a QTAILQ_ON_LIST(elm) macro.
3. Break the QTAILQ abstraction and test tge_prev directly.
What do you think?
Stefan
next prev parent reply other threads:[~2010-04-09 18:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-09 14:22 [Qemu-devel] [PATCH 0/2] block: Cleanups Stefan Hajnoczi
2010-04-09 14:22 ` [Qemu-devel] [PATCH 1/2] block: Do not export bdrv_first Stefan Hajnoczi
2010-04-09 16:50 ` Kevin Wolf
2010-04-09 14:22 ` [Qemu-devel] [PATCH 2/2] block: Convert bdrv_first to QTAILQ Stefan Hajnoczi
2010-04-09 16:47 ` Kevin Wolf
2010-04-09 18:17 ` Stefan Hajnoczi [this message]
2010-04-10 6:04 ` Stefan Hajnoczi
2010-04-10 7:56 ` 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=r2rfbd9d3991004091117m9d01fc59labc788ca5acd4b3a@mail.gmail.com \
--to=stefanha@gmail.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.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).