vagrant-libvirt/vagrant-libvirt-fix-halting.patch
2015-04-21 16:00:10 +02:00

37 lines
1.4 KiB
Diff

From cc8aadc9de397441b7e2a10eecc76feb6143b4c7 Mon Sep 17 00:00:00 2001
From: Josef Stribny <jstribny@redhat.com>
Date: Tue, 21 Apr 2015 09:04:53 +0200
Subject: [PATCH] Wait for libvirt to shutdown the domain
Fixes #293
---
lib/vagrant-libvirt/action/read_state.rb | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/vagrant-libvirt/action/read_state.rb b/lib/vagrant-libvirt/action/read_state.rb
index ad552a1..1848de4 100644
--- a/lib/vagrant-libvirt/action/read_state.rb
+++ b/lib/vagrant-libvirt/action/read_state.rb
@@ -27,10 +27,17 @@ module VagrantPlugins
end
# Find the machine
begin
+ # Wait for libvirt to shutdown the domain
+ while libvirt.servers.get(machine.id).state.to_sym == :'shutting-down' do
+ @logger.info('Waiting on the machine to shut down...')
+ sleep 1
+ end
+
server = libvirt.servers.get(machine.id)
- if server.nil? || [:'shutting-down', :terminated].include?(server.state.to_sym)
+
+ if server.nil? || server.state.to_sym == :terminated
# The machine can't be found
- @logger.info('Machine shutting down or terminated, assuming it got destroyed.')
+ @logger.info('Machine terminated, assuming it got destroyed.')
machine.id = nil
return :not_created
end
--
2.1.0