qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running server from within qemu


From: தாசெ ௩
Subject: Re: Running server from within qemu
Date: Tue, 18 Oct 2022 06:04:54 +0530

Hi Alex,

I tried what you suggested.  I have some observations.  

Before going into that that:
 
The file /etc/config/network within my OpenWRT has:

config interface 'loopback'
option device 'io'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'

config globals 'globals'
option url_prefix 'fd0d:5e50:c550::/40'

config device
option name 'br-lan'
option type 'bridge'
list ports 'eth0'

config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.0.201'
option netmask '255.255.255.0'
option ip6assign '60'

config interface 'wan'
option device 'eth1'
option proto 'dhcp'

config interface 'wan6'
option device 'eth1'
option proto 'dhcpv6'

Q: Do I need to make any chsnges in the above file and try?  
Note: I actually tried changing the confirmation of 'br-lan' as 'dhcp' and removing ipaddr, netmask and ip6assign, but no major change in the overall behaviour.

Without applying the change '-netdev.....' suggested by you and with having two '-nic user', which you pointed out, when I ran 'ifconfig', I got:
br-lan   Link encap:Whether......
              inet address:192.168.0.201 ..
              :
eth0        Link encap:Whether......
                /*no inet addr*/
                 :
eth1         Link encap:Whether......
                 inet addr:10.0.2.15..
                  :
lo               Link encap:Local Loopback
                 inet addr:127.0.0.1..
                 :
With this configuration I am able to access host-network & internet from within OpenWRT running on QEMU.  But, this is the same configuration where I couldn't hit the http server running on port 8000 within OpenWRT from the host OS, which is the issue which I mentioned in my first email.  FYI, from the host OS, I was trying to hit http://192.168.0.201:8000 . The IP address of my host OS is 192.168.0.101

Before trying your suggestion, I just thought of reloading qemu with just a single '-nic user' and when I ran 'ifconfig' within OpenWRT, I got the following: (see, eth1 is missing)

br-lan   Link encap:Whether......
              inet address:192.168.0.201 ..
              :
eth0        Link encap:Whether......
                /*no inet addr*/
                 :
lo               Link encap:Local Loopback
                 inet addr:127.0.0.1..
                 :

And I couldn't hit any of the external servers from within army/OpenWRT and hitting http://192.168.0.201:8000 from host OS also failed.

Now, I tried the option you suggested as '-netdev user,id=unet,hostfwd=tcp::9000-:8000 -device virtio-net-pci,netdev=unet' alone (without any '-nic user's) so that I can try hitting http://192.168.0.201:9000 from host OS.  After loading OpenWRT on QEMU, I tried 'ifconfig' and I got:
br-lan   Link encap:Whether......
              inet address:192.168.0.201 ..
              :
eth0        Link encap:Whether......
                /*no inet addr*/
                 :
lo               Link encap:Local Loopback
                 inet addr:127.0.0.1..
                 :

Which is very similar to the previous case

Here also, I couldn't hit any of the external servers from within army/OpenWRT and hitting http://192.168.0.201:9000 from host OS also failed.  Hitting http://192.168.0.101:9000 also failed.

Am I missing anything?

On Mon, Oct 17, 2022, 10:57 PM Alex Bennée <alex.bennee@linaro.org> wrote:

தாசெ ௩ <paxi.three@gmail.com> writes:

> Hi,
>
> I am new to using QEMU.  Is it possible to host a simple http/tcp server on a Linux which is running on qemu, without any
> accompanying vm (KVM), and hit that http server from the host OS (say Windows)? What options should I choose in army
> (command line args) to run any TCP based server from within qemu?
>
> As of now I use the following to start my OpenWRT Linux on QEMU:
> $ qemu-sysyem-arm -M vert-2.9 -kernel openwrt-22.03.1-armvirt-32-zImage -no-reboot -nographic -drive
> file=openwrt-32-rootfs-ext4.img,if=virtio,format=raw -append "root=/dev/vda" -m 1G -nic user -nic user
>

You have two nics in the command line. Anyway using a proper split
-netdev/-device specification:

  -netdev user,id=unet,hostfwd=tcp::2222-:22 -device virtio-net-pci,netdev=unet

which in this case forwards tcp port 2222 on the host to port 22 on the
guest. Just don't expect brilliant performance.


> Thankyou


--
Alex Bennée

reply via email to

[Prev in Thread] Current Thread [Next in Thread]