Hello, I am trying to run a program in lkvm sandbox so that it communicates with a program on host. I run lkvm as: ./lkvm sandbox --disk sandbox-test --mem=2048 --cpus=4 --kernel /arch/x86/boot/bzImage --network mode=user -- /my_prog /my_prog then connects to a program on host over a tcp socket. I see that host receives some data, sends some data back, but then my_prog hangs on network read. To localize this I wrote 2 programs (attached). ping is run on host and pong is run from lkvm sandbox. They successfully establish tcp connection, but after some iterations both hang on read. Networking code in Go runtime is there for more than 3 years, widely used in production and does not have any known bugs. However, it uses epoll edge-triggered readiness notifications that known to be tricky. Is it possible that lkvm contains some networking bug? Can it be related to the data races in lkvm I reported earlier today? I am on commit 3695adeb227813d96d9c41850703fb53a23845eb. Thank you
package main import ( "log" "net" ) func main() { c, err := net.Dial("tcp", "192.168.33.1:39921") if err != nil { log.Fatalf("failed to dial: %v", err) } log.Printf("connected") for { var buf [1]byte n, err := c.Write(buf[:]) if err != nil || n != 1 { log.Fatalf("failed to write: %v", err) } log.Printf("write") n, err = c.Read(buf[:]) if err != nil || n != 1 { log.Fatalf("failed to read: %v", err) } log.Printf("read") } }
package main import ( "log" "net" ) func main() { ln, err := net.Listen("tcp", "127.0.0.1:39921") if err != nil { log.Fatalf("failed to listen: %v", err) } log.Printf("listening") c, err := ln.Accept() if err != nil { log.Fatalf("failed to accept: %v", err) } log.Printf("connected") for { var buf [1]byte n, err := c.Read(buf[:]) if err != nil || n != 1 { log.Fatalf("failed to read: %v", err) } log.Printf("read") n, err = c.Write(buf[:]) if err != nil || n != 1 { log.Fatalf("failed to write: %v", err) } log.Printf("write") } }