Dan Čermák 8ce38a639b
Use systemctl poweroff in the background instead of shutdown
We have started seeing occasional shutdown failures on openSUSE Tumbleweed with
Virtualbox inside a qemu virtual machine, where `shutdown -h now` would return
nil. While the machine is successfully turned off, the command fails and vagrant
reports an error.
This commit changes the shutdown command to launch in the background which
also triggers a shutdown, but always succeeds.
2021-07-01 09:31:50 +02:00

17 lines
420 B
Ruby

module VagrantPlugins
module GuestSUSE
module Cap
class Halt
def self.halt(machine)
begin
machine.communicate.sudo("/usr/bin/systemctl poweroff &")
rescue IOError, Vagrant::Errors::SSHDisconnected
# Do nothing, because it probably means the machine shut down
# and SSH connection was lost.
end
end
end
end
end
end