Skip to contentSkip to conversation

Make it a standalone project

PATCH In review [email protected] 4 participants 17 messages Feb 8, 2019 – Feb 10, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Make it a standalone project

From: Marc-André Lureau <[email protected]>

Hi,

As discussed earlier in "[PATCH for-3.2 00/41] RFC: slirp: make it again a standalone project" and other threads, it would be useful to make slirp a separate project (the submodule approach was discarded) for various projects to share.

The first patch describes how to filter the qemu repository for the slirp/ content, and initial layout.

The following patches add meson build system (if necessary for older distros, autotools could be added - however I believe python & ninja are generally available on the QEMU supported platforms)

Finally, to be able to provide migration handling (currently handled by QEMU), I ported a subset of the QEMU state saving/loading code in "slirp: add state saving/loading" and added some slirp API.

Where should this new project be hosted? (I suggest some gitlab instance, because of the nice ui/CI/issues/milestone...)

thanks

Marc-André Lureau (5):
Extract slirp/ from qemu repository
build-sys: add a meson build
build-sys: add version tooling
slirp: add state saving/loading
Add .gitlab-ci.yml

 .gitlab-ci.yml                   |  20 ++
 Makefile.objs                    |  34 ---
 meson.build                      | 127 ++++++++++
 arp_table.c => src/arp_table.c   |   0
 bootp.c => src/bootp.c           |   0
 bootp.h => src/bootp.h           |   0
 cksum.c => src/cksum.c           |   0
 debug.h => src/debug.h           |   0
 dhcpv6.c => src/dhcpv6.c         |   0
 dhcpv6.h => src/dhcpv6.h         |   0
 dnssearch.c => src/dnssearch.c   |   0
 if.c => src/if.c                 |   0
 if.h => src/if.h                 |   0
 ip.h => src/ip.h                 |   0
 ip6.h => src/ip6.h               |   0
 ip6_icmp.c => src/ip6_icmp.c     |   0
 ip6_icmp.h => src/ip6_icmp.h     |   0
 ip6_input.c => src/ip6_input.c   |   0
 ip6_output.c => src/ip6_output.c |   0
 ip_icmp.c => src/ip_icmp.c       |   0
 ip_icmp.h => src/ip_icmp.h       |   0
 ip_input.c => src/ip_input.c     |   0
 ip_output.c => src/ip_output.c   |   0
 src/libslirp-version.h.in        |  22 ++
 libslirp.h => src/libslirp.h     |  13 +
 src/libslirp.map                 |  21 ++
 main.h => src/main.h             |   0
 mbuf.c => src/mbuf.c             |   0
 mbuf.h => src/mbuf.h             |   0
 misc.c => src/misc.c             |   0
 misc.h => src/misc.h             |   0
 ncsi-pkt.h => src/ncsi-pkt.h     |   0
 ncsi.c => src/ncsi.c             |   0
 ndp_table.c => src/ndp_table.c   |   0
 qtailq.h => src/qtailq.h         |   0
 sbuf.c => src/sbuf.c             |   0
 sbuf.h => src/sbuf.h             |   0
 slirp.c => src/slirp.c           |   9 -
 slirp.h => src/slirp.h           |   0
 socket.c => src/socket.c         |   0
 socket.h => src/socket.h         |   0
 state.c => src/state.c           |  50 ++--
 src/state.h                      |   0
 src/stream.c                     | 119 +++++++++
 src/stream.h                     |  34 +++
 tcp.h => src/tcp.h               |   0
 tcp_input.c => src/tcp_input.c   |   0
 tcp_output.c => src/tcp_output.c |   0
 tcp_subr.c => src/tcp_subr.c     |   0
 tcp_timer.c => src/tcp_timer.c   |   0
 tcp_timer.h => src/tcp_timer.h   |   0
 tcp_var.h => src/tcp_var.h       |   0
 tcpip.h => src/tcpip.h           |   0
 tftp.c => src/tftp.c             |   0
 tftp.h => src/tftp.h             |   0
 udp.c => src/udp.c               |   0
 udp.h => src/udp.h               |   0
 udp6.c => src/udp6.c             |   0
 util.c => src/util.c             |   0
 util.h => src/util.h             |   3 +
 src/version.c                    |  33 +++
 src/vmstate.c                    | 401 +++++++++++++++++++++++++++++++
 src/vmstate.h                    | 396 ++++++++++++++++++++++++++++++
 state.h                          |   9 -
 64 files changed, 1211 insertions(+), 80 deletions(-)
 create mode 100644 .gitlab-ci.yml
 delete mode 100644 Makefile.objs
 create mode 100644 meson.build
 rename arp_table.c => src/arp_table.c (100%)
 rename bootp.c => src/bootp.c (100%)
 rename bootp.h => src/bootp.h (100%)
 rename cksum.c => src/cksum.c (100%)
 rename debug.h => src/debug.h (100%)
 rename dhcpv6.c => src/dhcpv6.c (100%)
 rename dhcpv6.h => src/dhcpv6.h (100%)
 rename dnssearch.c => src/dnssearch.c (100%)
 rename if.c => src/if.c (100%)
 rename if.h => src/if.h (100%)
 rename ip.h => src/ip.h (100%)
 rename ip6.h => src/ip6.h (100%)
 rename ip6_icmp.c => src/ip6_icmp.c (100%)
 rename ip6_icmp.h => src/ip6_icmp.h (100%)
 rename ip6_input.c => src/ip6_input.c (100%)
 rename ip6_output.c => src/ip6_output.c (100%)
 rename ip_icmp.c => src/ip_icmp.c (100%)
 rename ip_icmp.h => src/ip_icmp.h (100%)
 rename ip_input.c => src/ip_input.c (100%)
 rename ip_output.c => src/ip_output.c (100%)
 create mode 100644 src/libslirp-version.h.in
 rename libslirp.h => src/libslirp.h (91%)
 create mode 100644 src/libslirp.map
 rename main.h => src/main.h (100%)
 rename mbuf.c => src/mbuf.c (100%)
 rename mbuf.h => src/mbuf.h (100%)
 rename misc.c => src/misc.c (100%)
 rename misc.h => src/misc.h (100%)
 rename ncsi-pkt.h => src/ncsi-pkt.h (100%)
 rename ncsi.c => src/ncsi.c (100%)
 rename ndp_table.c => src/ndp_table.c (100%)
 rename qtailq.h => src/qtailq.h (100%)
 rename sbuf.c => src/sbuf.c (100%)
 rename sbuf.h => src/sbuf.h (100%)
 rename slirp.c => src/slirp.c (99%)
 rename slirp.h => src/slirp.h (100%)
 rename socket.c => src/socket.c (100%)
 rename socket.h => src/socket.h (100%)
 rename state.c => src/state.c (93%)
 create mode 100644 src/state.h
 create mode 100644 src/stream.c
 create mode 100644 src/stream.h
 rename tcp.h => src/tcp.h (100%)
 rename tcp_input.c => src/tcp_input.c (100%)
 rename tcp_output.c => src/tcp_output.c (100%)
 rename tcp_subr.c => src/tcp_subr.c (100%)
 rename tcp_timer.c => src/tcp_timer.c (100%)
 rename tcp_timer.h => src/tcp_timer.h (100%)
 rename tcp_var.h => src/tcp_var.h (100%)
 rename tcpip.h => src/tcpip.h (100%)
 rename tftp.c => src/tftp.c (100%)
 rename tftp.h => src/tftp.h (100%)
 rename udp.c => src/udp.c (100%)
 rename udp.h => src/udp.h (100%)
 rename udp6.c => src/udp6.c (100%)
 rename util.c => src/util.c (100%)
 rename util.h => src/util.h (98%)
 create mode 100644 src/version.c
 create mode 100644 src/vmstate.c
 create mode 100644 src/vmstate.h
 delete mode 100644 state.h
