Commit 6c87d9f3 authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/elmarco/tags/chardev-pull-request' into staging



# gpg: Signature made Mon 13 Jul 2020 09:23:19 BST
# gpg:                using RSA key 87A9BD933F87C606D276F62DDAE8E10975969CE5
# gpg:                issuer "marcandre.lureau@redhat.com"
# gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>" [full]
# gpg:                 aka "Marc-André Lureau <marcandre.lureau@gmail.com>" [full]
# Primary key fingerprint: 87A9 BD93 3F87 C606 D276  F62D DAE8 E109 7596 9CE5

* remotes/elmarco/tags/chardev-pull-request:
  chardev: Extract system emulation specific code
  chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h"
  chardev: Restrict msmouse / wctablet / testdev to system emulation
  tests/test-char: Remove unused "chardev/char-mux.h" include
  monitor/misc: Remove unused "chardev/char-mux.h" include
  char: fix use-after-free with dup chardev & reconnect
  chardev: don't abort on attempt to add duplicated chardev
  char-socket: initialize reconnect timer only when the timer doesn't start

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 9f526fce 30827bad
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
chardev-obj-y += char.o
chardev-obj-$(CONFIG_SOFTMMU) += chardev-sysemu.o
chardev-obj-$(CONFIG_WIN32) += char-console.o
chardev-obj-$(CONFIG_POSIX) += char-fd.o
chardev-obj-y += char-fe.o
@@ -17,7 +18,7 @@ chardev-obj-y += char-udp.o
chardev-obj-$(CONFIG_WIN32) += char-win.o
chardev-obj-$(CONFIG_WIN32) += char-win-stdio.o

common-obj-y += msmouse.o wctablet.o testdev.o
common-obj-$(CONFIG_SOFTMMU) += msmouse.o wctablet.o testdev.o

ifeq ($(CONFIG_BRLAPI),y)
common-obj-m += baum.o
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@

#include "chardev/char-fe.h"
#include "chardev/char-io.h"
#include "chardev/char-mux.h"
#include "chardev-internal.h"

int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len)
{
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@
#include "chardev/char.h"
#include "sysemu/block-backend.h"
#include "sysemu/sysemu.h"
#include "chardev/char-mux.h"
#include "chardev-internal.h"

/* MUX driver for serial I/O splitting */

+3 −2
Original line number Diff line number Diff line
@@ -490,7 +490,7 @@ static void tcp_chr_disconnect_locked(Chardev *chr)
    if (emit_close) {
        qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
    }
    if (s->reconnect_time) {
    if (s->reconnect_time && !s->reconnect_timer) {
        qemu_chr_socket_restart_timer(chr);
    }
}
@@ -1129,7 +1129,8 @@ static void tcp_chr_connect_client_async(Chardev *chr)
     */
    s->connect_task = qio_task_new(OBJECT(sioc),
                                   qemu_chr_socket_connected,
                                   chr, NULL);
                                   object_ref(OBJECT(chr)),
                                   (GDestroyNotify)object_unref);
    qio_task_run_in_thread(s->connect_task,
                           tcp_chr_connect_client_task,
                           s->addr,
+7 −36
Original line number Diff line number Diff line
@@ -40,12 +40,12 @@
#include "qemu/id.h"
#include "qemu/coroutine.h"

#include "chardev/char-mux.h"
#include "chardev-internal.h"

/***********************************************************/
/* character device */

static Object *get_chardevs_root(void)
Object *get_chardevs_root(void)
{
    return container_get(object_get_root(), "/chardevs");
}
@@ -305,33 +305,6 @@ static const TypeInfo char_type_info = {
    .class_init = char_class_init,
};

static int chardev_machine_done_notify_one(Object *child, void *opaque)
{
    Chardev *chr = (Chardev *)child;
    ChardevClass *class = CHARDEV_GET_CLASS(chr);

    if (class->chr_machine_done) {
        return class->chr_machine_done(chr);
    }

    return 0;
}

static void chardev_machine_done_hook(Notifier *notifier, void *unused)
{
    int ret = object_child_foreach(get_chardevs_root(),
                                   chardev_machine_done_notify_one, NULL);

    if (ret) {
        error_report("Failed to call chardev machine_done hooks");
        exit(1);
    }
}

static Notifier chardev_machine_done_notify = {
    .notify = chardev_machine_done_hook,
};

static bool qemu_chr_is_busy(Chardev *s)
{
    if (CHARDEV_IS_MUX(s)) {
@@ -996,7 +969,11 @@ static Chardev *chardev_new(const char *id, const char *typename,
    }

    if (id) {
        object_property_add_child(get_chardevs_root(), id, obj);
        object_property_try_add_child(get_chardevs_root(), id, obj,
                                      &local_err);
        if (local_err) {
            goto end;
        }
        object_unref(obj);
    }

@@ -1194,12 +1171,6 @@ void qemu_chr_cleanup(void)
static void register_types(void)
{
    type_register_static(&char_type_info);

    /* this must be done after machine init, since we register FEs with muxes
     * as part of realize functions like serial_isa_realizefn when -nographic
     * is specified
     */
    qemu_add_machine_init_done_notifier(&chardev_machine_done_notify);
}

type_init(register_types);
Loading