From 65258a808a703de25f790b2cb5aff8e734228ad1 Mon Sep 17 00:00:00 2001
From: Qiumiao Zhang <zhangqiumiao1@huawei.com>
Date: Mon, 7 Nov 2022 11:33:53 +0800
Subject: [PATCH] Support configuration of additional boot arguments

---
 data/anaconda.conf                            | 2 ++
 pyanaconda/argument_parsing.py                | 2 +-
 pyanaconda/core/configuration/bootloader.py   | 8 ++++++++
 pyanaconda/modules/storage/bootloader/base.py | 5 +++++
 4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/data/anaconda.conf b/data/anaconda.conf
index 703114a..b80440e 100644
--- a/data/anaconda.conf
+++ b/data/anaconda.conf
@@ -159,6 +159,8 @@ preserved_arguments =
     biosdevname ipv6.disable net.ifnames net.ifnames.prefix
     nosmt
 
+# Arguments added by default.
+additional_arguments =
 
 [Storage]
 # Enable dmraid usage during the installation.
diff --git a/pyanaconda/argument_parsing.py b/pyanaconda/argument_parsing.py
index 75f28f4..dd5ecdf 100644
--- a/pyanaconda/argument_parsing.py
+++ b/pyanaconda/argument_parsing.py
@@ -589,7 +589,7 @@ def getArgumentParser(version_string, boot_cmdline=None):
 
     # some defaults change based on cmdline flags
     if boot_cmdline is not None:
-        if "console" in boot_cmdline:
+        if "console" in boot_cmdline and "inst.text" in boot_cmdline:
             ap.set_defaults(display_mode=DisplayModes.TUI)
 
     return ap
diff --git a/pyanaconda/core/configuration/bootloader.py b/pyanaconda/core/configuration/bootloader.py
index 6746e45..7b782d3 100644
--- a/pyanaconda/core/configuration/bootloader.py
+++ b/pyanaconda/core/configuration/bootloader.py
@@ -69,3 +69,11 @@ class BootloaderSection(Section):
         :return: a list of kernel arguments
         """
         return self._get_option("preserved_arguments", str).split()
+
+    @property
+    def additional_arguments(self):
+        """Arguments added by default.
+
+        :return: a list of kernel arguments
+        """
+        return self._get_option("additional_arguments", str).split()
diff --git a/pyanaconda/modules/storage/bootloader/base.py b/pyanaconda/modules/storage/bootloader/base.py
index be039c4..533d528 100644
--- a/pyanaconda/modules/storage/bootloader/base.py
+++ b/pyanaconda/modules/storage/bootloader/base.py
@@ -734,6 +734,7 @@ class BootLoader(object):
         self._set_extra_boot_args(bootloader_proxy)
         self._set_storage_boot_args(storage)
         self._preserve_some_boot_args()
+        self._add_additional_boot_args()
         self._set_graphical_boot_args()
         self._set_security_boot_args()
 
@@ -908,6 +909,10 @@ class BootLoader(object):
 
             self.boot_args.add(new_arg)
 
+    def _add_additional_boot_args(self):
+        for opt in conf.bootloader.additional_arguments:
+            self.boot_args.add(opt)
+
     def _set_graphical_boot_args(self):
         """Set up the graphical boot."""
         args = []
-- 
2.19.1

