lucavallin / barco

Linux containers from scratch in C.
https://lucavall.in
MIT License
1.48k stars 87 forks source link

Is it possible for barco to support WSL2 as well? #3

Open tanyeun opened 1 year ago

tanyeun commented 1 year ago

Great project btw

I was able to compile on WSL2 Distribution: Ubuntu 22.04 Kernel: 5.15.90.1-microsoft-standard-WSL2

but when I ran the example, it gave me to following error: image

lucavallin commented 1 year ago

Hey @tanyeun! Thanks for opening the issue - it's nice to see people are cloning the project and testing it out ;) Unfortunately I don't have a way to test barco on WSL2, but I will add a few labels to the issue to invite contributors to look into the problem and hopefully come up with a solution.

lucavallin commented 1 year ago

Hey @tanyeun! I just noticed the 5.15.90.1-microsoft-standard-WSL2 and I am thinking, is 5.15.90.1 the Linux Kernel version? If so, that might be the issue: I tested barco on version 6.1.0 and it's possible that 5.15.90.1 does not support cgroups v2 by default yet. If possible, you could try and manually enable cgroups v2: it might help!

tanyeun commented 1 year ago

Hi @lucavallin

My default linux kernel version is

5.15.90.1-microsoft-standard-WSL2

But I was not able to load linux modules so I follow the suggestions from this post

https://unix.stackexchange.com/questions/594470/wsl-2-does-not-have-lib-modules

to rebuild the bzImage, now my kernel version is

5.15.123.1-microsoft-standard-WSL2+

I turned on the debug message. The issue was I was not able to create this file

/sys/fs/cgroup/barcontainer

mkdir(cgroup_dir, S_IRUSR | S_IWUSR | S_IXUSR)

although this function call return 0, the actual file didn't create.

I tried to change the path to another folder under my home directory.

the function returns -1 but the acutal file created.

I am not sure why.

lucavallin commented 1 year ago

Hey @tanyeun! I am not entirely sure, but it seems it could be an issue with cgroups in WSL. I found this question on SO that might help: https://stackoverflow.com/questions/73021599/how-to-enable-cgroup-v2-in-wsl2. Let me know how that goes!

yangjinhao1234 commented 1 year ago

have solve this problem? i have the same question. and after i debug, i find barcontainer can be created , but fd = open(setting_dir, O_WRONLY) can be breate, seem like cant create cgroup file in wsl2? can anybody help me ? Or i should find a linux pc

ghost commented 1 year ago

My kerver version is Linux version 5.15.0-83-generic, seems the problem is from WSL2.