From 0fc948cf0198dd7c97dcafec3ca8e82f1a3e93dd Mon Sep 17 00:00:00 2001 From: Josef Stribny Date: Tue, 21 Apr 2015 14:47:14 +0200 Subject: [PATCH] Fix: Wait for libvirt to shutdown the domain --- vagrant-libvirt-fix-halting.patch | 37 +++++++++++++++++++++++++++++++ vagrant-libvirt.spec | 9 +++++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 vagrant-libvirt-fix-halting.patch diff --git a/vagrant-libvirt-fix-halting.patch b/vagrant-libvirt-fix-halting.patch new file mode 100644 index 0000000..94719f5 --- /dev/null +++ b/vagrant-libvirt-fix-halting.patch @@ -0,0 +1,37 @@ +From cc8aadc9de397441b7e2a10eecc76feb6143b4c7 Mon Sep 17 00:00:00 2001 +From: Josef Stribny +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 + diff --git a/vagrant-libvirt.spec b/vagrant-libvirt.spec index ea678f7..55605c9 100644 --- a/vagrant-libvirt.spec +++ b/vagrant-libvirt.spec @@ -2,7 +2,7 @@ Name: %{vagrant_plugin_name} Version: 0.0.26 -Release: 1%{?dist} +Release: 2%{?dist} Summary: libvirt provider for Vagrant Group: Development/Languages License: MIT @@ -11,6 +11,9 @@ Source0: https://rubygems.org/gems/%{vagrant_plugin_name}-%{version}.gem Source1: 10-vagrant-libvirt.rules # Adjust Vagrant's dependencies. Patch0: vagrant-libvirt-fix-dependencies.patch +# Wait for libvirt to shutdown the domain +# https://github.com/pradels/vagrant-libvirt/pull/347 +Patch1: vagrant-libvirt-fix-halting.patch Requires(pre): shadow-utils Requires(posttrans): vagrant Requires(preun): vagrant @@ -57,6 +60,7 @@ gem unpack %{SOURCE0} gem spec %{SOURCE0} -l --ruby > %{vagrant_plugin_name}.gemspec %patch0 -p1 +%patch1 -p1 %build gem build %{vagrant_plugin_name}.gemspec @@ -116,6 +120,9 @@ getent group vagrant >/dev/null || groupadd -r vagrant %changelog +* Tue Apr 21 2015 Josef Stribny - 0.0.26-2 +- Fix: Wait for libvirt to shutdown the domain + * Mon Apr 20 2015 Josef Stribny - 0.0.26-1 - Update to 0.0.26