On Fri, Jun 22, 2012 at 1:17 PM, Cleber Rosa <cr...@redhat.com> wrote:
> On 06/22/2012 11:38 AM, Cleber Rosa wrote:
>>
>> On 06/22/2012 03:58 AM, Lucas Meneghel Rodrigues wrote:
>>>
>>> On Wed, Jun 13, 2012 at 12:34 PM, Cleber Rosa <cr...@redhat.com> wrote:
>>>>
>>>> ----- Mensagem original -----
>>>>>
>>>>> De: "steve walsh" <steve.wa...@sap.com>
>>>>> Para: "Cleber Rosa" <cr...@redhat.com>
>>>>> Cc: autotest@test.kernel.org, "Lucas Meneghel Rodrigues"
>>>>> <l...@redhat.com>
>>>>> Enviadas: Quarta-feira, 13 de Junho de 2012 12:20:17
>>>>> Assunto: RE: [Autotest] kernel.boot is failing because "Unable to
>>>>> instantiate boottool"
>>>>>
>>>>> Hi Cleber,
>>>>>
>>>>> Results as follows:
>>>>>
>>>>> root@heca-autotest-b:/usr/local/autotest# ./tools/boottool
>>>>> --add-kernel=/boot/vmlinuz-autotest --initrd=/boot/initrd-autotest
>>>>> --title=autotest
>>>>> root@heca-autotest-b:/usr/local/autotest# grubby
>>>>> --info=/boot/vmlinuz-autotest
>>>>> index=0
>>>>> kernel=/boot/vmlinuz-autotest
>>>>> args="ro   crashkernel=384M-2G:64M,2G-:128M quiet panic=5"
>>>>> root=UUID=18790923-d357-4ce9-96c9-d09593dcbab8
>>>>> initrd=/boot/initrd-autotest
>>>>> title=autotest
>>>>>
>>>> This is actually good. Putting these messages aside for a while, do you
>>>> get to actually boot this new entry (and thus kernel)?
>>>
>>> I was working on this, and it seems the problem is that grub-reboot
>>> doesn't do what it avertises on ubuntu. After watching a couple of
>>> failed jobs, I've looked at the boot once code, and then tried
>>> grub-reboot an index. No way, it does reboot the machine to the
>>> permanent default entry, always, hence, failing the job.
>>>
>>> I don't have a good idea of how to fix this, but now we have a better
>>> idea of what's this problem all about.
>>
>>
>> Same thing here. I ended up running grub-reboot manually, but the result
>> was not the expected one.
>>
>> I'm now testing it on a Debian machine, since that was one of the distros
>> I used during the development and testing of the new boottool.
>>
>> I'll let you guys know about it.
>>
>
> So the behaviour is the same on Debian and Ubuntu. What's going on here is
> actually explained in the docstring, there's a caveat on already having
> grub's default set to saved.
>
> I'm now testing the removal of this caveat/requirement, with something like
> this:
>
> diff --git a/client/tools/boottool b/client/tools/boottool
> index 7a1cce1..f92441a 100755
> --- a/client/tools/boottool
> +++ b/client/tools/boottool
> @@ -1429,20 +1429,56 @@ class Grubby(object):
>         Caveat: this assumes the default set is of type "saved", and not a
>         numeric value.
>         '''
> -        grub_reboot_names = ['grub-reboot',
> -                             'grub2-reboot']
> -        executable = None
> +        grub_reboot_names = ['grub-reboot', 'grub2-reboot']
> +        grub_reboot_executable = None
>         for grub_reboot in grub_reboot_names:
> -            executable = find_executable(grub_reboot)
> -            if executable is not None:
> +            grub_reboot_executable = find_executable(grub_reboot)
> +            if grub_reboot_executable is not None:
>                 break
>
> -        if executable is None:
> +        if grub_reboot_executable is None:
>             self.log.error('Could not find executable among searched names:
> '
>                            '%s',' ,'.join(grub_reboot_names))
>             return -1
>
> -        return self._run_get_return([executable,
> +        grub_set_default_names = ['grub-set-default', 'grub2-set-default']
> +        grub_set_default_executable = None
> +        for grub_set_default in grub_set_default_names:
> +            grub_set_default_executable = find_executable(grub_set_default)
> +            if executable is not None:
> +                break
> +
> +        if grub_set_default_executable is None:
> +            self.log.error('Could not find executable among searched names:
> '
> +                           '%s',' ,'.join(grub_set_default_names))
> +            return -1
> +
> +        # Make sure the "set default" entry in the configuration file is
> set
> +        # to "${saved_entry}. Assuming the config file is at
> /boot/grub/grub.cfg
> +        deb_grub_cfg_path = '/boot/grub/grub.cfg'
> +        deb_grub_cfg_bkp_path = '%s.boottool.bak' % deb_grub_cfg_path
> +
> +        if os.path.exists(deb_grub_cfg_path):
> +            shutil.move(deb_grub_cfg_path, deb_grub_cfg_bkp_path)
> +            o = open(deb_grub_cfg_path, 'w')
> +            for l in open(deb_grub_cfg_bkp_path).readlines():
> +                if l.startswith('set default='):
> +                    o.write('set default="${saved_entry}"')
> +                else:
> +                    o.write(l)
> +            o.close()
> +
> +        # Make the current default entry the "previous saved entry"
> +        default_index = self.get_default_index()
> +        prev_saved_return =
> self._run_get_return([grub_set_default_executable,
> +                                                  '%s' % default_index])
> +        if prev_saved_return != 0:
> +            self.log.error('Could not make entry %s the previous saved
> entry',
> +                           default_index)
> +            return prev_saved_return
> +
> +        # Finally set the boot once entry
> +        return self._run_get_return([grubby_reboot_executable,
>                                      '%s' % entry_index])
>
>
> This should do the trick on the autotest/boottool side.
>
> But, since grubby already knows about "default saved" for grub2 (as part of
> the autotest patches), I'll also send another patch, making this a grubby
> feature. Maybe something like 'grubby --set-default=saved'.

Just sent a patch that is simpler and also does the job, take a look.



-- 
Lucas
_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to