From: Matthew Booth Date: Thu, 26 Aug 2010 11:11:59 +0000 (+0100) Subject: Call sync after guestfsd exits X-Git-Tag: 1.5.5~8 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=c0b38fbb27c8771916386f47361833722d54518f;p=libguestfs.git 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. --- 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='> ' + 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='> ' -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