All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Cc: "Chris Wulff" <crwulff@gmail.com>,
	"Sagar Karandikar" <sagark@eecs.berkeley.edu>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Anthony Green" <green@moxielogic.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Alistair Francis" <Alistair.Francis@wdc.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Guan Xuetao" <gxt@mprc.pku.edu.cn>,
	"Marek Vasut" <marex@denx.de>, "Jia Liu" <proljc@gmail.com>,
	qemu-trivial@nongnu.org, "Helge Deller" <deller@gmx.de>,
	"David Hildenbrand" <david@redhat.com>,
	"Magnus Damm" <magnus.damm@gmail.com>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@de.ibm.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Aleksandar Rikalo" <aleksandar.rikalo@rt-rk.com>,
	"Richard Henderson" <rth@twiddle.net>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	qemu-s390x@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@gmail.com>,
	"Stafford Horne" <shorne@gmail.com>,
	"David Gibson" <david@gibson.dropbear.id.au>,
	qemu-riscv@nongnu.org, "Thomas Huth" <huth@tuxfamily.org>,
	"Bastian Koppelmann" <kbastian@mail.uni-paderborn.de>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Michael Walle" <michael@walle.cc>,
	qemu-ppc@nongnu.org,
	"Aleksandar Markovic" <amarkovic@wavecomp.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Aurelien Jarno" <aurelien@aurel32.net>
Subject: Re: [PATCH v4 3/3] vl: Abort if multiple machines are registered as default
Date: Fri, 7 Feb 2020 19:05:58 +0100	[thread overview]
Message-ID: <f8b5897f-c11f-0272-cac8-f63e12f3783e@vivier.eu> (raw)
In-Reply-To: <20200207161948.15972-4-philmd@redhat.com>

Le 07/02/2020 à 17:19, Philippe Mathieu-Daudé a écrit :
> It would be confusing to have multiple default machines.
> Abort if this ever occurs.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v2: Use assert() instead of human friendly message (Marc-André)
> v3: Move the check to find_machine() (Michael)
> 
> Cc: Marc-André Lureau <marcandre.lureau@gmail.com>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> ---
>  vl.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index 7dcb0879c4..ebc203af0d 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1184,16 +1184,18 @@ static MachineClass *find_machine(const char *name, GSList *machines)
>  static MachineClass *find_default_machine(GSList *machines)
>  {
>      GSList *el;
> +    MachineClass *default_machineclass = NULL;
>  
>      for (el = machines; el; el = el->next) {
>          MachineClass *mc = el->data;
>  
>          if (mc->is_default) {
> -            return mc;
> +            assert(default_machineclass == NULL && "Multiple default machines");
> +            default_machineclass = mc;
>          }
>      }
>  
> -    return NULL;
> +    return default_machineclass;
>  }
>  
>  static int machine_help_func(QemuOpts *opts, MachineState *machine)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Tested-by: Laurent Vivier <laurent@vivier.eu>

I've tested "make check" actually fails when we have several default
machines.

Thanks,
Laurent


WARNING: multiple messages have this Message-ID (diff)
From: Laurent Vivier <laurent@vivier.eu>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Cc: "Aleksandar Rikalo" <aleksandar.rikalo@rt-rk.com>,
	"Guan Xuetao" <gxt@mprc.pku.edu.cn>,
	qemu-ppc@nongnu.org,
	"Sagar Karandikar" <sagark@eecs.berkeley.edu>,
	"David Gibson" <david@gibson.dropbear.id.au>,
	"Christian Borntraeger" <borntraeger@de.ibm.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Bastian Koppelmann" <kbastian@mail.uni-paderborn.de>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Anthony Green" <green@moxielogic.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>,
	qemu-trivial@nongnu.org, "Cornelia Huck" <cohuck@redhat.com>,
	"Aurelien Jarno" <aurelien@aurel32.net>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	qemu-riscv@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
	"Aleksandar Markovic" <amarkovic@wavecomp.com>,
	"Marek Vasut" <marex@denx.de>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Michael Walle" <michael@walle.cc>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	qemu-s390x@nongnu.org, "Richard Henderson" <rth@twiddle.net>,
	"Thomas Huth" <huth@tuxfamily.org>,
	"Magnus Damm" <magnus.damm@gmail.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Chris Wulff" <crwulff@gmail.com>,
	"Stafford Horne" <shorne@gmail.com>,
	"Helge Deller" <deller@gmx.de>,
	"Alistair Francis" <Alistair.Francis@wdc.com>,
	"Jia Liu" <proljc@gmail.com>,
	"Marc-André Lureau" <marcandre.lureau@gmail.com>
Subject: Re: [PATCH v4 3/3] vl: Abort if multiple machines are registered as default
Date: Fri, 7 Feb 2020 19:05:58 +0100	[thread overview]
Message-ID: <f8b5897f-c11f-0272-cac8-f63e12f3783e@vivier.eu> (raw)
In-Reply-To: <20200207161948.15972-4-philmd@redhat.com>

