Skip to content
Snippets Groups Projects
  1. Oct 06, 2023
    • Philippe Mathieu-Daudé's avatar
      qom/object_interfaces: Clean up global variable shadowing · e0c7de8d
      Philippe Mathieu-Daudé authored
      
      Fix:
      
        qom/object_interfaces.c:262:53: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
        ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp)
                                                            ^
        qom/object_interfaces.c:298:46: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
        bool user_creatable_add_from_str(const char *optarg, Error **errp)
                                                     ^
        qom/object_interfaces.c:313:49: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
        void user_creatable_process_cmdline(const char *optarg)
                                                        ^
        /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here
        extern char *optarg;                    /* getopt(3) external variables */
                     ^
      
      Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@linaro.org>
      Message-ID: <20231004120019.93101-9-philmd@linaro.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      e0c7de8d
  2. Oct 03, 2023
  3. Jun 20, 2023
  4. Feb 27, 2023
  5. Feb 04, 2023
  6. Dec 14, 2022
    • Markus Armbruster's avatar
      qapi qdev qom: Elide redundant has_FOO in generated C · 047f2ca1
      Markus Armbruster authored
      
      The has_FOO for pointer-valued FOO are redundant, except for arrays.
      They are also a nuisance to work with.  Recent commit "qapi: Start to
      elide redundant has_FOO in generated C" provided the means to elide
      them step by step.  This is the step for qapi/qdev.json and
      qapi/qom.json.
      
      Said commit explains the transformation in more detail.  The invariant
      violations mentioned there do not occur here.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Daniel P. Berrangé <berrange@redhat.com>
      Cc: Eduardo Habkost <eduardo@habkost.net>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20221104160712.3005652-21-armbru@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@linaro.org>
      047f2ca1
  7. Nov 06, 2022
    • Claudio Fontana's avatar
      module: add Error arguments to module_load and module_load_qom · c551fb0b
      Claudio Fontana authored
      
      improve error handling during module load, by changing:
      
      bool module_load(const char *prefix, const char *lib_name);
      void module_load_qom(const char *type);
      
      to:
      
      int module_load(const char *prefix, const char *name, Error **errp);
      int module_load_qom(const char *type, Error **errp);
      
      where the return value is:
      
       -1 on module load error, and errp is set with the error
        0 on module or one of its dependencies are not installed
        1 on module load success
        2 on module load success (module already loaded or built-in)
      
      module_load_qom_one has been introduced in:
      
      commit 28457744 ("module: qom module support"), which built on top of
      module_load_one, but discarded the bool return value. Restore it.
      
      Adapt all callers to emit errors, or ignore them, or fail hard,
      as appropriate in each context.
      
      Replace the previous emission of errors via fprintf in _some_ error
      conditions with Error and error_report, so as to emit to the appropriate
      target.
      
      A memory leak is also fixed as part of the module_load changes.
      
      audio: when attempting to load an audio module, report module load errors.
      Note that still for some callers, a single issue may generate multiple
      error reports, and this could be improved further.
      Regarding the audio code itself, audio_add() seems to ignore errors,
      and this should probably be improved.
      
      block: when attempting to load a block module, report module load errors.
      For the code paths that already use the Error API, take advantage of those
      to report module load errors into the Error parameter.
      For the other code paths, we currently emit the error, but this could be
      improved further by adding Error parameters to all possible code paths.
      
      console: when attempting to load a display module, report module load errors.
      
      qdev: when creating a new qdev Device object (DeviceState), report load errors.
            If a module cannot be loaded to create that device, now abort execution
            (if no CONFIG_MODULE) or exit (if CONFIG_MODULE).
      
      qom/object.c: when initializing a QOM object, or looking up class_by_name,
                    report module load errors.
      
      qtest: when processing the "module_load" qtest command, report errors
             in the load of the module.
      
      Signed-off-by: default avatarClaudio Fontana <cfontana@suse.de>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Message-Id: <20220929093035.4231-4-cfontana@suse.de>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      c551fb0b
    • Claudio Fontana's avatar
      module: rename module_load_one to module_load · dbc0e805
      Claudio Fontana authored
      
      Signed-off-by: default avatarClaudio Fontana <cfontana@suse.de>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Message-Id: <20220929093035.4231-3-cfontana@suse.de>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      dbc0e805
  8. Oct 27, 2022
    • Markus Armbruster's avatar
      qom: Improve error messages when property has no getter or setter · 3f7febc9
      Markus Armbruster authored
      
      When you try to set a property that has no setter, the error message
      blames "insufficient permission":
      
          $ qemu-system-x86_64 -S -display none -nodefaults -monitor stdio
          QEMU 7.1.50 monitor - type 'help' for more information
          (qemu) qom-set /machine type q35
          Error: Insufficient permission to perform this operation
      
      This implies it could work with "sufficient permission".  It can't.
      Change the error message to:
      
          Error: Property 'pc-i440fx-7.2-machine.type' is not writable
      
      Do the same for getting a property that has no getter.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20221012153801.2604340-2-armbru@redhat.com>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      3f7febc9
  9. Apr 21, 2022
  10. Mar 21, 2022
  11. Mar 07, 2022
  12. 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
  13. Feb 21, 2022
  14. Nov 10, 2021
  15. Oct 15, 2021
  16. 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
  17. Jul 06, 2021
  18. Jun 02, 2021
  19. Apr 01, 2021
  20. Mar 19, 2021
  21. 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
  22. Feb 25, 2021
  23. Feb 08, 2021
  24. Jan 02, 2021
  25. 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
Loading