[master 2/4] Add inst.kexec and --kexec support to reboot with kexec

bcl installerbot-noreply at redhat.com
Thu Apr 16 16:39:56 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.
---
 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 d9ef103..a1d2fd0 100755
--- a/anaconda
+++ b/anaconda
@@ -99,7 +99,11 @@ def exitHandler(rebootData, storage):
                 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"])
@@ -367,6 +371,8 @@ def parseArguments(argv=None, boot_cmdline=None):
                     help=help_parser.help_text("nodnf"))
     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:
@@ -1042,6 +1048,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 c05f983..fe4d8b5 100644
--- a/data/anaconda_options.txt
+++ b/data/anaconda_options.txt
@@ -236,3 +236,7 @@ See the multipathd documentation for more info.
 remotelog
 Send all the logs to a remote host:port using a TCP connection. The connection will
 be retried if there is no listener (ie. won't block the installation).
+
+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 207f132..5abf3f5 100644
--- a/pyanaconda/flags.py
+++ b/pyanaconda/flags.py
@@ -71,6 +71,7 @@ def __init__(self, read_cmdline=True):
         self.ksprompt = True
         self.rescue_mode = False
         self.noefi = 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 937c778..54bd337 100644
--- a/pyanaconda/install.py
+++ b/pyanaconda/install.py
@@ -33,6 +33,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")
@@ -122,6 +123,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/4542c7ce2a90551ac8eae87f4117dc90ee525a69


More information about the anaconda-patches mailing list