diff --git a/lib/vagrant-parallels/action/box_register.rb b/lib/vagrant-parallels/action/box_register.rb index 16df164..221a940 100644 --- a/lib/vagrant-parallels/action/box_register.rb +++ b/lib/vagrant-parallels/action/box_register.rb @@ -39,13 +39,13 @@ def call(env) protected def box_path(env) - pvm = Dir.glob(env[:machine].box.directory.join('*.pvm')).first + res = Dir.glob(env[:machine].box.directory.join('*.{pvm,macvm}')).first - if !pvm + if !res raise Errors::BoxImageNotFound, name: env[:machine].box.name end - pvm + res end def box_id(env) @@ -120,9 +120,6 @@ def register_box(env) f.write(env[:clone_id]) end - # Convert template to VM (compatibility with old-styled boxes) - env[:machine].provider.driver.execute_prlctl( - 'set', env[:clone_id], '--template', 'off') end end end diff --git a/lib/vagrant-parallels/action/import.rb b/lib/vagrant-parallels/action/import.rb index 823031d..d25330a 100644 --- a/lib/vagrant-parallels/action/import.rb +++ b/lib/vagrant-parallels/action/import.rb @@ -4,6 +4,7 @@ module VagrantPlugins module Parallels module Action class Import + include VagrantPlugins::Parallels::Util::Common @@lock = Mutex.new def initialize(app, env) @@ -24,7 +25,8 @@ def call(env) end # Linked clones are supported only for PD 11 and higher - if env[:machine].provider_config.linked_clone + # Linked clones are not supported in macvms + if env[:machine].provider_config.linked_clone and !is_macvm(env) # Linked clone creation should not be concurrent [GH-206] options[:snapshot_id] = env[:clone_snapshot_id] options[:linked] = true diff --git a/lib/vagrant-parallels/action/prepare_clone_snapshot.rb b/lib/vagrant-parallels/action/prepare_clone_snapshot.rb index d6ceda2..50a86fb 100644 --- a/lib/vagrant-parallels/action/prepare_clone_snapshot.rb +++ b/lib/vagrant-parallels/action/prepare_clone_snapshot.rb @@ -6,6 +6,7 @@ module VagrantPlugins module Parallels module Action class PrepareCloneSnapshot + include VagrantPlugins::Parallels::Util::Common @@lock = Mutex.new def initialize(app, env) @@ -19,6 +20,12 @@ def call(env) return @app.call(env) end + if is_macvm(env) + #Ignore, since macvms doesn't support snapshot creation + @logger.info('Snapshot creation is not supported yet for macOS ARM Guests, skip snapshot preparing') + return @app.call(env) + end + # If we're not doing a linked clone, snapshots don't matter if !env[:machine].provider_config.linked_clone return @app.call(env) diff --git a/lib/vagrant-parallels/action/sane_defaults.rb b/lib/vagrant-parallels/action/sane_defaults.rb index 2833423..ae97d6b 100644 --- a/lib/vagrant-parallels/action/sane_defaults.rb +++ b/lib/vagrant-parallels/action/sane_defaults.rb @@ -4,6 +4,8 @@ module VagrantPlugins module Parallels module Action class SaneDefaults + include VagrantPlugins::Parallels::Util::Common + def initialize(app, env) @logger = Log4r::Logger.new('vagrant_parallels::action::sanedefaults') @app = app @@ -27,6 +29,9 @@ def call(env) private def default_settings + # Options defined below are not supported for `*.macvm` VMs + return {} if is_macvm(@env) + { tools_autoupdate: 'no', on_shutdown: 'close', diff --git a/lib/vagrant-parallels/plugin.rb b/lib/vagrant-parallels/plugin.rb index 45c39ff..06afd64 100644 --- a/lib/vagrant-parallels/plugin.rb +++ b/lib/vagrant-parallels/plugin.rb @@ -168,6 +168,7 @@ module Model module Util autoload :CompileForwardedPorts, File.expand_path('../util/compile_forwarded_ports', __FILE__) + autoload :Common, File.expand_path('../util/common', __FILE__) end end end diff --git a/lib/vagrant-parallels/util/common.rb b/lib/vagrant-parallels/util/common.rb new file mode 100644 index 0000000..80af674 --- /dev/null +++ b/lib/vagrant-parallels/util/common.rb @@ -0,0 +1,15 @@ +module VagrantPlugins + module Parallels + module Util + module Common + + # Determines whether the VM's box contains a macOS guest for an Apple Silicon host. + # In this case the image file ends with '.macvm' instead of '.pvm' + def is_macvm(env) + return !!Dir.glob(env[:machine].box.directory.join('*.macvm')).first + end + + end + end + end +end diff --git a/locales/en.yml b/locales/en.yml index 711fa42..e3e756d 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -16,7 +16,7 @@ en: Box VM config: "%{config}" box_image_not_found: |- - Parallels VM image (*.pvm) could not be found in the directory of + Parallels VM image (*.pvm or *.macvm) could not be found in the directory of '%{name}' box. This is usually because the image has been removed manually. Please remove the box, re-add it, and try again. dhcp_leases_file_not_accessible: |-