From: Marcel Apfelbaum <marcel@redhat.com>
To: Markus Armbruster <armbru@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
lersek@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 1/4] vl.c: Fix regression in machine error message
Date: Mon, 15 Feb 2016 12:54:01 +0200 [thread overview]
Message-ID: <56C1AE49.9080700@redhat.com> (raw)
In-Reply-To: <87lh6m5l71.fsf@blackfin.pond.sub.org>
On 02/15/2016 12:20 PM, Markus Armbruster wrote:
> Eduardo Habkost <ehabkost@redhat.com> writes:
>
>> From: Marcel Apfelbaum <marcel@redhat.com>
>>
>> Commit e1ce0c3cb (vl.c: fix regression when reading machine type
>> from config file) fixed the error message when the machine type
>> was supplied inside the config file. However now the option name
>> is not displayed correctly if the error happens when the machine
>> is specified at command line.
>>
>> Running
>> ./x86_64-softmmu/qemu-system-x86_64 -M q35-1.5 -redir tcp:8022::22
>> will result in the error message:
>> qemu-system-x86_64: -redir tcp:8022::22: unsupported machine type
>> Use -machine help to list supported machines
>>
>> Fixed it by restoring the error location and also extracted the code
>> dealing with machine options into a separate function.
>>
>> Reported-by: Michael S. Tsirkin <mst@redhat.com>
>> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
>> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
>> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>> ---
>> vl.c | 37 ++++++++++++++++++++++++++-----------
>> 1 file changed, 26 insertions(+), 11 deletions(-)
>>
>> diff --git a/vl.c b/vl.c
>> index 175ebcc..afbf13f 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -2748,6 +2748,31 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
>> return popt;
>> }
>>
>> +static void set_machine_options(MachineClass **machine_class)
>> +{
>> + const char *optarg;
>> + QemuOpts *opts;
>> + Location loc;
>> +
>> + loc_push_none(&loc);
>> +
>> + opts = qemu_get_machine_opts();
>> + qemu_opts_loc_restore(opts);
>> +
>> + optarg = qemu_opt_get(opts, "type");
>> + if (optarg) {
>> + *machine_class = machine_parse(optarg);
>> + }
>> +
>> + if (*machine_class == NULL) {
>> + error_report("No machine specified, and there is no default");
>> + error_printf("Use -machine help to list supported machines\n");
>> + exit(1);
>> + }
>> +
>> + loc_pop(&loc);
>> +}
>> +
>> static int machine_set_property(void *opaque,
>> const char *name, const char *value,
>> Error **errp)
>> @@ -4030,17 +4055,7 @@ int main(int argc, char **argv, char **envp)
>>
>> replay_configure(icount_opts);
>>
>> - opts = qemu_get_machine_opts();
>> - optarg = qemu_opt_get(opts, "type");
>> - if (optarg) {
>> - machine_class = machine_parse(optarg);
>> - }
>> -
>> - if (machine_class == NULL) {
>> - error_report("No machine specified, and there is no default");
>> - error_printf("Use -machine help to list supported machines\n");
>> - exit(1);
>> - }
>> + set_machine_options(&machine_class);
>
> Style nit: I'd prefer
>
> machine_class = parse_machine_options();
>
> Can convert to that when I apply to error-next.
Hi Markus,
Sure, please do that.
It was suggested by Laszlo - I think - to match "set_memory_options" below.
We can add a trivial patch to rename it too, of course.
Thanks,
Marcel
>
>>
>> set_memory_options(&ram_slots, &maxram_size, machine_class);
next prev parent reply other threads:[~2016-02-15 10:54 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-12 19:02 [Qemu-devel] [PATCH v2 0/4] Error location reporting fixes Eduardo Habkost
2016-02-12 19:02 ` [Qemu-devel] [PATCH v2 1/4] vl.c: Fix regression in machine error message Eduardo Habkost
2016-02-15 10:20 ` Markus Armbruster
2016-02-15 10:54 ` Marcel Apfelbaum [this message]
2016-02-15 11:53 ` Laszlo Ersek
2016-02-15 14:30 ` Markus Armbruster
2016-02-16 12:46 ` Markus Armbruster
2016-02-12 19:02 ` [Qemu-devel] [PATCH v2 2/4] vl: Reset location after handling command-line arguments Eduardo Habkost
2016-02-12 19:34 ` Marcel Apfelbaum
2016-02-15 10:29 ` Markus Armbruster
2016-02-15 15:22 ` Eduardo Habkost
2016-02-12 19:02 ` [Qemu-devel] [PATCH v2 3/4] replay: Set error location properly when parsing options Eduardo Habkost
2016-02-12 19:34 ` Marcel Apfelbaum
2016-02-12 19:02 ` [Qemu-devel] [PATCH v2 4/4] vl: Set error location when parsing memory options Eduardo Habkost
2016-02-12 19:35 ` Marcel Apfelbaum
2016-02-15 10:33 ` [Qemu-devel] [PATCH v2 0/4] Error location reporting fixes Markus Armbruster
2016-02-16 14:57 ` [Qemu-devel] [PATCH 5/4] vl: Clean up machine selection in main() Markus Armbruster
2016-02-16 15:34 ` Laszlo Ersek
2016-02-16 19:56 ` Markus Armbruster
2016-02-16 16:27 ` Marcel Apfelbaum
2016-02-16 19:52 ` Markus Armbruster
2016-02-16 20:03 ` [Qemu-devel] [PATCH v2 0/4] Error location reporting fixes Markus Armbruster
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=56C1AE49.9080700@redhat.com \
--to=marcel@redhat.com \
--cc=armbru@redhat.com \
--cc=ehabkost@redhat.com \
--cc=lersek@redhat.com \
--cc=pbonzini@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).