From: "Andreas Färber" <afaerber@suse.de>
To: Luiz Capitulino <lcapitulino@redhat.com>
Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ
Date: Fri, 24 Feb 2012 15:23:43 +0100 [thread overview]
Message-ID: <4F479D6F.3000302@suse.de> (raw)
In-Reply-To: <1330092792-22455-5-git-send-email-lcapitulino@redhat.com>
Am 24.02.2012 15:13, schrieb Luiz Capitulino:
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Unless this fixes a bug, I'd rather not refactor this as in my head this
is already just object_class_foreach() / object_class_by_name(), similar
to CPUs on my qom-cpu branch.
Andreas
> ---
> hw/boards.h | 3 ++-
> vl.c | 16 ++++++----------
> 2 files changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/hw/boards.h b/hw/boards.h
> index 342a774..1eb8314 100644
> --- a/hw/boards.h
> +++ b/hw/boards.h
> @@ -4,6 +4,7 @@
> #define HW_BOARDS_H
>
> #include "qdev.h"
> +#include "qemu-queue.h"
>
> typedef void QEMUMachineInitFunc(ram_addr_t ram_size,
> const char *boot_device,
> @@ -28,7 +29,7 @@ typedef struct QEMUMachine {
> int is_default;
> const char *default_machine_opts;
> GlobalProperty *compat_props;
> - struct QEMUMachine *next;
> + QTAILQ_ENTRY(QEMUMachine) next;
> } QEMUMachine;
>
> void machine_register(QEMUMachine *m);
> diff --git a/vl.c b/vl.c
> index 9f9927c..4935106 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1160,24 +1160,20 @@ void pcmcia_info(Monitor *mon)
> /***********************************************************/
> /* machine registration */
>
> -static QEMUMachine *first_machine = NULL;
> +static QTAILQ_HEAD(QEMUMachineHead, QEMUMachine) machine_types =
> + QTAILQ_HEAD_INITIALIZER(machine_types);
> QEMUMachine *current_machine = NULL;
>
> void machine_register(QEMUMachine *m)
> {
> - QEMUMachine **pm;
> - pm = &first_machine;
> - while (*pm != NULL)
> - pm = &(*pm)->next;
> - m->next = NULL;
> - *pm = m;
> + QTAILQ_INSERT_TAIL(&machine_types, m, next);
> }
>
> static QEMUMachine *machine_find(const char *name)
> {
> QEMUMachine *m;
>
> - for(m = first_machine; m != NULL; m = m->next) {
> + QTAILQ_FOREACH(m, &machine_types, next) {
> if (!strcmp(m->name, name))
> return m;
> if (m->alias && !strcmp(m->alias, name))
> @@ -1190,7 +1186,7 @@ QEMUMachine *machine_find_default(void)
> {
> QEMUMachine *m;
>
> - for(m = first_machine; m != NULL; m = m->next) {
> + QTAILQ_FOREACH(m, &machine_types, next) {
> if (m->is_default) {
> return m;
> }
> @@ -1203,7 +1199,7 @@ void machine_print_all(void)
> QEMUMachine *m;
>
> printf("Supported machines are:\n");
> - for (m = first_machine; m != NULL; m = m->next) {
> + QTAILQ_FOREACH(m, &machine_types, next) {
> if (m->alias) {
> printf("%-10s %s (alias of %s)\n", m->alias, m->desc, m->name);
> }
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
next prev parent reply other threads:[~2012-02-24 14:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-24 14:13 [Qemu-devel] [PATCH 0/5]: Improve machine type functions Luiz Capitulino
2012-02-24 14:13 ` [Qemu-devel] [PATCH 1/5] boards: qemu_register_machine(): return void Luiz Capitulino
2012-02-24 14:17 ` Andreas Färber
2012-02-24 14:13 ` [Qemu-devel] [PATCH 2/5] boards: rename machine type functions Luiz Capitulino
2012-02-24 16:12 ` Peter Maydell
2012-02-24 16:15 ` Anthony Liguori
2012-02-24 16:51 ` Luiz Capitulino
2012-02-24 16:57 ` Anthony Liguori
2012-02-24 14:13 ` [Qemu-devel] [PATCH 3/5] boards: introduce machine_print_all() Luiz Capitulino
2012-02-24 14:26 ` Andreas Färber
2012-02-24 14:57 ` Luiz Capitulino
2012-02-24 14:13 ` [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ Luiz Capitulino
2012-02-24 14:23 ` Andreas Färber [this message]
2012-02-24 14:56 ` Luiz Capitulino
2012-02-24 15:21 ` Andreas Färber
2012-02-24 15:23 ` Luiz Capitulino
2012-02-24 14:13 ` [Qemu-devel] [PATCH 5/5] boards: move all machine type functions to boards.c Luiz Capitulino
2012-02-24 15:10 ` Andreas Färber
2012-02-24 15:22 ` Luiz Capitulino
2012-02-24 14:58 ` [Qemu-devel] [PATCH 0/5]: Improve machine type functions Anthony Liguori
2012-02-24 15:20 ` Luiz Capitulino
2012-02-24 15:44 ` Anthony Liguori
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=4F479D6F.3000302@suse.de \
--to=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).