diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2019-03-08 11:55:53 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2019-03-08 11:55:53 +0000 |
commit | 6bbbe16a02ecf631fffb4a339e1c662d60a1e529 (patch) | |
tree | 5e847e5af195f8399a8d18ba88bc91e2d06aac57 /net/slirp.c | |
parent | e56d931a9ddee7230f647a25ada33ee19d26aa6d (diff) | |
parent | be1911ff7504be95d5cf2c18bc99ce07246a91e5 (diff) |
Merge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into staging
Slirp updates
Greg Kurz (1):
slirp: Fix build with gcc 9
Marc-André Lureau (7):
slirp: adapt a subset of QEMU vmstate code
slirp: use libslirp migration code
slirp: use "slirp_" prefix for inet_aton() win32 implementation
slirp: move sources to src/ subdirectory
slirp: add a standalone Makefile
build-sys: link with slirp as an external project
slirp: remove QEMU Makefile.objs
Samuel Thibault (2):
slirp: fix big/little endian conversion in ident protocol
slirp: Mark pieces missing IPv6 support
Vic Lee (1):
slirp: check for ioctlsocket error and 0-length udp payload.
William Bowling (1):
slirp: check sscanf result when emulating ident
# gpg: Signature made Thu 07 Mar 2019 11:51:20 GMT
# gpg: using RSA key E61DBB15D4172BDEC97E92D9DB550E89F0FA54F3
# gpg: Good signature from "Samuel Thibault <samuel.thibault@aquilenet.fr>" [unknown]
# gpg: aka "Samuel Thibault <sthibault@debian.org>" [marginal]
# gpg: aka "Samuel Thibault <samuel.thibault@gnu.org>" [unknown]
# gpg: aka "Samuel Thibault <samuel.thibault@inria.fr>" [marginal]
# gpg: aka "Samuel Thibault <samuel.thibault@labri.fr>" [marginal]
# gpg: aka "Samuel Thibault <samuel.thibault@ens-lyon.org>" [marginal]
# gpg: aka "Samuel Thibault <samuel.thibault@u-bordeaux.fr>" [unknown]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg: It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 900C B024 B679 31D4 0F82 304B D017 8C76 7D06 9EE6
# Subkey fingerprint: E61D BB15 D417 2BDE C97E 92D9 DB55 0E89 F0FA 54F3
* remotes/thibault/tags/samuel-thibault:
slirp: remove QEMU Makefile.objs
build-sys: link with slirp as an external project
slirp: add a standalone Makefile
slirp: move sources to src/ subdirectory
slirp: use "slirp_" prefix for inet_aton() win32 implementation
slirp: use libslirp migration code
slirp: adapt a subset of QEMU vmstate code
slirp: Mark pieces missing IPv6 support
slirp: fix big/little endian conversion in ident protocol
slirp: check sscanf result when emulating ident
slirp: check for ioctlsocket error and 0-length udp payload.
slirp: Fix build with gcc 9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'net/slirp.c')
-rw-r--r-- | net/slirp.c | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/net/slirp.c b/net/slirp.c index 4ec989b592..95934fb36d 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -37,13 +37,15 @@ #include "monitor/monitor.h" #include "qemu/error-report.h" #include "qemu/sockets.h" -#include "slirp/libslirp.h" +#include <libslirp.h> #include "chardev/char-fe.h" #include "sysemu/sysemu.h" #include "qemu/cutils.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "util.h" +#include "migration/register.h" +#include "migration/qemu-file-types.h" static int get_str_sep(char *buf, int buf_size, const char **pp, int sep) { @@ -146,6 +148,7 @@ static void net_slirp_cleanup(NetClientState *nc) g_slist_free_full(s->fwd, slirp_free_fwd); main_loop_poll_remove_notifier(&s->poll_notifier); + unregister_savevm(NULL, "slirp", s->slirp); slirp_cleanup(s->slirp); if (s->exit_notifier.notify) { qemu_remove_exit_notifier(&s->exit_notifier); @@ -303,6 +306,46 @@ static void net_slirp_poll_notify(Notifier *notifier, void *data) } } +static ssize_t +net_slirp_stream_read(void *buf, size_t size, void *opaque) +{ + QEMUFile *f = opaque; + + return qemu_get_buffer(f, buf, size); +} + +static ssize_t +net_slirp_stream_write(const void *buf, size_t size, void *opaque) +{ + QEMUFile *f = opaque; + + qemu_put_buffer(f, buf, size); + if (qemu_file_get_error(f)) { + return -1; + } + + return size; +} + +static int net_slirp_state_load(QEMUFile *f, void *opaque, int version_id) +{ + Slirp *slirp = opaque; + + return slirp_state_load(slirp, version_id, net_slirp_stream_read, f); +} + +static void net_slirp_state_save(QEMUFile *f, void *opaque) +{ + Slirp *slirp = opaque; + + slirp_state_save(slirp, net_slirp_stream_write, f); +} + +static SaveVMHandlers savevm_slirp_state = { + .save_state = net_slirp_state_save, + .load_state = net_slirp_state_load, +}; + static int net_slirp_init(NetClientState *peer, const char *model, const char *name, int restricted, bool ipv4, const char *vnetwork, const char *vhost, @@ -523,6 +566,18 @@ static int net_slirp_init(NetClientState *peer, const char *model, &slirp_cb, s); QTAILQ_INSERT_TAIL(&slirp_stacks, s, entry); + /* + * Make sure the current bitstream version of slirp is 4, to avoid + * QEMU migration incompatibilities, if upstream slirp bumped the + * version. + * + * FIXME: use bitfields of features? teach libslirp to save with + * specific version? + */ + g_assert(slirp_state_version() == 4); + register_savevm_live(NULL, "slirp", 0, slirp_state_version(), + &savevm_slirp_state, s->slirp); + s->poll_notifier.notify = net_slirp_poll_notify; main_loop_poll_add_notifier(&s->poll_notifier); @@ -885,6 +940,7 @@ static ssize_t guestfwd_write(const void *buf, size_t len, void *chr) static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp) { + /* TODO: IPv6 */ struct in_addr server = { .s_addr = 0 }; struct GuestFwd *fwd; const char *p; |