diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2018-10-02 18:27:18 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2018-10-02 18:27:18 +0100 |
commit | dafd95053611aa14dda40266857608d12ddce658 (patch) | |
tree | b414d9e2871c2a701ed3c42a15cfd7d289a9db7e /chardev | |
parent | 3892f1f1a963e59dfe012cd9d461d33b2986fa3b (diff) | |
parent | 97866508669c4a75f531bfa94f8267900fcbb5dc (diff) |
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* configure fix for environment variables (Daniel)
* fix memory leaks (Alex)
* x86_64 MTTCG fixes (Emilio)
* introduce atomic64 (Emilio)
* Fix for virtio hang (Fam, myself)
* SH serial port fix (Geert)
* Deprecate rotation_rate for scsi-block (Fam)
* Extend memory-backend-file availability to all POSIX hosts (Hikaru)
* Memory API cleanups and fixes (Igor, Li Qiang, Peter, Philippe)
* MSI/IOMMU fix (Jan)
* Socket reconnection fixes (Marc-André)
* icount fixes (Emilio, myself)
* QSP fixes for Coverity (myself)
* Some record/replay improovements (Pavel)
* Packed struct fixes (Peter)
* Windows dump fixes and elf2dmp (Viktor)
* kbmclock fix (Yongji)
# gpg: Signature made Tue 02 Oct 2018 18:13:12 BST
# gpg: using RSA key BFFBD25F78C7AE83
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>"
# gpg: aka "Paolo Bonzini <pbonzini@redhat.com>"
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1
# Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83
* remotes/bonzini/tags/for-upstream: (80 commits)
hw/scsi/mptendian: Avoid taking address of fields in packed structs
cpus: fix TCG kick timer leak
docs/devel/memory.txt: Document _with_attrs accessors
hw/nvram/fw_cfg: Use memberwise copy of MemoryRegionOps struct
memory: Remove old_mmio accessors
memory: Fix access_with_adjusted_size(small size) on big-endian memory regions
memory: Refactor common shifting code from accessors
memory: Use MAKE_64BIT_MASK()
virtio: do not take address of packed members
replay: replay BH for IDE trim operation
hostmem-file: make available memory-backend-file on POSIX-based hosts
target/i386: fix translation for icount mode
hvf: drop unused variable
qom/object: add some interface asserts
accel/tcg: Remove dead code
lsi53c895a: convert to trace-events
scsi-block: Deprecate rotation_rate
kvmclock: run KVM_KVMCLOCK_CTRL ioctl in vcpu thread
MAINTAINERS: add myself as elf2dmp maintainer
contrib: add elf2dmp tool
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'chardev')
-rw-r--r-- | chardev/char-pty.c | 6 | ||||
-rw-r--r-- | chardev/char-socket.c | 86 |
2 files changed, 36 insertions, 56 deletions
diff --git a/chardev/char-pty.c b/chardev/char-pty.c index 68fd4e20c3..e8d9a53476 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -31,10 +31,6 @@ #include "chardev/char-io.h" -#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ - || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \ - || defined(__GLIBC__) - typedef struct { Chardev parent; QIOChannel *ioc; @@ -299,5 +295,3 @@ static void register_types(void) } type_init(register_types); - -#endif diff --git a/chardev/char-socket.c b/chardev/char-socket.c index efbad6ee7c..7cd0ae2824 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -32,7 +32,6 @@ #include "qapi/error.h" #include "qapi/clone-visitor.h" #include "qapi/qapi-visit-sockets.h" -#include "sysemu/sysemu.h" #include "chardev/char-io.h" @@ -354,6 +353,15 @@ static GSource *tcp_chr_add_watch(Chardev *chr, GIOCondition cond) return qio_channel_create_watch(s->ioc, cond); } +static void remove_hup_source(SocketChardev *s) +{ + if (s->hup_source != NULL) { + g_source_destroy(s->hup_source); + g_source_unref(s->hup_source); + s->hup_source = NULL; + } +} + static void tcp_chr_free_connection(Chardev *chr) { SocketChardev *s = SOCKET_CHARDEV(chr); @@ -368,11 +376,7 @@ static void tcp_chr_free_connection(Chardev *chr) s->read_msgfds_num = 0; } - if (s->hup_source != NULL) { - g_source_destroy(s->hup_source); - g_source_unref(s->hup_source); - s->hup_source = NULL; - } + remove_hup_source(s); tcp_set_msgfds(chr, NULL, 0); remove_fd_in_watch(chr); @@ -541,6 +545,27 @@ static char *sockaddr_to_str(struct sockaddr_storage *ss, socklen_t ss_len, } } +static void update_ioc_handlers(SocketChardev *s) +{ + Chardev *chr = CHARDEV(s); + + if (!s->connected) { + return; + } + + remove_fd_in_watch(chr); + chr->gsource = io_add_watch_poll(chr, s->ioc, + tcp_chr_read_poll, + tcp_chr_read, chr, + chr->gcontext); + + remove_hup_source(s); + s->hup_source = qio_channel_create_watch(s->ioc, G_IO_HUP); + g_source_set_callback(s->hup_source, (GSourceFunc)tcp_chr_hup, + chr, NULL); + g_source_attach(s->hup_source, chr->gcontext); +} + static void tcp_chr_connect(void *opaque) { Chardev *chr = CHARDEV(opaque); @@ -553,16 +578,7 @@ static void tcp_chr_connect(void *opaque) s->is_listen, s->is_telnet); s->connected = 1; - chr->gsource = io_add_watch_poll(chr, s->ioc, - tcp_chr_read_poll, - tcp_chr_read, - chr, chr->gcontext); - - s->hup_source = qio_channel_create_watch(s->ioc, G_IO_HUP); - g_source_set_callback(s->hup_source, (GSourceFunc)tcp_chr_hup, - chr, NULL); - g_source_attach(s->hup_source, chr->gcontext); - + update_ioc_handlers(s); qemu_chr_be_event(chr, CHR_EVENT_OPENED); } @@ -593,17 +609,7 @@ static void tcp_chr_update_read_handler(Chardev *chr) tcp_chr_telnet_init(CHARDEV(s)); } - if (!s->connected) { - return; - } - - remove_fd_in_watch(chr); - if (s->ioc) { - chr->gsource = io_add_watch_poll(chr, s->ioc, - tcp_chr_read_poll, - tcp_chr_read, chr, - chr->gcontext); - } + update_ioc_handlers(s); } static gboolean tcp_chr_telnet_init_io(QIOChannel *ioc, @@ -724,11 +730,6 @@ static void tcp_chr_tls_init(Chardev *chr) Error *err = NULL; gchar *name; - if (!machine_init_done) { - /* This will be postponed to machine_done notifier */ - return; - } - if (s->is_listen) { tioc = qio_channel_tls_new_server( s->ioc, s->tls_creds, @@ -1011,8 +1012,9 @@ static void qmp_chardev_open_socket(Chardev *chr, s->reconnect_time = reconnect; } - /* If reconnect_time is set, will do that in chr_machine_done. */ - if (!s->reconnect_time) { + if (s->reconnect_time) { + tcp_chr_connect_async(chr); + } else { if (s->is_listen) { char *name; s->listener = qio_net_listener_new(); @@ -1161,21 +1163,6 @@ char_socket_get_connected(Object *obj, Error **errp) return s->connected; } -static int tcp_chr_machine_done_hook(Chardev *chr) -{ - SocketChardev *s = SOCKET_CHARDEV(chr); - - if (s->reconnect_time) { - tcp_chr_connect_async(chr); - } - - if (s->ioc && s->tls_creds) { - tcp_chr_tls_init(chr); - } - - return 0; -} - static void char_socket_class_init(ObjectClass *oc, void *data) { ChardevClass *cc = CHARDEV_CLASS(oc); @@ -1191,7 +1178,6 @@ static void char_socket_class_init(ObjectClass *oc, void *data) cc->chr_add_client = tcp_chr_add_client; cc->chr_add_watch = tcp_chr_add_watch; cc->chr_update_read_handler = tcp_chr_update_read_handler; - cc->chr_machine_done = tcp_chr_machine_done_hook; object_class_property_add(oc, "addr", "SocketAddress", char_socket_get_addr, NULL, |