1. 19 5月, 2016 2 次提交
  2. 18 5月, 2016 2 次提交
  3. 17 5月, 2016 1 次提交
  4. 12 5月, 2016 2 次提交
    • E
      qapi: Use strict QMP input visitor in more places · 240f64b6
      Eric Blake 提交于
      The following uses of a QMP input visitor should be strict
      (that is, excess keys in QDict input should be flagged if not
      converted to QAPI):
      
      - Testsuite code unrelated to explicitly testing non-strict
      mode (test-qmp-commands, test-visitor-serialization); since
      we want more code to be strict by default, having more tests
      of strict mode doesn't hurt
      
      - Code used for cloning QAPI objects (replay-input.c,
      qemu-sockets.c); we are reparsing a QObject just barely
      produced by the qmp output visitor and which therefore should
      not have any garbage, so while it is extra work to be strict,
      it validates that our clone is correct [note that a later patch
      series will simplify these two uses by creating an actual
      clone visitor that is much more efficient than a
      generate/reparse cycle]
      
      - qmp_object_add(), which calls into user_creatable_add_type().
      Since command line parsing for '-object' uses the same
      user_creatable_add_type() through the OptsVisitor, and that is
      always strict, we want to ensure that any nested dictionaries
      would be treated the same in QMP and from the command line (I
      don't actually know if such nested dictionaries exist).  Note
      that on this code change, strictness only matters for nested
      dictionaries (if even possible), since we already flag excess
      input at the top level during an earlier object_property_set()
      on an unknown key, whether from QemuOpts:
      
      $ ./x86_64-softmmu/qemu-system-x86_64 -nographic -nodefaults -qmp stdio -object secret,id=sec0,data=letmein,format=raw,foo=bar
      qemu-system-x86_64: -object secret,id=sec0,data=letmein,format=raw,foo=bar: Property '.foo' not found
      
      or from QMP:
      
      $ ./x86_64-softmmu/qemu-system-x86_64 -nographic -nodefaults -qmp stdio
      {"QMP": {"version": {"qemu": {"micro": 93, "minor": 5, "major": 2}, "package": ""}, "capabilities": []}}
      {"execute":"qmp_capabilities"}
      {"return": {}}
      {"execute":"object-add","arguments":{"qom-type":"secret","id":"sec0","props":{"format":"raw","data":"letmein","foo":"bar"}}}
      {"error": {"class": "GenericError", "desc": "Property '.foo' not found"}}
      
      The only remaining uses of non-strict input visits are:
      
      - QMP 'qom-set' (which eventually executes
      object_property_set_qobject()) - mark it as something to revisit
      in the future (I didn't want to spend any more time on this patch
      auditing if we have any QOM dictionary properties that might be
      impacted, and couldn't easily prove whether this code path is
      shared with anything else).
      
      - test-qmp-input-visitor: explicit tests of non-strict mode. If
      we later get rid of users that don't need strictness, then this
      test should be merged with test-qmp-input-strict
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1461879932-9020-7-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      240f64b6
    • E
      qapi: Consolidate QMP input visitor creation · fc471c18
      Eric Blake 提交于
      Rather than having two separate ways to create a QMP input
      visitor, where the safer approach has the more verbose name,
      it is better to consolidate things into a single function
      where the caller must explicitly choose whether to be strict
      or to ignore excess input.  This patch is the strictly
      mechanical conversion; the next patch will then audit which
      uses can be made stricter.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1461879932-9020-6-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      fc471c18
  5. 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
  6. 22 4月, 2016 2 次提交
  7. 06 4月, 2016 1 次提交
  8. 05 4月, 2016 1 次提交
    • D
      util: retry getaddrinfo if getting EAI_BADFLAGS with AI_V4MAPPED · 340849a9
      Daniel P. Berrange 提交于
      The FreeBSD header files define the AI_V4MAPPED but its
      implementation of getaddrinfo() always returns an error
      when that flag is set. eg
      
        address resolution failed for localhost:9000: Invalid value for ai_flags
      
      There are also reports of the same problem on OS-X 10.6
      
      Since AI_V4MAPPED is not critical functionality, if we
      get an EAI_BADFLAGS error then just retry without the
      AI_V4MAPPED flag set. Use a static var to cache this
      status so we don't have to retry on every single call.
      
      Also remove its use from the test suite since it serves
      no useful purpose there.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1459786920-15961-1-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      340849a9
  9. 31 3月, 2016 1 次提交
  10. 23 3月, 2016 8 次提交
  11. 22 3月, 2016 1 次提交
  12. 18 3月, 2016 1 次提交
    • E
      qapi: Don't special-case simple union wrappers · 32bafa8f
      Eric Blake 提交于
      Simple unions were carrying a special case that hid their 'data'
      QMP member from the resulting C struct, via the hack method
      QAPISchemaObjectTypeVariant.simple_union_type().  But by using
      the work we started by unboxing flat union and alternate
      branches, coupled with the ability to visit the members of an
      implicit type, we can now expose the simple union's implicit
      type in qapi-types.h:
      
      | struct q_obj_ImageInfoSpecificQCow2_wrapper {
      |     ImageInfoSpecificQCow2 *data;
      | };
      |
      | struct q_obj_ImageInfoSpecificVmdk_wrapper {
      |     ImageInfoSpecificVmdk *data;
      | };
      ...
      | struct ImageInfoSpecific {
      |     ImageInfoSpecificKind type;
      |     union { /* union tag is @type */
      |         void *data;
      |-        ImageInfoSpecificQCow2 *qcow2;
      |-        ImageInfoSpecificVmdk *vmdk;
      |+        q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
      |+        q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
      |     } u;
      | };
      
      Doing this removes asymmetry between QAPI's QMP side and its
      C side (both sides now expose 'data'), and means that the
      treatment of a simple union as sugar for a flat union is now
      equivalent in both languages (previously the two approaches used
      a different layer of dereferencing, where the simple union could
      be converted to a flat union with equivalent C layout but
      different {} on the wire, or to an equivalent QMP wire form
      but with different C representation).  Using the implicit type
      also lets us get rid of the simple_union_type() hack.
      
      Of course, now all clients of simple unions have to adjust from
      using su->u.member to using su->u.member.data; while this touches
      a number of files in the tree, some earlier cleanup patches
      helped minimize the change to the initialization of a temporary
      variable rather than every single member access.  The generated
      qapi-visit.c code is also affected by the layout change:
      
      |@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
      |     }
      |     switch (obj->type) {
      |     case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
      |-        visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
      |+        visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
      |         break;
      |     case IMAGE_INFO_SPECIFIC_KIND_VMDK:
      |-        visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
      |+        visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
      |         break;
      |     default:
      |         abort();
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      32bafa8f
  13. 16 3月, 2016 2 次提交
  14. 11 3月, 2016 3 次提交
    • D
      osdep: remove use of socket_error() from all code · b16a44e1
      Daniel P. Berrange 提交于
      Now that QEMU wraps the Win32 sockets methods to automatically
      set errno upon failure, there is no reason for callers to use
      the socket_error() method. They can rely on accessing errno
      even on Win32. Remove all use of socket_error() from general
      code, leaving it as a static method in oslib-win32.c only.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      b16a44e1
    • D
      osdep: add wrappers for socket functions · a2d96af4
      Daniel P. Berrange 提交于
      The windows socket functions look identical to the normal POSIX
      sockets functions, but instead of setting errno, the caller needs
      to call WSAGetLastError(). QEMU has tried to deal with this
      incompatibility by defining a socket_error() method that callers
      must use that abstracts the difference between WSAGetLastError()
      and errno.
      
      This approach is somewhat error prone though - many callers of
      the sockets functions are just using errno directly because it
      is easy to forget the need use a QEMU specific wrapper. It is
      not always immediately obvious that a particular function will
      in fact call into Windows sockets functions, so the dev may not
      even realize they need to use socket_error().
      
      This introduces an alternative approach to portability inspired
      by the way GNULIB fixes portability problems. We use a macro to
      redefine the original socket function names to refer to a QEMU
      wrapper function. The wrapper function calls the original Win32
      sockets method and then sets errno from the WSAGetLastError()
      value.
      
      Thus all code can simply call the normal POSIX sockets APIs are
      have standard errno reporting on error, even on Windows. This
      makes the socket_error() method obsolete.
      
      We also bring closesocket & ioctlsocket into this approach. Even
      though they are non-standard Win32 names, we can't wrap the normal
      close/ioctl methods since there's no reliable way to distinguish
      between a file descriptor and HANDLE in Win32.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      a2d96af4
    • D
      osdep: fix socket_error() to work with Mingw64 · c6196440
      Daniel P. Berrange 提交于
      Historically QEMU has had a socket_error() macro that was
      defined to map to WSASocketError(). The os-win32.h header
      file would define errno constants that mapped to the
      WSA error constants. This worked fine with Mingw32 since
      its header files never defined any errno values, nor did
      it even provide an errno.h.  So callers of socket_error()
      could match on traditional Exxxx constants and it would
      all "just work".
      
      With Mingw64 though, things work rather differently. First
      there is an errno.h file which defines all the traditional
      errno constants you'd expect from a UNIX platform. There
      is then a winerror.h which defined the WSA error constants.
      Crucially the WSAExxxx errno values in winerror.h do not
      match the Exxxx errno values in error.h.
      
      If QEMU had only imported winerror.h it would still work,
      but the qemu/osdep.h file unconditionally imports errno.h.
      So callers of socket_error() will get now WSAExxxx values
      back and compare them to the Exxx constants. This will
      always fail silently at runtime.
      
      To solve this QEMU needs to stop assuming the WSAExxxx
      constant values match the Exxx constant values. Thus the
      socket_error() macro is turned into a small function that
      re-maps WSAExxxx values into Exxx.
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      c6196440
  15. 08 3月, 2016 1 次提交
    • L
      cutils: add avx2 instruction optimization · 28b90d9c
      Liang Li 提交于
      buffer_find_nonzero_offset() is a hot function during live migration.
      Now it use SSE2 instructions for optimization. For platform supports
      AVX2 instructions, use AVX2 instructions for optimization can help
      to improve the performance of buffer_find_nonzero_offset() about 30%
      comparing to SSE2.
      
      Live migration can be faster with this optimization, the test result
      shows that for an 8GiB RAM idle guest just boots, this patch can help
      to shorten the total live migration time about 6%.
      
      This patch use the ifunc mechanism to select the proper function when
      running, for platform supports AVX2, execute the AVX2 instructions,
      else, execute the original instructions.
      Signed-off-by: NLiang Li <liang.z.li@intel.com>
      Suggested-by: NPaolo Bonzini <pbonzini@redhat.com>
      Suggested-by: NRichard Henderson <rth@twiddle.net>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <1457416397-26671-3-git-send-email-liang.z.li@intel.com>
      Signed-off-by: NAmit Shah <amit.shah@redhat.com>
      28b90d9c
  16. 07 3月, 2016 1 次提交
    • P
      log: do not log if QEMU is daemonized but without -D · c586eac3
      Paolo Bonzini 提交于
      Commit 96c33a45 ("log: Redirect stderr to logfile if deamonized",
      2016-02-22) wanted to move stderr of a daemonized QEMU to the file
      specified with -D.
      
      However, if -D was not passed, the patch had the side effect of not
      redirecting stderr to /dev/null.  This happened because qemu_logfile
      was set to stderr rather than the expected value of NULL.  The fix
      is simply in the "if" condition of do_qemu_set_log; the "if" for
      closing the file is also changed to match.
      Reported-by: NJan Tomko <jtomko@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c586eac3
  17. 05 3月, 2016 1 次提交
    • E
      util: Shorten references into SocketAddress · 0399293e
      Eric Blake 提交于
      An upcoming patch will alter how simple unions, like SocketAddress,
      are laid out, which will impact all lines of the form 'addr->u.XXX'
      (expanding it to the longer 'addr->u.XXX.data').  For better
      legibility in that patch, and less need for line wrapping, it's better
      to use a temporary variable to reduce the effect of a layout change to
      just the variable initializations, rather than every reference within
      a SocketAddress.  Also, take advantage of some C99 initialization where
      it makes sense (simplifying g_new0() to g_new()).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1457021813-10704-7-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      0399293e
  18. 23 2月, 2016 1 次提交
  19. 22 2月, 2016 7 次提交
  20. 16 2月, 2016 1 次提交