Bug 1108498

Summary: ks_meta "grubport=" is ignored on UEFI-based system
Product: [Retired] Beaker Reporter: Jun'ichi NOMURA <junichi.nomura>
Component: lab controllerAssignee: Dan Callaghan <dcallagh>
Status: CLOSED CURRENTRELEASE QA Contact: tools-bugs <tools-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 0.16CC: aigao, asaha, dcallagh, kueda, naoya.horiguchi, rmancy, tatsu-ab1, tnishimura, xma
Target Milestone: 0.18Keywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-09-04 05:40:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jun'ichi NOMURA 2014-06-12 07:01:15 UTC
Description of the problem:
ks_meta "grubport=" is expected to be translated into "--port=" option of grub. However, it does not happen on UEFI-based systems.
"grubport=" is used for systems where "--port=" grub option is necessary for reliable specification of serial port.

Version-Release number of selected component (if applicable):
beaker-0.16.1-1.el6eng.noarch

How reproducible:
Always on UEFI-based system

Steps to Reproduce:
1. Add "grubport=0x2f8" for systems's "Kickstart Metadata"
2. Provision the system
3. Check grub configuration

Actual behavior:
grub config file (*) does not contain "--port=0x2f8" option
(*) config file path
    - /boot/efi/EFI/redhat/grub.conf (grub1, e.g. RHEL6)
    - /boot/efi/EFI/redhat/grub.cfg (grub2, e.g. RHEL7)

Expected behavior:
grub config file should contain "--port=0x2f8" option


Additional Information:

rhts_post snippet handles "grubport=". The snippet tries to apply the "--port=" change to appropriate grub config file. However, it misses the fact that the config file location is different on legacy BIOS system and UEFI system.

The problem can be fixed by the following patch.
Tested on RHEL6.5 and RHEL7.0, for both legacy BIOS system and UEFI system.

--- a/rhts_post	2014-03-26 00:16:45.000000000 -0400
+++ b/rhts_post	2014-06-11 21:04:08.000000000 -0400
@@ -70,11 +70,21 @@ fi
 {#
 #/bin/sed -i 's/^serial.*/serial --port={{ grubport }} --speed=115200/' /boot/grub/grub.conf
 #}
-if [ -e "/boot/grub/grub.conf" ]; then
-    /bin/sed -i 's/^\(serial.*\)--unit=\S\+\(.*\)$/\1--port={{ grubport }}\2/' /boot/grub/grub.conf
+if [ -e "/boot/grub/grub.conf" -o -e "/boot/efi/EFI/redhat/grub.conf" ]; then
+    if [ -d "/sys/firmware/efi" ]; then
+        GRUBCONF="/boot/efi/EFI/redhat/grub.conf"
+    else
+        GRUBCONF="/boot/grub/grub.conf"
+    fi
+    /bin/sed -i 's/^\(serial.*\)--unit=\S\+\(.*\)$/\1--port={{ grubport }}\2/' $GRUBCONF
 elif [ -e "/etc/default/grub" ]; then
+    if [ -d "/sys/firmware/efi" ]; then
+        GRUBCONF="/boot/efi/EFI/redhat/grub.cfg"
+    else
+        GRUBCONF="/boot/grub2/grub.cfg"
+    fi
     /bin/sed -i '/^GRUB_SERIAL_COMMAND="serial/ {s/--unit=[0-9]\+//; s/"$/ --port={{ grubport }}"/}' /etc/default/grub
-    /sbin/grub2-mkconfig -o /boot/grub2/grub.cfg
+    /sbin/grub2-mkconfig -o $GRUBCONF
 fi
 {% endif %}

Comment 2 Dan Callaghan 2014-08-08 02:11:17 UTC
Thanks for the patch, Jun'ichi!

I used a slightly different, more brute force approach here (sed every GRUB config we can find). Also split into a new snippet for convenience, and added some docs.

http://gerrit.beaker-project.org/3238

Comment 7 Dan Callaghan 2014-09-04 05:40:30 UTC
This bug fix was applied to the release-0.17 branch, but we are not doing any more maintenance releases of the 0.17.x series. So this bug is fixed in Beaker 0.18.0.