diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2016-10-22 12:52:52 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-10-24 15:27:20 +0200 |
commit | 32a6ebecd2ffe82ffade5edf9e054e20cb48f281 (patch) | |
tree | b1e82e3f6eb4a28c65098015dd8114e190a064bf /net/slirp.c | |
parent | becdfa00cfa2995e859ccefa4b7d72a72eb96581 (diff) |
char: remaining switch to CharBackend in frontend
Similar to previous change, for the remaining CharDriverState front ends
users.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20161022095318.17775-13-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'net/slirp.c')
-rw-r--r-- | net/slirp.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/net/slirp.c b/net/slirp.c index f9fdff5fb9..407e8aa704 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -40,6 +40,7 @@ #include "sysemu/char.h" #include "sysemu/sysemu.h" #include "qemu/cutils.h" +#include "qapi/error.h" static int get_str_sep(char *buf, int buf_size, const char **pp, int sep) { @@ -682,7 +683,7 @@ int net_slirp_smb(const char *exported_dir) #endif /* !defined(_WIN32) */ struct GuestFwd { - CharDriverState *hd; + CharBackend hd; struct in_addr server; int port; Slirp *slirp; @@ -746,15 +747,23 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, return -1; } } else { - fwd = g_new(struct GuestFwd, 1); - fwd->hd = qemu_chr_new(buf, p); - if (!fwd->hd) { + Error *err = NULL; + CharDriverState *chr = qemu_chr_new(buf, p); + + if (!chr) { error_report("could not open guest forwarding device '%s'", buf); + return -1; + } + + fwd = g_new(struct GuestFwd, 1); + qemu_chr_fe_init(&fwd->hd, chr, &err); + if (err) { + error_report_err(err); g_free(fwd); return -1; } - if (slirp_add_exec(s->slirp, 3, fwd->hd, &server, port) < 0) { + if (slirp_add_exec(s->slirp, 3, fwd->hd.chr, &server, port) < 0) { error_report("conflicting/invalid host:port in guest forwarding " "rule '%s'", config_str); g_free(fwd); @@ -764,8 +773,8 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, fwd->port = port; fwd->slirp = s->slirp; - qemu_chr_fe_claim_no_fail(fwd->hd); - qemu_chr_add_handlers(fwd->hd, guestfwd_can_read, guestfwd_read, + qemu_chr_fe_claim_no_fail(fwd->hd.chr); + qemu_chr_add_handlers(fwd->hd.chr, guestfwd_can_read, guestfwd_read, NULL, fwd); } return 0; |