1. 16 2月, 2015 11 次提交
    • J
      qtest/ahci: Store hba_base in AHCIQState · 6100ddb0
      John Snow 提交于
      Store the HBA memory base address in the new state object, to simplify
      function prototypes and encourage a more functional testing style.
      
      This causes a lot of churn, but this patch is as "simplified" as I could
      get it to be. This patch is therefore fairly mechanical and straightforward:
      Any case where we pass "hba_base" has been consolidated into the AHCIQState
      object and we pass the one unified parameter.
      
      Any case where we reference "ahci" and "hba_state" have been modified to use
      "ahci->dev" for the PCIDevice and "ahci->hba_state" to get at the base memory
      address, accordingly.
      
      Notes:
      
       - A needless return is removed from start_ahci_device.
      
       - For ease of reviewing, this patch can be reproduced (mostly) by:
         # Replace (ahci, hba_base) prototypes with unified parameter
         's/(QPCIDevice \*ahci, void \*\?\*hba_base/(AHCIQState *ahci/'
      
         # Replace (ahci->dev, hba_base) calls with unified parameter
         's/(ahci->dev, &\?hba_base)/(ahci)/'
      
         # Replace calls to PCI config space using "ahci" with "ahci->dev"
         's/qpci_config_\(read\|write\)\(.\)(ahci,/qpci_config_\1\2(ahci->dev,/'
      
         After these, the remaining differences are easy to review by hand.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421698563-6977-9-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      6100ddb0
    • J
      libqos: add pc specific interface · 90e5add6
      John Snow 提交于
      Create an operations structure so that the libqos interface can be
      architecture agnostic, and create a pc-specific interface to functions
      like qtest_boot.
      
      Move the libqos object in the Makefile from being ahci-test only to
      being linked with all tests that utilize the libqos features.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421698563-6977-8-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      90e5add6
    • J
      libqos: Update QGuestAllocator to be opaque · f6f363c1
      John Snow 提交于
      To avoid the architecture-specific implementations of the generic qtest
      allocator having to know about fields within the allocator, add a
      page_size setter method for users or arch specializations to use.
      The allocator will assume a default page_size for general use, but it
      can always be overridden.
      
      Since this was the last instance of code directly using properties of the
      QGuestAllocator object directly, modify the type to be opaque and move
      the structure inside of malloc.c.
      
      mlist_new, which was previously exported, is made static local to malloc.c,
      as it has no external users.
      
      [Peter Maydell <peter.maydell@linaro.org> reported the following clang
      warning:
        tests/libqos/malloc.c:35:3: warning:
        redefinition of typedef 'QGuestAllocator' is a C11 feature
              [-Wtypedef-redefinition]
        } QGuestAllocator;
      
      I converted typedef struct ... QGuestAllocator; to struct ...;
      --Stefan]
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NMarc Marí <marc.mari.barcelo@gmail.com>
      Message-id: 1421698563-6977-7-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      f6f363c1
    • J
      libqos: add alloc_init_flags · fa02e608
      John Snow 提交于
      Allow a generic interface to alloc_init_flags,
      not just through pc_alloc_init_flags.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421698563-6977-6-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      fa02e608
    • J
      libqos: add qtest_vboot · f1518d11
      John Snow 提交于
      Add a va_list variant of the qtest_boot function.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421698563-6977-5-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      f1518d11
    • J
      libqos: create libqos.c · dd0029c0
      John Snow 提交于
      The intent of this file is to serve as a misc. utilities file to be
      shared amongst tests that are utilizing libqos facilities.
      
      In a later patch, migration test helpers will be added to libqos.c that
      will allow simplified testing of migration cases where libqos is
      "Just Enough OS" for migrations testing.
      
      The addition of the AHCIQState structure will also allow us to eliminate
      global variables inside of qtests to manage allocators and test instances
      in a better, more functional way.
      
      libqos.c:
              - Add qtest_boot
              - Add qtest_shutdown
      
      libqos.h:
              - Create QOSState structure for allocator and QTestState.
      
      ahci-test.c:
              - Move qtest_boot and qtest_shutdown to libqos.c/h
              - Create AHCIQState to interface with new qtest_boot/shutdown prototypes
              - Modify tests slightly to use new types.
      
      For now, the new object file is only linked to ahci-test, because it still
      relies on pc architecture specific code in libqos. The next two patches will
      reorganize the code to be more general.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421698563-6977-4-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      dd0029c0
    • J
      qtest/ahci: Create ahci.h · 90fc5e09
      John Snow 提交于
      Extract defines and other information to ahci.h, to be shared with other
      tests if they so please.
      
      At the very least, reduce clutter in the test file itself.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421698563-6977-3-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      90fc5e09
    • J
      libqos: Split apart pc_alloc_init · af77f2cd
      John Snow 提交于
      Move the list-specific initialization over into
      malloc.c, to keep all of the list implementation
      details within the same file.
      
      The allocation and freeing of these structures are
      now both back within the same layer.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421698563-6977-2-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      af77f2cd
    • M
      iotests: Add test for drive-mirror with NBD target · 21c7f3f7
      Max Reitz 提交于
      When the drive-mirror block job is completed, it will call bdrv_swap()
      on the source and the target BDS; this should obviously not result in a
      segmentation fault.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423256778-3340-4-git-send-email-mreitz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      21c7f3f7
    • M
      iotests: Add "wait" functionality to _cleanup_qemu · ea82aa42
      Max Reitz 提交于
      The qemu process does not always need to be killed, just waiting for it
      can be fine, too. This introduces a way to do so.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423256778-3340-3-git-send-email-mreitz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      ea82aa42
    • M
      nbd: Drop BDS backpointer · f53a829b
      Max Reitz 提交于
      Before this patch, the "opaque" pointer in an NBD BDS points to a
      BDRVNBDState, which contains an NbdClientSession object, which in turn
      contains a pointer to the BDS. This pointer may become invalid due to
      bdrv_swap(), so drop it, and instead pass the BDS directly to the
      nbd-client.c functions which then retrieve the NbdClientSession object
      from there.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423256778-3340-2-git-send-email-mreitz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      f53a829b
  2. 13 2月, 2015 22 次提交
  3. 11 2月, 2015 7 次提交
    • P
      Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20150210.0' into staging · 449008f8
      Peter Maydell 提交于
      RCU fixes and cleanup (Paolo Bonzini)
      Switch to v2 IOMMU interface (Alex Williamson)
      DEBUG build fix (Alexey Kardashevskiy)
      
      # gpg: Signature made Tue 10 Feb 2015 17:37:06 GMT using RSA key ID 3BB08B22
      # gpg: Good signature from "Alex Williamson <alex.williamson@redhat.com>"
      # gpg:                 aka "Alex Williamson <alex@shazbot.org>"
      # gpg:                 aka "Alex Williamson <alwillia@redhat.com>"
      # gpg:                 aka "Alex Williamson <alex.l.williamson@gmail.com>"
      
      * remotes/awilliam/tags/vfio-update-20150210.0:
        vfio: Fix debug message compile error
        vfio: Use vfio type1 v2 IOMMU interface
        vfio: unmap and free BAR data in instance_finalize
        vfio: free dynamically-allocated data in instance_finalize
        vfio: cleanup vfio_get_device error path, remove vfio_populate_device callback
        memory: unregister AddressSpace MemoryListener within BQL
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      449008f8
    • A
      vfio: Fix debug message compile error · bc5baffa
      Alexey Kardashevskiy 提交于
      This fixes a compiler error which occurs if DEBUG_VFIO is defined.
      Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      bc5baffa
    • A
      vfio: Use vfio type1 v2 IOMMU interface · 2e6e697e
      Alex Williamson 提交于
      The difference between v1 and v2 is fairly subtle, simply more
      deterministic behavior for unmaps.  The v1 interface allows the user
      to attempt to unmap sub-regions of previous mappings, returning
      success with zero size if unable to comply.  This was a reflection of
      the underlying IOMMU API.  The v2 interface requires that the user
      may only unmap fully contained mappings, ie. an unmap cannot intersect
      or bisect a previous mapping, but may cover multiple mappings.  QEMU
      never made use of the sub-region v1 support anyway, so we can support
      either v1 or v2.  We'll favor v2 since it's newer.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      2e6e697e
    • P
      vfio: unmap and free BAR data in instance_finalize · ba5e6bfa
      Paolo Bonzini 提交于
      In the case of VFIO, the unrealize callback is too early to munmap the
      BARs.  The munmap must be delayed until memory accesses are complete.
      To do this, split vfio_unmap_bars in two.  The removal step, now called
      vfio_unregister_bars, remains in vfio_exitfn.  The reclamation step
      is vfio_unmap_bars and is moved to the instance_finalize callback.
      
      Similarly, quirk MemoryRegions have to be removed during
      vfio_unregister_bars, but freeing the data structure must be delayed
      to vfio_unmap_bars.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      ba5e6bfa
    • P
      vfio: free dynamically-allocated data in instance_finalize · 77a10d04
      Paolo Bonzini 提交于
      In order to enable out-of-BQL address space lookup, destruction of
      devices needs to be split in two phases.
      
      Unrealize is the first phase; once it complete no new accesses will
      be started, but there may still be pending memory accesses can still
      be completed.
      
      The second part is freeing the device, which only happens once all memory
      accesses are complete.  At this point the reference count has dropped to
      zero, an RCU grace period must have completed (because the RCU-protected
      FlatViews hold a reference to the device via memory_region_ref).  This is
      when instance_finalize is called.
      
      Freeing data belongs in an instance_finalize callback, because the
      dynamically allocated memory can still be used after unrealize by the
      pending memory accesses.
      
      This starts the process by creating an instance_finalize callback and
      freeing most of the dynamically-allocated data in instance_finalize.
      Because instance_finalize is also called on error paths or also when
      the device is actually not realized, the common code needs some changes
      to be ready for this.  The error path in vfio_initfn can be simplified too.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      77a10d04
    • P
      vfio: cleanup vfio_get_device error path, remove vfio_populate_device callback · 217e9fdc
      Paolo Bonzini 提交于
      Now that vfio_put_base_device is called unconditionally at instance_finalize
      time, it can be called twice if vfio_populate_device fails.  This works
      but it is slightly harder to follow.
      
      Change vfio_get_device to not touch the vbasedev struct until it will
      definitely succeed, moving the vfio_populate_device call back to vfio-pci.
      This way, vfio_put_base_device will only be called once.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      217e9fdc
    • P
      memory: unregister AddressSpace MemoryListener within BQL · 6e48e8f9
      Paolo Bonzini 提交于
      address_space_destroy_dispatch is called from an RCU callback and hence
      outside the iothread mutex (BQL).  However, after address_space_destroy
      no new accesses can hit the destroyed AddressSpace so it is not necessary
      to observe changes to the memory map.  Move the memory_listener_unregister
      call earlier, to make it thread-safe again.
      Reported-by: NAlex Williamson <alex.williamson@redhat.com>
      Fixes: 374f2981Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      6e48e8f9