1. 22 2月, 2016 1 次提交
  2. 20 2月, 2016 23 次提交
  3. 19 2月, 2016 16 次提交
    • P
      Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2016-02-19' into staging · 1b3337bb
      Peter Maydell 提交于
      Error reporting patches for 2016-02-19
      
      # gpg: Signature made Fri 19 Feb 2016 12:47:50 GMT using RSA key ID EB918653
      # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
      # gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
      
      * remotes/armbru/tags/pull-error-2016-02-19:
        vl: Clean up machine selection in main().
        vl: Set error location when parsing memory options
        replay: Set error location properly when parsing options
        vl: Reset location after handling command-line arguments
        vl.c: Fix regression in machine error message
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      1b3337bb
    • P
      Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2016-02-19' into staging · 5cfffc30
      Peter Maydell 提交于
      QAPI patches for 2016-02-19
      
      # gpg: Signature made Fri 19 Feb 2016 10:10:18 GMT using RSA key ID EB918653
      # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
      # gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
      
      * remotes/armbru/tags/pull-qapi-2016-02-19:
        qapi: Change visit_start_implicit_struct to visit_start_alternate
        qapi: Don't box branches of flat unions
        qapi: Don't box struct branch of alternate
        qapi-visit: Use common idiom in gen_visit_fields_decl()
        qapi: Emit structs used as variants in topological order
        qapi: Adjust layout of FooList types
        qapi-visit: Less indirection in visit_type_Foo_fields()
        qapi-visit: Unify struct and union visit
        qapi: Visit variants in visit_type_FOO_fields()
        qapi-visit: Simplify how we visit common union members
        qapi: Add tests of complex objects within alternate
        qapi: Forbid 'any' inside an alternate
        qapi: Forbid empty unions and useless alternates
        qapi: Simplify excess input reporting in input visitors
        qapi-visit: Honor prefix of discriminator enum
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      5cfffc30
    • M
      vl: Clean up machine selection in main(). · 7580f231
      Markus Armbruster 提交于
      We set machine_class to the default first, and update it to the real
      one later.  Any use of machine_class in between is almost certainly
      wrong (there are no such uses right now).  Set it once and for all
      instead.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel@redhat.com>
      7580f231
    • E
      vl: Set error location when parsing memory options · bbe2d25c
      Eduardo Habkost 提交于
      Set error location so the error_report() calls will show
      appropriate command-line argument or config file info.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <1455303747-19776-5-git-send-email-ehabkost@redhat.com>
      Reviewed-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      bbe2d25c
    • E
      replay: Set error location properly when parsing options · 890ad550
      Eduardo Habkost 提交于
      Set error location so the error_report() calls will show
      appropriate command-line argument or config file info.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <1455303747-19776-4-git-send-email-ehabkost@redhat.com>
      Reviewed-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      890ad550
    • E
      vl: Reset location after handling command-line arguments · 43fa1e0b
      Eduardo Habkost 提交于
      After looping through all command-line arguments, error location
      info becomes obsolete, and any function calling error_report()
      will print misleading information. This breaks error reporting
      for some option handling, like:
      
        $ qemu-system-x86_64 -icount rr=x -vnc :0
        qemu-system-x86_64: -vnc :0: Invalid icount rr option: x
      
        $ qemu-system-x86_64 -m size= -vnc :0
        qemu-system-x86_64: -vnc :0: missing 'size' option value
      
      Fix this by resetting location info as soon as we exit the
      command-line handling loop.
      
      With this, replay_configure() and set_memory_options() won't
      print any location info yet, but at least they won't print
      incorrect information.
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <1455303747-19776-3-git-send-email-ehabkost@redhat.com>
      Reviewed-by: NLaszlo Ersek <lersek@redhat.com>
      ["Do not insert code here" comment added to prevent regressions]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      43fa1e0b
    • M
      vl.c: Fix regression in machine error message · 34f405ae
      Marcel Apfelbaum 提交于
      Commit e1ce0c3c (vl.c: fix regression when reading machine type
      from config file) fixed the error message when the machine type
      was supplied inside the config file. However now the option name
      is not displayed correctly if the error happens when the machine
      is specified at command line.
      
      Running
          ./x86_64-softmmu/qemu-system-x86_64 -M q35-1.5 -redir tcp:8022::22
      will result in the error message:
          qemu-system-x86_64: -redir tcp:8022::22: unsupported machine type
          Use -machine help to list supported machines
      
      Fixed it by restoring the error location and also extracted the code
      dealing with machine options into a separate function.
      Reported-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NMarcel Apfelbaum <marcel@redhat.com>
      Reviewed-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <1455303747-19776-2-git-send-email-ehabkost@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      34f405ae
    • P
      Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging · 09125c5e
      Peter Maydell 提交于
      vhost, virtio, pci, pxe
      
      Fixes all over the place.
      New tests for pxe.
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      
      # gpg: Signature made Thu 18 Feb 2016 15:46:39 GMT using RSA key ID D28D5469
      # gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>"
      # gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>"
      
      * remotes/mst/tags/for_upstream:
        tests/vhost-user-bridge: add scattering of incoming packets
        vhost-user interrupt management fixes
        rules: filter out irrelevant files
        change type of pci_bridge_initfn() to void
        dec: convert to realize()
        tests: add pxe e1000 and virtio-pci tests
        msix: fix msix_vector_masked
        virtio: optimize virtio_access_is_big_endian() for little-endian targets
        vhost: simplify vhost_needs_vring_endian()
        vhost: move virtio 1.0 check to cross-endian helper
        virtio: move cross-endian helper to vhost
        vhost-net: revert support of cross-endian vnet headers
        virtio-net: use the backend cross-endian capabilities
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      09125c5e
    • E
      qapi: Change visit_start_implicit_struct to visit_start_alternate · dbf11922
      Eric Blake 提交于
      After recent changes, the only remaining use of
      visit_start_implicit_struct() is for allocating the space needed
      when visiting an alternate.  Since the term 'implicit struct' is
      hard to explain, rename the function to its current usage.  While
      at it, we can merge the functionality of visit_get_next_type()
      into the same function, making it more like visit_start_struct().
      
      Generated code is now slightly smaller:
      
      | {
      |     Error *err = NULL;
      |
      |-    visit_start_implicit_struct(v, (void**) obj, sizeof(BlockdevRef), &err);
      |+    visit_start_alternate(v, name, (GenericAlternate **)obj, sizeof(**obj),
      |+                          true, &err);
      |     if (err) {
      |         goto out;
      |     }
      |-    visit_get_next_type(v, name, &(*obj)->type, true, &err);
      |-    if (err) {
      |-        goto out_obj;
      |-    }
      |     switch ((*obj)->type) {
      |     case QTYPE_QDICT:
      |         visit_start_struct(v, name, NULL, 0, &err);
      ...
      |     }
      |-out_obj:
      |-    visit_end_implicit_struct(v);
      |+    visit_end_alternate(v);
      | out:
      |     error_propagate(errp, err);
      | }
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1455778109-6278-16-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      dbf11922
    • E
      qapi: Don't box branches of flat unions · 544a3731
      Eric Blake 提交于
      There's no reason to do two malloc's for a flat union; let's just
      inline the branch struct directly into the C union branch of the
      flat union.
      
      Surprisingly, fewer clients were actually using explicit references
      to the branch types in comparison to the number of flat unions
      thus modified.
      
      This lets us reduce the hack in qapi-types:gen_variants() added in
      the previous patch; we no longer need to distinguish between
      alternates and flat unions.
      
      The change to unboxed structs means that u.data (added in commit
      cee2dedb) is now coincident with random fields of each branch of
      the flat union, whereas beforehand it was only coincident with
      pointers (since all branches of a flat union have to be objects).
      Note that this was already the case for simple unions - but there
      we got lucky.  Remember, visit_start_union() blindly returns true
      for all visitors except for the dealloc visitor, where it returns
      the value !!obj->u.data, and that this result then controls
      whether to proceed with the visit to the variant.  Pre-patch,
      this meant that flat unions were testing whether the boxed pointer
      was still NULL, and thereby skipping visit_end_implicit_struct()
      and avoiding a NULL dereference if the pointer had not been
      allocated.  The same was true for simple unions where the current
      branch had pointer type, except there we bypassed visit_type_FOO().
      But for simple unions where the current branch had scalar type, the
      contents of that scalar meant that the decision to call
      visit_type_FOO() was data-dependent - the reason we got lucky there
      is that visit_type_FOO() for all scalar types in the dealloc visitor
      is a no-op (only the pointer variants had anything to free), so it
      did not matter whether the dealloc visit was skipped.  But with this
      patch, we would risk leaking memory if we could skip a call to
      visit_type_FOO_fields() based solely on a data-dependent decision.
      
      But notice: in the dealloc visitor, visit_type_FOO() already handles
      a NULL obj - it was only the visit_type_implicit_FOO() that was
      failing to check for NULL. And now that we have refactored things to
      have the branch be part of the parent struct, we no longer have a
      separate pointer that can be NULL in the first place.  So we can just
      delete the call to visit_start_union() altogether, and blindly visit
      the branch type; there is no change in behavior except to the dealloc
      visitor, where we now unconditionally visit the branch, but where that
      visit is now always safe (for a flat union, we can no longer
      dereference NULL, and for a simple union, visit_type_FOO() was already
      safely handling NULL on pointer types).
      
      Unfortunately, simple unions are not as easy to switch to unboxed
      layout; because we are special-casing the hidden implicit type with
      a single 'data' member, we really DO need to keep calling another
      layer of visit_start_struct(), with a second malloc; although there
      are some cleanups planned for simple unions in later patches.
      
      visit_start_union() and gen_visit_implicit_struct() are now unused.
      Drop them.
      
      Note that after this patch, the only remaining use of
      visit_start_implicit_struct() is for alternate types; the next patch
      will do further cleanup based on that fact.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1455778109-6278-14-git-send-email-eblake@redhat.com>
      [Dead code deletion squashed in, commit message updated accordingly]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      544a3731
    • E
      qapi: Don't box struct branch of alternate · becceedc
      Eric Blake 提交于
      There's no reason to do two malloc's for an alternate type visiting
      a QAPI struct; let's just inline the struct directly as the C union
      branch of the struct.
      
      Surprisingly, no clients were actually using the struct member prior
      to this patch outside of the testsuite; an earlier patch in the series
      added some testsuite coverage to make the effect of this patch more
      obvious.
      
      In qapi.py, c_type() gains a new is_unboxed flag to control when we
      are emitting a C struct unboxed within the context of an outer
      struct (different from our other two modes of usage with no flags
      for normal local variable declarations, and with is_param for adding
      'const' in a parameter list).  I don't know if there is any more
      pythonic way of collapsing the two flags into a single parameter,
      as we never have a caller setting both flags at once.
      
      Ultimately, we want to also unbox branches for QAPI unions, but as
      that touches a lot more client code, it is better as separate
      patches.  But since unions and alternates share gen_variants(), I
      had to hack in a way to test if we are visiting an alternate type
      for setting the is_unboxed flag: look for a non-object branch.
      This works because alternates have at least two branches, with at
      most one object branch, while unions have only object branches.
      The hack will go away in a later patch.
      
      The generated code difference to qapi-types.h is relatively small:
      
      | struct BlockdevRef {
      |     QType type;
      |     union { /* union tag is @type */
      |         void *data;
      |-        BlockdevOptions *definition;
      |+        BlockdevOptions definition;
      |         char *reference;
      |     } u;
      | };
      
      The corresponding spot in qapi-visit.c calls visit_type_FOO(), which
      first calls visit_start_struct() to allocate or deallocate the member
      and handle a layer of {} from the JSON stream, then visits the
      members.  To peel off the indirection and the memory management that
      comes with it, we inline this call, then suppress allocation /
      deallocation by passing NULL to visit_start_struct(), and adjust the
      member visit:
      
      |     switch ((*obj)->type) {
      |     case QTYPE_QDICT:
      |-        visit_type_BlockdevOptions(v, name, &(*obj)->u.definition, &err);
      |+        visit_start_struct(v, name, NULL, 0, &err);
      |+        if (err) {
      |+            break;
      |+        }
      |+        visit_type_BlockdevOptions_fields(v, &(*obj)->u.definition, &err);
      |+        error_propagate(errp, err);
      |+        err = NULL;
      |+        visit_end_struct(v, &err);
      |         break;
      |     case QTYPE_QSTRING:
      |         visit_type_str(v, name, &(*obj)->u.reference, &err);
      
      The visit of non-object fields is unchanged.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1455778109-6278-13-git-send-email-eblake@redhat.com>
      [Commit message tweaked]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      becceedc
    • E
      qapi-visit: Use common idiom in gen_visit_fields_decl() · 2208d649
      Eric Blake 提交于
      We have several instances of methods that do an early exit if
      output is not needed, then log that output is being generated,
      and finally produce the output; see qapi-types.py:gen_object()
      and qapi-visit.py:gen_visit_implicit_struct().  The odd man
      out was gen_visit_fields_decl(); rearrange it to be more like
      the others.  No semantic change or difference to generated code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1455778109-6278-12-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      2208d649
    • E
      qapi: Emit structs used as variants in topological order · 1de5d4ca
      Eric Blake 提交于
      Right now, we emit the branches of union types as a boxed pointer,
      and it suffices to have a forward declaration of the type.  However,
      a future patch will swap things to directly use the branch type,
      instead of hiding it behind a pointer.  For this to work, the
      compiler needs the full definition of the type, not just a forward
      declaration, prior to the union that is including the branch type.
      This patch just adds topological sorting to hoist all types
      mentioned in a branch of a union to be fully declared before the
      union itself.  The sort is always possible, because we do not
      allow circular union types that include themselves as a direct
      branch (it is, however, still possible to include a branch type
      that itself has a pointer to the union, for a type that can
      indirectly recursively nest itself - that remains safe, because
      that the member of the branch type will remain a pointer, and the
      QMP representation of such a type adds another {} for each recurring
      layer of the union type).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1455778109-6278-11-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      1de5d4ca
    • E
      qapi: Adjust layout of FooList types · e65d89bf
      Eric Blake 提交于
      By sticking the next pointer first, we don't need a union with
      64-bit padding for smaller types.  On 32-bit platforms, this
      can reduce the size of uint8List from 16 bytes (or 12, depending
      on whether 64-bit ints can tolerate 4-byte alignment) down to 8.
      It has no effect on 64-bit platforms (where alignment still
      dictates a 16-byte struct); but fewer anonymous unions is still
      a win in my book.
      
      It requires visit_next_list() to gain a size parameter, to know
      what size element to allocate; comparable to the size parameter
      of visit_start_struct().
      
      I debated about going one step further, to allow for fewer casts,
      by doing:
          typedef GenericList GenericList;
          struct GenericList {
              GenericList *next;
          };
          struct FooList {
              GenericList base;
              Foo *value;
          };
      so that you convert to 'GenericList *' by '&foolist->base', and
      back by 'container_of(generic, GenericList, base)' (as opposed to
      the existing '(GenericList *)foolist' and '(FooList *)generic').
      But doing that would require hoisting the declaration of
      GenericList prior to inclusion of qapi-types.h, rather than its
      current spot in visitor.h; it also makes iteration a bit more
      verbose through 'foolist->base.next' instead of 'foolist->next'.
      
      Note that for lists of objects, the 'value' payload is still
      hidden behind a boxed pointer.  Someday, it would be nice to do:
      
      struct FooList {
          FooList *next;
          Foo value;
      };
      
      for one less level of malloc for each list element.  This patch
      is a step in that direction (now that 'next' is no longer at a
      fixed non-zero offset within the struct, we can store more than
      just a pointer's-worth of data as the value payload), but the
      actual conversion would be a task for another series, as it will
      touch a lot of code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1455778109-6278-10-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      e65d89bf
    • E
      qapi-visit: Less indirection in visit_type_Foo_fields() · 65551903
      Eric Blake 提交于
      We were passing 'Foo **obj' to the internal helper function, but
      all uses within the helper were via reads of '*obj'.  Refactor
      things to pass one less level of indirection, by having the
      callers dereference before calling.
      
      For an example of the generated code change:
      
      |-static void visit_type_BalloonInfo_fields(Visitor *v, BalloonInfo **obj, Error **errp)
      |+static void visit_type_BalloonInfo_fields(Visitor *v, BalloonInfo *obj, Error **errp)
      | {
      |     Error *err = NULL;
      |
      |-    visit_type_int(v, "actual", &(*obj)->actual, &err);
      |+    visit_type_int(v, "actual", &obj->actual, &err);
      |     error_propagate(errp, err);
      | }
      |
      |@@ -261,7 +261,7 @@ void visit_type_BalloonInfo(Visitor *v,
      |     if (!*obj) {
      |         goto out_obj;
      |     }
      |-    visit_type_BalloonInfo_fields(v, obj, &err);
      |+    visit_type_BalloonInfo_fields(v, *obj, &err);
      | out_obj:
      
      The refactoring will also make it easier to reuse the helpers in
      a future patch when implicit structs are stored directly in the
      parent struct rather than boxed through a pointer.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1455778109-6278-9-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      65551903
    • M
      qapi-visit: Unify struct and union visit · 59d9e84c
      Markus Armbruster 提交于
      gen_visit_union() is now just like gen_visit_struct().  Rename
      it to gen_visit_object(), use it for structs, and drop
      gen_visit_struct().  Output is unchanged.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1453902888-20457-4-git-send-email-armbru@redhat.com>
      [split out variant handling, rebase to earlier changes]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1455778109-6278-8-git-send-email-eblake@redhat.com>
      59d9e84c