Signature · 1 line
2.21.0.rc0.1.g036caf7885
#1 lore raw

PATCH 1/5 Extract slirp/ from qemu repository

From: Marc-André Lureau <[email protected]>

$ git filter-branch --tree-filter "git ls-files '*.c' '*.h' | xargs
clang-format -i" -f --subdirectory-filter "slirp" --prune-empty
--tag-name-filter cat -- --all
$ git rm Makefiles.objs
$ mkdir src && git mv *.c *.h src/
$ git tag --no-merged | xargs git tag -d
$ git reflog expire --expire=now --all
$ git gc --prune=now --aggressive

This results in a 1.3M repostory with the tags, previewed here:
https://gitlab.freedesktop.org/elmarco/slirp

---
 Makefile.objs                    | 34 --------------------------------
 arp_table.c => src/arp_table.c   |  0
 bootp.c => src/bootp.c           |  0
 bootp.h => src/bootp.h           |  0
 cksum.c => src/cksum.c           |  0
 debug.h => src/debug.h           |  0
 dhcpv6.c => src/dhcpv6.c         |  0
 dhcpv6.h => src/dhcpv6.h         |  0
 dnssearch.c => src/dnssearch.c   |  0
 if.c => src/if.c                 |  0
 if.h => src/if.h                 |  0
 ip.h => src/ip.h                 |  0
 ip6.h => src/ip6.h               |  0
 ip6_icmp.c => src/ip6_icmp.c     |  0
 ip6_icmp.h => src/ip6_icmp.h     |  0
 ip6_input.c => src/ip6_input.c   |  0
 ip6_output.c => src/ip6_output.c |  0
 ip_icmp.c => src/ip_icmp.c       |  0
 ip_icmp.h => src/ip_icmp.h       |  0
 ip_input.c => src/ip_input.c     |  0
 ip_output.c => src/ip_output.c   |  0
 libslirp.h => src/libslirp.h     |  0
 main.h => src/main.h             |  0
 mbuf.c => src/mbuf.c             |  0
 mbuf.h => src/mbuf.h             |  0
 misc.c => src/misc.c             |  0
 misc.h => src/misc.h             |  0
 ncsi-pkt.h => src/ncsi-pkt.h     |  0
 ncsi.c => src/ncsi.c             |  0
 ndp_table.c => src/ndp_table.c   |  0
 qtailq.h => src/qtailq.h         |  0
 sbuf.c => src/sbuf.c             |  0
 sbuf.h => src/sbuf.h             |  0
 slirp.c => src/slirp.c           |  0
 slirp.h => src/slirp.h           |  0
 socket.c => src/socket.c         |  0
 socket.h => src/socket.h         |  0
 state.c => src/state.c           |  0
 state.h => src/state.h           |  0
 tcp.h => src/tcp.h               |  0
 tcp_input.c => src/tcp_input.c   |  0
 tcp_output.c => src/tcp_output.c |  0
 tcp_subr.c => src/tcp_subr.c     |  0
 tcp_timer.c => src/tcp_timer.c   |  0
 tcp_timer.h => src/tcp_timer.h   |  0
 tcp_var.h => src/tcp_var.h       |  0
 tcpip.h => src/tcpip.h           |  0
 tftp.c => src/tftp.c             |  0
 tftp.h => src/tftp.h             |  0
 udp.c => src/udp.c               |  0
 udp.h => src/udp.h               |  0
 udp6.c => src/udp6.c             |  0
 util.c => src/util.c             |  0
 util.h => src/util.h             |  0
 54 files changed, 34 deletions(-)
 delete mode 100644 Makefile.objs
 rename arp_table.c => src/arp_table.c (100%)
 rename bootp.c => src/bootp.c (100%)
 rename bootp.h => src/bootp.h (100%)
 rename cksum.c => src/cksum.c (100%)
 rename debug.h => src/debug.h (100%)
 rename dhcpv6.c => src/dhcpv6.c (100%)
 rename dhcpv6.h => src/dhcpv6.h (100%)
 rename dnssearch.c => src/dnssearch.c (100%)
 rename if.c => src/if.c (100%)
 rename if.h => src/if.h (100%)
 rename ip.h => src/ip.h (100%)
 rename ip6.h => src/ip6.h (100%)
 rename ip6_icmp.c => src/ip6_icmp.c (100%)
 rename ip6_icmp.h => src/ip6_icmp.h (100%)
 rename ip6_input.c => src/ip6_input.c (100%)
 rename ip6_output.c => src/ip6_output.c (100%)
 rename ip_icmp.c => src/ip_icmp.c (100%)
 rename ip_icmp.h => src/ip_icmp.h (100%)
 rename ip_input.c => src/ip_input.c (100%)
 rename ip_output.c => src/ip_output.c (100%)
 rename libslirp.h => src/libslirp.h (100%)
 rename main.h => src/main.h (100%)
 rename mbuf.c => src/mbuf.c (100%)
 rename mbuf.h => src/mbuf.h (100%)
 rename misc.c => src/misc.c (100%)
 rename misc.h => src/misc.h (100%)
 rename ncsi-pkt.h => src/ncsi-pkt.h (100%)
 rename ncsi.c => src/ncsi.c (100%)
 rename ndp_table.c => src/ndp_table.c (100%)
 rename qtailq.h => src/qtailq.h (100%)
 rename sbuf.c => src/sbuf.c (100%)
 rename sbuf.h => src/sbuf.h (100%)
 rename slirp.c => src/slirp.c (100%)
 rename slirp.h => src/slirp.h (100%)
 rename socket.c => src/socket.c (100%)
 rename socket.h => src/socket.h (100%)
 rename state.c => src/state.c (100%)
 rename state.h => src/state.h (100%)
 rename tcp.h => src/tcp.h (100%)
 rename tcp_input.c => src/tcp_input.c (100%)
 rename tcp_output.c => src/tcp_output.c (100%)
 rename tcp_subr.c => src/tcp_subr.c (100%)
 rename tcp_timer.c => src/tcp_timer.c (100%)
 rename tcp_timer.h => src/tcp_timer.h (100%)
 rename tcp_var.h => src/tcp_var.h (100%)
 rename tcpip.h => src/tcpip.h (100%)
 rename tftp.c => src/tftp.c (100%)
 rename tftp.h => src/tftp.h (100%)
 rename udp.c => src/udp.c (100%)
 rename udp.h => src/udp.h (100%)
 rename udp6.c => src/udp6.c (100%)
 rename util.c => src/util.c (100%)
 rename util.h => src/util.h (100%)
