Hi, On Wed, Feb 08, 2017 at 11:10:50PM +0100, Samuel Thibault wrote: > Hello, > > Stefan Hajnoczi, on Mon 06 Feb 2017 11:55:05 +0000, wrote: > > I'm proposing this topic for discussion because there might be common > > ground for Samuel from QEMU and the VDE folks to collaborate. > > > > Samuel: Should QEMU join forces with libslirp? > > Well, there are not that many forces from the QEMU side :) Neither on VDE side ;-) but many ants can move mountains... > > - we are using timers for icmp announcements > - qemu needs to be able to save/restore state, with compatibility with > previous versions
libslirp is using qemu's slirp code. If you try a diff between your "slirp" directory and libslirp's "src" directory you'll find that there are only 3 lines added: (at the date of the code extraction, e.g. qemu git's tag 1f8b56e7cebc71d80aec27a4760024b56acc957a) In slirp.h: #include <qemu2libslirp.h> Which includes stubs and specific implementations to give slirp all the stuff provided by qemu's core or other libraries used by qemu. In tcp_subr.c: 400a401,403 > if ((ret = unixtcp_fconnect(so, af)) >= 0) > return ret; which adds a nice feature that IMHO would be useful in qemu, too. unixtcp_fconnect creates a TCP to AF_UNIX socket redirection. The VM running on qemu (or in VDE a VM connected to the virtual net) can redirect a default route port (say 10.0.2.2:6000) to a UNIX socket (say /tmp/.X11-unix/0). In this example X clients using the X display 10.0.2.2:0 can appear on the X server of the host. Timers have been reimplemented using the qemu's API. save/restore are dummy stubs in libslirp. Qemu's code is still there but it is not used by libslirp. In this way we can inherit all bugfixes and new feature from Qemu at almost no cost. It would be a nice project to create a common codebase for libslirp. The project sould be interesting for other VM projects (virtualbox-OSE?) and maybe many others. We could collect several ants... Libslirp/QEMU integration is not so difficult. As a first step: * Qemu could add the UNIX socket redirect feature, or at least a unixtcp_fconnect dummy function returning -1 (#ifndef LIBSLIRP) * #include <qemu2libslirp.h> could be added in slirp.h (inside an #ifdef LIBSLIRP). In this way we could share exactly the same codebase. One further step: * discuss how to reduce/eliminate qemu-specific dependence * create an API for save/restore These are only my two (euro)cents. ciao renzo