[rhel7-branch 2/3] Add inst.kexec and --kexec support to reboot with kexec (#1207747)

bcl installerbot-noreply at redhat.com
Sat Jun 13 00:52:18 UTC 2015


From: "Brian C. Lane" <bcl at redhat.com>

Pass inst.kexec on the kernel cmdline or pass --kexec to anaconda
directly to make it reboot using kexec and the newly installed kernel
and initrd.

Resolves: rhbz#1207747
(cherry picked from commit d2ed867492cbfd385f7be4af4df1323ea9e1e22a)
---
 anaconda                  | 9 ++++++++-
 data/anaconda_options.txt | 4 ++++
 pyanaconda/flags.py       | 1 +
 pyanaconda/install.py     | 5 +++++
 4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/anaconda b/anaconda
index f846339..58dd325 100755
--- a/anaconda
+++ b/anaconda
@@ -94,7 +94,11 @@ def exitHandler(rebootData, storage, exitCode=None):
                 if get_mount_paths(cdrom.path):
                     dracut_eject(cdrom.path)
 
-        if rebootData.action == KS_SHUTDOWN:
+        if flags.kexec:
+            execWithRedirect("systemctl", ["--no-wall", "kexec"])
+            while True:
+                time.sleep(10000)
+        elif rebootData.action == KS_SHUTDOWN:
             execWithRedirect("systemctl", ["--no-wall", "poweroff"])
         elif rebootData.action == KS_WAIT:
             execWithRedirect("systemctl", ["--no-wall", "halt"])
@@ -348,6 +352,8 @@ def parseArguments(argv=None, boot_cmdline=None):
                     help=help_parser.help_text("nombr"))
     ap.add_argument("--mpathfriendlynames", action="store_true", default=True,
                     help=help_parser.help_text("mpathfriendlynames"))
+    ap.add_argument("--kexec", action="store_true", default=False,
+                    help=help_parser.help_text("kexec"))
 
     # some defaults change based on cmdline flags
     if boot_cmdline is not None:
@@ -933,6 +939,7 @@ if __name__ == "__main__":
     flags.ibft = opts.ibft
     flags.selinux = opts.selinux
     flags.eject = opts.eject
+    flags.kexec = opts.kexec
 
     # Switch to tty1 on exception in case something goes wrong during X start.
     # This way if, for example, metacity doesn't start, we switch back to a
diff --git a/data/anaconda_options.txt b/data/anaconda_options.txt
index 80f67f8..d2b5295 100644
--- a/data/anaconda_options.txt
+++ b/data/anaconda_options.txt
@@ -226,3 +226,7 @@ grub.cfg on the newly installed OS.
 mpathfriendlynames
 Tell multipathd to use user friendly names when naming devices during the installation.
 See the multipathd documentation for more info.
+
+kexec
+Reboot the system using kexec with the new kernel and initrd. This will result in
+a faster reboot by skipping the BIOS/Firmware and bootloader steps.
diff --git a/pyanaconda/flags.py b/pyanaconda/flags.py
index 549189a..496fac6 100644
--- a/pyanaconda/flags.py
+++ b/pyanaconda/flags.py
@@ -69,6 +69,7 @@ def __init__(self, read_cmdline=True):
         # ksprompt is whether or not to prompt for missing ksdata
         self.ksprompt = True
         self.rescue_mode = False
+        self.kexec = False
         # parse the boot commandline
         self.cmdline = BootArgs()
         # Lock it down: no more creating new flags!
diff --git a/pyanaconda/install.py b/pyanaconda/install.py
index dd32a73..dc7da33 100644
--- a/pyanaconda/install.py
+++ b/pyanaconda/install.py
@@ -31,6 +31,7 @@
 from pyanaconda.i18n import _
 from pyanaconda.threads import threadMgr
 from pyanaconda.ui.lib.entropy import wait_for_entropy
+from pyanaconda.kexec import setup_kexec
 import logging
 import blivet
 log = logging.getLogger("anaconda")
@@ -112,6 +113,10 @@ def doConfiguration(storage, payload, ksdata, instClass):
     with progress_report(_("Running post-installation scripts")):
         runPostScripts(ksdata.scripts)
 
+    # setup kexec reboot if requested
+    if flags.flags.kexec:
+        setup_kexec()
+
     # Write the kickstart file to the installed system (or, copy the input
     # kickstart file over if one exists).
     _writeKS(ksdata)


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/76ee88877e3c2a2c2de8a708a7bf88188b9d2ee4


More information about the anaconda-patches mailing list