Makefile.objs deleted +0 -34
deleted file mode 100644
index 88340a5..0000000
@@ -1,34 +0,0 @@
-slirp-obj-y = slirp.mo
-
-slirp.mo-objs = \
-	arp_table.o \
-	bootp.o \
-	cksum.o \
-	dhcpv6.o \
-	dnssearch.o \
-	if.o \
-	ip6_icmp.o \
-	ip6_input.o \
-	ip6_output.o \
-	ip_icmp.o \
-	ip_input.o \
-	ip_output.o \
-	mbuf.o \
-	misc.o \
-	ncsi.o \
-	ndp_table.o \
-	sbuf.o \
-	slirp.o \
-	socket.o \
-	state.o \
-	tcp_input.o \
-	tcp_output.o \
-	tcp_subr.o \
-	tcp_timer.o \
-	tftp.o \
-	udp.o \
-	udp6.o \
-	util.o \
-	$(NULL)
-
-slirp.mo-cflags = -DG_LOG_DOMAIN=\"Slirp\" -DWITH_QEMU
src/arp_table.c renamed from arp_table.c +0 -0
similarity index 100%
rename from arp_table.c
rename to src/arp_table.c
src/bootp.c renamed from bootp.c +0 -0
similarity index 100%
rename from bootp.c
rename to src/bootp.c
src/bootp.h renamed from bootp.h +0 -0
similarity index 100%
rename from bootp.h
rename to src/bootp.h
src/cksum.c renamed from cksum.c +0 -0
similarity index 100%
rename from cksum.c
rename to src/cksum.c
src/debug.h renamed from debug.h +0 -0
similarity index 100%
rename from debug.h
rename to src/debug.h
src/dhcpv6.c renamed from dhcpv6.c +0 -0
similarity index 100%
rename from dhcpv6.c
rename to src/dhcpv6.c
src/dhcpv6.h renamed from dhcpv6.h +0 -0
similarity index 100%
rename from dhcpv6.h
rename to src/dhcpv6.h
src/dnssearch.c renamed from dnssearch.c +0 -0
similarity index 100%
rename from dnssearch.c
rename to src/dnssearch.c
src/if.c renamed from if.c +0 -0
similarity index 100%
rename from if.c
rename to src/if.c
src/if.h renamed from if.h +0 -0
similarity index 100%
rename from if.h
rename to src/if.h
src/ip.h renamed from ip.h +0 -0
similarity index 100%
rename from ip.h
rename to src/ip.h
src/ip6.h renamed from ip6.h +0 -0
similarity index 100%
rename from ip6.h
rename to src/ip6.h
src/ip6_icmp.c renamed from ip6_icmp.c +0 -0
similarity index 100%
rename from ip6_icmp.c
rename to src/ip6_icmp.c
src/ip6_icmp.h renamed from ip6_icmp.h +0 -0
similarity index 100%
rename from ip6_icmp.h
rename to src/ip6_icmp.h
src/ip6_input.c renamed from ip6_input.c +0 -0
similarity index 100%
rename from ip6_input.c
rename to src/ip6_input.c
src/ip6_output.c renamed from ip6_output.c +0 -0
similarity index 100%
rename from ip6_output.c
rename to src/ip6_output.c
src/ip_icmp.c renamed from ip_icmp.c +0 -0
similarity index 100%
rename from ip_icmp.c
rename to src/ip_icmp.c
src/ip_icmp.h renamed from ip_icmp.h +0 -0
similarity index 100%
rename from ip_icmp.h
rename to src/ip_icmp.h
src/ip_input.c renamed from ip_input.c +0 -0
similarity index 100%
rename from ip_input.c
rename to src/ip_input.c
src/ip_output.c renamed from ip_output.c +0 -0
similarity index 100%
rename from ip_output.c
rename to src/ip_output.c
src/libslirp.h renamed from libslirp.h +0 -0
similarity index 100%
rename from libslirp.h
rename to src/libslirp.h
src/main.h renamed from main.h +0 -0
similarity index 100%
rename from main.h
rename to src/main.h
src/mbuf.c renamed from mbuf.c +0 -0
similarity index 100%
rename from mbuf.c
rename to src/mbuf.c
src/mbuf.h renamed from mbuf.h +0 -0
similarity index 100%
rename from mbuf.h
rename to src/mbuf.h
src/misc.c renamed from misc.c +0 -0
similarity index 100%
rename from misc.c
rename to src/misc.c
src/misc.h renamed from misc.h +0 -0
similarity index 100%
rename from misc.h
rename to src/misc.h
src/ncsi-pkt.h renamed from ncsi-pkt.h +0 -0
similarity index 100%
rename from ncsi-pkt.h
rename to src/ncsi-pkt.h
src/ncsi.c renamed from ncsi.c +0 -0
similarity index 100%
rename from ncsi.c
rename to src/ncsi.c
src/ndp_table.c renamed from ndp_table.c +0 -0
similarity index 100%
rename from ndp_table.c
rename to src/ndp_table.c
src/qtailq.h renamed from qtailq.h +0 -0
similarity index 100%
rename from qtailq.h
rename to src/qtailq.h
src/sbuf.c renamed from sbuf.c +0 -0
similarity index 100%
rename from sbuf.c
rename to src/sbuf.c
src/sbuf.h renamed from sbuf.h +0 -0
similarity index 100%
rename from sbuf.h
rename to src/sbuf.h
src/slirp.c renamed from slirp.c +0 -0
similarity index 100%
rename from slirp.c
rename to src/slirp.c
src/slirp.h renamed from slirp.h +0 -0
similarity index 100%
rename from slirp.h
rename to src/slirp.h
src/socket.c renamed from socket.c +0 -0
similarity index 100%
rename from socket.c
rename to src/socket.c
src/socket.h renamed from socket.h +0 -0
similarity index 100%
rename from socket.h
rename to src/socket.h
src/state.c renamed from state.c +0 -0
similarity index 100%
rename from state.c
rename to src/state.c
src/state.h renamed from state.h +0 -0
similarity index 100%
rename from state.h
rename to src/state.h
src/tcp.h renamed from tcp.h +0 -0
similarity index 100%
rename from tcp.h
rename to src/tcp.h
src/tcp_input.c renamed from tcp_input.c +0 -0
similarity index 100%
rename from tcp_input.c
rename to src/tcp_input.c
src/tcp_output.c renamed from tcp_output.c +0 -0
similarity index 100%
rename from tcp_output.c
rename to src/tcp_output.c
src/tcp_subr.c renamed from tcp_subr.c +0 -0
similarity index 100%
rename from tcp_subr.c
rename to src/tcp_subr.c
src/tcp_timer.c renamed from tcp_timer.c +0 -0
similarity index 100%
rename from tcp_timer.c
rename to src/tcp_timer.c
src/tcp_timer.h renamed from tcp_timer.h +0 -0
similarity index 100%
rename from tcp_timer.h
rename to src/tcp_timer.h
src/tcp_var.h renamed from tcp_var.h +0 -0
similarity index 100%
rename from tcp_var.h
rename to src/tcp_var.h
src/tcpip.h renamed from tcpip.h +0 -0
similarity index 100%
rename from tcpip.h
rename to src/tcpip.h
src/tftp.c renamed from tftp.c +0 -0
similarity index 100%
rename from tftp.c
rename to src/tftp.c
src/tftp.h renamed from tftp.h +0 -0
similarity index 100%
rename from tftp.h
rename to src/tftp.h
src/udp.c renamed from udp.c +0 -0
similarity index 100%
rename from udp.c
rename to src/udp.c
src/udp.h renamed from udp.h +0 -0
similarity index 100%
rename from udp.h
rename to src/udp.h
src/udp6.c renamed from udp6.c +0 -0
similarity index 100%
rename from udp6.c
rename to src/udp6.c
src/util.c renamed from util.c +0 -0
similarity index 100%
rename from util.c
rename to src/util.c
src/util.h renamed from util.h +0 -0
similarity index 100%
rename from util.h
rename to src/util.h
Signature · 1 line
2.21.0.rc0.1.g036caf7885
#2 lore raw

