1. 21 9月, 2015 7 次提交
    • 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 QAPISchemaVisitor · 3f7dc21b
      Markus Armbruster 提交于
      The visitor will help keeping the code generation code simple and
      reasonably separated from QAPISchema details.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1442401589-24189-5-git-send-email-armbru@redhat.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      3f7dc21b
    • M
      qapi: QAPISchema code generation helper methods · f51d8c3d
      Markus Armbruster 提交于
      New methods c_name(), c_type(), c_null(), json_type(),
      alternate_qtype().
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1442401589-24189-4-git-send-email-armbru@redhat.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      f51d8c3d
    • 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
    • M
      qapi: Rename class QAPISchema to QAPISchemaParser · a4bcb208
      Markus Armbruster 提交于
      I want to name a new class QAPISchema.
      
      While there, make it a new-style class.
      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-2-git-send-email-armbru@redhat.com>
      a4bcb208
  2. 19 9月, 2015 23 次提交
  3. 18 9月, 2015 10 次提交
    • P
      Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging · a53efe9c
      Peter Maydell 提交于
      # gpg: Signature made Fri 18 Sep 2015 15:59:02 BST using RSA key ID AAFC390E
      # gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>"
      
      * remotes/jnsnow/tags/ide-pull-request:
        ahci: clean up initial d2h semantics
        ahci: remove cmd_fis argument from write_fis_d2h
        ahci: fix signature generation
        ahci: remove dead reset code
        atapi: abort transfers with 0 byte limits
        ide: fix ATAPI command permissions
        ide-test: add cdrom dma test
        ide-test: add cdrom pio test
        qtest/ahci: export generate_pattern
        qtest/ahci: use generate_pattern everywhere
        ide: unify io_buffer_offset increments
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      a53efe9c
    • J
      ahci: clean up initial d2h semantics · e47f9eb1
      John Snow 提交于
      with write_fis_d2h and signature generation tidied up,
      let's adjust the initial d2h semantics to make more sense.
      
      The initial d2h is considered delivered if there is guest
      memory to save it to.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Message-id: 1441140641-17631-5-git-send-email-jsnow@redhat.com
      e47f9eb1
    • J
      ahci: remove cmd_fis argument from write_fis_d2h · 28ee8255
      John Snow 提交于
      It's no longer used. We used to generate a D2H FIS based
      upon the command FIS that prompted the update, but in reality,
      the D2H FIS is generated purely from register state.
      
      cmd_fis is vestigial, so get rid of it.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Message-id: 1441140641-17631-4-git-send-email-jsnow@redhat.com
      28ee8255
    • J
      ahci: fix signature generation · 33a983cb
      John Snow 提交于
      The initial register device-to-host FIS no longer needs to specially
      set certain fields, as these can be handled generically by setting those
      fields explicitly with the signatures we want at port reset time.
      
      (1) Signatures are decomposed into their four component registers and
          set upon (AHCI) port reset.
      (2) the signature cache register is no longer set manually per-each
          device type, but instead just once during ahci_init_d2h.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Message-id: 1441140641-17631-3-git-send-email-jsnow@redhat.com
      33a983cb
    • J
      ahci: remove dead reset code · f91a0aa3
      John Snow 提交于
      This check is dead due to an earlier conditional.
      AHCI does not currently support hotplugging, so
      checks to see if devices are present or not are useless.
      
      Remove it.
      Reported-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Message-id: 1441140641-17631-2-git-send-email-jsnow@redhat.com
      f91a0aa3
    • J
      atapi: abort transfers with 0 byte limits · 9ef2e93f
      John Snow 提交于
      We're supposed to abort on transfers like this, unless we fill
      Word 125 of our IDENTIFY data with a default transfer size, which
      we don't currently do.
      
      This is an ATA error, not a SCSI/ATAPI one.
      See ATA8-ACS3 sections 7.17.6.49 or 7.21.5.
      
      If we don't do this, QEMU will loop forever trying to transfer
      zero bytes, which isn't particularly useful.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Message-id: 1442253685-23349-2-git-send-email-jsnow@redhat.com
      9ef2e93f
    • J
      ide: fix ATAPI command permissions · d9033e1d
      John Snow 提交于
      We're a little too lenient with what we'll let an ATAPI drive handle.
      Clamp down on the IDE command execution table to remove CD_OK permissions
      from commands that are not and have never been ATAPI commands.
      
      For ATAPI command validity, please see:
      - ATA4 Section 6.5 ("PACKET Command feature set")
      - ATA8/ACS Section 4.3 ("The PACKET feature set")
      - ACS3 Section 4.3 ("The PACKET feature set")
      
      ACS3 has a historical command validity table in Table B.4
      ("Historical Command Assignments") that can be referenced to find when
      a command was introduced, deprecated, obsoleted, etc.
      
      The only reference for ATAPI command validity is by checking that
      version's PACKET feature set section.
      
      ATAPI was introduced by T13 into ATA4, all commands retired prior to ATA4
      therefore are assumed to have never been ATAPI commands.
      
      Mandatory commands, as listed in ATA8-ACS3, are:
      
      - DEVICE RESET
      - EXECUTE DEVICE DIAGNOSTIC
      - IDENTIFY DEVICE
      - IDENTIFY PACKET DEVICE
      - NOP
      - PACKET
      - READ SECTOR(S)
      - SET FEATURES
      
      Optional commands as listed in ATA8-ACS3, are:
      
      - FLUSH CACHE
      - READ LOG DMA EXT
      - READ LOG EXT
      - WRITE LOG DMA EXT
      - WRITE LOG EXT
      
      All other commands are illegal to send to an ATAPI device and should
      be rejected by the device.
      
      CD_OK removal justifications:
      
      0x06 WIN_DSM              Defined in ACS2. Not valid for ATAPI.
      0x21 WIN_READ_ONCE        Retired in ATA5. Not ATAPI in ATA4.
      0x94 WIN_STANDBYNOW2      Retired in ATA4. Did not coexist with ATAPI.
      0x95 WIN_IDLEIMMEDIATE2   Retired in ATA4. Did not coexist with ATAPI.
      0x96 WIN_STANDBY2         Retired in ATA4. Did not coexist with ATAPI.
      0x97 WIN_SETIDLE2         Retired in ATA4. Did not coexist with ATAPI.
      0x98 WIN_CHECKPOWERMODE2  Retired in ATA4. Did not coexist with ATAPI.
      0x99 WIN_SLEEPNOW2        Retired in ATA4. Did not coexist with ATAPI.
      0xE0 WIN_STANDBYNOW1      Not part of ATAPI in ATA4, ACS or ACS3.
      0xE1 WIN_IDLEIMMDIATE     Not part of ATAPI in ATA4, ACS or ACS3.
      0xE2 WIN_STANDBY          Not part of ATAPI in ATA4, ACS or ACS3.
      0xE3 WIN_SETIDLE1         Not part of ATAPI in ATA4, ACS or ACS3.
      0xE4 WIN_CHECKPOWERMODE1  Not part of ATAPI in ATA4, ACS or ACS3.
      0xE5 WIN_SLEEPNOW1        Not part of ATAPI in ATA4, ACS or ACS3.
      0xF8 WIN_READ_NATIVE_MAX  Obsoleted in ACS3. Not ATAPI in ATA4 or ACS.
      
      This patch fixes a divide by zero fault that can be caused by sending
      the WIN_READ_NATIVE_MAX command to an ATAPI drive, which causes it to
      attempt to use zeroed CHS values to perform sector arithmetic.
      Reported-by: NQinghao Tang <luodalongde@gmail.com>
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Message-id: 1441816082-21031-1-git-send-email-jsnow@redhat.com
      CC: qemu-stable@nongnu.org
      d9033e1d
    • J
      ide-test: add cdrom dma test · 00ea63fd
      John Snow 提交于
      Now, test the DMA functionality of the ATAPI drive.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Message-id: 1441926555-19471-5-git-send-email-jsnow@redhat.com
      00ea63fd
    • J
      ide-test: add cdrom pio test · f7ba8d7f
      John Snow 提交于
      Add a simple read test for ATAPI devices,
      using the PIO mechanism.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Message-id: 1441926555-19471-4-git-send-email-jsnow@redhat.com
      f7ba8d7f
    • J
      qtest/ahci: export generate_pattern · ab4f7057
      John Snow 提交于
      Share the pattern function for ide and ahci test.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Message-id: 1441926555-19471-3-git-send-email-jsnow@redhat.com
      ab4f7057