1. 31 10月, 2016 1 次提交
  2. 25 10月, 2016 1 次提交
  3. 14 9月, 2016 2 次提交
  4. 02 8月, 2016 3 次提交
  5. 13 7月, 2016 1 次提交
  6. 06 7月, 2016 4 次提交
    • E
      sockets: Use new QAPI cloning · 37f9e0a2
      Eric Blake 提交于
      Rather than rolling our own clone via an expensive conversion
      in and back out of QObject, use the new clone visitor.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1465490926-28625-15-git-send-email-eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      37f9e0a2
    • E
      qapi: Add new visit_complete() function · 3b098d56
      Eric Blake 提交于
      Making each output visitor provide its own output collection
      function was the only remaining reason for exposing visitor
      sub-types to the rest of the code base.  Add a polymorphic
      visit_complete() function which is a no-op for input visitors,
      and which populates an opaque pointer for output visitors.  For
      maximum type-safety, also add a parameter to the output visitor
      constructors with a type-correct version of the output pointer,
      and assert that the two uses match.
      
      This approach was considered superior to either passing the
      output parameter only during construction (action at a distance
      during visit_free() feels awkward) or only during visit_complete()
      (defeating type safety makes it easier to use incorrectly).
      
      Most callers were function-local, and therefore a mechanical
      conversion; the testsuite was a bit trickier, but the previous
      cleanup patch minimized the churn here.
      
      The visit_complete() function may be called at most once; doing
      so lets us use transfer semantics rather than duplication or
      ref-count semantics to get the just-built output back to the
      caller, even though it means our behavior is not idempotent.
      
      Generated code is simplified as follows for events:
      
      |@@ -26,7 +26,7 @@ void qapi_event_send_acpi_device_ost(ACP
      |     QDict *qmp;
      |     Error *err = NULL;
      |     QMPEventFuncEmit emit;
      |-    QmpOutputVisitor *qov;
      |+    QObject *obj;
      |     Visitor *v;
      |     q_obj_ACPI_DEVICE_OST_arg param = {
      |         info
      |@@ -39,8 +39,7 @@ void qapi_event_send_acpi_device_ost(ACP
      |
      |     qmp = qmp_event_build_dict("ACPI_DEVICE_OST");
      |
      |-    qov = qmp_output_visitor_new();
      |-    v = qmp_output_get_visitor(qov);
      |+    v = qmp_output_visitor_new(&obj);
      |
      |     visit_start_struct(v, "ACPI_DEVICE_OST", NULL, 0, &err);
      |     if (err) {
      |@@ -55,7 +54,8 @@ void qapi_event_send_acpi_device_ost(ACP
      |         goto out;
      |     }
      |
      |-    qdict_put_obj(qmp, "data", qmp_output_get_qobject(qov));
      |+    visit_complete(v, &obj);
      |+    qdict_put_obj(qmp, "data", obj);
      |     emit(QAPI_EVENT_ACPI_DEVICE_OST, qmp, &err);
      
      and for commands:
      
      | {
      |     Error *err = NULL;
      |-    QmpOutputVisitor *qov = qmp_output_visitor_new();
      |     Visitor *v;
      |
      |-    v = qmp_output_get_visitor(qov);
      |+    v = qmp_output_visitor_new(ret_out);
      |     visit_type_AddfdInfo(v, "unused", &ret_in, &err);
      |-    if (err) {
      |-        goto out;
      |+    if (!err) {
      |+        visit_complete(v, ret_out);
      |     }
      |-    *ret_out = qmp_output_get_qobject(qov);
      |-
      |-out:
      |     error_propagate(errp, err);
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1465490926-28625-13-git-send-email-eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      3b098d56
    • E
      qmp-output-visitor: Favor new visit_free() function · 1830f22a
      Eric Blake 提交于
      Now that we have a polymorphic visit_free(), we no longer need
      qmp_output_visitor_cleanup(); however, we still need to
      expose the subtype for qmp_output_get_qobject().
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1465490926-28625-10-git-send-email-eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      1830f22a
    • E
      qmp-input-visitor: Favor new visit_free() function · b70ce101
      Eric Blake 提交于
      Now that we have a polymorphic visit_free(), we no longer need
      qmp_input_visitor_cleanup(); which in turn means we no longer
      need to return a subtype from qmp_input_visitor_new() nor a
      public upcast function.
      
      Generated code changes to qmp-marshal.c look like:
      
      |@@ -52,11 +52,10 @@ void qmp_marshal_add_fd(QDict *args, QOb
      | {
      |     Error *err = NULL;
      |     AddfdInfo *retval;
      |-    QmpInputVisitor *qiv = qmp_input_visitor_new(QOBJECT(args), true);
      |     Visitor *v;
      |     q_obj_add_fd_arg arg = {0};
      |
      |-    v = qmp_input_get_visitor(qiv);
      |+    v = qmp_input_visitor_new(QOBJECT(args), true);
      |     visit_start_struct(v, NULL, NULL, 0, &err);
      |     if (err) {
      |         goto out;
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1465490926-28625-8-git-send-email-eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      b70ce101
  7. 29 6月, 2016 1 次提交
  8. 28 6月, 2016 1 次提交
  9. 18 5月, 2016 1 次提交
  10. 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
  11. 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
  12. 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
  13. 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
  14. 11 3月, 2016 1 次提交
  15. 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
  16. 11 2月, 2016 1 次提交
  17. 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
  18. 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
  19. 19 1月, 2016 4 次提交
  20. 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
  21. 06 11月, 2015 1 次提交
  22. 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
  23. 20 10月, 2015 3 次提交
  24. 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
  25. 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
  26. 12 6月, 2015 1 次提交
  27. 03 6月, 2015 1 次提交