1. 13 10月, 2015 3 次提交
    • E
      qapi: Test for various name collisions · d220fbcd
      Eric Blake 提交于
      Expose some weaknesses in the generator: we don't always forbid
      the generation of structs that contain multiple members that map
      to the same C or QMP name.  This has already been marked FIXME in
      qapi.py in commit d90675fa, but having more tests will make sure
      future patches produce desired behavior; and updating existing
      patches to better document things doesn't hurt, either.  Some of
      these collisions are already caught in the old-style parser
      checks, but ultimately we want all collisions to be caught in the
      new-style QAPISchema*.check() methods.
      
      This patch focuses on C struct members, and does not consider
      collisions between commands and events (affecting C function
      names), or even collisions between generated C type names with
      user type names (for things like automatic FOOList struct
      representing array types or FOOKind for an implicit enum).
      
      There are two types of struct collisions we want to catch:
       1) Collision between two keys in a JSON object. qapi.py prevents
          that within a single struct (see test duplicate-key), but it is
          possible to have collisions between a type's members and its
          base type's members (existing tests struct-base-clash,
          struct-base-clash-deep), and its flat union variant members
          (renamed test flat-union-clash-member).
       2) Collision between two members of the C struct that is generated
          for a given QAPI type:
          a) Multiple QAPI names map to the same C name (new test
             args-name-clash)
          b) A QAPI name maps to a C name that is used for another purpose
             (new tests flat-union-clash-branch, struct-base-clash-base,
             union-clash-data). We already fixed some such cases in commit
             0f61af3e and 1e6c1616, but more remain.
          c) Two C names generated for other purposes clash
             (updated test alternate-clash, new test union-clash-branches,
             union-clash-type, flat-union-clash-type)
      
      Ultimately, if we need to have a flat union where a tag value
      clashes with a base member name, we could change the generator to
      name the union (using 'foo.u.value' rather than 'foo.value') or
      otherwise munge the C name corresponding to tag values.  But
      unless such a need arises, it will probably be easier to just
      forbid these collisions.
      
      Some of these negative tests will be deleted later, and positive
      tests added to qapi-schema-test.json in their place, when the
      generator code is reworked to avoid particular code generation
      collisions in class 2).
      
      [Note that viewing this patch with git rename detection enabled
      may see some confusion due to renaming some tests while adding
      others, but where the content is similar enough that git picks
      the wrong pre- and post-patch files to associate]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1443565276-4535-6-git-send-email-eblake@redhat.com>
      [Improve commit message and comments a bit, drop an unrelated test]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      d220fbcd
    • E
      qapi: Improve 'include' error message · 7408fb67
      Eric Blake 提交于
      Use of '"...%s" % include' to print non-strings can lead to
      ugly messages, such as this (if the .json change is applied
      without the qapi.py change):
       Expected a file name (string), got: OrderedDict()
      
      Better is to just omit the actual non-string value in the
      message.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1443565276-4535-3-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      7408fb67
    • E
      qapi: Sort qapi-schema tests · 1ffe818a
      Eric Blake 提交于
      Recent changes to qapi have provided quite a bit of churn in
      the makefile, because we are inconsistent on what order test
      names appear in, and on whether to re-wrap the list of tests or
      just add arbitrary line lengths.  Writing the list in a sorted
      fashion, one test per line, will make future patches easier
      to see what tests are being added or removed by a patch.
      
      Although it is tempting to use $(wildcard qapi-schema/*.json)
      for a more compact listing, such an approach would risk picking
      up leftover garbage .json files in the directory; so keeping
      the list explicit is safer for ensuring reproducible tarballs
      and test results.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1443565276-4535-2-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      1ffe818a
  2. 12 10月, 2015 1 次提交
  3. 09 10月, 2015 7 次提交
    • M
      qdev: Protect device-list-properties against broken devices · 4c315c27
      Markus Armbruster 提交于
      Several devices don't survive object_unref(object_new(T)): they crash
      or hang during cleanup, or they leave dangling pointers behind.
      
      This breaks at least device-list-properties, because
      qmp_device_list_properties() needs to create a device to find its
      properties.  Broken in commit f4eb32b5 "qmp: show QOM properties in
      device-list-properties", v2.1.  Example reproducer:
      
          $ qemu-system-aarch64 -nodefaults -display none -machine none -S -qmp stdio
          {"QMP": {"version": {"qemu": {"micro": 50, "minor": 4, "major": 2}, "package": ""}, "capabilities": []}}
          { "execute": "qmp_capabilities" }
          {"return": {}}
          { "execute": "device-list-properties", "arguments": { "typename": "pxa2xx-pcmcia" } }
          qemu-system-aarch64: /home/armbru/work/qemu/memory.c:1307: memory_region_finalize: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
          Aborted (core dumped)
          [Exit 134 (SIGABRT)]
      
      Unfortunately, I can't fix the problems in these devices right now.
      Instead, add DeviceClass member cannot_destroy_with_object_finalize_yet
      to mark them:
      
      * Hang during cleanup (didn't debug, so I can't say why):
        "realview_pci", "versatile_pci".
      
      * Dangling pointer in cpus: most CPUs, plus "allwinner-a10", "digic",
        "fsl,imx25", "fsl,imx31", "xlnx,zynqmp", because they create such
        CPUs
      
      * Assert kvm_enabled(): "host-x86_64-cpu", host-i386-cpu",
        "host-powerpc64-cpu", "host-embedded-powerpc-cpu",
        "host-powerpc-cpu" (the powerpc ones can't currently reach the
        assertion, because the CPUs are only registered when KVM is enabled,
        but the assertion is arguably in the wrong place all the same)
      
      Make qmp_device_list_properties() fail cleanly when the device is so
      marked.  This improves device-list-properties from "crashes, hangs or
      leaves dangling pointers behind" to "fails".  Not a complete fix, just
      a better-than-nothing work-around.  In the above reproducer,
      device-list-properties now fails with "Can't list properties of device
      'pxa2xx-pcmcia'".
      
      This also protects -device FOO,help, which uses the same machinery
      since commit ef523587 "qdev-monitor: include QOM properties in -device
      FOO, help output", v2.2.  Example reproducer:
      
          $ qemu-system-aarch64 -machine none -device pxa2xx-pcmcia,help
      
      Before:
      
          qemu-system-aarch64: .../memory.c:1307: memory_region_finalize: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
      
      After:
      
          Can't list properties of device 'pxa2xx-pcmcia'
      
      Cc: "Andreas Färber" <afaerber@suse.de>
      Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
      Cc: Alexander Graf <agraf@suse.de>
      Cc: Anthony Green <green@moxielogic.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
      Cc: Blue Swirl <blauwirbel@gmail.com>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
      Cc: Jia Liu <proljc@gmail.com>
      Cc: Leon Alrae <leon.alrae@imgtec.com>
      Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Walle <michael@walle.cc>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: qemu-ppc@nongnu.org
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <1443689999-12182-10-git-send-email-armbru@redhat.com>
      4c315c27
    • M
      qmp: Fix device-list-properties not to crash for abstract device · edb1523d
      Markus Armbruster 提交于
      Broken in commit f4eb32b5 "qmp: show QOM properties in
      device-list-properties", v2.1.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NAndreas Färber <afaerber@suse.de>
      Message-Id: <1443689999-12182-9-git-send-email-armbru@redhat.com>
      edb1523d
    • M
      device-introspect-test: New, covering device introspection · 2d1abb85
      Markus Armbruster 提交于
      The test doesn't check that the output makes any sense, only that QEMU
      survives.  Useful since we've had an astounding number of crash bugs
      around there.
      
      In fact, we have a bunch of them right now: a few devices crash or
      hang, and some leave dangling pointers behind.  The test skips testing
      the broken parts.  The next commits will fix them up, and drop the
      skipping.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1443689999-12182-8-git-send-email-armbru@redhat.com>
      2d1abb85
    • M
      libqtest: New hmp() & friends · 5fb48d96
      Markus Armbruster 提交于
      New convenience function hmp() to facilitate use of
      human-monitor-command in tests.  Use it to simplify its existing uses.
      
      To blend into existing libqtest code, also add qtest_hmpv() and
      qtest_hmp().  That, and the egregiously verbose GTK-Doc comment format
      make this patch look bigger than it is.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Message-Id: <1443689999-12182-7-git-send-email-armbru@redhat.com>
      5fb48d96
    • M
      libqtest: Clean up unused QTestState member sigact_old · 82b15c7b
      Markus Armbruster 提交于
      Unused since commit d7668251.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1443689999-12182-6-git-send-email-armbru@redhat.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      82b15c7b
    • M
      tests: Fix how qom-test is run · e253c287
      Markus Armbruster 提交于
      We want to run qom-test for every architecture, without having to
      manually add it to every architecture's list of tests.  Commit 3687d532
      accomplished this by adding it to every architecture's list
      automatically.
      
      However, some architectures inherit their tests from others, like this:
      
          check-qtest-x86_64-y = $(check-qtest-i386-y)
          check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
          check-qtest-xtensaeb-y = $(check-qtest-xtensa-y)
      
      For such architectures, we ended up running the (slow!) test twice.
      Commit 2b8419cb attempted to avoid this by adding the test only when
      it's not already present.  Works only as long as we consider adding
      the test to the architectures on the left hand side *after* the ones
      on the right hand side: x86_64 after i386, microblazeel after
      microblaze, xtensaeb after xtensa.
      
      Turns out we consider them in $(SYSEMU_TARGET_LIST) order.  Defined as
      
          SYSEMU_TARGET_LIST := $(subst -softmmu.mak,,$(notdir \
             $(wildcard $(SRC_PATH)/default-configs/*-softmmu.mak)))
      
      On my machine, this results in the oder xtensa, x86_64, microblazeel,
      microblaze, i386.  Consequently, qom-test runs twice for microblazeel
      and x86_64.
      
      Replace this complex and flawed machinery with a much simpler one: add
      generic tests (currently just qom-test) to check-qtest-generic-y
      instead of check-qtest-$(target)-y for every target, then run
      $(check-qtest-generic-y) for every target.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NAndreas Färber <afaerber@suse.de>
      Message-Id: <1443689999-12182-5-git-send-email-armbru@redhat.com>
      e253c287
    • D
      tests: Unique test path for /string-visitor/output · deb847bf
      Dr. David Alan Gilbert 提交于
      Newer GLib's want unique test paths, and thus moan at dupes.
      (Seen on Fedora 23 which has glib 2.46)
      
      Uniquify the paths.
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
      deb847bf
  4. 06 10月, 2015 3 次提交
  5. 02 10月, 2015 6 次提交
  6. 25 9月, 2015 2 次提交
    • L
      rtl8139: remove muldiv64() · 37b9ab92
      Laurent Vivier 提交于
      Originally, timers were ticks based, and it made sense to
      add ticks to current time to know when to trigger an alarm.
      
      But since commit:
      
      74475455 change all other clock references to use nanosecond resolution accessors
      
      All timers use nanoseconds and we need to convert ticks to nanoseconds, by
      doing something like:
      
          y = muldiv64(x, get_ticks_per_sec(), PCI_FREQUENCY)
      
      where x is the number of device ticks and y the number of system ticks.
      
      y is used as nanoseconds in timer functions,
      it works because 1 tick is 1 nanosecond.
      (get_ticks_per_sec() is 10^9)
      
      But as PCI frequency is 33 MHz, we can also do:
      
          y = x * 30; /* 33 MHz PCI period is 30 ns */
      
      Which is much more simple.
      
      This implies a 33.333333 MHz PCI frequency,
      but this is correct.
      Signed-off-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      37b9ab92
    • M
      tests: add some qemu_strtosz() tests · fe854538
      Marc-André Lureau 提交于
      While reading the function I decided to write some tests.
      Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1442419377-9309-2-git-send-email-marcandre.lureau@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      fe854538
  7. 24 9月, 2015 1 次提交
  8. 21 9月, 2015 9 次提交
    • M
      qapi: New QMP command query-qmp-schema for QMP introspection · 39a18158
      Markus Armbruster 提交于
      qapi/introspect.json defines the introspection schema.  It's designed
      for QMP introspection, but should do for similar uses, such as QGA.
      
      The introspection schema does not reflect all the rules and
      restrictions that apply to QAPI schemata.  A valid QAPI schema has an
      introspection value conforming to the introspection schema, but the
      converse is not true.
      
      Introspection lowers away a number of schema details, and makes
      implicit things explicit:
      
      * The built-in types are declared with their JSON type.
      
        All integer types are mapped to 'int', because how many bits we use
        internally is an implementation detail.  It could be pressed into
        external interface service as very approximate range information,
        but that's a bad idea.  If we need range information, we better do
        it properly.
      
      * Implicit type definitions are made explicit, and given
        auto-generated names:
      
        - Array types, named by appending "List" to the name of their
          element type, like in generated C.
      
        - The enumeration types implicitly defined by simple union types,
          named by appending "Kind" to the name of their simple union type,
          like in generated C.
      
        - Types that don't occur in generated C.  Their names start with ':'
          so they don't clash with the user's names.
      
      * All type references are by name.
      
      * The struct and union types are generalized into an object type.
      
      * Base types are flattened.
      
      * Commands take a single argument and return a single result.
      
        Dictionary argument or list result is an implicit type definition.
      
        The empty object type is used when a command takes no arguments or
        produces no results.
      
        The argument is always of object type, but the introspection schema
        doesn't reflect that.
      
        The 'gen': false directive is omitted as implementation detail.
      
        The 'success-response' directive is omitted as well for now, even
        though it's not an implementation detail, because it's not used by
        QMP.
      
      * Events carry a single data value.
      
        Implicit type definition and empty object type use, just like for
        commands.
      
        The value is of object type, but the introspection schema doesn't
        reflect that.
      
      * Types not used by commands or events are omitted.
      
        Indirect use counts as use.
      
      * Optional members have a default, which can only be null right now
      
        Instead of a mandatory "optional" flag, we have an optional default.
        No default means mandatory, default null means optional without
        default value.  Non-null is available for optional with default
        (possible future extension).
      
      * Clients should *not* look up types by name, because type names are
        not ABI.  Look up the command or event you're interested in, then
        follow the references.
      
        TODO Should we hide the type names to eliminate the temptation?
      
      New generator scripts/qapi-introspect.py computes an introspection
      value for its input, and generates a C variable holding it.
      
      It can generate awfully long lines.  Marked TODO.
      
      A new test-qmp-input-visitor test case feeds its result for both
      tests/qapi-schema/qapi-schema-test.json and qapi-schema.json to a
      QmpInputVisitor to verify it actually conforms to the schema.
      
      New QMP command query-qmp-schema takes its return value from that
      variable.  Its reply is some 85KiBytes for me right now.
      
      If this turns out to be too much, we have a couple of options:
      
      * We can use shorter names in the JSON.  Not the QMP style.
      
      * Optionally return the sub-schema for commands and events given as
        arguments.
      
        Right now qmp_query_schema() sends the string literal computed by
        qmp-introspect.py.  To compute sub-schema at run time, we'd have to
        duplicate parts of qapi-introspect.py in C.  Unattractive.
      
      * Let clients cache the output of query-qmp-schema.
      
        It changes only on QEMU upgrades, i.e. rarely.  Provide a command
        query-qmp-schema-hash.  Clients can have a cache indexed by hash,
        and re-query the schema only when they don't have it cached.  Even
        simpler: put the hash in the QMP greeting.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      39a18158
    • M
      qapi: Pseudo-type '**' is now unused, drop it · 2d21291a
      Markus Armbruster 提交于
      'gen': false needs to stay for now, because netdev_add is still using
      it.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1442401589-24189-25-git-send-email-armbru@redhat.com>
      2d21291a
    • M
      qapi: Introduce a first class 'any' type · 28770e05
      Markus Armbruster 提交于
      It's first class, because unlike '**', it actually works, i.e. doesn't
      require 'gen': false.
      
      '**' will go away next.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      28770e05
    • M
      qapi: Make output visitor return qnull() instead of NULL · 6c2f9a15
      Markus Armbruster 提交于
      Before commit 1d10b445, it crashed.  Since then, it returns NULL, with
      a FIXME comment.  The FIXME is valid: code that assumes QObject *
      can't be null exists.  I'm not aware of a way to feed this problematic
      return value to code that actually chokes on null in the current code,
      but the next few commits will create one, failing "make check".
      
      Commit 481b002c solved a very similar problem by introducing a special
      null QObject.  Using this special null QObject is clearly the right
      way to resolve this FIXME, so do that, and update the test
      accordingly.
      
      However, the patch isn't quite right: it messes up the reference
      counting.  After about SIZE_MAX visits, the reference counter
      overflows, failing the assertion in qnull_destroy_obj().  Because
      that's many orders of magnitude more visits of nulls than we expect,
      we take this patch despite its flaws, to get the QMP introspection
      stuff in without further delay.  We'll want to fix it for real before
      the release.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1442401589-24189-21-git-send-email-armbru@redhat.com>
      6c2f9a15
    • M
      qapi-event: Convert to QAPISchemaVisitor, fixing data with base · 05f43a96
      Markus Armbruster 提交于
      Fixes events whose data is struct with base to include the struct's
      base members.  Test case is qapi-schema-test.json's event
      __org.qemu_x-command:
      
          { 'event': '__ORG.QEMU_X-EVENT', 'data': '__org.qemu_x-Struct' }
      
          { 'struct': '__org.qemu_x-Struct', 'base': '__org.qemu_x-Base',
            'data': { '__org.qemu_x-member2': 'str' } }
      
          { 'struct': '__org.qemu_x-Base',
            'data': { '__org.qemu_x-member1': '__org.qemu_x-Enum' } }
      
      Patch's effect on generated qapi_event_send___org_qemu_x_event():
      
          -void qapi_event_send___org_qemu_x_event(const char *__org_qemu_x_member2,
          +void qapi_event_send___org_qemu_x_event(__org_qemu_x_Enum __org_qemu_x_member1,
          +                                        const char *__org_qemu_x_member2,
                                                   Error **errp)
           {
               QDict *qmp;
          @@ -224,6 +225,10 @@ void qapi_event_send___org_qemu_x_event(
                   goto clean;
               }
      
          +    visit_type___org_qemu_x_Enum(v, &__org_qemu_x_member1, "__org.qemu_x-member1", &local_err);
          +    if (local_err) {
          +        goto clean;
          +    }
               visit_type_str(v, (char **)&__org_qemu_x_member2, "__org.qemu_x-member2", &local_err);
               if (local_err) {
                   goto clean;
      
      Code is generated in a different order now, but that doesn't matter.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      05f43a96
    • M
      qapi-visit: Convert to QAPISchemaVisitor, fixing bugs · 441cbac0
      Markus Armbruster 提交于
      Fixes flat unions to visit the base's base members (the previous
      commit merely added them to the struct).  Same test case.
      
      Patch's effect on visit_type_UserDefFlatUnion():
      
           static void visit_type_UserDefFlatUnion_fields(Visitor *m, UserDefFlatUnion **obj, Error **errp)
           {
               Error *err = NULL;
      
          +    visit_type_int(m, &(*obj)->integer, "integer", &err);
          +    if (err) {
          +        goto out;
          +    }
               visit_type_str(m, &(*obj)->string, "string", &err);
               if (err) {
                   goto out;
      
      Test cases updated for the bug fix.
      
      Fixes alternates to generate a visitor for their implicit enumeration
      type.  None of them are currently used, obviously.  Example:
      block-core.json's BlockdevRef now generates
      visit_type_BlockdevRefKind().
      
      Code is generated in a different order now, and therefore has got a
      few new forward declarations.  Doesn't matter.
      
      The guard QAPI_VISIT_BUILTIN_VISITOR_DECL is renamed to
      QAPI_VISIT_BUILTIN.
      
      The previous commit's two ugly special cases exist here, too.  Mark
      both TODO.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      441cbac0
    • M
      qapi-types: Convert to QAPISchemaVisitor, fixing flat unions · 2b162ccb
      Markus Armbruster 提交于
      Fixes flat unions to get the base's base members.  Test case is from
      commit 2fc00432, in qapi-schema-test.json:
      
          { 'union': 'UserDefFlatUnion',
            'base': 'UserDefUnionBase',
            'discriminator': 'enum1',
            'data': { 'value1' : 'UserDefA',
                      'value2' : 'UserDefB',
                      'value3' : 'UserDefB' } }
      
          { 'struct': 'UserDefUnionBase',
            'base': 'UserDefZero',
            'data': { 'string': 'str', 'enum1': 'EnumOne' } }
      
          { 'struct': 'UserDefZero',
            'data': { 'integer': 'int' } }
      
      Patch's effect on UserDefFlatUnion:
      
           struct UserDefFlatUnion {
               /* Members inherited from UserDefUnionBase: */
          +    int64_t integer;
               char *string;
               EnumOne enum1;
               /* Own members: */
               union { /* union tag is @enum1 */
                   void *data;
                   UserDefA *value1;
                   UserDefB *value2;
                   UserDefB *value3;
               };
           };
      
      Flat union visitors remain broken.  They'll be fixed next.
      
      Code is generated in a different order now, but that doesn't matter.
      
      The two guards QAPI_TYPES_BUILTIN_STRUCT_DECL and
      QAPI_TYPES_BUILTIN_CLEANUP_DECL are replaced by just
      QAPI_TYPES_BUILTIN.
      
      Two ugly special cases for simple unions now stand out like sore
      thumbs:
      
      1. The type tag is named 'type' everywhere, except in generated C,
         where it's 'kind'.
      
      2. QAPISchema lowers simple unions to semantically equivalent flat
         unions.  However, the C generated for a simple unions differs from
         the C generated for its equivalent flat union, and we therefore
         need special code to preserve that pointless difference for now.
      
      Mark both TODO.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      2b162ccb
    • M
      tests/qapi-schema: Convert test harness to QAPISchemaVisitor · 156402e5
      Markus Armbruster 提交于
      The old code prints the result of parsing (list of expression
      dictionaries), and partial results of semantic analysis (list of enum
      dictionaries, list of struct dictionaries).
      
      The new code prints a trace of a schema visit, i.e. what the back-ends
      are going to use.  Built-in and array types are omitted, because
      they're boring.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      156402e5
    • M
      qapi: New QAPISchema intermediate reperesentation · ac88219a
      Markus Armbruster 提交于
      The QAPI code generators work with a syntax tree (nested dictionaries)
      plus a few symbol tables (also dictionaries) on the side.
      
      They have clearly outgrown these simple data structures.  There's lots
      of rummaging around in dictionaries, and information is recomputed on
      the fly.  For the work I'm going to do, I want more clearly defined
      and more convenient interfaces.
      
      Going forward, I also want less coupling between the back-ends and the
      syntax tree, to make messing with the syntax easier.
      
      Create a bunch of classes to represent QAPI schemata.
      
      Have the QAPISchema initializer call the parser, then walk the syntax
      tree to create the new internal representation, and finally perform
      semantic analysis.
      
      Shortcut: the semantic analysis still relies on existing check_exprs()
      to do the actual semantic checking.  All this code needs to move into
      the classes.  Mark as TODO.
      
      Simple unions are lowered to flat unions.  Flat unions and structs are
      represented as a more general object type.
      
      Catching name collisions in generated code would be nice.  Mark as
      TODO.
      
      We generate array types eagerly, even though most of them aren't used.
      Mark as TODO.
      
      Nothing uses the new intermediate representation just yet, thus no
      change to generated files.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      ac88219a
  9. 18 9月, 2015 4 次提交
  10. 15 9月, 2015 4 次提交
    • D
      crypto: introduce new module for handling TLS sessions · d321e1e5
      Daniel P. Berrange 提交于
      Introduce a QCryptoTLSSession object that will encapsulate
      all the code for setting up and using a client/sever TLS
      session. This isolates the code which depends on the gnutls
      library, avoiding #ifdefs in the rest of the codebase, as
      well as facilitating any possible future port to other TLS
      libraries, if desired. It makes use of the previously
      defined QCryptoTLSCreds object to access credentials to
      use with the session. It also includes further unit tests
      to validate the correctness of the TLS session handshake
      and certificate validation. This is functionally equivalent
      to the current TLS session handling code embedded in the
      VNC server, and will obsolete it.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      d321e1e5
    • D
      crypto: add sanity checking of TLS x509 credentials · 9a2fd434
      Daniel P. Berrange 提交于
      If the administrator incorrectly sets up their x509 certificates,
      the errors seen at runtime during connection attempts are very
      obscure and difficult to diagnose. This has been a particular
      problem for people using openssl to generate their certificates
      instead of the gnutls certtool, because the openssl tools don't
      turn on the various x509 extensions that gnutls expects to be
      present by default.
      
      This change thus adds support in the TLS credentials object to
      sanity check the certificates when QEMU first loads them. This
      gives the administrator immediate feedback for the majority of
      common configuration mistakes, reducing the pain involved in
      setting up TLS. The code is derived from equivalent code that
      has been part of libvirt's TLS support and has been seen to be
      valuable in assisting admins.
      
      It is possible to disable the sanity checking, however, via
      the new 'sanity-check' property on the tls-creds object type,
      with a value of 'no'.
      
      Unit tests are included in this change to verify the correctness
      of the sanity checking code in all the key scenarios it is
      intended to cope with. As part of the test suite, the pkix_asn1_tab.c
      from gnutls is imported. This file is intentionally copied from the
      (long since obsolete) gnutls 1.6.3 source tree, since that version
      was still under GPLv2+, rather than the GPLv3+ of gnutls >= 2.0.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      9a2fd434
    • D
      crypto: introduce new base module for TLS credentials · a090187d
      Daniel P. Berrange 提交于
      Introduce a QCryptoTLSCreds class to act as the base class for
      storing TLS credentials. This will be later subclassed to provide
      handling of anonymous and x509 credential types. The subclasses
      will be user creatable objects, so instances can be created &
      deleted via 'object-add' and 'object-del' QMP commands respectively,
      or via the -object command line arg.
      
      If the credentials cannot be initialized an error will be reported
      as a QMP reply, or on stderr respectively.
      
      The idea is to make it possible to represent and manage TLS
      credentials independently of the network service that is using
      them. This will enable multiple services to use the same set of
      credentials and minimize code duplication. A later patch will
      convert the current VNC server TLS code over to use this object.
      
      The representation of credentials will be functionally equivalent
      to that currently implemented in the VNC server with one exception.
      The new code has the ability to (optionally) load a pre-generated
      set of diffie-hellman parameters, if the file dh-params.pem exists,
      whereas the current VNC server will always generate them on startup.
      This is beneficial for admins who wish to avoid the (small) time
      sink of generating DH parameters at startup and/or avoid depleting
      entropy.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      a090187d
    • D
      qom: allow QOM to be linked into tools binaries · 0c7012e0
      Daniel P. Berrange 提交于
      The qom objects are currently added to common-obj-y
      which is only linked into the system emulators. The
      later crypto patches will depend on QOM infrastructure
      and will also be used from tools binaries. Thus the QOM
      objects are moved into a new qom-obj-y variable which
      can be referenced when linking tools, system emulators
      and tests.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      0c7012e0