1. 27 9月, 2019 17 次提交
  2. 25 9月, 2019 2 次提交
  3. 24 9月, 2019 21 次提交
    • E
      tests: Use iothreads during iotest 223 · 506902c6
      Eric Blake 提交于
      Doing so catches the bugs we just fixed with NBD not properly using
      correct contexts.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20190920220729.31801-1-eblake@redhat.com>
      506902c6
    • E
      nbd/client: Add hint when TLS is missing · 1b5c15ce
      Eric Blake 提交于
      I received an off-list report of failure to connect to an NBD server
      expecting an x509 certificate, when the client was attempting something
      similar to this command line:
      
      $ ./x86_64-softmmu/qemu-system-x86_64 -name 'blah' -machine q35 -nodefaults \
        -object tls-creds-x509,id=tls0,endpoint=client,dir=$path_to_certs \
        -device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pcie.0,addr=0x6 \
        -drive id=drive_image1,if=none,snapshot=off,aio=threads,cache=none,format=raw,file=nbd:localhost:9000,werror=stop,rerror=stop,tls-creds=tls0 \
        -device scsi-hd,id=image1,drive=drive_image1,bootindex=0
      qemu-system-x86_64: -drive id=drive_image1,if=none,snapshot=off,aio=threads,cache=none,format=raw,file=nbd:localhost:9000,werror=stop,rerror=stop,tls-creds=tls0: TLS negotiation required before option 7 (go)
      server reported: Option 0x7 not permitted before TLS
      
      The problem?  As specified, -drive is trying to pass tls-creds to the
      raw format driver instead of the nbd protocol driver, but before we
      get to the point where we can detect that raw doesn't know what to do
      with tls-creds, the nbd driver has already failed because the server
      complained.  The fix to the broken command line?  Pass
      '...,file.tls-creds=tls0' to ensure the tls-creds option is handed to
      nbd, not raw.  But since the error message was rather cryptic, I'm
      trying to improve the error message.
      
      With this patch, the error message adds a line:
      
      qemu-system-x86_64: -drive id=drive_image1,if=none,snapshot=off,aio=threads,cache=none,format=raw,file=nbd:localhost:9000,werror=stop,rerror=stop,tls-creds=tls0: TLS negotiation required before option 7 (go)
      Did you forget a valid tls-creds?
      server reported: Option 0x7 not permitted before TLS
      
      And with luck, someone grepping for that error message will find this
      commit message and figure out their command line mistake.  Sadly, the
      only mention of file.tls-creds in our docs relates to an --image-opts
      use of PSK encryption with qemu-img as the client, rather than x509
      certificate encryption with qemu-kvm as the client.
      
      CC: Tingting Mao <timao@redhat.com>
      CC: Daniel P. Berrangé <berrange@redhat.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20190907172055.26870-1-eblake@redhat.com>
      [eblake: squash in iotest 233 fix]
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      1b5c15ce
    • M
      qapi: Fix missing 'if' checks in struct, union, alternate 'data' · dec0012e
      Markus Armbruster 提交于
      Commit 87adbbff..3e270dca "qapi: Add 'if' to (implicit
      struct|union|alternate) members" (v4.0.0) neglected test coverage, and
      promptly failed to check the conditions.  Review fail.
      
      Recent commit "tests/qapi-schema: Demonstrate insufficient 'if'
      checking" added test coverage, demonstrating the bug.  Fix it by add
      the missing check_if().
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190914153506.2151-13-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      dec0012e
    • M
      qapi: Reject blank 'if' conditions in addition to empty ones · c2c7065e
      Markus Armbruster 提交于
      "'if': 'COND'" generates "#if COND".  We reject empty COND because it
      won't compile.  Blank COND won't compile any better, so reject that,
      too.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190914153506.2151-12-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      c2c7065e
    • M
      qapi: Fix broken discriminator error messages · 887a2069
      Markus Armbruster 提交于
      check_union() checks the discriminator exists in base and makes sense.
      Two error messages mention the base.  These are broken for anonymous
      bases, as demonstrated by tests flat-union-invalid-discriminator and
      flat-union-invalid-if-discriminator.err.  The third one doesn't
      bother.
      
      First broken when commit ac4338f8 "qapi: Allow anonymous base for
      flat union" (v2.6.0) neglected to adjust the "not a member of base"
      error message.  Commit ccadd6bc "qapi: Add 'if' to implicit struct
      members" (v4.0.0) then cloned the flawed error message.
      
      Dumb them down not to mention the base.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190914153506.2151-11-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      887a2069
    • M
      qapi: Remove null from schema language · 9d55380b
      Markus Armbruster 提交于
      We represent the parse tree as OrderedDict.  We fetch optional dict
      members with .get().  So far, so good.
      
      We represent null literals as None.  .get() returns None both for
      "absent" and for "present, value is the null literal".  Uh-oh.
      
      Test features-if-invalid exposes this bug: "'if': null" is
      misinterpreted as absent "if".
      
      We added null to the schema language to "allow [...] an explicit
      default value" (commit e53188ad "qapi: Allow true, false and null in
      schema json", v2.4.0).  Hasn't happened; null is still unused except
      as generic invalid value in tests/.
      
      To fix, we'd have to replace .get() by something more careful, or
      represent null differently.  Feasible, but we got more and bigger fish
      to fry right now.  Remove the null literal from the schema language.
      Replace null in tests by another invalid value.
      
      Test features-if-invalid now behaves as it should.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190914153506.2151-10-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      9d55380b
    • M
      qapi: Improve reporting of lexical errors · 14c32795
      Markus Armbruster 提交于
      Show text up to next structural character, whitespace, or quote
      character instead of just the first character.
      
      Forgotten quotes now get reported like "Stray 'command'" instead of
      "Stray 'c'".
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190914153506.2151-9-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      14c32795
    • M
      qapi: Use quotes more consistently in frontend error messages · 9f5e6b08
      Markus Armbruster 提交于
      Consistently enclose error messages in double quotes.  Use single
      quotes within, except for one case of "'".
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190914153506.2151-8-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      9f5e6b08
    • M
      tests/qapi-schema: Demonstrate suboptimal lexical errors · 4d428155
      Markus Armbruster 提交于
      The error message for forgotten quotes around a name shows just the
      name's first character, which isn't as nice as it could be.  Same for
      attempting to use a number.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190914153506.2151-7-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      4d428155
    • M
      tests/qapi-schema: Demonstrate insufficient 'if' checking · ef91ab0d
      Markus Armbruster 提交于
      Cover invalid 'if' in struct members, features, union and alternate
      branches.  Four out of four are broken.  Mark FIXME.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190914153506.2151-6-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      [Comment typo fixed]
      ef91ab0d
    • M
      tests/qapi-schema: Demonstrate broken discriminator errors · 31248b98
      Markus Armbruster 提交于
      When the union definition's base is an object, some error messages
      show it as an OrderedDict.  Oops.  Mark FIXME.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190914153506.2151-5-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      31248b98
    • M
      tests/qapi-schema: Demonstrate misleading optional tag error · cd346bdc
      Markus Armbruster 提交于
      Test flat-union-optional-discriminator declares its union tag as
      '*switch': 'Enum', and points to it with 'discriminator': '*switch'.
      This gets rejected as "discriminator of flat union 'MyUnion' uses
      invalid name '*switch'".  Correct; member 'discriminator' doesn't
      accept a '*' prefix.
      
      However, this merely tests name validity checking, which we already
      cover elsewhere.  More interesting is testing the valid name 'switch'.
      This reports "discriminator 'switch' is not a member of base struct
      'Base'", which is misleading.
      
      Copy the existing 'discriminator': '*switch' test to
      flat-union-discriminator-bad-name, and rewrite its comment.  Change
      flat-union-optional-discriminator to test 'discriminator': 'switch',
      and mark it FIXME.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190914153506.2151-4-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      cd346bdc
    • M
      tests/qapi-schema: Delete two redundant tests · 352ada9a
      Markus Armbruster 提交于
      Tests duplicate-key and double-data test the same thing.  The former
      predates the latter, and it has a better name.  Delete the latter, and
      tweak the former's comment.
      
      Tests include-format-err and include-extra-junk test the same thing.
      The former predates the latter, but the latter has a better name and a
      comment.  Delete the former.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190914153506.2151-3-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      352ada9a
    • M
      tests/qapi-schema: Cover unknown pragma · 137cf6a9
      Markus Armbruster 提交于
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190914153506.2151-2-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      137cf6a9
    • M
      qapi: Tweak code to match docs/devel/qapi-code-gen.txt · 8d40738d
      Markus Armbruster 提交于
      The previous commit made qapi-code-gen.txt define "(top-level)
      expression" as either "directive" or "definition".  The code still
      uses "expression" when it really means "definition".  Tidy up.
      
      The previous commit made qapi-code-gen.txt use "object" rather than
      "dictionary".  The code still uses "dictionary".  Tidy up.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20190913201349.24332-17-armbru@redhat.com>
      8d40738d
    • M
      qapi: Adjust frontend errors to say enum value, not member · 398969fe
      Markus Armbruster 提交于
      For consistency with docs/devel/qapi-code-gen.txt.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20190913201349.24332-12-armbru@redhat.com>
      398969fe
    • M
      qapi: Permit omitting all flat union branches · 0ced9531
      Markus Armbruster 提交于
      Absent flat union branches default to the empty struct (since commit
      800877bb "qapi: allow empty branches in flat unions").  But an
      attempt to omit all of them is rejected with "Union 'FOO' has no
      branches".  Harmless oddity, but it's easy to avoid, so do that.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20190913201349.24332-11-armbru@redhat.com>
      [Commit message typo fixed]
      0ced9531
    • M
      qapi: Permit alternates with just one branch · f0325536
      Markus Armbruster 提交于
      A union or alternate without branches makes no sense and doesn't work:
      it can't be instantiated.  A union or alternate with just one branch
      works, but is degenerate.  We accept the former, but reject the
      latter.  Weird.  docs/devel/qapi-code-gen.txt doesn't mention the
      difference.  It claims an alternate definition is "is similar to a
      simple union type".
      
      Permit degenerate alternates to make them consistent with unions.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20190913201349.24332-10-armbru@redhat.com>
      f0325536
    • M
      qapi: Permit 'boxed' with empty type · 675b214b
      Markus Armbruster 提交于
      We reject empty types with 'boxed': true.  We don't really need that
      to work, but making it work is actually simpler than rejecting it, so
      do that.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20190913201349.24332-9-armbru@redhat.com>
      675b214b
    • M
      qapi: Drop support for escape sequences other than \\ · 9b4416bf
      Markus Armbruster 提交于
      Since the previous commit restricted strings to printable ASCII,
      \uXXXX's only use is obfuscation.  Drop it.
      
      This leaves \\, \/, \', and \".  Since QAPI schema strings are all
      names, and names are restricted to ASCII letters, digits, hyphen, and
      underscore, none of them is useful.
      
      The latter three have no test coverage.  Drop them.
      
      Keep \\ to avoid (more) gratuitous incompatibility with JSON.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20190913201349.24332-8-armbru@redhat.com>
      9b4416bf
    • M
      qapi: Restrict strings to printable ASCII · 56a8caff
      Markus Armbruster 提交于
      RFC 8259 on string contents:
      
         All Unicode characters may be placed within the quotation marks,
         except for the characters that MUST be escaped: quotation mark,
         reverse solidus, and the control characters (U+0000 through
         U+001F).
      
      The QAPI schema parser accepts both less and more than JSON: it
      accepts only ASCII with \u (less), and accepts control characters
      other than LF (new line) unescaped.  How it treats unescaped non-ASCII
      input differs between Python 2 and Python 3.
      
      Make it accept strictly less: require printable ASCII.  Drop support
      for \b, \f, \n, \r, \t.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20190913201349.24332-7-armbru@redhat.com>
      56a8caff