From 9704472d1c0edd9b04b294bd975ee3fc35b8c42d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Jun 2009 13:33:03 +0000 Subject: [PATCH] Some hacks to support clean shutdowns of VMs that mount the Nix store ove QEMU (and other NixOS instances that use a remote filesystem like NFS): * Don't take down the network interfaces during shutdown. * Don't try to unmount the Nix store. Usually, this doesn't work because it's still in use, but on remote filesystems like CIFS the `-f' umount flag actually works. svn path=/nixos/branches/modular-nixos/; revision=16036 --- modules/system/upstart-events/halt.nix | 7 ++++++- modules/tasks/network-interfaces.nix | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/system/upstart-events/halt.nix b/modules/system/upstart-events/halt.nix index 60727e3686b..82b5ffcae1a 100644 --- a/modules/system/upstart-events/halt.nix +++ b/modules/system/upstart-events/halt.nix @@ -69,7 +69,12 @@ let for mp in $(getMountPoints); do device=$(getDevice $mp) echo "unmounting $mp..." - if umount -f -n "$mp"; then + # !!! Don't unmount /nix/store or /hostfs. This is + # a quick hack to cleanly shutdown VMs that mount + # the Nix store via CIFS. "mount -f" will actually + # work on such filesystems, which makes all commands + # needed below disappear. + if test "$mp" != /nix/store -a "$mp" != /hostfs && umount -f -n "$mp"; then if test "$mp" != /; then tryAgain=1; fi else mount -n -o remount,ro "$mp" || true diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index 4c57b48bd94..d075d04ed6b 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -159,10 +159,10 @@ in respawn sleep 100000 stop script - for i in $(cd /sys/class/net && ls -d *); do - echo "Taking down network device $i..." - ${nettools}/sbin/ifconfig $i down || true - done + #for i in $(cd /sys/class/net && ls -d *); do + # echo "Taking down network device $i..." + # ${nettools}/sbin/ifconfig $i down || true + #done end script ''; }];