ppggff / vagrant-qemu

Use Vagrant to manage machines using QEMU. Test with Apple Silicon / M1 and CentOS aarch64 image
MIT License
408 stars 32 forks source link

Documention on Forwarding Ports is invalid #58

Open darkn3rd opened 1 month ago

darkn3rd commented 1 month ago

The current documentation (README.md) indicates that this functionality currently works, but with Macbook M1 (ARM64) with hvf, this is not working:

config.vm.network "forwarded_port", guest: 80, host: 8080

Please document exactly where this will work and where it does not. If it doesn't work for any solution, including q35 emulators, then maybe document that it doesn't work? Also, if there is a workaround through the qemu tool, then could this workaround be documented?

ppggff commented 1 month ago

It works, and I tested with a simple box:

Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "ppggff/centos-7-aarch64-2009-4K"
  config.vm.network "forwarded_port", guest: 80, host: 8080
end

Port works as following pic:

Screenshot 2024-05-11 at 18 27 39
darkn3rd commented 1 month ago

I am running into problems with blocked ports and SMB. I am not sure how/why SMB is turned on by default.

cat << EOF > Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.box = "ppggff/centos-7-aarch64-2009-4K"
  config.vm.network "forwarded_port", guest: 80, host: 8080
end
EOF

vagrant up --provider=qemu

I also get an issue that port 8080 is already used when I use --debug. But sudo lsof -nP -i4TCP:8080 shows nothing. So I changed the host port to 8081, and re-ran vagrant up --provider=qemu, which yields:

==> 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]):
darkn3rd commented 1 month ago

This seems to work using an alternative image. The the other issues with issue #40 have to deal with private networks and/or multi-machine? I have then some confusion between where this won't work, especially given the message (https://github.com/ppggff/vagrant-qemu/blob/master/locales/en.yml#L18-L21) that is splashed on vagrant up.

  1. Vagrantfile
    Vagrant.configure("2") do |config|
     config.vm.box = "perk/ubuntu-2204-arm64"
     config.vm.network "forwarded_port", guest: 80, host: 8082
     config.vm.provider "qemu" do |qe|
       qe.ssh_port = "50022" # change ssh port as needed
     end
    end
  2. On Guest: sudo python3 -m http.server 80
  3. On Host: curl -is localhost:8082 | head -5 works:
    HTTP/1.0 200 OK
    Server: SimpleHTTP/0.6 Python/3.10.12
    Date: Sun, 12 May 2024 01:11:20 GMT
    Content-type: text/html; charset=utf-8
    Content-Length: 626
darkn3rd commented 1 month ago

If there are scenarios where this should not be expected to work, it would be great to document that. If these are always expected to work, then maybe remove or modify the warning, as the setting was not ignored:

 Warning! The QEMU provider doesn't support any of the Vagrant
 high-level network configurations (`config.vm.network`). They
 will be silently ignored.
ppggff commented 1 month ago

The warning comes from vagrant, I will investigate how to remove it or change it.