PATCH 2/5 build-sys: add a meson build

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

Build a shared library, exporting only slirp_* symbols.

Install API headers and a slirp.pc pkg-config.

It has been tested to build on Linux and with mingw64 cross-compilation.

---
 meson.build      | 111 +++++++++++++++++++++++++++++++++++++++++++++++
 src/libslirp.map |  21 +++++++++
 2 files changed, 132 insertions(+)
 create mode 100644 meson.build
 create mode 100644 src/libslirp.map
meson.build new file +111 -0
new file mode 100644
index 0000000..d53d17a
@@ -0,0 +1,111 @@
+project('slirp', 'c',
+  version : '4.0.0',
+  license : 'BSD-3-Clause',
+  default_options : ['warning_level=1', 'c_std=gnu99']
+)
+
+version = meson.project_version()
+varr = version.split('.')
+major_version = varr[0]
+minor_version = varr[1]
+micro_version = varr[2]
+
+# libtool versioning - this applies to libpackagekit
+#
+# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
+#
+# - If interfaces have been changed or added, but binary compatibility
+#   has been preserved, change:
+#      CURRENT += 1
+#      REVISION = 0
+#      AGE += 1
+# - If binary compatibility has been broken (eg removed or changed
+#   interfaces), change:
+#      CURRENT += 1
+#      REVISION = 0
+#      AGE = 0
+# - If the interface is the same as the previous version, but bugs are
+#   fixed, change:
+#      REVISION += 1
+lt_current = '0'
+lt_revision = '0'
+lt_age = '0'
+lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision)
+
+host_system = host_machine.system()
+
+glib_dep = dependency('glib-2.0')
+
+cc = meson.get_compiler('c')
+
+platform_deps = []
+
+if host_system == 'windows'
+  platform_deps += [
+    cc.find_library('ws2_32'),
+    cc.find_library('iphlpapi')
+  ]
+endif
+
+cargs = [
+  '-DG_LOG_DOMAIN="Slirp"',
+]
+
+sources = [
+  'src/arp_table.c',
+  'src/bootp.c',
+  'src/cksum.c',
+  'src/dhcpv6.c',
+  'src/dnssearch.c',
+  'src/if.c',
+  'src/ip6_icmp.c',
+  'src/ip6_input.c',
+  'src/ip6_output.c',
+  'src/ip_icmp.c',
+  'src/ip_input.c',
+  'src/ip_output.c',
+  'src/mbuf.c',
+  'src/misc.c',
+  'src/ncsi.c',
+  'src/ndp_table.c',
+  'src/sbuf.c',
+  'src/slirp.c',
+  'src/socket.c',
+  'src/tcp_input.c',
+  'src/tcp_output.c',
+  'src/tcp_subr.c',
+  'src/tcp_timer.c',
+  'src/tftp.c',
+  'src/udp.c',
+  'src/udp6.c',
+  'src/util.c',
+]
+
+mapfile = 'src/libslirp.map'
+vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
+
+lib = shared_library('slirp', sources,
+  soversion : lt_current,
+  version : lt_version,
+  c_args : cargs,
+  link_args : vflag,
+  link_depends : mapfile,
+  dependencies : [glib_dep, platform_deps],
+  install : true
+)
+
+install_headers(['src/libslirp.h'], subdir : 'slirp')
+
+pkg = import('pkgconfig')
+
+pkg.generate(
+  version : version,
+  libraries : lib,
+  requires : [
+    'glib-2.0',
+  ],
+  name : 'slirp',
+  description : 'User-space network stack',
+  filebase : 'slirp',
+  subdirs : 'slirp',
+)
src/libslirp.map new file +21 -0
new file mode 100644
index 0000000..3eb730a
@@ -0,0 +1,21 @@
+SLIRP_4.0 {
+global:
+    slirp_add_exec;
+    slirp_add_guestfwd;
+    slirp_add_hostfwd;
+    slirp_cleanup;
+    slirp_connection_info;
+    slirp_init;
+    slirp_input;
+    slirp_pollfds_fill;
+    slirp_pollfds_poll;
+    slirp_remove_hostfwd;
+    slirp_socket_can_recv;
+    slirp_socket_recv;
+    slirp_state_load;
+    slirp_state_save;
+    slirp_state_version;
+    slirp_version_string;
+local:
+    *;
+};
Signature · 1 line
2.21.0.rc0.1.g036caf7885
#3 lore raw

