AsahiLinux / muvm

muvm - run programs from your system in a microVM
403 stars 23 forks source link

Listening ports of application not exposed to host #100

Open tiehfood opened 3 weeks ago

tiehfood commented 3 weeks ago

I finally managed to set up muvm inside an LXC container. But running my application inside muvm doesn't expose any of the ports the application is listening on to the container host.

ss inside muvm:

tcp          LISTEN        0             10                         0.0.0.0:9332                     0.0.0.0:*           users:(("application",pid=317,fd=216))          
tcp          LISTEN        0             10                         0.0.0.0:9331                     0.0.0.0:*           users:(("application",pid=317,fd=213))          
tcp          LISTEN        0             100                        0.0.0.0:9330                     0.0.0.0:*           users:(("application",pid=317,fd=146))          
tcp          LISTEN        0             10                         0.0.0.0:9200                     0.0.0.0:*           users:(("application",pid=367,fd=86))           
tcp          LISTEN        0             10                         0.0.0.0:9150                     0.0.0.0:*           users:(("application",pid=317,fd=210))          
tcp          LISTEN        0             4096                     127.0.0.1:33635                    0.0.0.0:*           users:(("application",pid=292,fd=48))           
tcp          LISTEN        0             1024                       0.0.0.0:3334                     0.0.0.0:*           users:(("muvm-server",pid=244,fd=9))        
tcp          LISTEN        0             4096                     127.0.0.1:9004                     0.0.0.0:*           users:(("application",pid=367,fd=48))           
tcp          LISTEN        0             100                        0.0.0.0:55000                    0.0.0.0:*           users:(("application",pid=317,fd=150)) 

ss on the container:

tcp              LISTEN            0                  128                                   0.0.0.0:3334                              0.0.0.0:*                users:(("passt",pid=361,fd=7))                       
tcp              LISTEN            0                  4096                            127.0.0.53%lo:53                                0.0.0.0:*                users:(("systemd-resolve",pid=181,fd=14))            
tcp              LISTEN            0                  32                              192.168.122.1:53                                0.0.0.0:*                users:(("dnsmasq",pid=305,fd=6))                     
tcp              LISTEN            0                  4096                               127.0.0.54:53                                0.0.0.0:*                users:(("systemd-resolve",pid=181,fd=16))    

also the /etc/resolf.conf is empty inside muvm

The only debug log I get from muvm is:

[2024-11-04T15:42:36Z DEBUG muvm::guest::net] dhcpcd output output=Output { status: ExitStatus(unix_wait_status(0)), stdout: "", stderr: "dhcpcd-10.0.6 starting\nmkdir: cannot create directory '/var/lib/ntp': Permission denied\nDropped protocol specifier '.link' from 'eth0.link'. Using 'eth0' (ifindex=2).\nsd_bus_open_system: No such file or directory\nmkdir: cannot create directory '/var/lib/ntp': Permission denied\neth0: waiting for carrier\neth0: carrier acquired\nmkdir: cannot create directory '/var/lib/ntp': Permission denied\nduid_get: cannot write duid: Permission denied\nDUID 00:03:00:01:5a:94:ef:e4:0c:ee\neth0: IAID ef:e4:0c:ee\neth0: soliciting a DHCP lease\neth0: offered 192.168.88.8 from 192.168.88.1\neth0: probing address 192.168.88.8/24\neth0: leased 192.168.88.8 for infinity\ndhcp_writefile: /var/lib/dhcpcd/eth0.lease: Permission denied\neth0: adding route to 192.168.88.0/24\neth0: adding default route via 192.168.88.1\nDropped protocol specifier '.dhcp' from 'eth0.dhcp'. Using 'eth0' (ifindex=2).\nsd_bus_open_system: No such file or directory\nmkdir: cannot create directory '/var/lib/ntp': Permission denied\n" }
[2024-11-04T15:42:36Z DEBUG muvm_guest] exec command="/home/test/.cargo/bin/muvm-server" command_args=["bash"]
teohhanhui commented 3 weeks ago

@tiehfood Please try with dhclient. See #77

tiehfood commented 3 weeks ago

I will try it, thanks. Could someone explain a bit more the network setup of the VM? How is routing done. Does e.g. MDNs work from services running on the VM?

If I want to forward all ports of the VM to the host, is the right way to set the TCP and UDP port options of passt to "all"?

tiehfood commented 3 weeks ago

I'm running muvm from ubuntu. I swapped dhcpcd with dhclient but not get this error: [2024-11-06T16:56:12Z DEBUG muvm::guest::net] dhclient output output=Output { status: ExitStatus(unix_wait_status(0)), stdout: "", stderr: "System has not been booted with systemd as init system (PID 1). Can't operate.\nFailed to connect to bus: Host is down\n" }