Parallels / vagrant-parallels

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

445 vagrant up exits with status 1 for macvms #446

Closed bineesh-n closed 1 year ago

bineesh-n commented 1 year ago

Made is_macvm a member of module since I was getting error in accessing the function from guest_cap. Since macvm is actually a darwin guest, darwin guest commands to share folders are getting executed. I skipped this in enable & disable functions for macvms.

@legal90 We need these changes within a week. Please review.

legal90 commented 1 year ago

Hi @bineesh-n ! I'll do my best to review and release it until the end of this week.

BTW, I finally got the chance to validate vagrant-parallels on Apple-series Macs. Could you please tell me if there are any public macvm boxes available? If not - is there some manual how to build the one locally (maybe using packer) ?

bineesh-n commented 1 year ago

Hi @legal90 ,

I couldn't find any macvm boxes in public. We are using this document to create macvm box (https://fe.parallels.com/c6030b623488876684972a82869c9b30/PDFM-Creating%20a%20MacVM%20box%20(temporary%20method)-110523-042148.pdf [link expires in 30 days])

legal90 commented 1 year ago

@bineesh-n Could you please try to update the usable? function in https://github.com/Parallels/vagrant-parallels/blob/0dfc4a13e986a274f32bc07e31814f8fb3ddb71a/lib/vagrant-parallels/synced_folder.rb#L6-L10

to this:

      def usable?(machine, raise_errors=false)
        # These synced folders only work if the provider is Parallels and the guest is not *.macvm
        machine.provider_name == :parallels &&
          machine.provider_config.functional_psf &&
          !Util::Common::is_macvm(machine)
      end

If that works, then all other changes down in synced_folder.rb won't be needed.


@bineesh-n A side question about running macvm: I built the macvm box and got the VM booted by vagrant up, but the provider fails to detect the VM IP because prlctl list --full --json for this VM always returns "ip_configured": "-". Guest tools are installed. Do you have any idea where to look at? Should I maybe file a support ticket? Host OS: macOS 13.3.1 (Apple M2 Pro) Guest OS: macOS 13.3.1 (Apple M2 Pro (Virtual)) PDfM version: Version 18.2.0 (53488)

bineesh-n commented 1 year ago

@legal90 I'll make the changes now.

"prlctl list --full --json" will work for ip address in next release of PD only (soon).

bineesh-n commented 1 year ago

@legal90 I tried the suggestion you provided, but now the system asks me smb password and configures SMB sharing instead. That's also failing.

Bringing machine 'default' up with 'parallels' provider...
==> default: Preparing SMB shared folders...
    default: You will be asked for the username and password to use for the SMB
    default: folders shortly. Please use the proper username/password of your
    default: account.
    default:
    default: Username (user[@domain]):
    default: Password (will be hidden):
Vagrant SMB synced folders require the account password to be stored
in an NT compatible format. Please update your sharing settings to
enable a Windows compatible password and try again.
legal90 commented 1 year ago

@bineesh-n It seems that Vagrant tries to find any other usable approach for handling shared folders. Is SMB not supported in *.macvm boxes too? In that case I would suggest to put that either to the box built-in Vagrantfile or into the end-user Vagrantfile:

config.vm.synced_folder ".", "/vagrant", disabled: true

It should disable the default synced folder explicitly. Could you please check if that helps?

bineesh-n commented 1 year ago

@legal90 we need to design vagrant-parallels to put the shared folder info in our config.pvs for macvms. But as per your current suggestion, we need to ask users to create box and disable default synced folder. So what about their custom shared folders ? It's not 'macvm' not supporting shared folders, but mounting and unmounting is not required this to work. Just putting entry in config.pvs is enough.

I tried your suggestion though. It shows following error.

1: from /Users/bineeshnadukkalam/.vagrant.d/gems/2.7.6/gems/vagrant-parallels-2.3.1/lib/vagrant-parallels/synced_folder.rb:10:in `usable?'
/Users/bineeshnadukkalam/.vagrant.d/gems/2.7.6/gems/vagrant-parallels-2.3.1/lib/vagrant-parallels/util/common.rb:9:in `is_macvm': undefined method `directory' for nil:NilClass (NoMethodError)
legal90 commented 1 year ago

@bineesh-n ,

It's not 'macvm' not supporting shared folders, but mounting and unmounting is not required this to work. Just putting entry in config.pvs is enough.

Thank you! That makes sense now. Although, as I remember, it was not recommended to edit config.pvs, as it's "internal" configure and the structure might change. We should do it only as a last resort. And it's always better to implement that feature via prlctl (feature request to Parallels). But if you are confident about the structure and want to make it working right now - feel free to do it via config.pvs and use this case as an example: https://github.com/Parallels/vagrant-parallels/blob/eb8f2df5194b0ab95066154adee0d60b622dbe10/lib/vagrant-parallels/action/export.rb#L125-L134

So what about their custom shared folders ?

Yes, that looks like a proper solution. We can implement it as yet another synced_folder instance, let's say :parallels_macvm or similar. https://github.com/Parallels/vagrant-parallels/blob/eb8f2df5194b0ab95066154adee0d60b622dbe10/lib/vagrant-parallels/plugin.rb#L101-L104

Overall, this PR looks OK for me now. Please let me know if you want me to merge it and release as is, or do you want to add synced folder implementation via config.pvs?

legal90 commented 1 year ago

@bineesh-n I have created a dummy placeholder class for synced folders for *.macvms: https://github.com/Parallels/vagrant-parallels/pull/448 Could you please try it?

It should fix the issue #445 and it could be used as a starting point for the correct implementation of synced folder for *.macvms (with editing config.pvs, as we discussed above).