1. 16 2月, 2015 40 次提交
    • F
      qemu-iotests: Add VM method qtest() to iotests.py · ed338bb0
      Fam Zheng 提交于
      This will allow test cases to run command in qtest protocol. It's
      write-only for now.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 1422586186-9925-4-git-send-email-famz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      ed338bb0
    • F
      qtest: Add scripts/qtest.py · a628daa4
      Fam Zheng 提交于
      This adds scripts/qtest.py as a python library for qtest protocol.
      
      This is a skeleton with a basic "cmd" method to execute a command,
      reading and parsing of qtest output could be added later on demand.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 1422586186-9925-3-git-send-email-famz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      a628daa4
    • F
      qemu-io: Account IO by aio_read and aio_write · a91f9584
      Fam Zheng 提交于
      This will enable accounting of aio requests issued from qemu-io aio
      read/write commands.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 1422586186-9925-2-git-send-email-famz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      a91f9584
    • F
      qtest: Fix deadloop by running main loop AIO context's timers · efef88b3
      Fam Zheng 提交于
      qemu_clock_run_timers() only takes care of main_loop_tlg, we shouldn't
      forget aio timer list groups.
      
      Currently, the qemu_clock_deadline_ns_all (a few lines above) counts all
      the timergroups of this clock type, including aio tlg, but we don't fire
      them, so they are never cleared, which makes a dead loop.
      
      For example, this function hangs when trying to drive throttled block
      request queue with qtest clock_step.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Acked-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421661103-29153-1-git-send-email-famz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      efef88b3
    • J
      block: vmdk - fixed sizeof() error · a7be17be
      Jeff Cody 提交于
      The size compared should be PATH_MAX, rather than sizeof(char *).
      Reported-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NJeff Cody <jcody@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 46d873261433f4527e88885582f96942d61758d6.1423592487.git.jcody@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      a7be17be
    • K
      savevm: Improve error message for blocked migration · 5d80448c
      Kevin Wolf 提交于
      If an internal snapshot can't be saved because migration is blocked
      (most commonly probably because of AHCI), we had a really bad error
      message:
      
      $ echo -e "savevm foo\nquit" | qemu -M q35 /tmp/test.qcow2 -monitor stdio
      QEMU 2.2.50 monitor - type 'help' for more information
      (qemu) savevm foo
      Error -22 while writing VM
      (qemu) quit
      
      This patch converts qemu_savevm_state() to the Error infrastructure so
      that a useful error pointing to the problematic device is produced now:
      
      $ echo -e "savevm foo\nquit" | qemu -M q35 /tmp/test.qcow2 -monitor stdio
      QEMU 2.2.50 monitor - type 'help' for more information
      (qemu) savevm foo
      State blocked by non-migratable device '0000:00:1f.2/ich9_ahci'
      (qemu) quit
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-id: 1423574702-23072-1-git-send-email-kwolf@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      5d80448c
    • B
      nbd: fix the co_queue multi-adding bug · 141cabe6
      Bin Wu 提交于
      When we tested the VM migartion between different hosts with NBD
      devices, we found if we sent a cancel command after the drive_mirror
      was just started, a coroutine re-enter error would occur. The stack
      was as follow:
      
      (gdb) bt
      00)  0x00007fdfc744d885 in raise () from /lib64/libc.so.6
      01)  0x00007fdfc744ee61 in abort () from /lib64/libc.so.6
      02)  0x00007fdfca467cc5 in qemu_coroutine_enter (co=0x7fdfcaedb400, opaque=0x0)
      at qemu-coroutine.c:118
      03)  0x00007fdfca467f6c in qemu_co_queue_run_restart (co=0x7fdfcaedb400) at
      qemu-coroutine-lock.c:59
      04)  0x00007fdfca467be5 in coroutine_swap (from=0x7fdfcaf3c4e8,
      to=0x7fdfcaedb400) at qemu-coroutine.c:96
      05)  0x00007fdfca467cea in qemu_coroutine_enter (co=0x7fdfcaedb400, opaque=0x0)
      at qemu-coroutine.c:123
      06)  0x00007fdfca467f6c in qemu_co_queue_run_restart (co=0x7fdfcaedbdc0) at
      qemu-coroutine-lock.c:59
      07)  0x00007fdfca467be5 in coroutine_swap (from=0x7fdfcaf3c4e8,
      to=0x7fdfcaedbdc0) at qemu-coroutine.c:96
      08)  0x00007fdfca467cea in qemu_coroutine_enter (co=0x7fdfcaedbdc0, opaque=0x0)
      at qemu-coroutine.c:123
      09)  0x00007fdfca4a1fa4 in nbd_recv_coroutines_enter_all (s=0x7fdfcaef7dd0) at
      block/nbd-client.c:41
      10) 0x00007fdfca4a1ff9 in nbd_teardown_connection (client=0x7fdfcaef7dd0) at
      block/nbd-client.c:50
      11) 0x00007fdfca4a20f0 in nbd_reply_ready (opaque=0x7fdfcaef7dd0) at
      block/nbd-client.c:92
      12) 0x00007fdfca45ed80 in aio_dispatch (ctx=0x7fdfcae15e90) at aio-posix.c:144
      13) 0x00007fdfca45ef1b in aio_poll (ctx=0x7fdfcae15e90, blocking=false) at
      aio-posix.c:222
      14) 0x00007fdfca448c34 in aio_ctx_dispatch (source=0x7fdfcae15e90, callback=0x0,
      user_data=0x0) at async.c:212
      15) 0x00007fdfc8f2f69a in g_main_context_dispatch () from
      /usr/lib64/libglib-2.0.so.0
      16) 0x00007fdfca45c391 in glib_pollfds_poll () at main-loop.c:190
      17) 0x00007fdfca45c489 in os_host_main_loop_wait (timeout=1483677098) at
      main-loop.c:235
      18) 0x00007fdfca45c57b in main_loop_wait (nonblocking=0) at main-loop.c:484
      19) 0x00007fdfca25f403 in main_loop () at vl.c:2249
      20) 0x00007fdfca266fc2 in main (argc=42, argv=0x7ffff517d638,
      envp=0x7ffff517d790) at vl.c:4814
      
      We find the nbd_recv_coroutines_enter_all function (triggered by a cancel
      command or a network connection breaking down) will enter a coroutine which
      is waiting for the sending lock. If the lock is still held by another coroutine,
      the entering coroutine will be added into the co_queue again. Latter, when the
      lock is released, a coroutine re-enter error will occur.
      
      This bug can be fixed simply by delaying the setting of recv_coroutine as
      suggested by paolo. After applying this patch, we have tested the cancel
      operation in mirror phase looply for more than 5 hous and everything is fine.
      Without this patch, a coroutine re-enter error will occur in 5 minutes.
      Signed-off-by: NBn Wu <wu.wubin@huawei.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423552846-3896-1-git-send-email-wu.wubin@huawei.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      141cabe6
    • J
      qtest/ahci: Adding simple dma read-write test · 81705ee4
      John Snow 提交于
      Adds a test case for AHCI wherein we write a 4K
      block of a changing pattern to sector 0, then
      read back that 4K and compare the transmit and
      receive buffers.
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Message-id: 1423158090-25580-20-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      81705ee4
    • J
      qtest/ahci: Assert sector size in identify test · 122482a3
      John Snow 提交于
      A minor sanity check to assert that the sector size is 512.
      The current block layer code deeply assumes that the IDE
      sector size will be 512 bytes, so we carry forward that assumption
      here.
      
      This is useful for the DMA tests, which currently assume that
      a sector will always be 512 bytes.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423158090-25580-19-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      122482a3
    • J
      libqos/ahci: Add ahci_clean_mem · 259342d3
      John Snow 提交于
      Clean up guest memory being used in ahci_clean_mem, to be
      called during ahci_shutdown. With all guest memory leaks removed,
      add an option to the allocator to throw an assertion if a leak
      occurs.
      
      This test adds some sanity to both the AHCI library and the
      allocator.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423158090-25580-18-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      259342d3
    • J
      libqos/ahci: add ahci_io · ae029620
      John Snow 提交于
      ahci_io is a wrapper around ahci_guest_io that takes a pointer to host
      memory instead, and will create a guest memory buffer and copy the data
      to/from as needed and as appropriate for a read/write command, such that
      after a read, the guest data will be in a host buffer, and for a write,
      the data will be transmitted to guest memory prior to the block operation.
      
      Now that we have all the syntactic sugar functions in place for AHCI,
      we can convert the identify test to be very, very short.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423158090-25580-17-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      ae029620
    • J
      libqos/ahci: Add ahci_guest_io · 11322195
      John Snow 提交于
      ahci_guest_io is a shorthand function that will, in one shot,
      execute a data command on the guest to the specified guest buffer
      location, in the requested amount.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423158090-25580-16-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      11322195
    • J
      libqos/ahci: add ahci command size setters · cbc97569
      John Snow 提交于
      Adds setters for size, prd_size and both via set_sizes.
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Message-id: 1423158090-25580-15-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      cbc97569
    • J
      libqos/ahci: add ahci command verify · ea41deb6
      John Snow 提交于
      Helps to verify that a command completed successfully.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423158090-25580-14-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      ea41deb6
    • J
      libqos/ahci: add ahci command functions · 64a5a272
      John Snow 提交于
      This patch adds the AHCICommand structure, and a set of functions to
      operate on the structure.
      
      ahci_command_create - Initialize and create a new AHCICommand in memory
      ahci_command_free - Destroy this object.
      ahci_command_set_buffer - Set where the guest memory DMA buffer is.
      ahci_command_commit - Write this command to the AHCI HBA.
      ahci_command_issue - Issue the committed command synchronously.
      ahci_command_issue_async - Issue the committed command asynchronously.
      ahci_command_wait - Wait for an asynchronous command to finish.
      ahci_command_slot - Get the number of the command slot we committed to.
      
      Helpers:
      size_to_prdtl       - Calculate the required minimum PRDTL size from
                            a buffer size.
      ahci_command_find   - Given an ATA command mnemonic, look it up in the
                            properties table to obtain info about the command.
      command_header_init - Initialize the command header with sane values.
      command_table_init  - Initialize the command table with sane values.
      
      [Peter Maydell <peter.maydell@linaro.org> reported the following clang
      warning:
      
        tests/libqos/ahci.c:598:3: warning: redefinition
        of typedef 'AHCICommand' is a C11 feature
            [-Wtypedef-redefinition]
        } AHCICommand;
      
      I have replaced typedef struct ... AHCICommand; with struct ... ;
      --Stefan]
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Message-id: 1423158090-25580-13-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      64a5a272
    • J
      libqos/ahci: Add ide cmd properties · 716b6407
      John Snow 提交于
      Add a structure that defines some properties of various IDE commands.
      These will be used to simplify the interface to the libqos AHCI calls,
      lessening the redundancy of specifying and respecifying properties of
      commands to various helper functions.
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Message-id: 1423158090-25580-12-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      716b6407
    • J
      qtest/ahci: add ahci_write_fis · 52515766
      John Snow 提交于
      Similar to ahci_set_command_header, add a helper that takes an
      in-memory representation of a command FIS and writes it to guest
      memory, handling endianness as-needed.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Message-id: 1423158090-25580-11-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      52515766
    • J
      qtest/ahci: Demagic ahci tests. · 36e36726
      John Snow 提交于
      Add human-readable command names and other miscellaneous #defines
      to help make the code more readable.
      
      Some of these definitions are not yet used in this current series,
      but for convenience and sanity they have been lumped together here,
      as it's more trouble than it is worth in a test suite to hand-pick,
      one-by-one, which preprocessor definitions are useful per-each test.
      
      These definitions include:
      
      ATA Command Mnemonics
      Current expected AHCI sector size
      FIS magic bytes
      REG_H2D_FIS flags
      Command Header flags
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Message-id: 1423158090-25580-10-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      36e36726
    • J
      libqos/ahci: Add cmd response sanity check helpers · d1ef8838
      John Snow 提交于
      This patch adds a few helpers to help sanity-check the response of the
      AHCI device after a command.
      
      ahci_d2h_check_sanity inspects the D2H Register FIS,
      ahci_pio_check_sanity inspects the PIO Setup FIS, and
      ahci_cmd_check_sanity inspects the command header.
      
      To support the PIO sanity check, a new structure is added for the
      PIO Setup FIS type. Existing FIS types (H2D and D2H) have had their
      members renamed slightly to condense reserved members into fewer
      fields; and LBA fields are now represented by arrays of 8 byte chunks
      instead of independent variables.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423158090-25580-9-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      d1ef8838
    • J
      libqos/ahci: Add port_check_nonbusy helper · 89a46723
      John Snow 提交于
      A simple helper that asserts a given port is not busy processing any
      commands via the TFD, Command Issue and SACT registers.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423158090-25580-8-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      89a46723
    • J
      libqos/ahci: Add ahci_port_check_interrupts helper · 5bf99aa1
      John Snow 提交于
      A helper that compares a given port's current interrupts and checks them
      against a supplied list of expected interrupt bits, and throws an error
      if they do not match.
      
      The helper then resets the requested interrupts on this port, and asserts
      that the interrupt register is now empty.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423158090-25580-7-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      5bf99aa1
    • J
      libqos/ahci: Add ahci_port_check_error helper · 85c34e93
      John Snow 提交于
      ahci_port_check_error checks a given port's error registers and asserts
      that everything from the port-level view is still OK.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423158090-25580-6-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      85c34e93
    • J
      libqos/ahci: Add command header helpers · 6cae27a6
      John Snow 提交于
      Adds command header helper functions:
      -ahci_command_header_set
      -ahci_command_header_get,
      -ahci_command_destroy, and
      -ahci_cmd_pick
      
      These helpers help to quickly manage the command header information in
      the AHCI device.
      
      ahci_command_header_set and get will store or retrieve an AHCI command
      header, respectively.
      
      ahci_cmd_pick chooses the first available but least recently used
      command slot to allow us to cycle through the available command slots.
      
      ahci_command_destroy obliterates all information contained within a
      given slot's command header, and frees its associated command table,
      but not its DMA buffer!
      
      Lastly, the command table pointer fields (dba and dbau) are merged into
      a single 64bit value to make managing 64bit tests simpler.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Message-id: 1423158090-25580-5-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      6cae27a6
    • J
      qtest/ahci: rename 'Command' to 'CommandHeader' · c7f9c570
      John Snow 提交于
      The structure name is a bit of a misnomer; the structure currently named
      command is actually the commandheader. A future patch in this series
      will add an actual "Command" structure, so we'll rename it now before the
      rest of the functions in this series try to use it.
      
      In addition, rename the "b1" and "b2" fields
      to be a unified uint16_t named "flags."
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Message-id: 1423158090-25580-4-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      c7f9c570
    • J
      libqos/ahci: Add ahci_port_clear helper · e83fd96b
      John Snow 提交于
      Add a helper that assists in clearing out potentially old error and FIS
      information from an AHCI port's data structures. This ensures we always
      start with a blank slate for interrupt and FIS receipt information.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423158090-25580-3-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      e83fd96b
    • J
      libqos/ahci: Add ahci_port_select helper · e77448a3
      John Snow 提交于
      This helper identifies which port of the
      AHCI HBA has a device we may run tests on.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423158090-25580-2-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      e77448a3
    • C
      dataplane: endianness-aware accesses · b0e5d90e
      Cornelia Huck 提交于
      The vring.c code currently assumes that guest and host endianness match,
      which is not true for a number of cases:
      
      - emulating targets with a different endianness than the host
      - bi-endian targets, where the correct endianness depends on the virtio
        device
      - upcoming support for the virtio-1 standard mandates little-endian
        accesses even for big-endian targets and hosts
      
      Make sure to use accessors that depend on the virtio device.
      
      Note that dataplane now needs to be built per-target.
      
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Fam Zheng <famz@redhat.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Tested-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NCornelia Huck <cornelia.huck@de.ibm.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Message-id: 1422289602-17874-2-git-send-email-cornelia.huck@de.ibm.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      b0e5d90e
    • J
      libqos/ahci: create libqos/ahci.c · 9a75b0a0
      John Snow 提交于
      With global state removed, code responsible for booting up,
      verifying, and initializing the AHCI HBA is extracted and
      inserted into libqos/ahci.c, which would allow for other
      qtests in the future to quickly grab a meaningfully initialized
      reference to an AHCI HBA.
      
      Even without other users, functionalizing and isolating the code
      assists future AHCI tests that exercise Q35 migration.
      
      For now, libqos/ahci.o will be PC-only, but can be expanded into
      something arch-agnostic in the future, if needed.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421698563-6977-16-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      9a75b0a0
    • J
      qtest/ahci: Bookmark FB and CLB pointers · f3dd2da4
      John Snow 提交于
      Instead of re-querying the AHCI device for the FB and CLB buffers, save
      the pointer we gave to the device during initialization and reference
      these values instead.
      
      [Peter Maydell <peter.maydell@linaro.org> reported the following clang
      compiler warnings:
      
        tests/libqos/ahci.c:256:40: warning: format specifies type 'unsigned
            long' but the argument has type 'uint64_t'
            (aka 'unsigned long long') [-Wformat]
              g_test_message("CLB: 0x%08lx", ahci->port[i].clb);
        tests/libqos/ahci.c:264:39: warning: format specifies type 'unsigned
            long' but the argument has type 'uint64_t'
            (aka 'unsigned long long') [-Wformat]
              g_test_message("FB: 0x%08lx", ahci->port[i].fb);
      
      The commit moved from uint32_t to uint64_t, so PRIx64 should be used for
      the format specifier.
      --Stefan]
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421698563-6977-15-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      f3dd2da4
    • J
      qtest/ahci: remove getter/setter macros · 1a8bba4d
      John Snow 提交于
      These macros were a bad idea: They relied upon certain arguments being
      present locally with a specific name.
      
      With the endgoal being to factor out AHCI helper functions outside of
      the test file itself, these have to be replaced by more explicit helper
      setter/getter functions.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421698563-6977-14-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      1a8bba4d
    • J
      libqos/ahci: Functional register helpers · 4882f359
      John Snow 提交于
      Introduce a set of "static inline" register helpers that are intended to
      replace the current set of macros with more functional versions that are
      better suited to inclusion in libqos than porcelain macros.
      
      As a stopgap measure before eliminating the porcelain macros, define them
      to use the new functions defined in the ahci.h header.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421698563-6977-13-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      4882f359
    • J
      qtest/ahci: remove guest_malloc global · c12e8293
      John Snow 提交于
      Make helper routines rely on the earmarked
      guest allocator object with AHCIQState/QOSSTate instead.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421698563-6977-12-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      c12e8293
    • J
      qtest/ahci: remove pcibus global · 7f410456
      John Snow 提交于
      Rely on the PCI Device's bus pointer instead.
      One less global to worry about.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421698563-6977-11-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      7f410456
    • J
      qtest/ahci: finalize AHCIQState consolidation · 8d5eeced
      John Snow 提交于
      Move barsize, ahci_fingerprint and capabilities registers into
      the AHCIQState object, removing global ahci-related state
      from the ahci-test.c file.
      
      More churn, less globals.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1421698563-6977-10-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      8d5eeced
    • 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