qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Laurent Vivier <laurent@vivier.eu>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH] vl: Abort if multiple machines are registered as default
Date: Fri, 7 Feb 2020 12:25:13 +0100	[thread overview]
Message-ID: <078fbde9-3c93-b00a-2d53-34e65c7f56d9@redhat.com> (raw)
In-Reply-To: <24bddc77-801e-ae63-dd1d-e06e3ac1cc03@vivier.eu>

On 2/7/20 12:08 PM, Laurent Vivier wrote:
> Le 07/02/2020 à 12:02, 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>
>> ---
>>   vl.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/vl.c b/vl.c
>> index 7dcb0879c4..da828188eb 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -2354,6 +2354,8 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
>>       GSList *el;
>>   
>>       if (is_help_option(name)) {
>> +        int default_count = 0;
>> +
>>           printf("Supported machines are:\n");
>>           machines = g_slist_sort(machines, machine_class_cmp);
>>           for (el = machines; el; el = el->next) {
>> @@ -2364,6 +2366,11 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
>>               printf("%-20s %s%s%s\n", mc->name, mc->desc,
>>                      mc->is_default ? " (default)" : "",
>>                      mc->deprecation_reason ? " (deprecated)" : "");
>> +            default_count += !!mc->is_default;
>> +        }
>> +        if (default_count > 1) {
>> +            error_printf("Multiple default machines available\n");
>> +            abort();
>>           }
>>           exit(0);
>>       }
>>
> 
> Does it really deserve an abort?
> Ideal solution would be to be able to check this at build or in the unit
> tests.

This is for developers, not for users. I'll use Marc-André suggestion 
and use an assertion.



  reply	other threads:[~2020-02-07 11:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-07 11:02 [PATCH] vl: Abort if multiple machines are registered as default Philippe Mathieu-Daudé
2020-02-07 11:08 ` Laurent Vivier
2020-02-07 11:25   ` Philippe Mathieu-Daudé [this message]
2020-02-07 11:28     ` Laurent Vivier
2020-02-07 11:29       ` Laurent Vivier
2020-02-07 11:10 ` Marc-André Lureau

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=078fbde9-3c93-b00a-2d53-34e65c7f56d9@redhat.com \
    --to=philmd@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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).