Parallels / vagrant-parallels

Vagrant Parallels Provider
https://parallels.github.io/vagrant-parallels
MIT License
996 stars 87 forks source link

How to create a simple vagrant box for mac arm #444

Closed craigching closed 1 year ago

craigching commented 1 year ago

I'm trying to create a vagrant box with a host of macOS 13.2.1 and a guest of 13.3.1 (this was downloaded and installed using Parallels). The base vm works fine. Now I do:

% ls -l ~/Parallels
total 0
drwxr-xr-x@ 10 craigching  staff  320 Apr 25 09:22 macOS 13.macvm
% cp -R ~/Parallels/macOS\ 13.macvm .
% tar -zcvf macos-ventura-base.box macOS\ 13.macvm metadata.json
% vagrant box add --name macos-ventura-base macos-ventura-base.box

metadata.json is as simple as it gets:

{
    "provider": "parallels"
}

And then I run:

% ls -l ~/.vagrant.d/boxes/macos-ventura-base/0/parallels/                                                                    
total 8
drwxr-xr-x  10 craigching  staff  320 Apr 25 08:57 macOS 13.macvm
-rw-r--r--   1 craigching  staff   32 Apr 25 08:57 metadata.json
% ls -l ~/.vagrant.d/boxes/macos-ventura-base/0/parallels/macOS\ 13.macvm                                                     
total 134288424
-rw-------  1 craigching  staff     33570816 Apr 25 08:55 aux.bin
-rwxr--r--  1 craigching  staff        21809 Apr 25 08:57 config.pvs
-rwxr--r--  1 craigching  staff        21809 Apr 25 08:57 config.pvs.backup
-rw-------  1 craigching  staff  68719476736 Apr 25 08:57 disk0.img
-rw-r--r--  1 craigching  staff          150 Apr 25 08:57 machw.bin
-rw-r--r--  1 craigching  staff           68 Apr 25 08:57 macid.bin
-rw-r--r--  1 craigching  staff        28634 Apr 25 08:57 parallels.log
-rw-r--r--  1 craigching  staff          916 Apr 25 08:57 statistic.log

all looks good at this point. Then I vagrant init:

% vagrant init macos-ventura-base
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

and vagrant up:

% vagrant up
Bringing machine 'default' up with 'parallels' provider...
==> default: Registering VM image from the base box 'macos-ventura-base'...
==> default: Creating new virtual machine as a linked clone of the box image...
==> default: Unregistering the box VM image...
==> default: Setting the default configuration for VM...
==> default: Setting the name of the VM: tmp_default_1682432931129_16590
==> default: Preparing network interfaces based on configuration...
    default: Adapter 0: shared
==> default: Clearing any previously set network interfaces...
==> default: Booting VM...
There was an error while command execution. The command and stderr is shown below.

Command: ["/usr/local/bin/prlctl", "start", "de13b3dd-beb0-46f6-a8c4-210beef6ddf9"]

Stderr: Failed to start the VM: The virtual machine cannot be started due to a critical error.

There is a dialog box that says "Cannot retrieve the hardware model data" over the VM that was launched, I click ok and it fails as above.

My vagrant and vagrant-parallels version:

% vagrant --version
Vagrant 2.3.4
% vagrant plugin list
vagrant-parallels (2.3.1, global)

I also noticed that after I tried to vagrant up, the vagrant box directory now looks like this:

 % ls -l ~/.vagrant.d/boxes/macos-ventura-base/0/parallels
total 16
-rw-r--r--   1 craigching  staff   36 Apr 25 09:28 box_id
drwxr-xr-x@ 12 craigching  staff  384 Apr 25 09:28 macOS 13.macvm (1).pvm
-rw-r--r--   1 craigching  staff   32 Apr 25 08:57 metadata.json

Why does it now have a .pvm extension?

bineesh-n commented 1 year ago

We are working on this.

As a workaround, please check if you have another VM with name "macOS 13" registered. Unregister other VM to make this work.

Also delete the "Snapshots.xml" or "Snapshot" folder if exists from base machine.

cjlapao commented 1 year ago

We now have new documentation on how you can achieve this. You will need the latest version of the provider, but you should be able to do this. Let me know if you find any other issue

legal90 commented 1 year ago

The new doc page for building macOS box on M-series Macs is available here: https://parallels.github.io/vagrant-parallels/docs/boxes/base_macos.html

I think this issue can be closed now.