1. 23 3月, 2016 1 次提交
    • 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
  2. 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
  3. 16 3月, 2016 2 次提交
  4. 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
  5. 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
  6. 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
  7. 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
  8. 23 2月, 2016 1 次提交
  9. 22 2月, 2016 7 次提交
  10. 16 2月, 2016 1 次提交
  11. 11 2月, 2016 1 次提交
  12. 09 2月, 2016 2 次提交
    • P
      iov: avoid memcpy for "simple" iov_from_buf/iov_to_buf · ad523bca
      Paolo Bonzini 提交于
      memcpy can take a large amount of time for small reads and writes.
      For virtio it is a common case that the first iovec can satisfy the
      whole read or write.  In that case, and if bytes is a constant to
      avoid excessive growth of code, inline the first iteration
      into the caller.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1450782213-14227-1-git-send-email-pbonzini@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      ad523bca
    • E
      qapi: Swap visit_* arguments for consistent 'name' placement · 51e72bc1
      Eric Blake 提交于
      JSON uses "name":value, but many of our visitor interfaces were
      called with visit_type_FOO(v, &value, name, errp).  This can be
      a bit confusing to have to mentally swap the parameter order to
      match JSON order.  It's particularly bad for visit_start_struct(),
      where the 'name' parameter is smack in the middle of the
      otherwise-related group of 'obj, kind, size' parameters! It's
      time to do a global swap of the parameter ordering, so that the
      'name' parameter is always immediately after the Visitor argument.
      
      Additional reason in favor of the swap: the existing include/qjson.h
      prefers listing 'name' first in json_prop_*(), and I have plans to
      unify that file with the qapi visitors; listing 'name' first in
      qapi will minimize churn to the (admittedly few) qjson.h clients.
      
      Later patches will then fix docs, object.h, visitor-impl.h, and
      those clients to match.
      
      Done by first patching scripts/qapi*.py by hand to make generated
      files do what I want, then by running the following Coccinelle
      script to affect the rest of the code base:
       $ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
      I then had to apply some touchups (Coccinelle insisted on TAB
      indentation in visitor.h, and botched the signature of
      visit_type_enum() by rewriting 'const char *const strings[]' to
      the syntactically invalid 'const char*const[] strings').  The
      movement of parameters is sufficient to provoke compiler errors
      if any callers were missed.
      
          // Part 1: Swap declaration order
          @@
          type TV, TErr, TObj, T1, T2;
          identifier OBJ, ARG1, ARG2;
          @@
           void visit_start_struct
          -(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
           { ... }
      
          @@
          type bool, TV, T1;
          identifier ARG1;
          @@
           bool visit_optional
          -(TV v, T1 ARG1, const char *name)
          +(TV v, const char *name, T1 ARG1)
           { ... }
      
          @@
          type TV, TErr, TObj, T1;
          identifier OBJ, ARG1;
          @@
           void visit_get_next_type
          -(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
           { ... }
      
          @@
          type TV, TErr, TObj, T1, T2;
          identifier OBJ, ARG1, ARG2;
          @@
           void visit_type_enum
          -(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
           { ... }
      
          @@
          type TV, TErr, TObj;
          identifier OBJ;
          identifier VISIT_TYPE =~ "^visit_type_";
          @@
           void VISIT_TYPE
          -(TV v, TObj OBJ, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, TErr errp)
           { ... }
      
          // Part 2: swap caller order
          @@
          expression V, NAME, OBJ, ARG1, ARG2, ERR;
          identifier VISIT_TYPE =~ "^visit_type_";
          @@
          (
          -visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
          +visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
          |
          -visit_optional(V, ARG1, NAME)
          +visit_optional(V, NAME, ARG1)
          |
          -visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
          +visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
          |
          -visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
          +visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
          |
          -VISIT_TYPE(V, OBJ, NAME, ERR)
          +VISIT_TYPE(V, NAME, OBJ, ERR)
          )
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      51e72bc1
  13. 05 2月, 2016 2 次提交
    • P
      all: Clean up includes · d38ea87a
      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-16-git-send-email-peter.maydell@linaro.org
      d38ea87a
    • 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
  14. 03 2月, 2016 3 次提交
  15. 20 1月, 2016 1 次提交
  16. 19 1月, 2016 4 次提交
  17. 13 1月, 2016 3 次提交
    • M
      error: New error_prepend(), error_reportf_err() · 8277d2aa
      Markus Armbruster 提交于
      Instead of simply propagating an error verbatim, we sometimes want to
      add to its message, like this:
      
          frobnicate(arg, &err);
          error_setg(errp, "Can't frobnicate %s: %s",
                           arg, error_get_pretty(err));
          error_free(err);
      
      This is suboptimal, because it loses err's hint (if any).  Moreover,
      when errp is &error_abort or is subsequently propagated to
      &error_abort, the abort message points to the place where we last
      added to the error, not to the place where it originated.
      
      To avoid these issues, provide means to add to an error's message in
      place:
      
          frobnicate(arg, errp);
          error_prepend(errp, "Can't frobnicate %s: ", arg);
      
      Likewise, reporting an error like
      
          frobnicate(arg, &err);
          error_report("Can't frobnicate %s: %s", arg, error_get_pretty(err));
      
      can lose err's hint.  To avoid:
      
          error_reportf_err(err, "Can't frobnicate %s: ", arg);
      
      The next commits will put these functions to use.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1450452927-8346-10-git-send-email-armbru@redhat.com>
      8277d2aa
    • M
      error: Improve documentation · f4d0064a
      Markus Armbruster 提交于
      While there, tighten error_append_hint()'s assertion.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1450452927-8346-6-git-send-email-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      f4d0064a
    • 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. 22 12月, 2015 1 次提交
    • M
      mmap-alloc: tweak a comment on ppc64 · 097a50d0
      Michael S. Tsirkin 提交于
      The comment I put in mmap-alloc to document the ppc64 rules
      refers to the previous revision of the patch:
      we don't look at memory alignment anymore, we check
      the fs from which the fd is mapped, instead.
      
      It's also not clear what does "in this case" refer
      to, rearrange text to make it clearer.
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      
      
      
      097a50d0
  19. 19 12月, 2015 1 次提交
  20. 18 12月, 2015 2 次提交
  21. 04 12月, 2015 1 次提交