Skip to content
Snippets Groups Projects
  1. Apr 21, 2022
  2. Mar 21, 2022
  3. Mar 07, 2022
  4. Mar 04, 2022
    • Michael S. Tsirkin's avatar
      qom: assert integer does not overflow · e3682878
      Michael S. Tsirkin authored
      QOM reference counting is not designed with an infinite amount of
      references in mind, trying to take a reference in a loop without
      dropping a reference will overflow the integer.
      
      It is generally a symptom of a reference leak (a missing deref, commonly
      as part of error handling - such as one fixed here:
      https://lore.kernel.org/r/20220228095058.27899-1-sgarzare%40redhat.com
      
       ).
      
      All this can lead to either freeing the object too early (memory
      corruption) or never freeing it (memory leak).
      
      If we happen to dereference at just the right time (when it's wrapping
      around to 0), we might eventually assert when dereferencing, but the
      real problem is an extra object_ref so let's assert there to make such
      issues cleaner and easier to debug.
      
      Some micro-benchmarking shows using fetch and add this is essentially
      free on x86.
      
      Since multiple threads could be incrementing in parallel, we assert
      around INT_MAX to make sure none of these approach the wrap around
      point: this way we get a memory leak and not a memory corruption, the
      former is generally easier to debug.
      
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      e3682878
  5. Feb 21, 2022
  6. Nov 10, 2021
  7. Oct 15, 2021
  8. Jul 23, 2021
    • Paolo Bonzini's avatar
      qom: use correct field name when getting/setting alias properties · cbc94d97
      Paolo Bonzini authored
      Alias targets have a different name than the alias property itself
      (e.g. a machine's pflash0 might be an alias of a property named 'drive').
      When the target's getter or setter invokes the visitor, it will use
      a different name than what the caller expects, and the visitor will
      not be able to find it (or will consume erroneously).
      
      The solution is for alias getters and setters to wrap the incoming
      visitor, and forward the sole field that the target is expecting while
      renaming it appropriately.
      
      This bug has been there forever, but it was exposed after -M parsing
      switched from QemuOptions and StringInputVisitor to keyval and
      QObjectInputVisitor.  Before, the visitor ignored the name. Now, it
      checks "drive" against what was passed on the command line and finds
      that no such property exists.
      
      Fixes: https://gitlab.com/qemu-project/qemu/-/issues/484
      
      
      Reported-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      cbc94d97
  9. Jul 06, 2021
  10. Jun 02, 2021
  11. Apr 01, 2021
  12. Mar 19, 2021
  13. Mar 06, 2021
    • Kevin Wolf's avatar
      qom: Check for wellformed id in user_creatable_add_type() · 0bd5a2eb
      Kevin Wolf authored
      
      Most code paths for creating a user creatable object go through
      QemuOpts, which ensures that the provided 'id' option is actually a
      valid identifier.
      
      However, there are some code paths that don't go through QemuOpts:
      qemu-storage-daemon --object (since commit 8db1efd3) and QMP object-add
      (since it was first introduced in commit cff8b2c6). We need to have the
      same validity check for those, too.
      
      This adds the check and makes it print the same error message as
      QemuOpts on failure.
      
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Message-Id: <20210302171623.49709-1-kwolf@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      0bd5a2eb
  14. Feb 25, 2021
  15. Feb 08, 2021
  16. Jan 02, 2021
  17. Dec 19, 2020
    • Markus Armbruster's avatar
      Revert "qobject: let object_property_get_str() use new API" · 26c52828
      Markus Armbruster authored
      
      Commit aafb21a0 "qobject: let object_property_get_str() use new API"
      isn't much of a simplification.  Not worth having
      object_property_get_str() differ from the other
      object_property_get_FOO().  Revert.
      
      This reverts commit aafb21a0.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Daniel P. Berrangé <berrange@redhat.com>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201211171152.146877-12-armbru@redhat.com>
      Reviewed-by: default avatarEduardo Habkost <ehabkost@redhat.com>
      26c52828
    • Markus Armbruster's avatar
      qobject: Change qobject_to_json()'s value to GString · eab3a467
      Markus Armbruster authored
      
      qobject_to_json() and qobject_to_json_pretty() build a GString, then
      covert it to QString.  Just one of the callers actually needs a
      QString: qemu_rbd_parse_filename().  A few others need a string they
      can modify: qmp_send_response(), qga's send_response(), to_json_str(),
      and qmp_fd_vsend_fds().  The remainder just need a string.
      
      Change qobject_to_json() and qobject_to_json_pretty() to return the
      GString.
      
      qemu_rbd_parse_filename() now has to convert to QString.  All others
      save a QString temporary.  to_json_str() actually becomes a bit
      simpler, because GString provides more convenient modification
      functions.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201211171152.146877-6-armbru@redhat.com>
      eab3a467
    • Markus Armbruster's avatar
      qobject: Make qobject_to_json_pretty() take a pretty argument · 6589f459
      Markus Armbruster authored
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201211171152.146877-4-armbru@redhat.com>
      6589f459
    • 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
  18. Dec 10, 2020
  19. Oct 15, 2020
  20. Oct 12, 2020
  21. Oct 06, 2020
  22. 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
  23. Sep 22, 2020
    • Daniel P. Berrangé's avatar
      qom: simplify object_find_property / object_class_find_property · efba1595
      Daniel P. Berrangé authored
      
      When debugging QEMU it is often useful to put a breakpoint on the
      error_setg_internal method impl.
      
      Unfortunately the object_property_add / object_class_property_add
      methods call object_property_find / object_class_property_find methods
      to check if a property exists already before adding the new property.
      
      As a result there are a huge number of calls to error_setg_internal
      on startup of most QEMU commands, making it very painful to set a
      breakpoint on this method.
      
      Most callers of object_find_property and object_class_find_property,
      however, pass in a NULL for the Error parameter. This simplifies the
      methods to remove the Error parameter entirely, and then adds some
      new wrapper methods that are able to raise an Error when needed.
      
      Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-Id: <20200914135617.1493072-1-berrange@redhat.com>
      Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
      efba1595
Loading