Skip to content
Snippets Groups Projects
  1. Apr 06, 2022
  2. Mar 22, 2022
  3. Sep 30, 2021
  4. Sep 27, 2021
    • Markus Armbruster's avatar
      qapi: Convert simple union SocketAddressLegacy to flat one · 935a867c
      Markus Armbruster authored
      
      Simple unions predate flat unions.  Having both complicates the QAPI
      schema language and the QAPI generator.  We haven't been using simple
      unions in new code for a long time, because they are less flexible and
      somewhat awkward on the wire.
      
      To prepare for their removal, convert simple union SocketAddressLegacy
      to an equivalent flat one, with existing enum SocketAddressType
      replacing implicit enum type SocketAddressLegacyKind.  Adds some
      boilerplate to the schema, which is a bit ugly, but a lot easier to
      maintain than the simple union feature.
      
      Cc: "Daniel P. Berrangé" <berrange@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20210917143134.412106-9-armbru@redhat.com>
      935a867c
  5. Sep 06, 2021
    • Michael Tokarev's avatar
      qemu-sockets: fix unix socket path copy (again) · 118d527f
      Michael Tokarev authored
      Commit 4cfd970e added an
      assert which ensures the path within an address of a unix
      socket returned from the kernel is at least one byte and
      does not exceed sun_path buffer. Both of this constraints
      are wrong:
      
      A unix socket can be unnamed, in this case the path is
      completely empty (not even \0)
      
      And some implementations (notable linux) can add extra
      trailing byte (\0) _after_ the sun_path buffer if we
      passed buffer larger than it (and we do).
      
      So remove the assertion (since it causes real-life breakage)
      but at the same time fix the usage of sun_path. Namely,
      we should not access sun_path[0] if kernel did not return
      it at all (this is the case for unnamed sockets),
      and use the returned salen when copyig actual path as an
      upper constraint for the amount of bytes to copy - this
      will ensure we wont exceed the information provided by
      the kernel, regardless whenever there is a trailing \0
      or not. This also helps with unnamed sockets.
      
      Note the case of abstract socket, the sun_path is actually
      a blob and can contain \0 characters, - it should not be
      passed to g_strndup and the like, it should be accessed by
      memcpy-like functions.
      
      Fixes: 4cfd970e
      Fixes: http://bugs.debian.org/993145
      
      
      Signed-off-by: default avatarMichael Tokarev <mjt@tls.msk.ru>
      Reviewed-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      CC: qemu-stable@nongnu.org
      118d527f
  6. Aug 04, 2021
  7. Jun 18, 2021
  8. Jun 08, 2021
  9. May 11, 2021
  10. 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
      sockets: Bypass "replace empty @path" for abstract unix sockets · ef298e38
      Markus Armbruster authored
      
      unix_listen_saddr() replaces empty @path by unique value.  It obtains
      the value by creating and deleting a unique temporary file with
      mkstemp().  This is racy, as the comment explains.  It's also entirely
      undocumented as far as I can tell.  Goes back to commit d247d25f
      "sockets: helper functions for qemu (Gerd Hoffman)", v0.10.0.
      
      Since abstract socket addresses have no connection with filesystem
      pathnames, making them up with mkstemp() seems inappropriate.  Bypass
      the replacement of empty @path.
      
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      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>
      ef298e38
    • Markus Armbruster's avatar
      sockets: Fix socket_sockaddr_to_address_unix() for abstract sockets · 3b14b4ec
      Markus Armbruster authored
      
      Commit 776b97d3 "qemu-sockets: add abstract UNIX domain socket
      support" neglected to update socket_sockaddr_to_address_unix().  The
      function returns a non-abstract socket address for abstract
      sockets (wrong) with a null @path (also wrong; a non-optional QAPI str
      member must never be null).
      
      The null @path is due to confused code going back all the way to
      commit 17c55dec "sockets: add helpers for creating SocketAddress
      from a socket".
      
      Add the required special case, and simplify the confused code.
      
      Fixes: 776b97d3
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      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>
      3b14b4ec
    • 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
  11. Oct 29, 2020
  12. Oct 09, 2020
  13. Sep 23, 2020
    • Stefan Hajnoczi's avatar
      qemu/atomic.h: rename atomic_ to qatomic_ · d73415a3
      Stefan Hajnoczi authored
      
      clang's C11 atomic_fetch_*() functions only take a C11 atomic type
      pointer argument. QEMU uses direct types (int, etc) and this causes a
      compiler error when a QEMU code calls these functions in a source file
      that also included <stdatomic.h> via a system header file:
      
        $ CC=clang CXX=clang++ ./configure ... && make
        ../util/async.c:79:17: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid)
      
      Avoid using atomic_*() names in QEMU's atomic.h since that namespace is
      used by <stdatomic.h>. Prefix QEMU's APIs with 'q' so that atomic.h
      and <stdatomic.h> can co-exist. I checked /usr/include on my machine and
      searched GitHub for existing "qatomic_" users but there seem to be none.
      
      This patch was generated using:
      
        $ git grep -h -o '\<atomic\(64\)\?_[a-z0-9_]\+' include/qemu/atomic.h | \
          sort -u >/tmp/changed_identifiers
        $ for identifier in $(</tmp/changed_identifiers); do
              sed -i "s%\<$identifier\>%q$identifier%g" \
                  $(git grep -I -l "\<$identifier\>")
          done
      
      I manually fixed line-wrap issues and misaligned rST tables.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20200923105646.47864-1-stefanha@redhat.com>
      d73415a3
  14. Sep 17, 2020
  15. May 20, 2020
  16. May 04, 2020
    • Simran Singhal's avatar
      Compress lines for immediate return · b3ac2b94
      Simran Singhal authored
      
      Compress two lines into a single line if immediate return statement is found.
      
      It also remove variables progress, val, data, ret and sock
      as they are no longer needed.
      
      Remove space between function "mixer_load" and '(' to fix the
      checkpatch.pl error:-
      ERROR: space prohibited between function name and open parenthesis '('
      
      Done using following coccinelle script:
      @@
      local idexpression ret;
      expression e;
      @@
      
      -ret =
      +return
           e;
      -return ret;
      
      Signed-off-by: default avatarSimran Singhal <singhalsimran0@gmail.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Message-Id: <20200401165314.GA3213@simran-Inspiron-5558>
      [lv: in handle_aiocb_write_zeroes_unmap() move "int ret" inside the #ifdef]
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      b3ac2b94
  17. Sep 25, 2019
  18. Sep 03, 2019
  19. Aug 15, 2019
  20. 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
  21. May 10, 2019
  22. May 03, 2019
    • Daniel P. Berrangé's avatar
      sockets: avoid string truncation warnings when copying UNIX path · 2d2023c3
      Daniel P. Berrangé authored
      
      In file included from /usr/include/string.h:494,
                       from include/qemu/osdep.h:101,
                       from util/qemu-sockets.c:18:
      In function ‘strncpy’,
          inlined from ‘unix_connect_saddr.isra.0’ at util/qemu-sockets.c:925:5:
      /usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ specified bound 108 equals destination size [-Wstringop-truncation]
        106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
            |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In function ‘strncpy’,
          inlined from ‘unix_listen_saddr.isra.0’ at util/qemu-sockets.c:880:5:
      /usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ specified bound 108 equals destination size [-Wstringop-truncation]
        106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
            |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      We are already validating the UNIX socket path length earlier in
      the functions. If we save this string length when we first check
      it, then we can simply use memcpy instead of strcpy later, avoiding
      the gcc truncation warnings.
      
      Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20190501145052.12579-1-berrange@redhat.com>
      Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
      2d2023c3
  23. Jan 11, 2019
    • Paolo Bonzini's avatar
      avoid TABs in files that only contain a few · 7d37435b
      Paolo Bonzini authored
      
      Most files that have TABs only contain a handful of them.  Change
      them to spaces so that we don't confuse people.
      
      disas, standard-headers, linux-headers and libdecnumber are imported
      from other projects and probably should be exempted from the check.
      Outside those, after this patch the following files still contain both
      8-space and TAB sequences at the beginning of the line.  Many of them
      have a majority of TABs, or were initially committed with all tabs.
      
          bsd-user/i386/target_syscall.h
          bsd-user/x86_64/target_syscall.h
          crypto/aes.c
          hw/audio/fmopl.c
          hw/audio/fmopl.h
          hw/block/tc58128.c
          hw/display/cirrus_vga.c
          hw/display/xenfb.c
          hw/dma/etraxfs_dma.c
          hw/intc/sh_intc.c
          hw/misc/mst_fpga.c
          hw/net/pcnet.c
          hw/sh4/sh7750.c
          hw/timer/m48t59.c
          hw/timer/sh_timer.c
          include/crypto/aes.h
          include/disas/bfd.h
          include/hw/sh4/sh.h
          libdecnumber/decNumber.c
          linux-headers/asm-generic/unistd.h
          linux-headers/linux/kvm.h
          linux-user/alpha/target_syscall.h
          linux-user/arm/nwfpe/double_cpdo.c
          linux-user/arm/nwfpe/fpa11_cpdt.c
          linux-user/arm/nwfpe/fpa11_cprt.c
          linux-user/arm/nwfpe/fpa11.h
          linux-user/flat.h
          linux-user/flatload.c
          linux-user/i386/target_syscall.h
          linux-user/ppc/target_syscall.h
          linux-user/sparc/target_syscall.h
          linux-user/syscall.c
          linux-user/syscall_defs.h
          linux-user/x86_64/target_syscall.h
          slirp/cksum.c
          slirp/if.c
          slirp/ip.h
          slirp/ip_icmp.c
          slirp/ip_icmp.h
          slirp/ip_input.c
          slirp/ip_output.c
          slirp/mbuf.c
          slirp/misc.c
          slirp/sbuf.c
          slirp/socket.c
          slirp/socket.h
          slirp/tcp_input.c
          slirp/tcpip.h
          slirp/tcp_output.c
          slirp/tcp_subr.c
          slirp/tcp_timer.c
          slirp/tftp.c
          slirp/udp.c
          slirp/udp.h
          target/cris/cpu.h
          target/cris/mmu.c
          target/cris/op_helper.c
          target/sh4/helper.c
          target/sh4/op_helper.c
          target/sh4/translate.c
          tcg/sparc/tcg-target.inc.c
          tests/tcg/cris/check_addo.c
          tests/tcg/cris/check_moveq.c
          tests/tcg/cris/check_swap.c
          tests/tcg/multiarch/test-mmap.c
          ui/vnc-enc-hextile-template.h
          ui/vnc-enc-zywrle.h
          util/envlist.c
          util/readline.c
      
      The following have only TABs:
      
          bsd-user/i386/target_signal.h
          bsd-user/sparc64/target_signal.h
          bsd-user/sparc64/target_syscall.h
          bsd-user/sparc/target_signal.h
          bsd-user/sparc/target_syscall.h
          bsd-user/x86_64/target_signal.h
          crypto/desrfb.c
          hw/audio/intel-hda-defs.h
          hw/core/uboot_image.h
          hw/sh4/sh7750_regnames.c
          hw/sh4/sh7750_regs.h
          include/hw/cris/etraxfs_dma.h
          linux-user/alpha/termbits.h
          linux-user/arm/nwfpe/fpopcode.h
          linux-user/arm/nwfpe/fpsr.h
          linux-user/arm/syscall_nr.h
          linux-user/arm/target_signal.h
          linux-user/cris/target_signal.h
          linux-user/i386/target_signal.h
          linux-user/linux_loop.h
          linux-user/m68k/target_signal.h
          linux-user/microblaze/target_signal.h
          linux-user/mips64/target_signal.h
          linux-user/mips/target_signal.h
          linux-user/mips/target_syscall.h
          linux-user/mips/termbits.h
          linux-user/ppc/target_signal.h
          linux-user/sh4/target_signal.h
          linux-user/sh4/termbits.h
          linux-user/sparc64/target_syscall.h
          linux-user/sparc/target_signal.h
          linux-user/x86_64/target_signal.h
          linux-user/x86_64/termbits.h
          pc-bios/optionrom/optionrom.h
          slirp/mbuf.h
          slirp/misc.h
          slirp/sbuf.h
          slirp/tcp.h
          slirp/tcp_timer.h
          slirp/tcp_var.h
          target/i386/svm.h
          target/sparc/asi.h
          target/xtensa/core-dc232b/xtensa-modules.inc.c
          target/xtensa/core-dc233c/xtensa-modules.inc.c
          target/xtensa/core-de212/core-isa.h
          target/xtensa/core-de212/xtensa-modules.inc.c
          target/xtensa/core-fsf/xtensa-modules.inc.c
          target/xtensa/core-sample_controller/core-isa.h
          target/xtensa/core-sample_controller/xtensa-modules.inc.c
          target/xtensa/core-test_kc705_be/core-isa.h
          target/xtensa/core-test_kc705_be/xtensa-modules.inc.c
          tests/tcg/cris/check_abs.c
          tests/tcg/cris/check_addc.c
          tests/tcg/cris/check_addcm.c
          tests/tcg/cris/check_addoq.c
          tests/tcg/cris/check_bound.c
          tests/tcg/cris/check_ftag.c
          tests/tcg/cris/check_int64.c
          tests/tcg/cris/check_lz.c
          tests/tcg/cris/check_openpf5.c
          tests/tcg/cris/check_sigalrm.c
          tests/tcg/cris/crisutils.h
          tests/tcg/cris/sys.c
          tests/tcg/i386/test-i386-ssse3.c
          ui/vgafont.h
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20181213223737.11793-3-pbonzini@redhat.com>
      Reviewed-by: default avatarAleksandar Markovic <amarkovic@wavecomp.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarWainer dos Santos Moschetta <wainersm@redhat.com>
      Acked-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Acked-by: default avatarEric Blake <eblake@redhat.com>
      Acked-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: default avatarStefan Markovic <smarkovic@wavecomp.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      7d37435b
  24. Mar 13, 2018
  25. Mar 02, 2018
  26. Feb 05, 2018
  27. Dec 21, 2017
  28. Dec 18, 2017
  29. Nov 28, 2017
  30. Nov 07, 2017
  31. Oct 16, 2017
  32. Sep 05, 2017
  33. Jul 14, 2017
Loading