mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
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>
This commit is contained in:
parent
d7df0b41dc
commit
625a526b32
7 changed files with 33 additions and 15 deletions
|
@ -668,9 +668,9 @@ ssize_t qemu_send_packet_async(NetClientState *sender,
|
|||
buf, size, sent_cb);
|
||||
}
|
||||
|
||||
void qemu_send_packet(NetClientState *nc, const uint8_t *buf, int size)
|
||||
ssize_t qemu_send_packet(NetClientState *nc, const uint8_t *buf, int size)
|
||||
{
|
||||
qemu_send_packet_async(nc, buf, size, NULL);
|
||||
return qemu_send_packet_async(nc, buf, size, NULL);
|
||||
}
|
||||
|
||||
ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int size)
|
||||
|
|
|
@ -108,11 +108,12 @@ static void slirp_smb_cleanup(SlirpState *s);
|
|||
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 void net_slirp_unregister_poll_fd(int fd)
|
|||
}
|
||||
|
||||
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 @@ static void guestfwd_read(void *opaque, const uint8_t *buf, int size)
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue