Hi Stefano

I think we'll need a more complex solution [1] (unless someone else has a better patch).

Here [1] you can find a version of kata-runtime that supports all namespaces (yes, including mnt namespace!!) unlike upstream kata-runtime

Since you want to use it for testing net ns, I just enabled it, but if you need other namespace, just uncomment it out from the list [2]

I only tested v1 (no netmom, no vmtemplating) with docker

let me know if it works for you

[1] - https://github.com/devimc/kata-runtime/tree/nodelete/namespaces
[2] - https://github.com/devimc/kata-runtime/blob/556f11ec6e8a5f98973b9023f1746888f5b69725/pkg/katautils/main.c#L117-L126


From: Stefano Garzarella <sgarzare@redhat.com>
Sent: Tuesday, December 17, 2019 6:47 AM
To: Montes, Julio <julio.montes@intel.com>
Cc: Boeuf, Sebastien <sebastien.boeuf@intel.com>; kata-dev@lists.katacontainers.io <kata-dev@lists.katacontainers.io>; Peng Tao <tao.peng@linux.alibaba.com>
Subject: Re: [kata-dev] vsock & network namespaces in Kata
 
Hi Julio,

On Mon, Dec 16, 2019 at 09:51:56PM +0000, Montes, Julio wrote:
> Hi Stefano
>
> This patch [1] moves the runtime to the sandbox's (qemu) net namespace.
> This patch is a hotfix that should be used only for testing

Thanks for the patch!

I tried it, but I have the same behaviour (v1 doesn't work, v2 works).

I did a minimal debugging with the old vsock modules, where v1 works well,
checking the netns:
$ ip netns
cnitest-3c2d7774-b4e1-1901-6c8a-fb20b857898b (id: 0)
$ ip netns pids cnitest-3c2d7774-b4e1-1901-6c8a-fb20b857898b
1343
1357
$ ps -p 1357 1343
  PID TTY      STAT   TIME COMMAND
 1343 ?        Sl     0:21 /usr/bin/qemu-vanilla-system-x86_64 -name sandbox-b00b4ff14f15714027d76221d316ad778cfda3cb5e104421c5942c2e04adc752 -uuid 1cee59f0-ff07-4602-af2e-d25962de412f -machine pc,accel=kvm,kernel_irqchip,nvdimm -cpu host,pmu=off -qmp unix:/run/vc/vm/b00b4ff14f15714027d76221d316ad778cfda3cb5e104421c5942c2e04adc752/qmp.sock,server,nowait -m 2048M,slots=10,maxmem=8979M -device pci-bridge,bus=pci.0,id=pci-bridge-0,chassis_nr=1,shpc=on,addr=2,romfile= -device virtio-serial-pci,disable-modern=true,id=serial0,romfile= -device virtconsole,chardev=charconsole0,id=console0 -chardev socket,id=charconsole0,path=/run/vc/vm/b00b4ff14f15714027d76221d316ad778cfda3cb5e104421c5942c2e04adc752/console.sock,server,nowait -device nvdimm,id=nv0,memdev=mem0 -object memory-backend-file,id=mem0,mem-path=/usr/share/kata-containers/kata-containers-image_clearlinux_1.10.0-alpha1_agent_c87f497312.img,size=134217728 -device virtio-scsi-pci,id=scsi0,disable-modern=true,romfile= -object rng-random,id=rng0,filename=/dev/urandom -device virtio-rng,rng=rng0,romfile= -device vhost-vsock-pci,disable-modern=true,vhostfd=3,id=vsock-1011671291,guest-cid=1011671291,romfile= -device virtio-9p-pci,disable-modern=true,fsdev=extra-9p-kataShared,mount_tag=kataShared,romfile= -fsdev local,id=extra-9p-kataShared,path=/run/kata-containers/shared/sandboxes/b00b4ff14f15714027d76221d316ad778cfda3cb5e104421c5942c2e04adc752,security_model=none -netdev tap,id=network-0,vhost=on,vhostfds=4,fds=5 -device driver=virtio-net-pci,netdev=network-0,mac=02:42:ac:11:00:02,disable-modern=true,mq=on,vectors=4,romfile= -global kvm-pit.lost_tick_policy=discard -vga none -no-user-config -nodefaults -nographic -daemonize -object memory-backend-ram,id=dimm1,size=2048M -numa node,memdev=dimm1 -kernel /usr/share/kata-containers/vmlinuz-4.19.75.55-59.1.container -append tsc=reliable no_timer_check rcupdate.rcu_expedited=1 i8042.direct=1 i8042.dumbkbd=1 i8042.nopnp=1 i8042.noaux=1 noreplace-smp reboot=k console=hvc0 console=hvc1 iommu=off cryptomgr.notests net.ifnames=0 pci=lastbus=0 root=/dev/pmem0p1 rootflags=dax,data=ordered,errors=remount-ro ro rootfstype=ext4 quiet systemd.show_status=false panic=1 nr_cpus=4 agent.use_vsock=true systemd.unit=kata-containers.target systemd.mask=systemd-networkd.service systemd.mask=systemd-networkd.socket -pidfile /run/vc/vm/b00b4ff14f15714027d76221d316ad778cfda3cb5e104421c5942c2e04adc752/pid -smp 1,cores=1,threads=1,sockets=4,maxcpus=4
 1357 pts/2    Ssl+   0:00 /usr/libexec/kata-containers/kata-shim -agent vsock://1011671291:1024 -container b00b4ff14f15714027d76221d316ad778cfda3cb5e104421c5942c2e04adc752 -exec-id b00b4ff14f15714027d76221d316ad778cfda3cb5e104421c5942c2e04adc752 -terminal

It seems that only qemu and kata-shim are in the same netns.
Maybe I did something wrong, can you double check?

If you want, I can provide you a Fedora VM with new vsock kernel
modules.

Thanks,
Stefano