Closed jayunit100 closed 11 months ago
The '-' comes from qemu's doc:
[cp|udp]:[hostaddr]:hostport-[guestaddr]:guestport]
(https://man.archlinux.org/man/qemu.1.en#hostfwd=_tcp_udp_:_hostaddr_:hostport)
Redirect incoming TCP or UDP connections to the host port hostport to the guest IP address guestaddr on guest port guestport. If guestaddr is not specified, its value is x.x.x.15 (default first address given by the built-in DHCP server). By specifying hostaddr, the rule can be bound to a specific host interface. If no connection type is set, TCP is used. This option can be given multiple times.
I thinks there is a bug when 127.0.0.1
appears...
Please provide the original Vagrantfile for debug
Thanks! Ok the Vagrantfile branch is https://github.com/kubernetes-sigs/sig-windows-dev-tools branch "master-qemu"
I did some playing around and I guess with or without the dash.... I would get different errors.
When looking at the generated portfwd directive to qemu they seemed identical....
It wasn't obvious to me wether dashes are expected or not so I couldn't figure it out.
trying the experiment of removing 127.0.0.1 from the Vagrantfile... will post what happens
Thanks again @ppggff ! I posted the Vagrantfile and Error message at the top of this issue.
trying the experiment of removing 127.0.0.1 from the Vagrantfile... will post what happens
From the log error, it seemed the hostfwd
syntax was wrong.
Below is part of my Vagrantfile, which works well. You can take a try.
Vagrant.configure("2") do |config|
config.vm.provider "qemu" do |qe|
...
qe.extra_netdev_args = "net=192.168.51.0/24,dhcpstart=192.168.51.10,hostfwd=tcp:127.0.0.1:6443-:6443"
...
end
end
The bug is in this provider code that is generating the QEMU hostfwd
entries at:
https://github.com/ppggff/vagrant-qemu/blob/v0.3.4/lib/vagrant-qemu/action/start_instance.rb#L48-L52
From the QEMU documentation, the syntax is:
hostfwd=[tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport
But this provider ends up calling qemu with an extra :
character after hostaddr
:
qemu-system-x86_64: -netdev user,id=net0,hostfwd=tcp::50022-:22,hostfwd=tcp:127.0.0.1::55985-:5985,hostfwd=tcp:127.0.0.1::55986-:5986: Invalid host forwarding rule 'tcp:127.0.0.1::55986-:5986' (Bad host port)
BTW, those networks/ports are there because vagrant creates them automatically at:
https://github.com/hashicorp/vagrant/blob/v2.3.7/plugins/kernel_v2/config/vm.rb#L575-L593
Until this is fixed, the following workaround should work:
Vagrant.configure(2) do |config|
...
config.vm.provider 'qemu' do |qe, config|
...
# XXX this is required to prevent the bug described at https://github.com/ppggff/vagrant-qemu/issues/39
# see https://github.com/ppggff/vagrant-qemu/blob/v0.3.4/lib/vagrant-qemu/action/start_instance.rb#L48-L52
# see https://github.com/hashicorp/vagrant/blob/v2.3.7/plugins/kernel_v2/config/vm.rb#L575-L593
# NB "disabled: true" is used by the vagrant-qemu plugin, but will be
# ignored by vagrant itself, which means that network will still be
# used by the vagrant winrm communicator.
config.vm.network 'forwarded_port', id: 'winrm', host_ip: '127.0.0.1', host: 55985, guest: 5985, auto_correct: true, disabled: true
config.vm.network 'forwarded_port', id: 'winrm-ssl', host_ip: '127.0.0.1', host: 55986, guest: 5986, auto_correct: true, disabled: true
qe.extra_netdev_args = 'hostfwd=tcp:127.0.0.1:55985-:5985'
...
Am finding it tricky to forward ports properly... getting this message
Vagrant file and Error message are pasted below for simplifying the repro of this issue...
Error:
And the exact error message happens here:
Vagrantfile:
Original issue
Update: maybe theres an issue when we setup hostfwd w/ 127.0.0.1 being explicitly in the url... 127.0.0.1 ... am investigating further....
Looks like in lib/vagrant-qemu/driver.rb ... there's a line that always adds
-
to the end of hostfwd port 22.Somewhere after this some generated statement is invalid .....
is that necessary or required ? it seems to work but subsequent port fwd commands fail and I'm not sure why. In windows we want to fwd the winrm as well as ssh ports so there are 3 or maybe more hostfwd entries....... the final one qemu complains is invalid
example 1
if i do
then i get a message that
55985-:5985
is invalid... but i didnt specify that-
... where does it come from ?example 2
In general this seems to be injected in all of them...
i see an error message with port ranges injected into them.... which break qemu.....