Skip to content
Snippets Groups Projects
  1. Jan 13, 2021
  2. Jan 02, 2021
  3. Dec 19, 2020
    • Eric Blake's avatar
      qapi: Use QAPI_LIST_PREPEND() where possible · 54aa3de7
      Eric Blake authored
      
      Anywhere we create a list of just one item or by prepending items
      (typically because order doesn't matter), we can use
      QAPI_LIST_PREPEND().  But places where we must keep the list in order
      by appending remain open-coded until later patches.
      
      Note that as a side effect, this also performs a cleanup of two minor
      issues in qga/commands-posix.c: the old code was performing
       new = g_malloc0(sizeof(*ret));
      which 1) is confusing because you have to verify whether 'new' and
      'ret' are variables with the same type, and 2) would conflict with C++
      compilation (not an actual problem for this file, but makes
      copy-and-paste harder).
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20201113011340.463563-5-eblake@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Acked-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      [Straightforward conflicts due to commit a8aa94b5 "qga: update
      schema for guest-get-disks 'dependents' field" and commit a10b453a
      "target/mips: Move mips_cpu_add_definition() from helper.c to cpu.c"
      resolved.  Commit message tweaked.]
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      54aa3de7
  4. Dec 15, 2020
    • Paolo Bonzini's avatar
      chardev: do not use machine_init_done · 5a1ee607
      Paolo Bonzini authored
      
      machine_init_done is not the right flag to check when preconfig
      is taken into account; for example "./qemu-system-x86_64 -serial
      mon:stdio -preconfig" does not print the QEMU monitor header until after
      exit_preconfig.  Add back a custom bool for mux character devices.  This
      partially undoes commit c7278b43 ("chardev: introduce chr_machine_done
      hook", 2018-03-12), but it keeps the cleaner logic using a function
      pointer in ChardevClass.
      
      Reviewed-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      5a1ee607
  5. Dec 10, 2020
  6. Nov 17, 2020
  7. Nov 03, 2020
    • Markus Armbruster's avatar
      sockets: Make abstract UnixSocketAddress depend on CONFIG_LINUX · 8acefc79
      Markus Armbruster authored
      
      The abstract socket namespace is a non-portable Linux extension.  An
      attempt to use it elsewhere should fail with ENOENT (the abstract
      address looks like a "" pathname, which does not resolve).  We report
      this failure like
      
          Failed to connect socket abc: No such file or directory
      
      Tolerable, although ENOTSUP would be better.
      
      However, introspection lies: it has @abstract regardless of host
      support.  Easy enough to fix: since Linux provides them since 2.2,
      'if': 'defined(CONFIG_LINUX)' should do.
      
      The above failure becomes
      
          Parameter 'backend.data.addr.data.abstract' is unexpected
      
      I consider this an improvement.
      
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      8acefc79
    • Markus Armbruster's avatar
      char-socket: Fix qemu_chr_socket_address() for abstract sockets · dea7cd17
      Markus Armbruster authored
      
      Commit 776b97d3 "qemu-sockets: add abstract UNIX domain socket
      support" neglected to update qemu_chr_socket_address().  It shows
      shows neither @abstract nor @tight.  Fix that.
      
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      dea7cd17
    • Markus Armbruster's avatar
      sockets: Fix default of UnixSocketAddress member @tight · b08cc97d
      Markus Armbruster authored
      
      An optional bool member of a QAPI struct can be false, true, or absent.
      The previous commit demonstrated that socket_listen() and
      socket_connect() are broken for absent @tight, and indeed QMP chardev-
      add also defaults absent member @tight to false instead of true.
      
      In C, QAPI members are represented by two fields, has_MEMBER and MEMBER.
      We have:
      
                  has_MEMBER    MEMBER
          false         true     false
          true          true      true
          absent       false  false/ignore
      
      When has_MEMBER is false, MEMBER should be set to false on write, and
      ignored on read.
      
      For QMP, the QAPI visitors handle absent @tight by setting both
      @has_tight and @tight to false.  unix_listen_saddr() and
      unix_connect_saddr() however use @tight only, disregarding @has_tight.
      This is wrong and means that absent @tight defaults to false whereas it
      should default to true.
      
      The same is true for @has_abstract, though @abstract defaults to
      false and therefore has the same behavior for all of QMP, HMP and CLI.
      Fix unix_listen_saddr() and unix_connect_saddr() to check
      @has_abstract/@has_tight, and to default absent @tight to true.
      
      However, this is only half of the story.  HMP chardev-add and CLI
      -chardev so far correctly defaulted @tight to true, but defaults to
      false again with the above fix for HMP and CLI.  In fact, the "tight"
      and "abstract" options now break completely.
      
      Digging deeper, we find that qemu_chr_parse_socket() also ignores
      @has_tight, leaving it false when it sets @tight.  That is also wrong,
      but the two wrongs cancelled out.  Fix qemu_chr_parse_socket() to set
      @has_tight and @has_abstract; writing testcases for HMP and CLI is left
      for another day.
      
      Fixes: 776b97d3
      Reported-by: default avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      b08cc97d
  8. Oct 21, 2020
  9. Oct 15, 2020
  10. Oct 12, 2020
  11. Sep 30, 2020
    • Daniel P. Berrangé's avatar
      char: fix logging when chardev write fails · d96aa5db
      Daniel P. Berrangé authored
      The qemu_chr_write_buffer() method sends data to the chardev backend for
      writing, and then also writes to the log file. In case the chardev
      backend only writes part of the data buffer, we need to make sure we
      only log the same subset. qemu_chr_write_buffer() will be invoked again
      later to write the rest of the buffer.
      
      In the case the chardev backend returns an error though, no further
      attempts to likely to be made to write the data. We must therefore write
      the entire buffer to the log immediately.
      
      An example where this is important is with the socket backend. This will
      return -1 for all writes if no client is currently connected. We still
      wish to write data to the log file when no client is present though.
      This used to work because the chardev would return "len" to pretend it
      had written all data when no client is connected, but this changed to
      return an error in
      
        commit 27109447
        Author: Dima Stepanov <dimastep@yandex-team.ru>
        Date: Thu May 28 12:11:18 2020 +0300
      
          char-socket: return -1 in case of disconnect during tcp_chr_write
      
      and this broke the logging, resulting in all data being discarded when
      no client is present.
      
      Fixes: https://bugs.launchpad.net/qemu/+bug/1893691
      
      
      Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      d96aa5db
  12. Sep 16, 2020
  13. Sep 09, 2020
  14. Sep 08, 2020
    • Bruce Rogers's avatar
      meson: remove linkage of sdl to baum · fd6c986d
      Bruce Rogers authored
      
      Ever since commit 537fe2d6 there
      has been a 'linkage' to sdl for compiling baum.c. Originally it
      had to do with including sdl cflags for any file including sdl
      headers. There is no longer any such need for baum.c, but the
      association has persisted in the make system, and with the switch
      to meson it has now become a hard requirement, which now causes
      chardev-baum.so to not be produced if sdl is not configured.
      Remove this bogus linkage.
      
      Signed-off-by: default avatarBruce Rogers <brogers@suse.com>
      Message-Id: <20200903152933.97838-1-brogers@suse.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      fd6c986d
  15. Sep 01, 2020
  16. Aug 27, 2020
  17. Aug 21, 2020
  18. Jul 13, 2020
    • Philippe Mathieu-Daudé's avatar
      chardev: Extract system emulation specific code · 30827bad
      Philippe Mathieu-Daudé authored
      
      Split out code only used during system emulation,
      to reduce code pulled in user emulation and tools.
      
      Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-Id: <20200423202112.644-6-philmd@redhat.com>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      30827bad
    • Philippe Mathieu-Daudé's avatar
      chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h" · ffa0f7eb
      Philippe Mathieu-Daudé authored
      
      No file out of chardev/ requires access to this header,
      restrict its scope.
      
      Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-Id: <20200423202112.644-5-philmd@redhat.com>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      ffa0f7eb
    • Philippe Mathieu-Daudé's avatar
      chardev: Restrict msmouse / wctablet / testdev to system emulation · c383efd5
      Philippe Mathieu-Daudé authored
      
      The msmouse / wctablet / testdev character devices are only
      used by system emulation. Remove them from user mode and tools.
      
      Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-Id: <20200423202112.644-4-philmd@redhat.com>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      c383efd5
    • Marc-André Lureau's avatar
      char: fix use-after-free with dup chardev & reconnect · 68066019
      Marc-André Lureau authored
      
      With a reconnect socket, qemu_char_open() will start a background
      thread. It should keep a reference on the chardev.
      
      Fixes invalid read:
      READ of size 8 at 0x6040000ac858 thread T7
          #0 0x5555598d37b8 in unix_connect_saddr /home/elmarco/src/qq/util/qemu-sockets.c:954
          #1 0x5555598d4751 in socket_connect /home/elmarco/src/qq/util/qemu-sockets.c:1109
          #2 0x555559707c34 in qio_channel_socket_connect_sync /home/elmarco/src/qq/io/channel-socket.c:145
          #3 0x5555596adebb in tcp_chr_connect_client_task /home/elmarco/src/qq/chardev/char-socket.c:1104
          #4 0x555559723d55 in qio_task_thread_worker /home/elmarco/src/qq/io/task.c:123
          #5 0x5555598a6731 in qemu_thread_start /home/elmarco/src/qq/util/qemu-thread-posix.c:519
          #6 0x7ffff40d4431 in start_thread (/lib64/libpthread.so.0+0x9431)
          #7 0x7ffff40029d2 in __clone (/lib64/libc.so.6+0x1019d2)
      
      Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      Message-Id: <20200420112012.567284-1-marcandre.lureau@redhat.com>
      68066019
    • Marc-André Lureau's avatar
      chardev: don't abort on attempt to add duplicated chardev · 14a7a203
      Marc-André Lureau authored
      
      This is a regression from commit d2623129 ("qom: Drop parameter @errp
      of object_property_add() & friends").
      
      (qemu) chardev-add id=null,backend=null
      (qemu) chardev-add id=null,backend=null
      Unexpected error in object_property_try_add() at /home/elmarco/src/qemu/qom/object.c:1166:
      attempt to add duplicate property 'null' to object (type 'container')
      
      That case is currently not covered in the test suite, but will be with
      the queued patch "char: fix use-after-free with dup chardev &
      reconnect".
      
      Fixes: d2623129
      Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      14a7a203
    • Li Feng's avatar
      char-socket: initialize reconnect timer only when the timer doesn't start · 2b61bb71
      Li Feng authored
      
      When the disconnect event is triggered in the connecting stage,
      the tcp_chr_disconnect_locked may be called twice.
      
      The first call:
          #0  qemu_chr_socket_restart_timer (chr=0x55555582ee90) at chardev/char-socket.c:120
          #1  0x000055555558e38c in tcp_chr_disconnect_locked (chr=<optimized out>) at chardev/char-socket.c:490
          #2  0x000055555558e3cd in tcp_chr_disconnect (chr=0x55555582ee90) at chardev/char-socket.c:497
          #3  0x000055555558ea32 in tcp_chr_new_client (chr=chr@entry=0x55555582ee90, sioc=sioc@entry=0x55555582f0b0) at chardev/char-socket.c:892
          #4  0x000055555558eeb8 in qemu_chr_socket_connected (task=0x55555582f300, opaque=<optimized out>) at chardev/char-socket.c:1090
          #5  0x0000555555574352 in qio_task_complete (task=task@entry=0x55555582f300) at io/task.c:196
          #6  0x00005555555745f4 in qio_task_thread_result (opaque=0x55555582f300) at io/task.c:111
          #7  qio_task_wait_thread (task=0x55555582f300) at io/task.c:190
          #8  0x000055555558f17e in tcp_chr_wait_connected (chr=0x55555582ee90, errp=0x555555802a08 <error_abort>) at chardev/char-socket.c:1013
          #9  0x0000555555567cbd in char_socket_client_reconnect_test (opaque=0x5555557fe020 <client8unix>) at tests/test-char.c:1152
      The second call:
          #0  0x00007ffff5ac3277 in raise () from /lib64/libc.so.6
          #1  0x00007ffff5ac4968 in abort () from /lib64/libc.so.6
          #2  0x00007ffff5abc096 in __assert_fail_base () from /lib64/libc.so.6
          #3  0x00007ffff5abc142 in __assert_fail () from /lib64/libc.so.6
          #4  0x000055555558d10a in qemu_chr_socket_restart_timer (chr=0x55555582ee90) at chardev/char-socket.c:125
          #5  0x000055555558df0c in tcp_chr_disconnect_locked (chr=<optimized out>) at chardev/char-socket.c:490
          #6  0x000055555558df4d in tcp_chr_disconnect (chr=0x55555582ee90) at chardev/char-socket.c:497
          #7  0x000055555558e5b2 in tcp_chr_new_client (chr=chr@entry=0x55555582ee90, sioc=sioc@entry=0x55555582f0b0) at chardev/char-socket.c:892
          #8  0x000055555558e93a in tcp_chr_connect_client_sync (chr=chr@entry=0x55555582ee90, errp=errp@entry=0x7fffffffd178) at chardev/char-socket.c:944
          #9  0x000055555558ec78 in tcp_chr_wait_connected (chr=0x55555582ee90, errp=0x555555802a08 <error_abort>) at chardev/char-socket.c:1035
          #10 0x000055555556804b in char_socket_client_test (opaque=0x5555557fe020 <client8unix>) at tests/test-char.c:1023
      
      Run test/test-char to reproduce this issue.
      
      test-char: chardev/char-socket.c:125: qemu_chr_socket_restart_timer: Assertion `!s->reconnect_timer' failed.
      
      Signed-off-by: default avatarLi Feng <fengli@smartx.com>
      Acked-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <20200522025554.41063-1-fengli@smartx.com>
      2b61bb71
  19. Jul 10, 2020
    • Markus Armbruster's avatar
      qemu-option: Use returned bool to check for failure · 235e59cf
      Markus Armbruster authored
      
      The previous commit enables conversion of
      
          foo(..., &err);
          if (err) {
              ...
          }
      
      to
      
          if (!foo(..., &err)) {
              ...
          }
      
      for QemuOpts functions that now return true / false on success /
      error.  Coccinelle script:
      
          @@
          identifier fun = {
              opts_do_parse, parse_option_bool, parse_option_number,
              parse_option_size, qemu_opt_parse, qemu_opt_rename, qemu_opt_set,
              qemu_opt_set_bool, qemu_opt_set_number, qemu_opts_absorb_qdict,
              qemu_opts_do_parse, qemu_opts_from_qdict_entry, qemu_opts_set,
              qemu_opts_validate
          };
          expression list args, args2;
          typedef Error;
          Error *err;
          @@
          -    fun(args, &err, args2);
          -    if (err)
          +    if (!fun(args, &err, args2))
               {
                   ...
               }
      
      A few line breaks tidied up manually.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20200707160613.848843-15-armbru@redhat.com>
      [Conflict with commit 0b6786a9 "block/amend: refactor qcow2 amend
      options" resolved by rerunning Coccinelle on master's version]
      235e59cf
  20. Jul 07, 2020
  21. Jul 02, 2020
  22. Jun 18, 2020
  23. Jun 10, 2020
  24. Jun 09, 2020
    • Dima Stepanov's avatar
      char-socket: return -1 in case of disconnect during tcp_chr_write · 27109447
      Dima Stepanov authored
      
      During testing of the vhost-user-blk reconnect functionality the qemu
      SIGSEGV was triggered:
       start qemu as:
       x86_64-softmmu/qemu-system-x86_64 -m 1024M -M q35 \
         -object memory-backend-file,id=ram-node0,size=1024M,mem-path=/dev/shm/qemu,share=on \
         -numa node,cpus=0,memdev=ram-node0 \
         -chardev socket,id=chardev0,path=./vhost.sock,noserver,reconnect=1 \
         -device vhost-user-blk-pci,chardev=chardev0,num-queues=4 --enable-kvm
       start vhost-user-blk daemon:
       ./vhost-user-blk -s ./vhost.sock -b test-img.raw
      
      If vhost-user-blk will be killed during the vhost initialization
      process, for instance after getting VHOST_SET_VRING_CALL command, then
      QEMU will fail with the following backtrace:
      
      Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
      0x00005555559272bb in vhost_user_read (dev=0x7fffef2d53e0, msg=0x7fffffffd5b0)
          at ./hw/virtio/vhost-user.c:260
      260         CharBackend *chr = u->user->chr;
      
       #0  0x00005555559272bb in vhost_user_read (dev=0x7fffef2d53e0, msg=0x7fffffffd5b0)
          at ./hw/virtio/vhost-user.c:260
       #1  0x000055555592acb8 in vhost_user_get_config (dev=0x7fffef2d53e0, config=0x7fffef2d5394 "", config_len=60)
          at ./hw/virtio/vhost-user.c:1645
       #2  0x0000555555925525 in vhost_dev_get_config (hdev=0x7fffef2d53e0, config=0x7fffef2d5394 "", config_len=60)
          at ./hw/virtio/vhost.c:1490
       #3  0x00005555558cc46b in vhost_user_blk_device_realize (dev=0x7fffef2d51a0, errp=0x7fffffffd8f0)
          at ./hw/block/vhost-user-blk.c:429
       #4  0x0000555555920090 in virtio_device_realize (dev=0x7fffef2d51a0, errp=0x7fffffffd948)
          at ./hw/virtio/virtio.c:3615
       #5  0x0000555555a9779c in device_set_realized (obj=0x7fffef2d51a0, value=true, errp=0x7fffffffdb88)
          at ./hw/core/qdev.c:891
       ...
      
      The problem is that vhost_user_write doesn't get an error after
      disconnect and try to call vhost_user_read(). The tcp_chr_write()
      routine should return -1 in case of disconnect. Indicate the EIO error
      if this routine is called in the disconnected state.
      
      Signed-off-by: default avatarDima Stepanov <dimastep@yandex-team.ru>
      Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <aeb7806bfc945faadf09f64dcfa30f59de3ac053.1590396396.git.dimastep@yandex-team.ru>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      27109447
  25. May 27, 2020
  26. May 20, 2020
Loading