diff --git a/lib/vagrant-libvirt/action/handle_box_image.rb b/lib/vagrant-libvirt/action/handle_box_image.rb index 45dacf0..b08ed17 100644 --- a/lib/vagrant-libvirt/action/handle_box_image.rb +++ b/lib/vagrant-libvirt/action/handle_box_image.rb @@ -37,9 +37,12 @@ module VagrantPlugins env[:box_volume_name] = env[:machine].box.name.to_s.dup.gsub("/", "-VAGRANTSLASH-") env[:box_volume_name] << "_vagrant_box_image_#{env[:machine].box.version.to_s rescue ''}.img" + # while inside the synchronize block take care not to call the next + # action in the chain, as must exit this block first to prevent + # locking all subsequent actions as well. @@lock.synchronize do # Don't continue if image already exists in storage pool. - return @app.call(env) if ProviderLibvirt::Util::Collection.find_matching( + break if ProviderLibvirt::Util::Collection.find_matching( env[:libvirt_compute].volumes.all, env[:box_volume_name]) # Box is not available as a storage pool volume. Create and upload diff --git a/lib/vagrant-libvirt/action/handle_storage_pool.rb b/lib/vagrant-libvirt/action/handle_storage_pool.rb index e405638..f567687 100644 --- a/lib/vagrant-libvirt/action/handle_storage_pool.rb +++ b/lib/vagrant-libvirt/action/handle_storage_pool.rb @@ -14,14 +14,16 @@ module VagrantPlugins end def call(env) - @@lock.synchronize do - # Get config options. - config = env[:machine].provider_config + # Get config options. + config = env[:machine].provider_config + # while inside the synchronize block take care not to call the next + # action in the chain, as must exit this block first to prevent + # locking all subsequent actions as well. + @@lock.synchronize do # Check for storage pool, where box image should be created - fog_pool = ProviderLibvirt::Util::Collection.find_matching( + break if ProviderLibvirt::Util::Collection.find_matching( env[:libvirt_compute].pools.all, config.storage_pool_name) - return @app.call(env) if fog_pool @logger.info("No storage pool '#{config.storage_pool_name}' is available.")