Issue
Was wondering if such a thing is possible: I have a server listening on localhost:1889
of my local PC and my QEMU image is able to access the server using the same port and IP - localhost:1889
.
Really looking any one of the following solutions:-
- A QEMU flag to enable this. This is what my current command looks like:
qemu-system-aarch64 -nographic -machine virt,gic-version=max -m 2058M -cpu cortex-a57 \
-netdev user,id=net0,net=192.168.76.0/24 \
-device virtio-net-pci,netdev=net0 \
-drive file=ubuntu-image.img,if=none,id=drive0,cache=writeback \
-device virtio-blk,drive=drive0,bootindex=0 \
-drive file=flash0.img,format=raw,if=pflash -drive file=flash1.img,format=raw,if=pflash
- A chain of iptables - though would avoid it.
Solution
A QEMU image running the 'user-mode' networking (as in your command line example) already has access to the host machine. It can access it either via any (non-loopback) IP address the host has, or by using the special 'gateway' IP address. If you're using the default 10.0.2.0/24 network setting then the 'gateway' is 10.0.2.2. I haven't confirmed but suspect that for a non-default net setting it will still be on .2, so in this example 192.168.76.2.
You cannot literally make 'localhost' in the guest point to the host PC, because 'localhost' for the guest is the guest itself, and having it point somewhere else would likely confuse software running in the guest.
Answered By - Peter Maydell
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.