All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gonglei <arei.gonglei@huawei.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Huangpeng (Peter)" <peter.huangpeng@huawei.com>,
	"dvaleev@suse.de" <dvaleev@suse.de>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"agraf@suse.de" <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH v2 2/3] bootdevice: check boot order argument validation before vm running
Date: Fri, 6 Feb 2015 17:26:04 +0800	[thread overview]
Message-ID: <54D488AC.3050304@huawei.com> (raw)
In-Reply-To: <87ioffwgs4.fsf@blackfin.pond.sub.org>

On 2015/2/6 17:06, Markus Armbruster wrote:

> <arei.gonglei@huawei.com> writes:
> 
>> From: Gonglei <arei.gonglei@huawei.com>
>>
>> Either 'once' option or 'order' option can take effect for -boot at
>> the same time, that is say initial startup processing can check only
>> one. And pc.c's set_boot_dev() fails when its boot order argument
>> is invalid. This patch provide a solution fix this problem:
>>
>>  1. If "once" is given, register reset handler to restore boot order.
>>
>>  2. Pass the normal boot order to machine creation.  Should fail when
>>    the normal boot order is invalid.
>>
>>  3. If "once" is given, set it with qemu_boot_set().  Fails when the
>>    once boot order is invalid.
>>
>>  4. Start the machine.
>>
>>  5. On reset, the reset handler calls qemu_boot_set() to restore boot
>>    order.  Should never fail.
>>
>> Suggested-by: Markus Armbruster <armbru@redhat.com>
>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>> ---
>>  vl.c | 13 +++++++++++--
>>  1 file changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/vl.c b/vl.c
>> index 983259b..0d90d98 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -2734,6 +2734,7 @@ int main(int argc, char **argv, char **envp)
>>      const char *initrd_filename;
>>      const char *kernel_filename, *kernel_cmdline;
>>      const char *boot_order;
>> +    const char *once = NULL;
> 
> Consider renaming once to boot_once.  In its much larger scope, the boot
> context isn't obvious anymore, so a more telling name would be in order.
> 

Agree.

>>      DisplayState *ds;
>>      int cyls, heads, secs, translation;
>>      QemuOpts *hda_opts = NULL, *opts, *machine_opts, *icount_opts = NULL;
>> @@ -4046,7 +4047,7 @@ int main(int argc, char **argv, char **envp)
>>      opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
>>      if (opts) {
>>          char *normal_boot_order;
>> -        const char *order, *once;
>> +        const char *order;
>>          Error *local_err = NULL;
>>  
>>          order = qemu_opt_get(opts, "order");
>> @@ -4067,7 +4068,6 @@ int main(int argc, char **argv, char **envp)
>>                  exit(1);
>>              }
>>              normal_boot_order = g_strdup(boot_order);
>> -            boot_order = once;
>>              qemu_register_reset(restore_boot_order, normal_boot_order);
>>          }
>>  
> 
> normal_boot_order can be eliminated now.
> 
>         }
>         qemu_register_reset(restore_boot_order, strdup(order));
>     }
> 
> Even better, move qemu_register_reset()...
> 
>> @@ -4246,6 +4246,15 @@ int main(int argc, char **argv, char **envp)
>>  
>>      net_check_clients();
>>  
>> +    if (once) {
>> +        Error *local_err = NULL;
>> +        qemu_boot_set(once, &local_err);
>> +        if (local_err) {
>> +            error_report("%s", error_get_pretty(local_err));
>> +            exit(1);
>> +        }
> 
> ... here:
> 
>            qemu_register_reset(restore_boot_order, strdup(boot_order));
> 
>> +    }
>> +
>>      ds = init_displaystate();
>>  
>>      /* init local displays */
> 
> Clearer, don't you think?

Yes, it's cool. :)

Regards,
-Gonglei

  reply	other threads:[~2015-02-06  9:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03 12:34 [Qemu-devel] [PATCH v2 0/3] bootdevcie: change the boot order validation logic arei.gonglei
2015-02-03 12:34 ` [Qemu-devel] [PATCH v2 1/3] bootdevice: remove the check about boot_set_handler arei.gonglei
2015-02-06  8:56   ` Markus Armbruster
2015-02-06  9:17     ` Gonglei
2015-02-03 12:34 ` [Qemu-devel] [PATCH v2 2/3] bootdevice: check boot order argument validation before vm running arei.gonglei
2015-02-06  9:06   ` Markus Armbruster
2015-02-06  9:26     ` Gonglei [this message]
2015-02-03 12:34 ` [Qemu-devel] [PATCH v2 3/3] bootdevice: add check in restore_boot_order() arei.gonglei
2015-02-06  8:05 ` [Qemu-devel] [PATCH v2 0/3] bootdevcie: change the boot order validation logic Gonglei

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=54D488AC.3050304@huawei.com \
    --to=arei.gonglei@huawei.com \
    --cc=agraf@suse.de \
    --cc=armbru@redhat.com \
    --cc=dvaleev@suse.de \
    --cc=peter.huangpeng@huawei.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 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.