@@ -798,10 +798,9 @@ def _DisableCpus(self):
798798
799799 if self .num_disable_cpus <= 0 or self .num_disable_cpus >= self .num_cpus :
800800 raise ValueError (
801- 'num_disable_cpus must be between 1 and '
802- '(num_cpus - 1) inclusive. '
803- 'num_disable_cpus: %i, num_cpus: %i'
804- % (self .num_disable_cpus , self .num_cpus )
801+ 'num_disable_cpus must be between 1 and (num_cpus - 1) inclusive. '
802+ f'num_disable_cpus: { self .num_disable_cpus } , '
803+ f'num_cpus: { self .num_cpus } '
805804 )
806805
807806 # We can't disable cpu 0, starting from the last cpu in /proc/cpuinfo.
@@ -1690,6 +1689,8 @@ def _AfterReboot(self):
16901689 self ._kernel_release = None
16911690 self ._kernel_command_line = None
16921691 self ._lscpu_cache = None
1692+ # recalculated in RecordAdditionalMetadata
1693+ self .num_cpus = None
16931694 self .RecordAdditionalMetadata ()
16941695 if self .install_packages :
16951696 self ._CreateInstallDir ()
@@ -2774,8 +2775,14 @@ def AppendKernelCommandLine(self, command_line, reboot=True):
27742775 r'echo GRUB_CMDLINE_LINUX_DEFAULT=\"\${GRUB_CMDLINE_LINUX_DEFAULT} %s\"'
27752776 ' | sudo tee -a /etc/default/grub' % command_line
27762777 )
2777- self .RemoteCommand ('sudo grub2-mkconfig -o /boot/grub2/grub.cfg' )
2778- self .RemoteCommand ('sudo grub2-mkconfig -o /etc/grub2.cfg' )
2778+ # RHEL 9.3+ requires a flag to update the kernel command line.
2779+ # It does not exist in older versions.
2780+ # https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/9.3_release_notes/new-features#new-features-boot-loader
2781+ update_grub = 'sudo grub2-mkconfig'
2782+ if self .TryRemoteCommand (f'{ update_grub } --update-bls-cmdline' ):
2783+ update_grub += ' --update-bls-cmdline'
2784+ self .RemoteCommand (f'{ update_grub } -o /boot/grub2/grub.cfg' )
2785+ self .RemoteCommand (f'{ update_grub } -o /etc/grub2.cfg' )
27792786 if reboot :
27802787 self .Reboot ()
27812788
0 commit comments