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. 11 3月, 2016 1 次提交
  4. 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
  5. 11 2月, 2016 1 次提交
  6. 09 2月, 2016 1 次提交
    • 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
  7. 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
  8. 19 1月, 2016 4 次提交
  9. 18 12月, 2015 1 次提交
    • D
      io: add QIOChannelSocket class · 559607ea
      Daniel P. Berrange 提交于
      Implement a QIOChannel subclass that supports sockets I/O.
      The implementation is able to manage a single socket file
      descriptor, whether a TCP/UNIX listener, TCP/UNIX connection,
      or a UDP datagram. It provides APIs which can listen and
      connect either asynchronously or synchronously. Since there
      is no asynchronous DNS lookup API available, it uses the
      QIOTask helper for spawning a background thread to ensure
      non-blocking operation.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      559607ea
  10. 06 11月, 2015 1 次提交
  11. 02 11月, 2015 1 次提交
    • E
      sockets: Convert to new qapi union layout · 2d32adda
      Eric Blake 提交于
      We have two issues with our qapi union layout:
      1) Even though the QMP wire format spells the tag 'type', the
      C code spells it 'kind', requiring some hacks in the generator.
      2) The C struct uses an anonymous union, which places all tag
      values in the same namespace as all non-variant members. This
      leads to spurious collisions if a tag value matches a non-variant
      member's name.
      
      Make the conversion to the new layout for socket-related code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1445898903-12082-17-git-send-email-eblake@redhat.com>
      [Commit message tweaked slightly]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      2d32adda
  12. 20 10月, 2015 3 次提交
  13. 13 10月, 2015 1 次提交
    • P
      qemu-sockets: fix conversion of ipv4/ipv6 JSON to QemuOpts · b77e7c8e
      Paolo Bonzini 提交于
      The QemuOpts-based code treats "option not set" and "option set
      to false" the same way for the ipv4 and ipv6 options, because it
      is meant to handle only the ",ipv4" and ",ipv6" substrings in
      hand-crafted option parsers.
      
      When converting InetSocketAddress to QemuOpts, however, it is
      necessary to handle all three cases (not set, set to true, set
      to false).  Currently we are not handling all cases correctly.
      The rules are:
      
      * if none or both options are absent, leave things as is
      
      * if the single present option is Y, the other should be N.
      This can be implemented by leaving things as is, or by setting
      the other option to N as done in this patch.
      
      * if the single present option is N, the other should be Y.
      This is handled by the "else if" branch of this patch.
      
      This ensures that the ipv4 option has an effect on Windows,
      where creating the socket with PF_UNSPEC makes an ipv6
      socket.  With this patch, ",ipv4" will result in a PF_INET
      socket instead.
      Reported-by: NSair, Umair <Umair_Sair@mentor.com>
      Tested-by: NSair, Umair <Umair_Sair@mentor.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b77e7c8e
  14. 24 6月, 2015 1 次提交
    • W
      util/qemu-sockets: improve ai_flag hints for ipv6 hosts · 3de3d698
      Wolfgang Bumiller 提交于
      *) Do not use AI_ADDRCONFIG on listening sockets, because this flag
      makes it impossible to explicitly listen on '127.0.0.1' if no global
      ipv4 address is configured additionally, making this a very
      uncomfortable option.
      *) Add AI_V4MAPPED hint for connecting sockets.
      
      If your system is globally only connected via ipv6 you often still want
      to be able to use '127.0.0.1' and 'localhost' (even if localhost doesn't
      also have an ipv6 entry).
      For example, PVE - unless explicitly asking for insecure mode - uses
      ipv4 loopback addresses with QEMU for live migrations tunneled over SSH.
      These fail to start because AI_ADDRCONFIG makes getaddrinfo refuse to
      work with '127.0.0.1'.
      
      As for the AI_V4MAPPED flag: glibc uses it by default, and providing
      non-0 flags removes it. I think it makes sense to use it.
      
      I also want to point out that glibc explicitly sidesteps POSIX standards
      when passing 0 as hints by then assuming both AI_V4MAPPED and
      AI_ADDRCONFIG (the latter being a rather weird choice IMO), while
      according to POSIX.1-2001 it should be assumed 0. (glibc considers its
      choice an improvement.)
      Since either AI_CANONNAME or AI_PASSIVE are passed in our cases, glibc's
      default flags in turn are disabled again unless explicitly added, which
      I do with this patch.
      Signed-off-by: NWolfgang Bumiller <w.bumiller@proxmox.com>
      Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
      3de3d698
  15. 12 6月, 2015 1 次提交
  16. 03 6月, 2015 1 次提交
  17. 20 5月, 2015 1 次提交
    • C
      qemu-sockets: Report explicit error if unlink fails · 0ef705a2
      Cole Robinson 提交于
      Consider this case:
      
      $ ls -ld ~/root-owned/
      drwx--x--x. 2 root root 4096 Apr 29 12:55 /home/crobinso/root-owned/
      $ ls -l ~/root-owned/foo.sock
      -rwxrwxrwx. 1 crobinso crobinso 0 Apr 29 12:55 /home/crobinso/root-owned/foo.sock
      
      $ qemu-system-x86_64 -vnc unix:~/root-owned/foo.sock
      qemu-system-x86_64: -vnc unix:/home/crobinso/root-owned/foo.sock: Failed to start VNC server: Failed to bind socket to /home/crobinso/root-owned/foo.sock: Address already in use
      
      ...which is techinically true, but the real error is that we failed to
      unlink. So report it.
      
      This may seem pathological but it's a real possibility via libvirt.
      Signed-off-by: NCole Robinson <crobinso@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      0ef705a2
  18. 26 2月, 2015 3 次提交
  19. 10 2月, 2015 2 次提交
  20. 09 10月, 2014 1 次提交
  21. 27 9月, 2014 1 次提交
  22. 17 9月, 2014 1 次提交
    • P
      util/qemu-sockets.c: Support specifying IPv4 or IPv6 in socket_dgram() · 8287fea3
      Peter Maydell 提交于
      Currently you can specify whether you want a UDP chardev backend
      to be IPv4 or IPv6 using the ipv4 or ipv6 options if you use the
      QemuOpts parsing code in inet_dgram_opts(). However the QMP struct
      parsing code in socket_dgram() doesn't provide this flexibility
      (which in turn prevents us from converting the UDP backend handling
      to the new style QAPI framework).
      
      Use the existing inet_addr_to_opts() function to convert the
      remote->inet address to option strings; this handles ipv4 and
      ipv6 flags as well as host and port. (It will also convert any
      'to' specification, which is harmless as it is ignored in this
      context.)
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1409653457-27863-3-git-send-email-peter.maydell@linaro.org
      8287fea3
  23. 15 8月, 2014 1 次提交
  24. 23 6月, 2014 2 次提交
  25. 13 6月, 2014 1 次提交
  26. 10 6月, 2014 1 次提交
  27. 21 5月, 2014 1 次提交
  28. 07 1月, 2014 1 次提交
  29. 03 10月, 2013 1 次提交
  30. 29 6月, 2013 2 次提交