slirp: improve send_packet() callback
Use a more descriptive name for the callback.
Reuse the SlirpWriteCb type. Wrap it to check that all data has been written.
Return a ssize_t for potential error handling and data-loss reporting.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
diff --git a/net/slirp.c b/net/slirp.c
index 7b4f9f5..664ff1c 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -108,11 +108,12 @@
static inline void slirp_smb_cleanup(SlirpState *s) { }
#endif
-static void net_slirp_output(void *opaque, const uint8_t *pkt, int pkt_len)
+static ssize_t net_slirp_send_packet(const void *pkt, size_t pkt_len,
+ void *opaque)
{
SlirpState *s = opaque;
- qemu_send_packet(&s->nc, pkt, pkt_len);
+ return qemu_send_packet(&s->nc, pkt, pkt_len);
}
static ssize_t net_slirp_receive(NetClientState *nc, const uint8_t *buf, size_t size)
@@ -197,7 +198,7 @@
}
static const SlirpCb slirp_cb = {
- .output = net_slirp_output,
+ .send_packet = net_slirp_send_packet,
.guest_error = net_slirp_guest_error,
.clock_get_ns = net_slirp_clock_get_ns,
.timer_new = net_slirp_timer_new,
@@ -780,7 +781,7 @@
slirp_socket_recv(fwd->slirp, fwd->server, fwd->port, buf, size);
}
-static int guestfwd_write(const void *buf, size_t len, void *chr)
+static ssize_t guestfwd_write(const void *buf, size_t len, void *chr)
{
return qemu_chr_fe_write_all(chr, buf, len);
}