Page MenuHomeFreeBSD

bhyve: Implement the libslirp notify callback
ClosedPublic

Authored by markj on Tue, Dec 24, 3:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jan 10, 10:49 AM
Unknown Object (File)
Fri, Jan 10, 4:05 AM
Unknown Object (File)
Fri, Jan 10, 4:05 AM
Unknown Object (File)
Tue, Jan 7, 2:38 PM
Unknown Object (File)
Fri, Jan 3, 7:53 AM
Unknown Object (File)
Wed, Jan 1, 10:12 PM
Unknown Object (File)
Wed, Jan 1, 9:41 PM
Unknown Object (File)
Wed, Jan 1, 9:23 PM
Subscribers

Details

Summary

libslirp can invoke a callback when received data is removed from a
socket buffer, generally because the guest ACKed some data. Previously
it didn't do anything, but it needs to wake up the poll thread to get
reasonable throughput.

Suppose one is using scp to copy data into a guest filesystem via the
slirp backend. Data is received on libslirp's socket, which we poll for
data in slirp_pollfd_td_loop(). That data gets buffered in priv->pipe,
and eventually is placed in the device model's RX rings by the backend's
mevent handler. When implementing TCP, libslirp holds on to a copy of
data until it's ACKed by the guest via slirp_send(), at which point it
drops that data and invokes the notify callback.

The initial implementation of this backend didn't take into account the
fact that slirp_pollfds_fill() will not add libslirp's socket to the
pollfd set if more than a threshold amount of data is already buffered.
Then poll() needs to time out before the backend sends more data to the
guest. With a default timeout of 500ms, this kills throughput.

Use a pipe to implement a simple in-band signal to the poll thread so
that it reacts quickly when more buffer space becomes available.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Tue, Dec 24, 3:39 PM
usr.sbin/bhyve/net_backend_slirp.c
94

So close errors can cause bhyve to die? I know this os copied code, but it's a good time to ask.

373

If errno is eintr, don't you need to rodo the poll?

393

Need to ignore eintr and retry?

usr.sbin/bhyve/net_backend_slirp.c
94

This is closing some internal descriptors; the assertion is basically there to catch programming errors like double-close or so.

373

We'll redo it anyway, libslirp won't do the usual packet processing if error == -1; see the slirp_pollfds_poll_p() call below.

Removing the inner loop just makes this routine a bit simpler.

393

This is a non-blocking read() - is it possible to get EINTR there?

This revision was not accepted when it landed; it landed in state Needs Review.Tue, Jan 7, 2:35 PM
This revision was automatically updated to reflect the committed changes.