Skip to content
Snippets Groups Projects
  1. Dec 19, 2020
    • Markus Armbruster's avatar
      string-output-visitor: Fix to use sufficient precision · 54addb01
      Markus Armbruster authored
      
      The string output visitor should serialize numbers so that the string
      input visitor deserializes them back to the same number.  It fails to
      do so.
      
      print_type_number() uses format %f.  This is prone to nasty rounding
      errors.  For instance, numbers between 0 and 0.0000005 get flushed to
      zero.
      
      We currently use this visitor only for HMP info migrate, info network,
      info qtree, and info memdev.  No double values occur there as far as I
      can tell.
      
      Fix anyway by formatting with %.17g.  17 decimal digits always suffice
      for IEEE double.
      
      See also recent commit "qobject: Fix qnum_to_string() to use
      sufficient precision".
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201210161452.2813491-9-armbru@redhat.com>
      54addb01
    • Markus Armbruster's avatar
      test-string-output-visitor: Cover "unround" number · 7b205a73
      Markus Armbruster authored
      
      This demonstrates rounding error due to insufficient precision: double
      3.1415926535897932 gets converted to JSON 3.141593.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201210161452.2813491-8-armbru@redhat.com>
      7b205a73
    • Markus Armbruster's avatar
      qobject: Fix qnum_to_string() to use sufficient precision · f917eed3
      Markus Armbruster authored
      
      We should serialize numbers to JSON so that they deserialize back to
      the same number.  We fail to do so.
      
      The culprit is qnum_to_string(): it uses format %f with trailing '0'
      trimmed.  Results in pretty output for "nice" numbers, but is prone to
      nasty rounding errors.  For instance, numbers between 0 and 0.0000005
      get flushed to zero.
      
      Where exactly the incorrect rounding can bite is tiresome to gauge.
      Here's my take.
      
      * In QMP output, type 'number':
      
        - query-blockstats value avg_rd_queue_depth
      
        - QMP query-migrate values mbps, cache-miss-rate, encoding-rate,
          busy-rate, compression-rate.
      
        Relatively harmless, I guess.
      
      * In tracing QMP input.  Harmless.
      
      * In qemu-ga output, type 'number': guest-get-users value login-time.
        Harmless.
      
      * In output of HMP qom-get.  Harmless.
      
      Not affected, because double values don't actually occur there (I
      think):
      
      * QMP output, type 'any':
      
        * qom-get value
      
        * qom-list, qom-list-properties value default-value
      
        * query-cpu-model-comparison, query-cpu-model-baseline,
          query-cpu-model-expansion value props.
      
      * qemu-img --output json output.
      
      * "json:" pseudo-filenames generated by bdrv_refresh_filename().
      
      * The rbd block driver's "=keyvalue-pairs" hack.
      
      * In -object help on property default values.  Aside: use of JSON
        feels inappropriate here.
      
      * Output of HMP qom-get.
      
      * Argument conversion to QemuOpts for qdev_device_add() and HMP with
        qemu_opts_from_qdict()
      
        QMP and HMP device_add, virtio-net failover primary creation,
        xen-usb "usb-host" creation, HMP netdev_add, object_add.
      
      * The uses of qobject_input_visitor_new_flat_confused()
      
        As far as I can tell, none of the visited types contain double
        values.
      
      * Dumping ImageInfoSpecific with dump_qobject()
      
      Fix by formatting with %.17g.  17 decimal digits always suffice for
      IEEE double.
      
      The change to expected test output illustrates the effect: the
      rounding errors are gone, but some seemingly "nice" numbers now get
      converted to not so nice strings, e.g. 0.42 to "0.41999999999999998".
      This is because 0.42 is not representable exactly in double.  It's
      more accurate in this example than strictly necessary, though.
      
      If ugly accuracy bothers us, we can we can try using the least number
      of digits that still converts back to the same double.  In this
      example, "0.42" would do.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201210161452.2813491-7-armbru@redhat.com>
      f917eed3
    • Markus Armbruster's avatar
      tests/check-qnum: Cover qnum_to_string() for "unround" argument · 1a907691
      Markus Armbruster authored
      
      qnum_to_string() has a FIXME comment about rounding errors due to
      insufficient precision.  Cover it: 2.718281828459045 gets converted to
      "2.718282".  The next commit will fix it.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201210161452.2813491-6-armbru@redhat.com>
      1a907691
    • Markus Armbruster's avatar
      tests/check-qjson: Replace redundant large_number() · 780df5d4
      Markus Armbruster authored
      
      Move one of large_number()'s three checks to uint_number(), and the
      other two to float_number().
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201210161452.2813491-5-armbru@redhat.com>
      780df5d4
    • Markus Armbruster's avatar
      tests/check-qjson: Cover number 2^63 · 4aea8833
      Markus Armbruster authored
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201210161452.2813491-4-armbru@redhat.com>
      4aea8833
    • Markus Armbruster's avatar
      tests/check-qjson: Examine QNum more thoroughly · 1a68eb8c
      Markus Armbruster authored
      
      simple_number() checks only qnum_get_try_int().  Also check
      qnum_get_try_uint() and qnum_get_double().
      
      float_number() checks only qnum_get_double().  Also check
      qnum_get_try_int() and qnum_get_try_uint().
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201210161452.2813491-3-armbru@redhat.com>
      1a68eb8c
    • Markus Armbruster's avatar
      tests/check-qjson: Don't skip funny QNumber to JSON conversions · 3953f826
      Markus Armbruster authored
      
      simple_number() and float_number() convert from JSON to QNumber and
      back.
      
      simple_number() tests "-0", but skips the conversion back to JSON,
      because it yields "0", not "-0".  Works as intended, so better cover
      it: don't skip, but expect the funny result.
      
      float_number() tests "-32.20e-10", but skips the conversion back to
      JSON, because it yields "-0".  This is a known bug in
      qnum_to_string(), marked FIXME there.  Cover the bug: don't skip, but
      expect the funny result.
      
      While there, switch from g_assert() to g_assert_cmpstr() & friends for
      friendlier test failures.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201210161452.2813491-2-armbru@redhat.com>
      3953f826
    • 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
    • Eric Blake's avatar
      migration: Refactor migrate_cap_add · eaedde52
      Eric Blake authored
      
      Instead of taking a list parameter and returning a new head at a
      distance, just return the new item for the caller to insert into a
      list via QAPI_LIST_PREPEND.
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20201113011340.463563-4-eblake@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      eaedde52
    • Eric Blake's avatar
      rocker: Revamp fp_port_get_info · fe4d7e33
      Eric Blake authored
      
      Instead of modifying the value member of a list element passed as a
      parameter, and open-coding the manipulation of that list, it's nicer
      to just return a freshly allocated value to be prepended to a list
      using QAPI_LIST_PREPEND.
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20201113011340.463563-3-eblake@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      fe4d7e33
  2. Dec 18, 2020
  3. Dec 17, 2020
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/ehabkost-gl/tags/x86-next-pull-request' into staging · 75ee62ac
      Peter Maydell authored
      
      x86 queue, 2020-12-17
      
      Features:
      * AVX512_FP16 feature (Cathy Zhang)
      
      Cleanups:
      * accel code cleanup (Claudio Fontana)
      * hyperv initialization cleanup (Vitaly Kuznetsov)
      
      # gpg: Signature made Thu 17 Dec 2020 18:44:45 GMT
      # gpg:                using RSA key 5A322FD5ABC4D3DBACCFD1AA2807936F984DC5A6
      # gpg:                issuer "ehabkost@redhat.com"
      # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [full]
      # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF  D1AA 2807 936F 984D C5A6
      
      * remotes/ehabkost-gl/tags/x86-next-pull-request:
        cpu: Remove unnecessary noop methods
        tcg: Make CPUClass.debug_excp_handler optional
        tcg: make CPUClass.cpu_exec_* optional
        tcg: cpu_exec_{enter,exit} helpers
        i386: tcg: remove inline from cpu_load_eflags
        i386: move TCG cpu class initialization to tcg/
        x86/cpu: Add AVX512_FP16 cpu feature
        i386: move hyperv_limits initialization to x86_cpu_realizefn()
        i386: move hyperv_version_id initialization to x86_cpu_realizefn()
        i386: move hyperv_interface_id initialization to x86_cpu_realizefn()
        i386: move hyperv_vendor_id initialization to x86_cpu_realizefn()
        i386: move cpu dump out of helper.c into cpu-dump.c
        i386: move TCG accel files into tcg/
        i386: hvf: remove stale MAINTAINERS entry for old hvf stubs
        i386: move hax accel files into hax/
        i386: move whpx accel files into whpx/
        i386: move kvm accel files into kvm/
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      75ee62ac
  4. Dec 16, 2020
Loading