PATCH 3/5 build-sys: add version tooling

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

Add SLIRP_CHECK_VERSION() macro, and a slirp_version_string() helpers.

---
 meson.build               | 13 +++++++++++++
 src/libslirp-version.h.in | 22 ++++++++++++++++++++++
 src/libslirp.h            |  5 +++++
 src/util.h                |  3 +++
 src/version.c             | 33 +++++++++++++++++++++++++++++++++
 5 files changed, 76 insertions(+)
 create mode 100644 src/libslirp-version.h.in
 create mode 100644 src/version.c
meson.build +13 -0
index d53d17a..ec0a0dd 100644
@@ -10,6 +10,11 @@ major_version = varr[0]
 minor_version = varr[1]
 micro_version = varr[2]
 
+conf = configuration_data()
+conf.set('SLIRP_MAJOR_VERSION', major_version)
+conf.set('SLIRP_MINOR_VERSION', minor_version)
+conf.set('SLIRP_MICRO_VERSION', micro_version)
+
 # libtool versioning - this applies to libpackagekit
 #
 # See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
@@ -79,11 +84,19 @@ sources = [
   'src/udp.c',
   'src/udp6.c',
   'src/util.c',
+  'src/version.c',
 ]
 
 mapfile = 'src/libslirp.map'
 vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
 
+configure_file(
+  input : 'src/libslirp-version.h.in',
+  output : 'libslirp-version.h',
+  install_dir : join_paths(get_option('includedir'), 'slirp'),
+  configuration : conf
+)
+
 lib = shared_library('slirp', sources,
   soversion : lt_current,
   version : lt_version,
src/libslirp-version.h.in new file +22 -0
new file mode 100644
index 0000000..e7d56f1
@@ -0,0 +1,22 @@
+#ifndef LIBSLIRP_VERSION_H_
+#define LIBSLIRP_VERSION_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SLIRP_MAJOR_VERSION @SLIRP_MAJOR_VERSION@
+#define SLIRP_MINOR_VERSION @SLIRP_MINOR_VERSION@
+#define SLIRP_MICRO_VERSION @SLIRP_MICRO_VERSION@
+
+#define SLIRP_CHECK_VERSION(major,minor,micro)                          \
+    (SLIRP_MAJOR_VERSION > (major) ||                                   \
+     (SLIRP_MAJOR_VERSION == (major) && SLIRP_MINOR_VERSION > (minor)) || \
+     (SLIRP_MAJOR_VERSION == (major) && SLIRP_MINOR_VERSION == (minor) && \
+      SLIRP_MICRO_VERSION >= (micro)))
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* LIBSLIRP_VERSION_H_ */
src/libslirp.h +5 -0
index c6cb6a9..8008bd9 100644
@@ -12,6 +12,8 @@
 #include <arpa/inet.h>
 #endif
 
+#include "libslirp-version.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -97,6 +99,9 @@ void slirp_socket_recv(Slirp *slirp, struct in_addr guest_addr, int guest_port,
                        const uint8_t *buf, int size);
 size_t slirp_socket_can_recv(Slirp *slirp, struct in_addr guest_addr,
                              int guest_port);
