1. 17 7月, 2018 1 次提交
  2. 29 6月, 2018 1 次提交
  3. 11 6月, 2018 1 次提交
  4. 09 5月, 2018 3 次提交
    • D
      opts: don't silently truncate long option values · 950c4e6c
      Daniel P. Berrangé 提交于
      The existing QemuOpts parsing code uses a fixed size 1024 byte buffer
      for storing the option values. If a value exceeded this size it was
      silently truncated and no error reported to the user. Long option values
      is not a common scenario, but it is conceivable that they will happen.
      eg if the user has a very deeply nested filesystem it would be possible
      to come up with a disk path that was > 1024 bytes. Most of the time if
      such data was silently truncated, the user would get an error about
      opening a non-existant disk. If they're unlucky though, QEMU might use a
      completely different disk image from another VM, which could be
      considered a security issue. Another example program was in using the
      -smbios command line arg with very large data blobs. In this case the
      silent truncation will be providing semantically incorrect data to the
      guest OS for SMBIOS tables.
      
      If the operating system didn't limit the user's argv when spawning QEMU,
      the code should honour whatever length arguments were given without
      imposing its own length restrictions. This patch thus changes the code
      to use a heap allocated buffer for storing the values during parsing,
      lifting the arbitrary length restriction.
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      Message-Id: <20180416111743.8473-4-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      950c4e6c
    • D
      opts: don't silently truncate long parameter keys · e652714f
      Daniel P. Berrangé 提交于
      The existing QemuOpts parsing code uses a fixed size 128 byte buffer
      for storing the parameter keys. If a key exceeded this size it was
      silently truncate and no error reported to the user. This behaviour was
      reasonable & harmless because traditionally the key names are all
      statically declared, and it was known that no code was declaring a key
      longer than 127 bytes. This assumption, however, ceased to be valid once
      the block layer added support for dot-separate compound keys. This
      syntax allows for keys that can be arbitrarily long, limited only by the
      number of block drivers you can stack up. With this usage, silently
      truncating the key name can never lead to correct behaviour.
      
      Hopefully such truncation would turn into an error, when the block code
      then tried to extract options later, but there's no guarantee that will
      happen. It is conceivable that an option specified by the user may be
      truncated and then ignored. This could have serious consequences,
      possibly even leading to security problems if the ignored option set a
      security relevant parameter.
      
      If the operating system didn't limit the user's argv when spawning QEMU,
      the code should honour whatever length arguments were given without
      imposing its own length restrictions. This patch thus changes the code
      to use a heap allocated buffer for storing the keys during parsing,
      lifting the arbitrary length restriction.
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      Message-Id: <20180416111743.8473-3-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      e652714f
    • D
      accel: use g_strsplit for parsing accelerator names · 20efc49e
      Daniel P. Berrangé 提交于
      Instead of re-using the get_opt_name() method from QemuOpts to split a
      string on ':', just use g_strsplit().
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      Message-Id: <20180416111743.8473-2-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      20efc49e
  5. 20 3月, 2018 1 次提交
    • M
      qapi: Replace qobject_to_X(o) by qobject_to(X, o) · 7dc847eb
      Max Reitz 提交于
      This patch was generated using the following Coccinelle script:
      
      @@
      expression Obj;
      @@
      (
      - qobject_to_qnum(Obj)
      + qobject_to(QNum, Obj)
      |
      - qobject_to_qstring(Obj)
      + qobject_to(QString, Obj)
      |
      - qobject_to_qdict(Obj)
      + qobject_to(QDict, Obj)
      |
      - qobject_to_qlist(Obj)
      + qobject_to(QList, Obj)
      |
      - qobject_to_qbool(Obj)
      + qobject_to(QBool, Obj)
      )
      
      and a bit of manual fix-up for overly long lines and three places in
      tests/check-qjson.c that Coccinelle did not find.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NAlberto Garcia <berto@igalia.com>
      Message-Id: <20180224154033.29559-4-mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      [eblake: swap order from qobject_to(o, X), rebase to master, also a fix
      to latent false-positive compiler complaint about hw/i386/acpi-build.c]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      7dc847eb
  6. 09 3月, 2018 1 次提交
  7. 09 2月, 2018 2 次提交
  8. 20 12月, 2017 2 次提交
  9. 20 6月, 2017 1 次提交
  10. 09 5月, 2017 2 次提交
  11. 01 3月, 2017 1 次提交
  12. 24 2月, 2017 3 次提交
    • M
      option: Fix checking of sizes for overflow and trailing crap · 75cdcd15
      Markus Armbruster 提交于
      parse_option_size()'s checking for overflow and trailing crap is
      wrong.  Has always been that way.  qemu_strtosz() gets it right, so
      use that.
      
      This adds support for size suffixes 'P', 'E', and ignores case for all
      suffixes, not just 'k'.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1487708048-2131-25-git-send-email-armbru@redhat.com>
      75cdcd15
    • M
      option: Fix to reject invalid and overflowing numbers · 3403e5eb
      Markus Armbruster 提交于
      parse_option_number() fails to check for these errors after
      strtoull().  Has always been broken.  Fix that.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1487708048-2131-10-git-send-email-armbru@redhat.com>
      3403e5eb
    • M
      option: Assert value string isn't null · 8ee8409e
      Markus Armbruster 提交于
      Plenty of code relies on QemuOpt member @str not being null, including
      qemu_opts_print(), qemu_opts_to_qdict(), and callbacks passed to
      qemu_opt_foreach().
      
      Begs the question whether it can be null.  Only opt_set() creates
      QemuOpt.  It sets member @str to its argument @value.  Passing null
      for @value would plant a time bomb.  Callers:
      
      * opts_do_parse() can't pass null.
      
      * qemu_opt_set() passes its argument @value.  Callers:
      
        - qemu_opts_from_qdict_1() can't pass null
      
        - qemu_opts_set() passes its argument @value, but none of its
          callers pass null.
      
        - Many more outside qemu-option.c, but they shouldn't pass null,
          either.
      
      Assert member @str isn't null, so that misuse is caught right away.
      
      Simplify parse_option_bool(), parse_option_number() and
      parse_option_size() accordingly.  Best viewed with whitespace changes
      ignored.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1487708048-2131-3-git-send-email-armbru@redhat.com>
      8ee8409e
  13. 10 2月, 2017 1 次提交
  14. 28 4月, 2016 1 次提交
    • M
      QemuOpts: Fix qemu_opts_foreach() dangling location regression · 37f32349
      Markus Armbruster 提交于
      qemu_opts_foreach() pushes and pops a Location with automatic storage
      duration.  Except it fails to pop when @func() returns non-zero.
      cur_loc then points to unused stack space, and will most likely get
      clobbered in short order.
      
      Clobbered cur_loc can make loc_pop() and error_print_loc() crash or
      report bogus locations.
      
      Affects several qemu command line options as well as qemu-img,
      qemu-io, qemu-nbd -object, and blkdebug's configuration file.
      
      Broken in commit a4c7367f, v2.4.0.
      
      Reproducer:
          $ qemu-system-x86_64 -nodefaults -display none -object secret,id=foo,foo=bar
      
      main() reports "Property '.foo' not found" like this:
      
          if (qemu_opts_foreach(qemu_find_opts("object"),
                                user_creatable_add_opts_foreach,
                                object_create_delayed, &err)) {
              error_report_err(err);
              exit(1);
          }
      
      cur_loc then points to where qemu_opts_foreach()'s Location used to
      be, i.e. unused stack space.  With optimization, this Location doesn't
      get clobbered for me, and also happens to be the correct location.
      Without optimization, it does get clobbered in a way that makes
      error_report_err() report no location.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1461767349-15329-2-git-send-email-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      37f32349
  15. 23 3月, 2016 2 次提交
    • V
      util: move declarations out of qemu-common.h · f348b6d1
      Veronia Bahaa 提交于
      Move declarations out of qemu-common.h for functions declared in
      utils/ files: e.g. include/qemu/path.h for utils/path.c.
      Move inline functions out of qemu-common.h and into new files (e.g.
      include/qemu/bcd.h)
      Signed-off-by: NVeronia Bahaa <veroniabahaa@gmail.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f348b6d1
    • M
      include/qemu/osdep.h: Don't include qapi/error.h · da34e65c
      Markus Armbruster 提交于
      Commit 57cb38b3 included qapi/error.h into qemu/osdep.h to get the
      Error typedef.  Since then, we've moved to include qemu/osdep.h
      everywhere.  Its file comment explains: "To avoid getting into
      possible circular include dependencies, this file should not include
      any other QEMU headers, with the exceptions of config-host.h,
      compiler.h, os-posix.h and os-win32.h, all of which are doing a
      similar job to this file and are under similar constraints."
      qapi/error.h doesn't do a similar job, and it doesn't adhere to
      similar constraints: it includes qapi-types.h.  That's in excess of
      100KiB of crap most .c files don't actually need.
      
      Add the typedef to qemu/typedefs.h, and include that instead of
      qapi/error.h.  Include qapi/error.h in .c files that need it and don't
      get it now.  Include qapi-types.h in qom/object.h for uint16List.
      
      Update scripts/clean-includes accordingly.  Update it further to match
      reality: replace config.h by config-target.h, add sysemu/os-posix.h,
      sysemu/os-win32.h.  Update the list of includes in the qemu/osdep.h
      comment quoted above similarly.
      
      This reduces the number of objects depending on qapi/error.h from "all
      of them" to less than a third.  Unfortunately, the number depending on
      qapi-types.h shrinks only a little.  More work is needed for that one.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  16. 05 2月, 2016 1 次提交
    • P
      util: Clean up includes · aafd7584
      Peter Maydell 提交于
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1454089805-5470-6-git-send-email-peter.maydell@linaro.org
      aafd7584
  17. 13 1月, 2016 1 次提交
    • M
      error: Don't append a newline when printing the error hint · 543202c0
      Markus Armbruster 提交于
      Since commit 50b7b000, we have error_append_hint() to conveniently
      accumulate Error member @hint.  error_report_err() prints it with a
      newline appended.  Consequently, users of error_append_hint() need to
      know whether theirs is the final line of the hint to decide whether it
      needs a newline.  Not a nice interface.
      
      Change error_report_err() to print just the hint, and the (still few)
      users of error_append_hint() to add the required newline.
      
      Cc: Eric Blake <eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1450370121-5768-7-git-send-email-armbru@redhat.com>
      543202c0
  18. 18 9月, 2015 1 次提交
    • E
      hmp: Allow for error message hints on HMP · 50b7b000
      Eric Blake 提交于
      Commits 7216ae3d and d2828429 disabled some error message hints,
      all because a change to use modern error reporting meant that the
      hint would be output prior to the actual error.  Fix this by making
      hints a first-class member of Error.
      
      For example, we are now back to the pleasant:
      
       $ qemu-system-x86_64 --nodefaults -S --vnc :0 --chardev null,id=,
       qemu-system-x86_64: --chardev null,id=,: Parameter 'id' expects an identifier
       Identifiers consist of letters, digits, '-', '.', '_', starting with a letter.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <1441901956-21991-1-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      50b7b000
  19. 11 9月, 2015 1 次提交
  20. 05 9月, 2015 1 次提交
    • B
      qemu-iotests: s390x: fix test 049, reject negative sizes in QemuOpts · 21278992
      Bo Tu 提交于
      when creating an image qemu-img enable us specifying the size of the
      image using -o size=xx options. But when we specify an invalid size
      such as a negtive size then different platform gives different result.
      
      parse_option_size() function in util/qemu-option.c will be called to
      parse the size, a cast was called in the function to cast the input
      (saved as a double in the function) size to an unsigned int64 value,
      when the input is a negtive value or exceeds the maximum of uint64, then
      the result is undefined.
      
      According to C99 6.3.1.4, the result of converting a floating point
      number to an integer that cannot represent the (integer part of) number
      is undefined.  And sure enough the results are different on x86 and
      s390.
      
      C99 Language spec 6.3.1.4 Real floating and integers:
      the result of this assignment/cast is undefined if the float is not
      in the open interval (-1, U<type>_MAX+1).
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NSascha Silbe <silbe@linux.vnet.ibm.com>
      Signed-off-by: NBo Tu <tubo@linux.vnet.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      21278992
  21. 23 6月, 2015 2 次提交
    • M
      qerror: Clean up QERR_ macros to expand into a single string · c6bd8c70
      Markus Armbruster 提交于
      These macros expand into error class enumeration constant, comma,
      string.  Unclean.  Has been that way since commit 13f59ae8.
      
      The error class is always ERROR_CLASS_GENERIC_ERROR since the previous
      commit.
      
      Clean up as follows:
      
      * Prepend every use of a QERR_ macro by ERROR_CLASS_GENERIC_ERROR, and
        delete it from the QERR_ macro.  No change after preprocessing.
      
      * Rewrite error_set(ERROR_CLASS_GENERIC_ERROR, ...) into
        error_setg(...).  Again, no change after preprocessing.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NLuiz Capitulino <lcapitulino@redhat.com>
      c6bd8c70
    • M
      QemuOpts: Wean off qerror_report_err() · 70b94331
      Markus Armbruster 提交于
      qerror_report_err() is a transitional interface to help with
      converting existing monitor commands to QMP.  It should not be used
      elsewhere.
      
      The only remaining user in qemu-option.c is qemu_opts_parse().  Is it
      used in QMP context?  If not, we can simply replace
      qerror_report_err() by error_report_err().
      
      The uses in qemu-img.c, qemu-io.c, qemu-nbd.c and under tests/ are
      clearly not in QMP context.
      
      The uses in vl.c aren't either, because the only QMP command handlers
      there are qmp_query_status() and qmp_query_machines(), and they don't
      call it.
      
      Remaining uses:
      
      * drive_def(): Command line -drive and such, HMP drive_add and pci_add
      
      * hmp_chardev_add(): HMP chardev-add
      
      * monitor_parse_command(): HMP core
      
      * tmp_config_parse(): Command line -tpmdev
      
      * net_host_device_add(): HMP host_net_add
      
      * net_client_parse(): Command line -net and -netdev
      
      * qemu_global_option(): Command line -global
      
      * vnc_parse_func(): Command line -display, -vnc, default display, HMP
        change, QMP change.  Bummer.
      
      * qemu_pci_hot_add_nic(): HMP pci_add
      
      * usb_net_init(): Command line -usbdevice, HMP usb_add
      
      Propagate errors through qemu_opts_parse().  Create a convenience
      function qemu_opts_parse_noisily() that passes errors to
      error_report_err().  Switch all non-QMP users outside tests to it.
      
      That leaves vnc_parse_func().  Propagate errors through it.  Since I'm
      touching it anyway, rename it to vnc_parse().
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NLuiz Capitulino <lcapitulino@redhat.com>
      70b94331
  22. 22 6月, 2015 1 次提交
  23. 09 6月, 2015 4 次提交
  24. 26 2月, 2015 5 次提交