From a8e1ccde1f6c2c835ce520289f2818597b1197cd Mon Sep 17 00:00:00 2001 From: Jarek Prokop Date: Mon, 22 May 2023 16:58:48 +0200 Subject: [PATCH] Fix "HandleBox not defined" error with parallel operations. This error shows up with defining multiple vagrant machines and running operations like `vagrant up`. Resolves: rhbz#2100543 --- ...-defined-error-on-parallel-operation.patch | 68 +++++++++++++++++++ vagrant-libvirt.spec | 12 ++++ 2 files changed, 80 insertions(+) create mode 100644 vagrant-libvirt-0.7.0-Fix-HandleBox-not-defined-error-on-parallel-operation.patch diff --git a/vagrant-libvirt-0.7.0-Fix-HandleBox-not-defined-error-on-parallel-operation.patch b/vagrant-libvirt-0.7.0-Fix-HandleBox-not-defined-error-on-parallel-operation.patch new file mode 100644 index 0000000..5cd7c43 --- /dev/null +++ b/vagrant-libvirt-0.7.0-Fix-HandleBox-not-defined-error-on-parallel-operation.patch @@ -0,0 +1,68 @@ +From 709745261a4401f3418378e08be615ff6d24c865 Mon Sep 17 00:00:00 2001 +From: Jarek Prokop +Date: Mon, 22 May 2023 17:40:13 +0200 +Subject: [PATCH] Use require for HandleBox, SyncedFolders, WaitForCommunicator + +Using `autoload` fairly consistently results in 'constant not defined' +errors for each of HandleBox, SyncedFolders, WaitForCommunicator +when using ruby 3.1. Presumably there's some sort of race condition. +Explicitly using `require` for these three makes the problem go away. +It might be a bit ugly to have those `require` lines right at the +point where those symbols are used, vs. the neat `autoload` section +at the top of the file, but I'm not sure how better to structure this. +Suggestions most welcome :-) + +=== + +This patch is originally from PR + + +Fedora user named Shawn K. O'Shea adapted the patch for version 0.7.0. +https://bugzilla.redhat.com/show_bug.cgi?id=2100543#c4 +--- + lib/vagrant-libvirt/action.rb | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/lib/vagrant-libvirt/action.rb b/lib/vagrant-libvirt/action.rb +index 17b3a60..1b79d92 100644 +--- a/lib/vagrant-libvirt/action.rb ++++ b/lib/vagrant-libvirt/action.rb +@@ -35,6 +35,7 @@ module VagrantPlugins + b2.use StartDomain + else + b2.use HandleStoragePool ++ require 'vagrant/action/builtin/handle_box' + b2.use HandleBox + b2.use HandleBoxImage + b2.use CreateDomainVolume +@@ -103,6 +104,7 @@ module VagrantPlugins + + b3.use PrepareNFSValidIds + b3.use SyncedFolderCleanup ++ require 'vagrant/action/builtin/synced_folders' + b3.use SyncedFolders + + # Start it.. +@@ -111,6 +113,7 @@ module VagrantPlugins + # Machine should gain IP address when comming up, + # so wait for dhcp lease and store IP into machines data_dir. + b3.use WaitTillUp ++ require 'vagrant/action/builtin/wait_for_communicator' + b3.use WaitForCommunicator, [:running] + + b3.use ForwardPorts +@@ -392,11 +395,8 @@ module VagrantPlugins + autoload :PackageSetupFiles, 'vagrant/action/general/package_setup_files' + autoload :PackageSetupFolders, 'vagrant/action/general/package_setup_folders' + autoload :SSHRun, 'vagrant/action/builtin/ssh_run' +- autoload :HandleBox, 'vagrant/action/builtin/handle_box' +- autoload :SyncedFolders, 'vagrant/action/builtin/synced_folders' + autoload :SyncedFolderCleanup, 'vagrant/action/builtin/synced_folder_cleanup' + autoload :ProvisionerCleanup, 'vagrant/action/builtin/provisioner_cleanup' +- autoload :WaitForCommunicator, 'vagrant/action/builtin/wait_for_communicator' + end + end + end +-- +2.41.0.rc1 + diff --git a/vagrant-libvirt.spec b/vagrant-libvirt.spec index a723df5..c296ee0 100644 --- a/vagrant-libvirt.spec +++ b/vagrant-libvirt.spec @@ -25,6 +25,13 @@ Patch1: vagrant-libvirt-0.7.0-Reduce-patching-for-distro-default-session-use.pat # A bit modified: spec/support/libvirt_acceptance_context.rb does not exist # with 0.7.0 yet Patch2: vagrant-libvirt-pr1709-ruby32-File_exists-URL-parse.patch +# Vagrant-libvirt uses autoload feature. This is not necessarily thread safe +# https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1445#issuecomment-1044276044 +# This patch is taken from reported bug's attachment "Proposed patch": +# https://bugzilla.redhat.com/show_bug.cgi?id=2100543 +# Which is functionally this commit adapted for 0.7.0: +# https://github.com/vagrant-libvirt/vagrant-libvirt/commit/3bdb1c93e63886a95d472091ff8381f53338f632 +Patch3: vagrant-libvirt-0.7.0-Fix-HandleBox-not-defined-error-on-parallel-operation.patch # Enable QEMU Session by default # https://github.com/vagrant-libvirt/vagrant-libvirt/pull/969 @@ -70,6 +77,7 @@ Documentation for %{name}. %patch0 -p1 %patch1 -p1 %patch2 -p1 +%patch3 -p1 %patch100 -p1 %build @@ -139,6 +147,10 @@ popd %{vagrant_plugin_instdir}/spec %changelog +* Mon May 22 2023 Jarek Prokop - 0.7.0-5 +- Fix parallel vagrant up with libvirt provider. + Resolves: rhbz#2100543 + * Fri Jan 20 2023 Mamoru TASAKA - 0.7.0-5 - Backport upstream fix for ruby3.2 compatibility (File.exists? removal, URI#parse host name result change)