+
+const char *slirp_version_string(void);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
src/util.h +3 -0
index a9c4e32..82b1901 100644
@@ -71,6 +71,9 @@ struct iovec {
 #include <sys/uio.h>
 #endif
 
+#define stringify(s) tostring(s)
+#define tostring(s) #s
+
 #define SCALE_MS 1000000
 
 #define ETH_ALEN 6
src/version.c new file +33 -0
new file mode 100644
index 0000000..1a1d51e
@@ -0,0 +1,33 @@
+/*
+ * libslirp version
+ *
+ * Copyright (c) 2018 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "libslirp.h"
+#include "util.h"
+
+const char *
+slirp_version_string(void)
+{
+    return stringify(SLIRP_MAJOR_VERSION) "."
+        stringify(SLIRP_MINOR_VERSION) "."
+        stringify(SLIRP_MICRO_VERSION);
+}
Signature · 1 line
2.21.0.rc0.1.g036caf7885
#4 lore raw

PATCH 4/5 slirp: add state saving/loading

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

Based on qemu vmstate serialization code. At this point it should produce the same result. However, with future state versions, slirp should be free to change its format, by bumping the reported state version.

---
 meson.build    |   3 +
 src/libslirp.h |   8 +
 src/slirp.c    |   9 --
 src/state.c    |  50 +++---
 src/state.h    |   9 --
 src/stream.c   | 119 +++++++++++++++
 src/stream.h   |  34 +++++
 src/vmstate.c  | 401 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/vmstate.h  | 396 ++++++++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 983 insertions(+), 46 deletions(-)
 create mode 100644 src/stream.c
 create mode 100644 src/stream.h
 create mode 100644 src/vmstate.c
 create mode 100644 src/vmstate.h
meson.build +3 -0
index ec0a0dd..8ac40e4 100644
@@ -76,6 +76,8 @@ sources = [
   'src/sbuf.c',
   'src/slirp.c',
   'src/socket.c',
+  'src/state.c',
+  'src/stream.c',
   'src/tcp_input.c',
   'src/tcp_output.c',
   'src/tcp_subr.c',
@@ -85,6 +87,7 @@ sources = [
   'src/udp6.c',
   'src/util.c',
   'src/version.c',
+  'src/vmstate.c',
 ]
 
 mapfile = 'src/libslirp.map'
src/libslirp.h +8 -0
index 8008bd9..0f07489 100644
@@ -28,6 +28,7 @@ enum {
     SLIRP_POLL_HUP = 1 << 4,
 };
 
+typedef ssize_t (*SlirpReadCb)(void *buf, size_t len, void *opaque);
 typedef ssize_t (*SlirpWriteCb)(const void *buf, size_t len, void *opaque);
 typedef void (*SlirpTimerCb)(void *opaque);
 typedef int (*SlirpAddPollCb)(int fd, int events, void *opaque);
@@ -102,6 +103,13 @@ size_t slirp_socket_can_recv(Slirp *slirp, struct in_addr guest_addr,
 
 const char *slirp_version_string(void);
 
+void slirp_state_save(Slirp *s, SlirpWriteCb write_cb, void *opaque);
+
+int slirp_state_load(Slirp *s, int version_id,
+                     SlirpReadCb read_cb, void *opaque);
+
+int slirp_state_version(void);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
src/slirp.c +0 -9
index ab531e9..0604270 100644
@@ -23,9 +23,6 @@
  */
 #include "slirp.h"
 
-#ifdef WITH_QEMU
-#include "state.h"
-#endif
 
 #ifndef _WIN32
 #include <net/if.h>
@@ -321,9 +318,6 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork,
         translate_dnssearch(slirp, vdnssearch);
     }
 
-#ifdef WITH_QEMU
-    slirp_state_register(slirp);
-#endif
     return slirp;
 }
 
@@ -337,9 +331,6 @@ void slirp_cleanup(Slirp *slirp)
         g_free(e);
     }
 
-#ifdef WITH_QEMU
-    slirp_state_unregister(slirp);
-#endif
     ip_cleanup(slirp);
     ip6_cleanup(slirp);
     m_cleanup(slirp);
src/state.c +22 -28

90 lines not on this page · raw message

src/state.h +0 -9
index 1548668..e69de29 100644
@@ -1,9 +0,0 @@
-#ifndef SLIRP_STATE_H_
-#define SLIRP_STATE_H_
-
-#include "libslirp.h"
-
-void slirp_state_register(Slirp *slirp);
-void slirp_state_unregister(Slirp *slirp);
-
-#endif /* SLIRP_STATE_H_ */
src/stream.c new file +119 -0

119 lines not on this page · raw message

