Skip to content
Snippets Groups Projects
  1. Jun 02, 2021
  2. Mar 16, 2021
  3. Mar 06, 2021
  4. Feb 25, 2021
  5. Jan 28, 2021
  6. Jan 22, 2021
  7. Nov 11, 2020
  8. 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
  9. Sep 18, 2020
  10. Sep 17, 2020
  11. Sep 09, 2020
  12. Sep 01, 2020
  13. Aug 21, 2020
  14. Jul 21, 2020
  15. May 27, 2020
  16. May 15, 2020
    • Markus Armbruster's avatar
      qom: Drop parameter @errp of object_property_add() & friends · d2623129
      Markus Armbruster authored
      
      The only way object_property_add() can fail is when a property with
      the same name already exists.  Since our property names are all
      hardcoded, failure is a programming error, and the appropriate way to
      handle it is passing &error_abort.
      
      Same for its variants, except for object_property_add_child(), which
      additionally fails when the child already has a parent.  Parentage is
      also under program control, so this is a programming error, too.
      
      We have a bit over 500 callers.  Almost half of them pass
      &error_abort, slightly fewer ignore errors, one test case handles
      errors, and the remaining few callers pass them to their own callers.
      
      The previous few commits demonstrated once again that ignoring
      programming errors is a bad idea.
      
      Of the few ones that pass on errors, several violate the Error API.
      The Error ** argument must be NULL, &error_abort, &error_fatal, or a
      pointer to a variable containing NULL.  Passing an argument of the
      latter kind twice without clearing it in between is wrong: if the
      first call sets an error, it no longer points to NULL for the second
      call.  ich9_pm_add_properties(), sparc32_ledma_realize(),
      sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
      are wrong that way.
      
      When the one appropriate choice of argument is &error_abort, letting
      users pick the argument is a bad idea.
      
      Drop parameter @errp and assert the preconditions instead.
      
      There's one exception to "duplicate property name is a programming
      error": the way object_property_add() implements the magic (and
      undocumented) "automatic arrayification".  Don't drop @errp there.
      Instead, rename object_property_add() to object_property_try_add(),
      and add the obvious wrapper object_property_add().
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20200505152926.18877-15-armbru@redhat.com>
      [Two semantic rebase conflicts resolved]
      d2623129
  17. Mar 16, 2020
    • Christophe de Dinechin's avatar
      scsi/qemu-pr-helper: Fix out-of-bounds access to trnptid_list[] · 4ce1e15f
      Christophe de Dinechin authored
      
      Compile error reported by gcc 10.0.1:
      
      scsi/qemu-pr-helper.c: In function ‘multipath_pr_out’:
      scsi/qemu-pr-helper.c:523:32: error: array subscript <unknown> is outside array bounds of ‘struct transportid *[0]’ [-Werror=array-bounds]
        523 |             paramp.trnptid_list[paramp.num_transportid++] = id;
            |             ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      In file included from scsi/qemu-pr-helper.c:36:
      /usr/include/mpath_persist.h:168:22: note: while referencing ‘trnptid_list’
        168 |  struct transportid *trnptid_list[];
            |                      ^~~~~~~~~~~~
      scsi/qemu-pr-helper.c:424:35: note: defined here ‘paramp’
        424 |     struct prout_param_descriptor paramp;
            |                                   ^~~~~~
      
      This highlights an actual implementation issue in function multipath_pr_out.
      The variable paramp is declared with type `struct prout_param_descriptor`,
      which is a struct terminated by an empty array in mpath_persist.h:
      
              struct transportid *trnptid_list[];
      
      That empty array was filled with code that looked like that:
      
              trnptid_list[paramp.descr.num_transportid++] = id;
      
      This is an actual out-of-bounds access.
      
      The fix is to malloc `paramp`.
      
      Signed-off-by: default avatarChristophe de Dinechin <dinechin@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      4ce1e15f
  18. Dec 17, 2019
  19. Oct 03, 2019
    • Maxim Levitsky's avatar
      qemu-pr-helper: fix crash in mpath_reconstruct_sense · b2aca78c
      Maxim Levitsky authored
      The 'r' variable was accidently shadowed, and because of this
      we were always passing 0 to mpath_generic_sense, instead of original
      return value, which triggers an abort()
      
      This is an attempt to fix the
      https://bugzilla.redhat.com/show_bug.cgi?id=1720047
      
      
      although there might be other places in the code
      that trigger qemu-pr-helper crash, and this fix might
      not be the root cause.
      
      The crash was reproduced by creating an iscsi target on a test machine,
      and passing it twice to the guest like that:
      
      -blockdev node-name=idisk0,driver=iscsi,transport=...,target=...
      -device scsi-block,drive=idisk0,bus=scsi0.0,bootindex=-1,scsi-id=1,lun=0,share-rw=on
      -device scsi-block,drive=idisk0,bus=scsi0.0,bootindex=-1,scsi-id=1,lun=1,share-rw=on
      
      Then in the guest, both /dev/sda and /dev/sdb were aggregated by multipath to /dev/mpatha,
      which was passed to a nested guest like that
      
      -object pr-manager-helper,id=qemu_pr_helper,path=/root/work/vm/testvm/.run/pr_helper.socket
      -blockdev node-name=test,driver=host_device,filename=/dev/mapper/mpatha,pr-manager=qemu_pr_helper
      -device scsi-block,drive=test,bus=scsi0.0,bootindex=-1,scsi-id=0,lun=0
      
      The nested guest run:
      
      sg_persist --no-inquiry  -v --out --register --param-sark 0x1234 /dev/sda
      
      Strictly speaking this is wrong configuration since qemu is where
      the multipath was split, and thus the iscsi target was not aware of
      multipath, and thus when libmpathpersist code rightfully tried to register
      the PR key on all paths, it failed to do so.
      
      However qemu-pr-helper should not crash in this case.
      
      Signed-off-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      b2aca78c
  20. Sep 10, 2019
  21. Sep 03, 2019
  22. Jul 15, 2019
  23. 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
  24. May 13, 2019
  25. Apr 17, 2019
    • Christophe Fergeau's avatar
      log: Make glib logging go through QEMU · f5852efa
      Christophe Fergeau authored
      
      This commit adds a error_init() helper which calls
      g_log_set_default_handler() so that glib logs (g_log, g_warning, ...)
      are handled similarly to other QEMU logs. This means they will get a
      timestamp if timestamps are enabled, and they will go through the
      HMP monitor if one is configured.
      
      This commit also adds a call to error_init() to the binaries
      installed by QEMU. Since error_init() also calls error_set_progname(),
      this means that *-linux-user, *-bsd-user and qemu-pr-helper messages
      output with error_report, info_report, ... will slightly change: they
      will be prefixed by the binary name.
      
      glib debug messages are enabled through G_MESSAGES_DEBUG similarly to
      the glib default log handler.
      
      At the moment, this change will mostly impact SPICE logging if your
      spice version is >= 0.14.1. With older spice versions, this is not going
      to work as expected, but will not have any ill effect, so this call is
      not conditional on the SPICE version.
      
      Signed-off-by: default avatarChristophe Fergeau <cfergeau@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Message-Id: <20190131164614.19209-3-cfergeau@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      f5852efa
  26. Mar 22, 2019
  27. Dec 14, 2018
  28. Nov 27, 2018
  29. Oct 02, 2018
    • Marc-André Lureau's avatar
      util: add qemu_write_pidfile() · 9e6bdef2
      Marc-André Lureau authored
      
      There are variants of qemu_create_pidfile() in qemu-pr-helper and
      qemu-ga. Let's have a common implementation in libqemuutil.
      
      The code is initially based from pr-helper write_pidfile(), with
      various improvements and suggestions from Daniel Berrangé:
      
        QEMU will leave the pidfile existing on disk when it exits which
        initially made me think it avoids the deletion race. The app
        managing QEMU, however, may well delete the pidfile after it has
        seen QEMU exit, and even if the app locks the pidfile before
        deleting it, there is still a race.
      
        eg consider the following sequence
      
              QEMU 1        libvirtd        QEMU 2
      
        1.    lock(pidfile)
      
        2.    exit()
      
        3.                 open(pidfile)
      
        4.                 lock(pidfile)
      
        5.                                  open(pidfile)
      
        6.                 unlink(pidfile)
      
        7.                 close(pidfile)
      
        8.                                  lock(pidfile)
      
        IOW, at step 8 the new QEMU has successfully acquired the lock, but
        the pidfile no longer exists on disk because it was deleted after
        the original QEMU exited.
      
        While we could just say no external app should ever delete the
        pidfile, I don't think that is satisfactory as people don't read
        docs, and admins don't like stale pidfiles being left around on
        disk.
      
        To make this robust, I think we might want to copy libvirt's
        approach to pidfile acquisition which runs in a loop and checks that
        the file on disk /after/ acquiring the lock matches the file that
        was locked. Then we could in fact safely let QEMU delete its own
        pidfiles on clean exit..
      
      Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <20180831145314.14736-2-marcandre.lureau@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      9e6bdef2
  30. Aug 28, 2018
  31. Aug 23, 2018
  32. Jul 06, 2018
Loading