[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 2/4] Call sync after guestfsd exits



Core files are not reliably written to disk if guestfsd dumps core. This patch
makes libguestfs do the same appliance cleanup for guestfsd and virt-rescue,
which seems to fix the matter.

It also removes a redundant sleep and additional sync when exiting virt-rescue.
---
 appliance/init |   45 ++++++++++++++++++++++++---------------------
 1 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/appliance/init b/appliance/init
index 6aeea0c..90da1cb 100755
--- a/appliance/init
+++ b/appliance/init
@@ -88,27 +88,30 @@ if grep -sq guestfs_verbose=1 /proc/cmdline; then
 fi
 
 if ! grep -sq guestfs_rescue=1 /proc/cmdline; then
-  exec guestfsd -f
+  # The host will kill qemu abruptly if guestfsd shuts down normally
+  guestfsd -f
+
+  # Otherwise we try to clean up gracefully. For example, this ensures that a
+  # core dump generated by the guest daemon will be written to disk.
+else
+  # Use appliance in rescue mode, also used by the virt-rescue command.
+  eval $(grep -Eo 'TERM=[^[:space:]]+' /proc/cmdline)
+  PS1='><rescue> '
+  export TERM PS1
+  echo
+  echo "------------------------------------------------------------"
+  echo
+  echo "Welcome to virt-rescue, the libguestfs rescue shell."
+  echo
+  echo "Note: The contents of / are the rescue appliance."
+  echo "You have to mount the guest's partitions under /sysroot"
+  echo "before you can examine them."
+  echo
+  bash -i
+  echo
+  echo "virt-rescue: Syncing the disk now before exiting ..."
+  echo "(Don't worry if you see a 'Kernel panic' message below)"
+  echo
 fi
 
-# Use appliance in rescue mode, also used by the virt-rescue command.
-eval $(grep -Eo 'TERM=[^[:space:]]+' /proc/cmdline)
-PS1='><rescue> '
-export TERM PS1
-echo
-echo "------------------------------------------------------------"
-echo
-echo "Welcome to virt-rescue, the libguestfs rescue shell."
-echo
-echo "Note: The contents of / are the rescue appliance."
-echo "You have to mount the guest's partitions under /sysroot"
-echo "before you can examine them."
-echo
-bash -i
-echo
-echo "virt-rescue: Syncing the disk now before exiting ..."
-echo "(Don't worry if you see a 'Kernel panic' message below)"
-echo
-sync
-sleep 1
 sync
-- 
1.7.2.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]