Le 07/02/2020 à 17:19, Philippe Mathieu-Daudé a écrit :
> It would be confusing to have multiple default machines.
> Abort if this ever occurs.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v2: Use assert() instead of human friendly message (Marc-André)
> v3: Move the check to find_machine() (Michael)
> 
> Cc: Marc-André Lureau <marcandre.lureau@gmail.com>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> ---
>  vl.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index 7dcb0879c4..ebc203af0d 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1184,16 +1184,18 @@ static MachineClass *find_machine(const char *name, GSList *machines)
>  static MachineClass *find_default_machine(GSList *machines)
>  {
>      GSList *el;
> +    MachineClass *default_machineclass = NULL;
>  
>      for (el = machines; el; el = el->next) {
>          MachineClass *mc = el->data;
>  
>          if (mc->is_default) {
> -            return mc;
> +            assert(default_machineclass == NULL && "Multiple default machines");
> +            default_machineclass = mc;
>          }
>      }
>  
> -    return NULL;
> +    return default_machineclass;
>  }
>  
>  static int machine_help_func(QemuOpts *opts, MachineState *machine)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Tested-by: Laurent Vivier <laurent@vivier.eu>

I've tested "make check" actually fails when we have several default
machines.

Thanks,
Laurent


  parent reply	other threads:[~2020-02-07 18:10 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-07 16:19 [PATCH v4 0/3] Make MachineClass::is_default boolean, refuse multiple default machines Philippe Mathieu-Daudé
2020-02-07 16:19 ` Philippe Mathieu-Daudé
2020-02-07 16:19 ` [PATCH v4 1/3] hw: Do not initialize MachineClass::is_default to 0 Philippe Mathieu-Daudé
2020-02-07 16:19   ` Philippe Mathieu-Daudé
2020-02-07 17:44   ` Laurent Vivier
2020-02-07 17:44     ` Laurent Vivier
2020-02-08  9:23   ` David Gibson
2020-02-08  9:23     ` David Gibson
2020-02-10  9:35   ` Tricore default machine (was: [PATCH v4 1/3] hw: Do not initialize MachineClass::is_default to 0) Thomas Huth
2020-02-10  9:35     ` Thomas Huth
2020-02-10 10:08     ` Tricore default machine Philippe Mathieu-Daudé
2020-02-10 10:08       ` Philippe Mathieu-Daudé
2020-02-10 10:26       ` Thomas Huth
2020-02-10 10:26         ` Thomas Huth
2020-02-10 12:31         ` Bastian Koppelmann
2020-02-10 12:31           ` Bastian Koppelmann
2020-02-10 13:22           ` Peter Maydell
2020-02-10 13:22             ` Peter Maydell
2020-02-10 13:25             ` Philippe Mathieu-Daudé
2020-02-10 13:25               ` Philippe Mathieu-Daudé
2020-02-07 16:19 ` [PATCH v4 2/3] hw: Make MachineClass::is_default a boolean type Philippe Mathieu-Daudé
2020-02-07 16:19   ` Philippe Mathieu-Daudé
2020-02-07 16:32   ` Marc-André Lureau
2020-02-07 16:32     ` Marc-André Lureau
2020-02-07 17:48   ` Laurent Vivier
2020-02-07 17:48     ` Laurent Vivier
2020-02-08  9:24   ` David Gibson
2020-02-08  9:24     ` David Gibson
2020-02-10  8:51   ` Cornelia Huck
2020-02-10  8:51     ` Cornelia Huck
2020-02-10  9:22   ` Thomas Huth
2020-02-10  9:22     ` Thomas Huth
2020-02-07 16:19 ` [PATCH v4 3/3] vl: Abort if multiple machines are registered as default Philippe Mathieu-Daudé
2020-02-07 16:19   ` Philippe Mathieu-Daudé
2020-02-07 16:31   ` Marc-André Lureau
2020-02-07 16:31     ` Marc-André Lureau
2020-02-07 18:05   ` Laurent Vivier [this message]
2020-02-07 18:05     ` Laurent Vivier
2020-02-08  9:25   ` David Gibson
2020-02-08  9:25     ` David Gibson
2020-02-07 18:03 ` [PATCH v4 0/3] Make MachineClass::is_default boolean, refuse multiple default machines Eduardo Habkost
2020-02-07 18:03   ` Eduardo Habkost

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=f8b5897f-c11f-0272-cac8-f63e12f3783e@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=Alistair.Francis@wdc.com \
    --cc=aleksandar.rikalo@rt-rk.com \
    --cc=amarkovic@wavecomp.com \
    --cc=atar4qemu@gmail.com \
    --cc=aurelien@aurel32.net \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=crwulff@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=david@redhat.com \
    --cc=deller@gmx.de \
    --cc=edgar.iglesias@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=green@moxielogic.com \
    --cc=gxt@mprc.pku.edu.cn \
    --cc=huth@tuxfamily.org \
    --cc=kbastian@mail.uni-paderborn.de \
    --cc=magnus.damm@gmail.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=marex@denx.de \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=michael@walle.cc \
    --cc=mst@redhat.com \
    --cc=palmer@dabbelt.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=proljc@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=rth@twiddle.net \
    --cc=sagark@eecs.berkeley.edu \
    --cc=shorne@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.