[Libguestfs] [PATCH WIP 3/5] appliance: Fix job control in virt-rescue.

Richard W.M. Jones rjones at redhat.com
Fri Mar 3 10:23:02 UTC 2017


See comment and link to busybox FAQ for explanation.
---
 appliance/init | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/appliance/init b/appliance/init
index 8be27a2..b3b8a45 100755
--- a/appliance/init
+++ b/appliance/init
@@ -194,7 +194,15 @@ else
   echo "You have to mount the guest's partitions under /sysroot"
   echo "before you can examine them."
   echo
-  bash -i
+    # The shell is opened by default on /dev/console, which (on Linux)
+    # is not a controlling terminal, causing job control to fail.  For
+    # how we work around this, see:
+    # https://busybox.net/FAQ.html#job_control
+    #
+    # Get name of the serial port, from console= passed by libguestfs.
+    export serial=`grep -Eo 'console=[^[:space:]]+' /proc/cmdline |
+                   sed s/console=//`
+    setsid bash -c 'exec bash </dev/$serial >/dev/$serial 2>&1'
   echo
   echo "virt-rescue: Syncing the disk now before exiting ..."
   echo
-- 
2.9.3




More information about the Libguestfs mailing list