src/stream.h new file +34 -0
new file mode 100644
index 0000000..985334c
@@ -0,0 +1,34 @@
+#ifndef STREAM_H_
+#define STREAM_H_
+
+#include "libslirp.h"
+
+typedef struct SlirpIStream {
+    SlirpReadCb read_cb;
+    void *opaque;
+} SlirpIStream;
+
+typedef struct SlirpOStream {
+    SlirpWriteCb write_cb;
+    void *opaque;
+} SlirpOStream;
+
+bool slirp_istream_read(SlirpIStream *f, void *buf, size_t size);
+bool slirp_ostream_write(SlirpOStream *f, const void *buf, size_t size);
+
+uint8_t slirp_istream_read_u8(SlirpIStream *f);
+bool slirp_ostream_write_u8(SlirpOStream *f, uint8_t b);
+
+uint16_t slirp_istream_read_u16(SlirpIStream *f);
+bool slirp_ostream_write_u16(SlirpOStream *f, uint16_t b);
+
+uint32_t slirp_istream_read_u32(SlirpIStream *f);
+bool slirp_ostream_write_u32(SlirpOStream *f, uint32_t b);
+
+int16_t slirp_istream_read_i16(SlirpIStream *f);
+bool slirp_ostream_write_i16(SlirpOStream *f, int16_t b);
+
+int32_t slirp_istream_read_i32(SlirpIStream *f);
+bool slirp_ostream_write_i32(SlirpOStream *f, int32_t b);
+
+#endif /* STREAM_H_ */
src/vmstate.c new file +401 -0

401 lines not on this page · raw message

src/vmstate.h new file +396 -0

396 lines not on this page · raw message

Signature · 1 line
2.21.0.rc0.1.g036caf7885
#5 lore raw

Re: [Qemu-devel] [PATCH slirp 4/5] slirp: add state saving/loading

[email protected], le ven. 08 févr. 2019 19:11:21 +0100, a ecrit:

Quoted 6 lines

From: Marc-André Lureau <[email protected]>

Based on qemu vmstate serialization code. At this point it should produce the same result. However, with future state versions, slirp should be free to change its format, by bumping the reported state version.

Mmm, then qemu needs to be taught to call slirp_state_save/load/version?

Samuel

#6 lore raw

Re: [Qemu-devel] [PATCH slirp 4/5] slirp: add state saving/loading

Hi

Quoted 10 lines · Samuel Thibault

[email protected], le ven. 08 févr. 2019 19:11:21 +0100, a ecrit:

Quoted 6 lines

From: Marc-André Lureau <[email protected]>

Based on qemu vmstate serialization code. At this point it should produce the same result. However, with future state versions, slirp should be free to change its format, by bumping the reported state version.

Mmm, then qemu needs to be taught to call slirp_state_save/load/version?

Yes, see "[Qemu-devel] [PATCH 1/1] RFC: net/slirp: link with libslirp"

#7 lore raw

Re: [Qemu-devel] [PATCH slirp 4/5] slirp: add state saving/loading

Marc-André Lureau, le sam. 09 févr. 2019 14:09:02 +0100, a ecrit:

Quoted 5 lines · Samuel Thibault
Quoted 4 lines

[email protected], le ven. 08 févr. 2019 19:11:21 +0100, a ecrit:

Quoted 2 lines

From: Marc-André Lureau <[email protected]>

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Based on qemu vmstate serialization code. At this point it should produce the same result. However, with future state versions, slirp should be free to change its format, by bumping the reported state version.

Mmm, then qemu needs to be taught to call slirp_state_save/load/version?

Yes, see "[Qemu-devel] [PATCH 1/1] RFC: net/slirp: link with libslirp"

Ah, I did have a look there but somehow missed it because burried within file removals :)

Samuel

#8 lore raw

Re: [Qemu-devel] [PATCH slirp 4/5] slirp: add state saving/loading

Hi

Quoted 12 lines · Samuel Thibault

Marc-André Lureau, le sam. 09 févr. 2019 14:09:02 +0100, a ecrit:

Quoted 10 lines · Samuel Thibault
Quoted 9 lines

[email protected], le ven. 08 févr. 2019 19:11:21 +0100, a ecrit:

Quoted 6 lines

From: Marc-André Lureau <[email protected]>

Based on qemu vmstate serialization code. At this point it should produce the same result. However, with future state versions, slirp should be free to change its format, by bumping the reported state version.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Mmm, then qemu needs to be taught to call slirp_state_save/load/version?

Yes, see "[Qemu-devel] [PATCH 1/1] RFC: net/slirp: link with libslirp"

Ah, I did have a look there but somehow missed it because burried within file removals :)

Indeed, the original patch series was splited in 2, but I thought as an RFC it was easier to send a single patch. Bad choice I suppose.

Signature · 1 line
Marc-André Lureau
#9 lore raw

Re: [Qemu-devel] [PATCH slirp 4/5] slirp: add state saving/loading

Marc-André Lureau, le sam. 09 févr. 2019 14:16:53 +0100, a ecrit:

Quoted 17 lines

Hi

Quoted 14 lines · Samuel Thibault

Marc-André Lureau, le sam. 09 févr. 2019 14:09:02 +0100, a ecrit:

Quoted 12 lines · Samuel Thibault
Quoted 10 lines

[email protected], le ven. 08 févr. 2019 19:11:21 +0100, a ecrit:

Quoted 6 lines

From: Marc-André Lureau <[email protected]>

Based on qemu vmstate serialization code. At this point it should produce the same result. However, with future state versions, slirp should be free to change its format, by bumping the reported state version.

Mmm, then qemu needs to be taught to call slirp_state_save/load/version?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Yes, see "[Qemu-devel] [PATCH 1/1] RFC: net/slirp: link with libslirp"

Ah, I did have a look there but somehow missed it because burried within file removals :)

Indeed, the original patch series was splited in 2, but I thought as an RFC it was easier to send a single patch. Bad choice I suppose.

No, it's fine enough, it's just the file ordering in the patch which posed problem :)

Samuel

#10 lore raw

PATCH 5/5 Add .gitlab-ci.yml

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

---
 .gitlab-ci.yml | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 .gitlab-ci.yml
