This changes allow to build the bare VM. But in order to display graphics, it requires a display plugin, which uses X11 and OpenGL. I tried to build it using xlibe, but the display plugin requires X11/extensions/Xrandr.h which xlibe lacks.
There are two ways to solve this problem:
Either one needs to add Xrandr to xlibe
Or to implement a display plugin which uses native Haiku API
But I have no experience with neither X11 nor Be API. So I would appreciate some help or at least suggestions.
Reading the source code, it appears Xrandr is optional; it compiles against it but can fall back on other things at runtime if it’s not present. So, you should be able to add some modifications to allow compiling without it, either.
I won’t be too surprised if you run into other missing Xlibe functionality, though, after you get it to build. Let me know if you do and I’ll take a look.
With GDB I finally know where VM stalls. Here, inside recv call:
/* answer 1 if the given socket is readable,
0 if read would block, or
-1 if the socket is no longer connected */
static int
socketReadable(int s)
{
char buf[1];
int n = recv(s, (void *)buf, 1, MSG_PEEK);
if (n > 0) return 1;
if ((n < 0) && (errno == EWOULDBLOCK)) return 0;
return -1; /* EOF */
}
It seems like this function is not supposed to block and yet it blocks. I don’t know why yet.
Haiku’s activity report mentions that MSG_PEEK could cause a hang:
waddlesplash (in a series of commits scattered across the month) refactored the handling of the flags parameter of send/sendmsg and recv/recvmsg inside the network stack. Initially, this was done to fix test failures and hangs in some programs using UNIX domain sockets which passed flags that altered behavior (like MSG_PEEK) but which were not actually handled by the UNIX domain sockets implementation; the initial change just made EOPNOTSUPP be returned when unhandled flags were specified. This, however, wound up uncovering that some applications (including curl) had been passing some (relatively unimportant) unsupported flags, leading to some of those being first implemented in the UNIX domain sockets module, but eventually led to refactoring in the main network sockets module and a variety of flags logic being consolidated there rather than implemented uniquely by every socket module (TCP, UDP, etc.) A number of minor bugs in the implementation of such flags were corrected along the way, along with various code cleanups done to the socket module and others (old FIFO templates code, etc.)
If the socket is supposed to be non-blocking, you’ll have to go back to where it was set up that way. and figure out what went wrong.
If it’s supposed to block, except for the recv() in socketReadable(), then you might try MSG_PEEK|MSG_DONTWAIT.
This seems funky to me. If it can be made to work, no real problem, but if it continues to give you trouble, it might be worth the time to look into how this is normally done with poll() or select().
All of those options are related to POSIX AIO (which sends signals to processes when I/O is available), which we indeed do not support. Does this VM really depend on POSIX AIO? If it doesn’t, then it should just set O_NONBLOCK without O_ASYNC.