Skip to content
Snippets Groups Projects
  1. Oct 03, 2023
    • Thomas Huth's avatar
      chardev/char-pty: Avoid losing bytes when the other side just (re-)connected · 4f7689f0
      Thomas Huth authored
      
      When starting a guest via libvirt with "virsh start --console ...",
      the first second of the console output is missing. This is especially
      annoying on s390x that only has a text console by default and no graphical
      output - if the bios fails to boot here, the information about what went
      wrong is completely lost.
      
      One part of the problem (there is also some things to be done on the
      libvirt side) is that QEMU only checks with a 1 second timer whether
      the other side of the pty is already connected, so the first second of
      the console output is always lost.
      
      This likely used to work better in the past, since the code once checked
      for a re-connection during write, but this has been removed in commit
      f8278c7d ("char-pty: remove the check for connection on write") to avoid
      some locking.
      
      To ease the situation here at least a little bit, let's check with g_poll()
      whether we could send out the data anyway, even if the connection has not
      been marked as "connected" yet. The file descriptor is marked as non-blocking
      anyway since commit fac6688a ("Do not hang on full PTY"), so this should
      not cause any trouble if the other side is not ready for receiving yet.
      
      With this patch applied, I can now successfully see the bios output of
      a s390x guest when running it with "virsh start --console" (with a patched
      version of virsh that fixes the remaining issues there, too).
      
      Reported-by: default avatarMarc Hartmayer <mhartmay@linux.ibm.com>
      Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
      Reviewed-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      Message-Id: <20230816210743.1319018-1-thuth@redhat.com>
      4f7689f0
  2. Jun 05, 2023
  3. Jan 09, 2023
  4. May 03, 2022
  5. Apr 06, 2022
  6. Sep 09, 2020
  7. Jun 12, 2019
    • Markus Armbruster's avatar
      Include qemu-common.h exactly where needed · a8d25326
      Markus Armbruster authored
      
      No header includes qemu-common.h after this commit, as prescribed by
      qemu-common.h's file comment.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190523143508.25387-5-armbru@redhat.com>
      [Rebased with conflicts resolved automatically, except for
      include/hw/arm/xlnx-zynqmp.h hw/arm/nrf51_soc.c hw/arm/msf2-soc.c
      block/qcow2-refcount.c block/qcow2-cluster.c block/qcow2-cache.c
      target/arm/cpu.h target/lm32/cpu.h target/m68k/cpu.h target/mips/cpu.h
      target/moxie/cpu.h target/nios2/cpu.h target/openrisc/cpu.h
      target/riscv/cpu.h target/tilegx/cpu.h target/tricore/cpu.h
      target/unicore32/cpu.h target/xtensa/cpu.h; bsd-user/main.c and
      net/tap-bsd.c fixed up]
      a8d25326
    • Markus Armbruster's avatar
      Include qemu/module.h where needed, drop it from qemu-common.h · 0b8fa32f
      Markus Armbruster authored
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190523143508.25387-4-armbru@redhat.com>
      [Rebased with conflicts resolved automatically, except for
      hw/usb/dev-hub.c hw/misc/exynos4210_rng.c hw/misc/bcm2835_rng.c
      hw/misc/aspeed_scu.c hw/display/virtio-vga.c hw/arm/stm32f205_soc.c;
      ui/cocoa.m fixed up]
      0b8fa32f
  8. Apr 18, 2019
    • Markus Armbruster's avatar
      char-pty: Print "char device redirected" message to stdout · 6ade45f2
      Markus Armbruster authored
      
      char_pty_open() prints a "char device redirected to PTY_NAME (label
      LABEL)" message to the current monitor or else to stderr.  This is not
      an error, so it shouldn't go to stderr.  Print it to stdout instead.
      
      Why is it even printed?  No other ChardevClass::open() prints anything
      on success.  It's because you need to know PTY_NAME to actually use
      this char device, e.g. like e.g. "socat STDIO,cfmakeraw FILE:PTY_NAME"
      to use the monitor's readline interface.  You can get PTY_NAME with
      "info chardev" (a.k.a. query-chardev for QMP), but only if you already
      have a monitor.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190417190641.26814-15-armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      6ade45f2
  9. Feb 13, 2019
  10. Oct 19, 2018
  11. Oct 02, 2018
  12. Feb 05, 2018
    • Peter Xu's avatar
      chardev: fix incorrect unref of source · 4e4b5734
      Peter Xu authored
      
      glib reported error when pty chardev used:
      
      $ ./qemu-system-x86_64 -chardev pty,id=foo -device isa-serial,chardev=foo
      qemu-system-x86_64: -chardev pty,id=foo: char device redirected to /dev/pts/2 (label foo)
      (qemu-system-x86_64:27885): GLib-CRITICAL **: g_source_unref: assertion 'source != NULL' failed
      (qemu-system-x86_64:27885): GLib-CRITICAL **: g_source_unref: assertion 'source != NULL' failed
      
      This patch fixes that.
      
      Fixes: 2c716ba1 ("chardev: introduce qemu_chr_timeout_add_ms()")
      CC: Paolo Bonzini <pbonzini@redhat.com>
      Reported-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20180118052049.31119-1-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      4e4b5734
  13. Jan 12, 2018
    • Peter Xu's avatar
      chardev: introduce qemu_chr_timeout_add_ms() · 2c716ba1
      Peter Xu authored
      
      It's a replacement of g_timeout_add[_seconds]() for chardevs.  Chardevs
      now can have dedicated gcontext, we should always bind chardev tasks
      onto those gcontext rather than the default main context.  Since there
      are quite a few of g_timeout_add[_seconds]() callers, a new function
      qemu_chr_timeout_add_ms() is introduced.
      
      One thing to mention is that, terminal3270 is still always running on
      main gcontext.  However let's convert that as well since it's still part
      of chardev codes and in case one day we'll miss that when we move it out
      of main gcontext too.
      
      Also, convert all the timers from GSource tags into GSource pointers.
      Gsource tag IDs and g_source_remove()s can only work with default
      gcontext, while now these GSources can logically be attached to other
      contexts.  So let's use explicit g_source_destroy() plus another
      g_source_unref() to remove a timer.
      
      Note: when in the timer handler, we don't need the g_source_destroy()
      any more since that'll be done automatically if the timer handler
      returns false (and that's what all the current handlers do).
      
      Yet another note: in pty_chr_rearm_timer() we take special care for
      ms=1000.  This patch merged the two cases into one.
      
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20180104141835.17987-4-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      2c716ba1
    • Peter Xu's avatar
      chardev: let g_idle_add() be with chardev gcontext · 938eb9e9
      Peter Xu authored
      
      The idle task will be attached to main gcontext even if the chardev
      backend is running in another gcontext.  Fix the only caller by
      extending the g_idle_add() logic into the more powerful
      g_source_attach().  It's basically g_idle_add_full() implementation, but
      with the chardev's gcontext passed in.
      
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20180104141835.17987-3-peterx@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      938eb9e9
  14. Sep 22, 2017
  15. Jun 02, 2017
  16. May 04, 2017
  17. May 03, 2017
    • Hailiang Zhang's avatar
      char: Fix removing wrong GSource that be found by fd_in_tag · b19456dd
      Hailiang Zhang authored
      
      We use fd_in_tag to find a GSource, fd_in_tag is return value of
      g_source_attach(GSource *source, GMainContext *context), the return
      value is unique only in the same context, so we may get the same
      values with different 'context' parameters.
      
      It is no problem to find the right fd_in_tag by using
       g_main_context_find_source_by_id(GMainContext *context, guint source_id)
      while there is only one default main context.
      
      But colo-compare tries to create/use its own context, and if we pass wrong
      'context' parameter with right fd_in_tag, we will find a wrong GSource to handle.
      We tried to fix the related codes in commit b43decb0,
      but it didn't fix the bug completely, because we still have some codes didn't pass
      *right* context parameter for remove_fd_in_watch().
      
      Let's fix it by record the GSource directly instead of fd_in_tag.
      
      Signed-off-by: default avatarzhanghailiang <zhang.zhanghailiang@huawei.com>
      Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1492564532-91680-1-git-send-email-zhang.zhanghailiang@huawei.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      b19456dd
  18. Mar 06, 2017
  19. Feb 16, 2017
    • Ed Swierk's avatar
      char: drop data written to a disconnected pty · 1c64fdbc
      Ed Swierk authored
      
      When a serial port writes data to a pty that's disconnected, drop the
      data and return the length dropped. This avoids triggering pointless
      retries in callers like the 16550A serial_xmit(), and causes
      qemu_chr_fe_write() to write all data to the log file, rather than
      logging only while a pty client like virsh console happens to be
      connected.
      
      Signed-off-by: default avatarEd Swierk <eswierk@skyportsystems.com>
      Message-Id: <1485870329-79428-1-git-send-email-eswierk@skyportsystems.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      1c64fdbc
  20. Jan 31, 2017
Loading