.gitlab-ci.yml new file +20 -0
new file mode 100644
index 0000000..71fda28
@@ -0,0 +1,20 @@
+image: fedora:latest
+
+variables:
+  DEPS: meson ninja-build
+        gcc pkg-config glib2-devel
+        mingw64-gcc mingw64-pkg-config mingw64-glib2
+
+before_script:
+  - dnf install -y $DEPS
+
+build:
+  script:
+    - meson build || (cat build/meson-logs/meson-log.txt && exit 1)
+    - ninja -C build
+    - (cd build && meson test) || (cat build/meson-logs/testlog.txt && exit 1)
+
+build-mingw64:
+  script:
+    - (mkdir buildw && cd buildw && mingw64-meson) || (cat buildw/meson-logs/meson-log.txt && exit 1)
+    - ninja -C buildw
Signature · 1 line
2.21.0.rc0.1.g036caf7885
#12 lore raw
In reply to [email protected]
Quoted 8 lines · On Fri, 8 Feb 2019 at 20:58, <[email protected]> wrote:

As discussed earlier in "[PATCH for-3.2 00/41] RFC: slirp: make it again a standalone project" and other threads, it would be useful to make slirp a separate project (the submodule approach was discarded) for various projects to share.

The following patches add meson build system (if necessary for older distros, autotools could be added - however I believe python & ninja are generally available on the QEMU supported platforms)

Do you really need to make QEMU add an extra build dependency just to use a different build system? From my end that seems like just unnecessary pain for us (we're going to need to ship libslirp as a submodule for a while until it's been around long enough to be in stable distros, so its build dependencies will get added to QEMU's build deps).

Is the standalone project going to provide a shared library or just a .a static library? (ie are you confident enough in the long-term stability of your API and ABI to do the shared library yet? the prudent approach might be to start with just the .a...)

thanks
-- PMM

#13 lore raw

Hello,

Peter Maydell, le dim. 10 févr. 2019 21:35:37 +0000, a ecrit:

Quoted 6 lines · On Fri, 8 Feb 2019 at 20:58, <[email protected]> wrote:
Quoted 4 lines

As discussed earlier in "[PATCH for-3.2 00/41] RFC: slirp: make it again a standalone project" and other threads, it would be useful to make slirp a separate project (the submodule approach was discarded) for various projects to share.

Quoted 6 lines
Quoted 3 lines

The following patches add meson build system (if necessary for older distros, autotools could be added - however I believe python & ninja are generally available on the QEMU supported platforms)

Do you really need to make QEMU add an extra build dependency just to use a different build system?

AIUI, this patches series is meant for the slirp repository, not the QEMU repository. I.e. just to show how it'll look like, until a project it settled somewhere and the discussion can happen there.

Samuel

#14 lore raw
Quoted 14 lines · Samuel Thibault

Hello,

Peter Maydell, le dim. 10 févr. 2019 21:35:37 +0000, a ecrit:

Quoted 10 lines · On Fri, 8 Feb 2019 at 20:58, <[email protected]> wrote:
Quoted 8 lines

As discussed earlier in "[PATCH for-3.2 00/41] RFC: slirp: make it again a standalone project" and other threads, it would be useful to make slirp a separate project (the submodule approach was discarded) for various projects to share.

The following patches add meson build system (if necessary for older distros, autotools could be added - however I believe python & ninja are generally available on the QEMU supported platforms)

Quoted 6 lines
Quoted 2 lines

Do you really need to make QEMU add an extra build dependency just to use a different build system?

AIUI, this patches series is meant for the slirp repository, not the QEMU repository. I.e. just to show how it'll look like, until a project it settled somewhere and the discussion can happen there.

Yes, but we're going to be pulling it in as a submodule, so a split out libslirp in its own repository with extra build dependencies is harder to work with than one without.

thanks
-- PMM

#15 lore raw

Hi

Quoted 19 lines · Peter Maydell
Quoted 17 lines · Samuel Thibault

Hello,

Peter Maydell, le dim. 10 févr. 2019 21:35:37 +0000, a ecrit:

Quoted 12 lines · On Fri, 8 Feb 2019 at 20:58, <[email protected]> wrote:
Quoted 8 lines

As discussed earlier in "[PATCH for-3.2 00/41] RFC: slirp: make it again a standalone project" and other threads, it would be useful to make slirp a separate project (the submodule approach was discarded) for various projects to share.

The following patches add meson build system (if necessary for older distros, autotools could be added - however I believe python & ninja are generally available on the QEMU supported platforms)

Do you really need to make QEMU add an extra build dependency just to use a different build system?

Quoted 8 lines
Quoted 3 lines

AIUI, this patches series is meant for the slirp repository, not the QEMU repository. I.e. just to show how it'll look like, until a project it settled somewhere and the discussion can happen there.

Yes, but we're going to be pulling it in as a submodule, so a split out libslirp in its own repository with extra build dependencies is harder to work with than one without.

Why do you think it should be a submodule? That's the approach I proposed first, but Daniel suggested to make it immediately a shared library if possible.

Regarding the build system, if meson/ninja is problematic for some distro, we can come up with autotools or plain Make for a while.

Signature · 1 line
Marc-André Lureau
#16 lore raw
Quoted 3 lines · Marc-André Lureau

Why do you think it should be a submodule? That's the approach I proposed first, but Daniel suggested to make it immediately a shared library if possible.

It needs to be a submodule because you don't have a time machine to arrange for it to be an available package in all the stable versions of the distros we support. As and when it is packaged in the oldest stable versions we care about, we can drop the submodule, but submodule is where we need to start. (This is the same as we did with third party bits of code like pixman.)

I think immediately going for the shared library (as opposed to static) is a bit of a bold decision also because it is a hard commitment to API and ABI compatibility, which previously has been something the slirp code didn't need to care about at all.

Quoted 2 lines

Regarding the build system, if meson/ninja is problematic for some distro, we can come up with autotools or plain Make for a while.

I think plain make would be more convenient. Otherwise everybody building QEMU needs to install a random extra build tool.

thanks
-- PMM