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.
---
appliance/init | 43 ++++++++++++++++++++++++-------------------
1 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/appliance/init b/appliance/init
index b8133ca..ef6ad5c 100755
--- a/appliance/init
+++ b/appliance/init
@@ -86,27 +86,32 @@ date
echo -n "uptime: "; cat /proc/uptime
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