1. 17 12月, 2015 40 次提交
    • J
      i.MX: Fix i.MX31 default/reset configuration · 9de46a0a
      Jean-Christophe Dubois 提交于
      Linux on i.MX31/KZM is expecting the CCM to use the CKIH ref clock
      instead of the CKIL plus the FPM multiplier.
      
      We change the CCMR reg reset value to match linux expected config.
      
      This allows the CCM to provide a 39MHz clk (as expected by linux)
      instead of the actual 50MHz.
      
      With this change the "sleep 60" command on linux is time accurate
      with "real world time".
      Signed-off-by: NJean-Christophe Dubois <jcd@tribudubois.net>
      Reviewed-by: NPeter Crosthwaite <crosthwaite.peter@gmail.com>
      Message-id: 6dc5bc4e0a450b20cecdb2991112e7281b653345.1449528242.git.jcd@tribudubois.net
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      9de46a0a
    • A
      tests/guest-debug: introduce basic gdbstub tests · 261f4d6d
      Alex Bennée 提交于
      The aim of these tests is to combine with an appropriate kernel
      image (with symbol-file vmlinux) and check it behaves as it should.
      Given a kernel it checks:
      
        - single step
        - software breakpoint
        - hardware breakpoint
        - access, read and write watchpoints
      
      On success it returns 0 to the calling process.
      
      I've not plumbed this into the "make check" logic though as we need a
      solution for providing non-host binaries to the tests. However the test
      is structured to work with pretty much any Linux kernel image as it
      uses the basic kernel_init code which is common across architectures.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Message-id: 1449599553-24713-7-git-send-email-alex.bennee@linaro.org
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      261f4d6d
    • A
      target-arm: kvm - re-inject guest debug exceptions · 34c45d53
      Alex Bennée 提交于
      If we can't find details for the debug exception in our debug state
      then we can assume the exception is due to debugging inside the guest.
      To inject the exception into the guest state we re-use the TCG exception
      code (do_interrupt).
      
      However while guest debugging is in effect we currently can't handle the
      guest using single step as we will keep trapping to back to userspace.
      GDB makes heavy use of single-step behind the scenes which effectively
      means the guest's ability to debug itself is disabled while it is being
      debugged.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Message-id: 1449599553-24713-6-git-send-email-alex.bennee@linaro.org
      [PMM: Fixed a few typos in comments and commit message]
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      34c45d53
    • A
      target-arm: kvm - add support for HW assisted debug · e4482ab7
      Alex Bennée 提交于
      This adds basic support for HW assisted debug. The ioctl interface to
      KVM allows us to pass an implementation defined number of break and
      watch point registers. When KVM_GUESTDBG_USE_HW is specified these
      debug registers will be installed in place on the world switch into the
      guest.
      
      The hardware is actually capable of more advanced matching but it is
      unclear if this expressiveness is available via the gdbstub protocol.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Message-id: 1449599553-24713-5-git-send-email-alex.bennee@linaro.org
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      e4482ab7
    • A
      target-arm: kvm - support for single step · 26ae5934
      Alex Bennée 提交于
      This adds support for single-step. There isn't much to do on the QEMU
      side as after we set-up the request for single step via the debug ioctl
      it is all handled within the kernel.
      
      The actual setting of the KVM_GUESTDBG_SINGLESTEP flag is already in the
      common code. If the kernel doesn't support guest debug the ioctl will
      simply error.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Message-id: 1449599553-24713-4-git-send-email-alex.bennee@linaro.org
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      26ae5934
    • A
      target-arm: kvm - implement software breakpoints · 2ecb2027
      Alex Bennée 提交于
      These don't involve messing around with debug registers, just setting
      the breakpoint instruction in memory. GDB will not use this mechanism if
      it can't access the memory to write the breakpoint.
      
      All the kernel has to do is ensure the hypervisor traps the breakpoint
      exceptions and returns to userspace.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Message-id: 1449599553-24713-3-git-send-email-alex.bennee@linaro.org
      [PMM: Fixed typo in comment]
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      2ecb2027
    • A
      target-arm: kvm64 - introduce kvm_arm_init_debug() · 29eb3d9a
      Alex Bennée 提交于
      As we haven't always had guest debug support we need to probe for it.
      Additionally we don't do this in the start-up capability code so we
      don't fall over on old kernels.
      Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
      Message-id: 1449599553-24713-2-git-send-email-alex.bennee@linaro.org
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      29eb3d9a
    • S
      ARM: Virt: Add gpio-keys node for Poweroff using DT · 3e6ebb64
      Shannon Zhao 提交于
      Add a gpio-keys node. This is used for Poweroff for the systems which
      use DT not ACPI.
      Signed-off-by: NShannon Zhao <zhaoshenglong@huawei.com>
      Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
      Tested-by: NWei Huang <wei@redhat.com>
      Message-id: 1449804086-3464-11-git-send-email-zhaoshenglong@huawei.com
      [PMM: use "standard-headers/linux/input.h" rather than <linux/input.h>]
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      3e6ebb64
    • S
      ARM: Virt: Add QEMU powerdown notifier and hook it to GPIO Pin 3 · 4bedd849
      Shannon Zhao 提交于
      Currently mach-virt model doesn't support powerdown request. Guest VM
      doesn't react to system_powerdown from monitor console (or QMP) because
      there is no communication mechanism for such requests. This patch registers
      GPIO Pin 3 with powerdown notification. So guest VM can receive notification
      when such powerdown request is triggered.
      Signed-off-by: NWei Huang <wei@redhat.com>
      Signed-off-by: NShannon Zhao <zhaoshenglong@huawei.com>
      Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
      Reviewed-by: NWei Huang <wei@redhat.com>
      Tested-by: NWei Huang <wei@redhat.com>
      Message-id: 1449804086-3464-10-git-send-email-zhaoshenglong@huawei.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      4bedd849
    • S
      ARM: ACPI: Add _E03 for Power Button · c1a158b7
      Shannon Zhao 提交于
      Here GPIO pin 3 is used for Power Button, add _E03 in ACPI DSDT table.
      Signed-off-by: NShannon Zhao <zhaoshenglong@huawei.com>
      Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
      Tested-by: NWei Huang <wei@redhat.com>
      Message-id: 1449804086-3464-9-git-send-email-zhaoshenglong@huawei.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      c1a158b7
    • S
      ACPI: Add aml_gpio_int() wrapper for GPIO Interrupt Connection · 37d0e980
      Shannon Zhao 提交于
      Signed-off-by: NShannon Zhao <zhaoshenglong@huawei.com>
      Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
      Tested-by: NWei Huang <wei@redhat.com>
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Message-id: 1449804086-3464-8-git-send-email-zhaoshenglong@huawei.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      37d0e980
    • S
      ACPI: Add GPIO Connection Descriptor · 4ecdc746
      Shannon Zhao 提交于
      Signed-off-by: NShannon Zhao <zhaoshenglong@huawei.com>
      Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
      Tested-by: NWei Huang <wei@redhat.com>
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Message-id: 1449804086-3464-7-git-send-email-zhaoshenglong@huawei.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      4ecdc746
    • S
      ARM: ACPI: Add power button device in ACPI DSDT table · ac6aa59a
      Shannon Zhao 提交于
      Add power button device in ACPI DSDT table.
      Signed-off-by: NShannon Zhao <zhaoshenglong@huawei.com>
      Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
      Reviewed-by: NWei Huang <wei@redhat.com>
      Tested-by: NWei Huang <wei@redhat.com>
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Message-id: 1449804086-3464-6-git-send-email-zhaoshenglong@huawei.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      ac6aa59a
    • S
      ARM: ACPI: Add GPIO controller in ACPI DSDT table · aeb1a36d
      Shannon Zhao 提交于
      Add GPIO controller in ACPI DSDT table. It can be used for gpio event.
      Signed-off-by: NShannon Zhao <zhaoshenglong@huawei.com>
      Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
      Tested-by: NWei Huang <wei@redhat.com>
      Message-id: 1449804086-3464-5-git-send-email-zhaoshenglong@huawei.com
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      aeb1a36d
    • S
      ARM: Virt: Add a GPIO controller · b0a3721e
      Shannon Zhao 提交于
      ACPI 5.0 supports GPIO-signaled ACPI Events. This can be used for
      powerdown, hotplug evnets. Add a GPIO controller in machine virt,
      to support powerdown, maybe can be used for cpu hotplug. And
      here we use pl061.
      Signed-off-by: NShannon Zhao <zhaoshenglong@huawei.com>
      Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
      Reviewed-by: NWei Huang <wei@redhat.com>
      Tested-by: NWei Huang <wei@redhat.com>
      Message-id: 1449804086-3464-4-git-send-email-zhaoshenglong@huawei.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      b0a3721e
    • I
      acpi: extend aml_interrupt() to support multiple irqs · 45fcf539
      Igor Mammedov 提交于
      ASL Interrupt() macro translates to Extended Interrupt Descriptor
      which supports variable number of IRQs. It will be used for
      conversion of ASL code for pc/q35 machines that use it for
      returning several IRQs in _PSR object.
      Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
      Reviewed-by: NShannon Zhao <shannon.zhao@linaro.org>
      Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
      Message-id: 1449804086-3464-3-git-send-email-zhaoshenglong@huawei.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      45fcf539
    • X
      acpi: support serialized method · 4dbfc881
      Xiao Guangrong 提交于
      Add serialized method support so that explicit Mutex can be
      avoided
      Signed-off-by: NXiao Guangrong <guangrong.xiao@linux.intel.com>
      Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
      Reviewed-by: NShannon Zhao <shannon.zhao@linaro.org>
      Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
      Message-id: 1449804086-3464-2-git-send-email-zhaoshenglong@huawei.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      4dbfc881
    • S
      target-arm: Fix and improve AA32 singlestep translation completion code · 7999a5c8
      Sergey Fedorov 提交于
      The AArch32 translation completion code for singlestep enabled/active
      case was a way more confusing and too repetitive then it needs to be.
      Probably that was the cause for a bug to be introduced into it at some
      point. The bug was that SWI/HVC/SMC exception would be generated in
      condition-failed instruction code path whereas it shouldn't.
      
      This patch rewrites the code in a way similar to the non-singlestep
      case.
      
      In the condition-passed/unconditional instruction code path we need to:
       - Write the condexec bits back to the CPU state
       - Advance the singlestep state machine and generate a corresponding
         exception in case of SWI/HVC/SMC
       - Write the PC back to the CPU state if it hasn't already been written
         and generate an appropriate singlestep exception otherwise
      
      In the condition-failed instruction code path we need to:
       - Set a TCG label to jump to it if the condition is failed
       - Write the condexec bits back to the CPU state
       - Write the PC back to the CPU state since it hasn't been written in
         this case
       - Generate an appropriate singlestep exception
      Signed-off-by: NSergey Fedorov <serge.fdrv@gmail.com>
      Message-id: 1448474560-22475-1-git-send-email-serge.fdrv@gmail.com
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      7999a5c8
    • A
      target-arm: raise exception on misaligned LDREX operands · 30901475
      Andrew Baumann 提交于
      Qemu does not generally perform alignment checks. However, the ARM ARM
      requires implementation of alignment exceptions for a number of cases
      including LDREX, and Windows-on-ARM relies on this.
      
      This change adds plumbing to enable alignment checks on loads using
      MO_ALIGN, a do_unaligned_access hook to raise the exception (data
      abort), and uses the new aligned loads in LDREX (for all but
      single-byte loads).
      Signed-off-by: NAndrew Baumann <Andrew.Baumann@microsoft.com>
      Message-id: 1449167808-5656-1-git-send-email-Andrew.Baumann@microsoft.com
      [PMM: set WnR bits in syndrome and FSR as appropriate]
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      30901475
    • P
      arm: soc-dma: use hwaddr instead of target_ulong in printf · 580106df
      Paolo Bonzini 提交于
      This is a first baby step towards removing widespread inclusion of
      cpu.h and compiling more devices once (so that arm, aarch64 and
      in the future target-multi can share the object files).
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      [PMM: changed __FUNCTION__ to __func__ since we're touching
       these lines of code anyway]
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      580106df
    • P
      arm: explicitly mark device loads as little-endian · 58f6d82f
      Paolo Bonzini 提交于
      Behaviour of emulated devices should not depend on the endianness
      of the CPU, so avoid using the endian-dependent load and store
      functions in the PXA2xx and OMAP display devices. These devices
      are little endian when they do DMA access.
      
      (Since ARM softmmu is always compiled as little endian, this means
      that the endian-dependent load and store functions are always little
      endian, so this commit makes no functionally visible change.)
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      [PMM: rewrote commit message]
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      58f6d82f
    • J
      i.MX: add support for lower and upper interrupt in GPIO. · f1f7e4bf
      Jean-Christophe Dubois 提交于
      The i.MX6 GPIO device supports 2 interrupts instead of one.
      
      * 1 for the lower 16 GPIOs.
      * 1 for the upper 16 GPIOs.
      
      i.MX31 and i.MX25 only support 1 interrupt for the 32 GPIOs.
      
      So we add a property to turn the behavior on when required.
      Signed-off-by: NJean-Christophe Dubois <jcd@tribudubois.net>
      Reviewed-by: NPeter Crosthwaite <crosthwaite.peter@gmail.com>
      Message-id: 1447497668-1603-1-git-send-email-jcd@tribudubois.net
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      f1f7e4bf
    • P
      Merge remote-tracking branch 'remotes/kraxel/tags/pull-fw-cfg-20151217-1' into staging · 98557acf
      Peter Maydell 提交于
      fw_cfg: doc updates, various optimizations.
      
      # gpg: Signature made Thu 17 Dec 2015 08:59:32 GMT using RSA key ID D3E87138
      # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
      # gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
      # gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
      
      * remotes/kraxel/tags/pull-fw-cfg-20151217-1:
        fw_cfg: replace ioport data read with generic method
        fw_cfg: add generic non-DMA read method
        fw_cfg: avoid calculating invalid current entry pointer
        fw_cfg: remove offset argument from callback prototype
        fw_cfg: amend callback behavior spec to once per select
        fw_cfg: move internal function call docs to header file
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      98557acf
    • P
      Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2015-12-17' into staging · c1a5f950
      Peter Maydell 提交于
      QAPI patches for 2015-12-17
      
      # gpg: Signature made Thu 17 Dec 2015 07:33:41 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-2015-12-17: (40 commits)
        qapi: Detect base class loops
        qapi: Move duplicate collision checks to schema check()
        qapi: Enforce (or whitelist) case conventions on qapi members
        qapi: Track enum values by QAPISchemaMember, not string
        qapi: Prepare new QAPISchemaMember base class
        qapi: Shorter visits of optional fields
        qapi: Simplify visits of optional fields
        qapi: Fix alternates that accept 'number' but not 'int'
        qapi: Inline _make_implicit_tag()
        qapi-types: Drop unnedeed ._fwdefn
        qapi: Simplify visiting of alternate types
        qapi: Convert QType into QAPI built-in enum type
        qobject: Rename qtype_code to QType
        qobject: Simplify QObject
        qapi: Change munging of CamelCase enum values
        qapi: Add alias for ErrorClass
        cpu: Convert CpuInfo into flat union
        qapi: Remove obsolete tests for MAX collision
        qapi: Don't let implicit enum MAX member collide
        qapi: Tighten the regex on valid names
        ...
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      c1a5f950
    • P
      Merge remote-tracking branch 'remotes/kraxel/tags/pull-audio-20151215-1' into staging · fc77eb20
      Peter Maydell 提交于
      coreaudio: use new-in-OSX-10.6 APIs, cleanups.
      
      # gpg: Signature made Tue 15 Dec 2015 10:15:24 GMT using RSA key ID D3E87138
      # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
      # gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
      # gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
      
      * remotes/kraxel/tags/pull-audio-20151215-1:
        audio/coreaudio.c: Avoid deprecated AudioDeviceAdd/RemoveIOProc APIs
        audio/coreaudio.c: Use new-in-OSX-10.6 APIs when available
        audio/coreaudio.c: Factor out uses of AudioDeviceGet/SetProperty
        audio/coreaudio.c: Use new-in-OSX-10.6 API for getting default voice
        audio/coreaudio.c: Factor out use of AudioHardwareGetProperty
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      fc77eb20
    • P
      Merge remote-tracking branch 'remotes/kraxel/tags/pull-usb-20151215-1' into staging · dc337c6e
      Peter Maydell 提交于
      usb: ehci idt fix, event support for mtp
      
      # gpg: Signature made Tue 15 Dec 2015 09:54:22 GMT using RSA key ID D3E87138
      # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
      # gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
      # gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
      
      * remotes/kraxel/tags/pull-usb-20151215-1:
        ehci: make idt processing more robust
        usb-mtp: add support for basic mtp events
        usb-mtp: Add support for inotify based file monitoring
        usb-mtp: free objects on a mtp reset
        usb-mtp: use a list for keeping track of children
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      dc337c6e
    • P
      Open 2.6 development tree · 71f3ef08
      Peter Maydell 提交于
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      71f3ef08
    • E
      qapi: Detect base class loops · bac5429c
      Eric Blake 提交于
      It should be fairly obvious that qapi base classes need to
      form an acyclic graph, since QMP cannot specify the same
      key more than once, while base classes are included as flat
      members alongside other members added by the child.  But the
      old check_member_clash() parser function was not prepared to
      check for this, and entered an infinite recursion (at least
      until Python gives up, complaining about nesting too deep).
      
      Now that check_member_clash() has been recently removed,
      attempts at self-inheritance trigger an assertion failure
      introduced by commit ac88219a.  The obvious fix is to turn
      the assertion into a conditional.
      
      This patch includes both the tests (base-cycle-direct and
      base-cycle-indirect) and the fix, since the .err file output
      for the unfixed case is not useful (particularly when it was
      warning about unbounded recursion, as that limit may be
      platform-specific).
      
      We don't need to worry about cycles in flat unions (neither
      the base type nor the type of a variant can be a union) nor
      in alternates (alternate branches cannot themselves be an
      alternate).  But if we later allow a union type as a variant,
      we will still be okay, as QAPISchemaObjectTypeVariants.check()
      triggers the same QAPISchemaObjectType.check() that will
      detect any loops.
      
      Likewise, we need not worry about the case of diamond
      inheritance where the same class is used for a flat union base
      class and one of its variants; either both uses will introduce
      a collision in trying to insert the same member name twice, or
      the shared type is empty and changes nothing.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1449033659-25497-16-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      bac5429c
    • E
      qapi: Move duplicate collision checks to schema check() · 01cfbaa4
      Eric Blake 提交于
      With the recent commit 'qapi: Detect collisions in C member
      names', we have two different locations for detecting clashes -
      one at parse time, and another at QAPISchema*.check() time.
      Remove all of the ad hoc parser checks, and delete associated
      code (for example, the global check_member_clash() method is
      no longer needed).
      
      Testing this showed that the test union-bad-branch wasn't adding
      much: union-clash-branches also exposes the error message when
      branches collide, and we've recently fixed things to avoid an
      implicit collision with max.  Likewise, the error for
      enum-clash-member changes to report our new detection of
      upper case in a value name, unless we modify the test to use
      all lower case.
      
      The wording of several error messages has changed, but the
      change is generally an improvement rather than a regression.
      
      No change to generated code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1449033659-25497-15-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      01cfbaa4
    • E
      qapi: Enforce (or whitelist) case conventions on qapi members · 893e1f2c
      Eric Blake 提交于
      We document that members of enums and objects should be
      'lower-case', although we were not enforcing it.  We have to
      whitelist a few pre-existing entities that violate the norms.
      Add three new tests to expose the new error message, each of
      which first uses the whitelisted name 'UuidInfo' to prove the
      whitelist works, then triggers the failure (this is the same
      pattern used in the existing returns-whitelist.json test).
      
      Note that by adding this check, we have effectively forbidden
      an entity with a case-insensitive clash of member names, for
      any entity that is not on the whitelist (although there is
      still the possibility to clash via '-' vs. '_').
      
      Not done here: a future patch should also add naming convention
      support and whitelist exceptions for command, event, and type
      names.
      
      The additions to QAPISchemaMember.check_clash() check whether
      info['name'] is in the whitelist (the top-most entity name at
      the point 'info' tracks), rather than self.owner (the type,
      possibly implicit, that directly owns the member), because it
      is easier to maintain the whitelist by the names actually in
      the user's .json file, rather than worrying about the names
      of implicit types.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1449033659-25497-14-git-send-email-eblake@redhat.com>
      [Simplified a bit as per discussion with Eric]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      893e1f2c
    • E
      qapi: Track enum values by QAPISchemaMember, not string · 93bda4dd
      Eric Blake 提交于
      Rather than using just an array of strings, make enum.values be
      an array of the new QAPISchemaMember type, and add a helper
      member_names() method to get back at the original list of names.
      Likewise, creating an enum requires wrapping strings, via a new
      QAPISchema._make_enum_members() method.  The benefit of wrapping
      enum members in a QAPISchemaMember Python object is that we now
      share the existing code for C name clash detection (although the
      code is not yet active until a later commit removes the earlier
      ad hoc parser checks).
      
      In a related change, the QAPISchemaMember._pretty_owner() method
      needs to learn about one more implicit type name: the generated
      enum associated with a simple union.
      
      In the interest of keeping the changes of this patch local to one
      file, the visitor interface still passes just a list of names
      rather than the full list of QAPISchemaMember instances.  We may
      want to revisit this in the future, if the consistency with
      visit_object_type() is worth it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1449033659-25497-12-git-send-email-eblake@redhat.com>
      [Eric's simplifying followup squashed in]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      93bda4dd
    • E
      qapi: Prepare new QAPISchemaMember base class · d44f9ac8
      Eric Blake 提交于
      We want to share some clash detection code between enum values
      and object type members.  To assist with that, split off part
      of QAPISchemaObjectTypeMember into a new base class
      QAPISchemaMember that tracks name, owner, and common clash
      detection code; while the former keeps the additional fields
      for type and optional flag.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1449033659-25497-11-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      d44f9ac8
    • E
      qapi: Shorter visits of optional fields · 29637a6e
      Eric Blake 提交于
      For less code, reflect the determined boolean value of an optional
      visit back to the caller instead of making the caller read the
      boolean after the fact.
      
      The resulting generated code has the following diff:
      
      |-    visit_optional(v, &has_fdset_id, "fdset-id");
      |-    if (has_fdset_id) {
      |+    if (visit_optional(v, &has_fdset_id, "fdset-id")) {
      |         visit_type_int(v, &fdset_id, "fdset-id", &err);
      |         if (err) {
      |             goto out;
      |         }
      |     }
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1449033659-25497-10-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      29637a6e
    • E
      qapi: Simplify visits of optional fields · 5cdc8831
      Eric Blake 提交于
      None of the visitor callbacks would set an error when testing
      if an optional field was present; make this part of the interface
      contract by eliminating the errp argument.
      
      The resulting generated code has a nice diff:
      
      |-    visit_optional(v, &has_fdset_id, "fdset-id", &err);
      |-    if (err) {
      |-        goto out;
      |-    }
      |+    visit_optional(v, &has_fdset_id, "fdset-id");
      |     if (has_fdset_id) {
      |         visit_type_int(v, &fdset_id, "fdset-id", &err);
      |         if (err) {
      |             goto out;
      |         }
      |     }
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1449033659-25497-9-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      5cdc8831
    • E
      qapi: Fix alternates that accept 'number' but not 'int' · d00341af
      Eric Blake 提交于
      The QMP input visitor allows integral values to be assigned by
      promotion to a QTYPE_QFLOAT.  However, when parsing an alternate,
      we did not take this into account, such that an alternate that
      accepts 'number' and some other type, but not 'int', would reject
      integral values.
      
      With this patch, we now have the following desirable table:
      
          alternate has      case selected for
          'int'  'number'    QTYPE_QINT  QTYPE_QFLOAT
            no        no     error       error
            no       yes     'number'    'number'
           yes        no     'int'       error
           yes       yes     'int'       'number'
      
      While it is unlikely that we will ever use 'number' in an
      alternate other than in the testsuite, it never hurts to be
      more precise in what we allow.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1449033659-25497-8-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      d00341af
    • E
      qapi: Inline _make_implicit_tag() · 9d3f3494
      Eric Blake 提交于
      Now that alternates no longer use an implicit tag, we can
      inline _make_implicit_tag() into its one caller,
      _def_union_type().
      
      No change to generated code.
      Suggested-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1449033659-25497-7-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      9d3f3494
    • E
      qapi-types: Drop unnedeed ._fwdefn · 0b2e84ba
      Eric Blake 提交于
      Previously, the generated code in qapi-types.c initialized all
      enum lookup tables first, prior to any other definitions.  But
      there are no topological sorting requirements that mandate this
      layout, so we can drop the QAPISchemaGenTypeVisitor._fwdefn
      field and just generate all definitions in visitation order.
      
      The generated code shows some churn due to reordering, but it
      is still fairly straightforward to follow (all the deletions
      occur in one hunk, and all the deleted lines are re-inserted
      in the same order later in the same files, just spread across
      multiple insertion points).
      Suggested-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1449033659-25497-6-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      0b2e84ba
    • E
      qapi: Simplify visiting of alternate types · 0426d53c
      Eric Blake 提交于
      Previously, working with alternates required two lookup arrays
      and some indirection: for type Foo, we created Foo_qtypes[]
      which maps each qtype to a value of the generated FooKind enum,
      then look up that value in FooKind_lookup[] like we do for other
      union types.
      
      This has a couple of subtle bugs.  First, the generator was
      creating a call with a parameter '(int *) &(*obj)->type' where
      type is an enum type; this is unsafe if the compiler chooses
      to store the enum type in a different size than int, where
      assigning through the wrong size pointer can corrupt data or
      cause a SIGBUS.
      
      Related bug, not not fixed in this patch: qapi-visit.py's
      gen_visit_enum() generates a cast of its enum * argument to
      int *. Marked FIXME.
      
      Second, since the values of the FooKind enum start at zero, all
      entries of the Foo_qtypes[] array that were not explicitly
      initialized will map to the same branch of the union as the
      first member of the alternate, rather than triggering a desired
      failure in visit_get_next_type().  Fortunately, the bug seldom
      bites; the very next thing the input visitor does is try to
      parse the incoming JSON with the wrong parser, which normally
      fails; the output visitor is not used with a C struct in that
      state, and the dealloc visitor has nothing to clean up (so
      there is no leak).
      
      However, the second bug IS observable in one case: parsing an
      integer causes unusual behavior in an alternate that contains
      at least a 'number' member but no 'int' member, because the
      'number' parser accepts QTYPE_QINT in addition to the expected
      QTYPE_QFLOAT (that is, since 'int' is not a member, the type
      QTYPE_QINT accidentally maps to FooKind 0; if this enum value
      is the 'number' branch the integer parses successfully, but if
      the 'number' branch is not first, some other branch tries to
      parse the integer and rejects it).  A later patch will worry
      about fixing alternates to always parse all inputs that a
      non-alternate 'number' would accept, for now this is still
      marked FIXME in the updated test-qmp-input-visitor.c, to
      merely point out that new undesired behavior of 'ans' matches
      the existing undesired behavior of 'asn'.
      
      This patch fixes the default-initialization bug by deleting the
      indirection, and modifying get_next_type() to directly assign a
      QTypeCode parameter.  This in turn fixes the type-casting bug,
      as we are no longer casting a pointer to enum to a questionable
      size. There is no longer a need to generate an implicit FooKind
      enum associated with the alternate type (since the QMP wire
      format never uses the stringized counterparts of the C union
      member names).  Since the updated visit_get_next_type() does not
      know which qtypes are expected, the generated visitor is
      modified to generate an error statement if an unexpected type is
      encountered.
      
      Callers now have to know the QTYPE_* mapping when looking at the
      discriminator; but so far, only the testsuite was even using the
      C struct of an alternate types.  I considered the possibility of
      keeping the internal enum FooKind, but initialized differently
      than most generated arrays, as in:
        typedef enum FooKind {
            FOO_KIND_A = QTYPE_QDICT,
            FOO_KIND_B = QTYPE_QINT,
        } FooKind;
      to create nicer aliases for knowing when to use foo->a or foo->b
      when inspecting foo->type; but it turned out to add too much
      complexity, especially without a client.
      
      There is a user-visible side effect to this change, but I
      consider it to be an improvement. Previously,
      the invalid QMP command:
        {"execute":"blockdev-add", "arguments":{"options":
          {"driver":"raw", "id":"a", "file":true}}}
      failed with:
        {"error": {"class": "GenericError",
          "desc": "Invalid parameter type for 'file', expected: QDict"}}
      (visit_get_next_type() succeeded, and the error comes from the
      visit_type_BlockdevOptions() expecting {}; there is no mention of
      the fact that a string would also work).  Now it fails with:
        {"error": {"class": "GenericError",
          "desc": "Invalid parameter type for 'file', expected: BlockdevRef"}}
      (the error when the next type doesn't match any expected types for
      the overall alternate).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1449033659-25497-5-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      0426d53c
    • E
      qapi: Convert QType into QAPI built-in enum type · 7264f5c5
      Eric Blake 提交于
      What's more meta than using qapi to define qapi? :)
      
      Convert QType into a full-fledged[*] builtin qapi enum type, so
      that a subsequent patch can then use it as the discriminator
      type of qapi alternate types.  Fortunately, the judicious use of
      'prefix' in the qapi definition avoids churn to the spelling of
      the enum constants.
      
      To avoid circular definitions, we have to flip the order of
      inclusion between "qobject.h" vs. "qapi-types.h".  Back in commit
      28770e05, we had the latter include the former, so that we could
      use 'QObject *' for our implementation of 'any'.  But that usage
      also works with only a forward declaration, whereas the
      definition of QObject requires QType to be a complete type.
      
      [*] The type has to be builtin, rather than declared in
      qapi/common.json, because we want to use it for alternates even
      when common.json is not included. But since it is the first
      builtin enum type, we have to add special cases to qapi-types
      and qapi-visit to only emit definitions once, even when two
      qapi files are being compiled into the same binary (the way we
      already handled builtin list types like 'intList').  We may
      need to revisit how multiple qapi files share common types,
      but that's a project for another day.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1449033659-25497-4-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      7264f5c5
    • E
      qobject: Rename qtype_code to QType · 1310a3d3
      Eric Blake 提交于
      The name QType matches our CODING_STYLE conventions for type names
      in CamelCase.  It also matches the fact that we are already naming
      all the enum members with a prefix of QTYPE, not QTYPE_CODE.  And
      doing the rename will also make it easier for the next patch to use
      QAPI for providing the enum, which also wants CamelCase type names.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1449033659-25497-3-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      1310a3d3