1. 09 6月, 2018 1 次提交
  2. 09 2月, 2018 1 次提交
  3. 12 10月, 2017 1 次提交
    • D
      ide: support reporting of rotation rate · 3b19f450
      Daniel P. Berrange 提交于
      The Linux kernel will query the ATA IDENTITY DEVICE data, word 217
      to determine the rotations per minute of the disk. If this has
      the value 1, it is taken to be an SSD and so Linux sets the
      'rotational' flag to 0 for the I/O queue and will stop using that
      disk as a source of random entropy. Other operating systems may
      also take into account rotation rate when setting up default
      behaviour.
      
      Mgmt apps should be able to set the rotation rate for virtualized
      block devices, based on characteristics of the host storage in use,
      so that the guest OS gets sensible behaviour out of the box. This
      patch thus adds a 'rotation-rate' parameter for 'ide-hd' device
      types.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <20171004114008.14849-3-berrange@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      3b19f450
  4. 22 9月, 2017 1 次提交
  5. 19 9月, 2017 5 次提交
  6. 16 3月, 2017 1 次提交
  7. 30 9月, 2016 1 次提交
  8. 08 9月, 2016 1 次提交
  9. 12 7月, 2016 1 次提交
  10. 29 6月, 2016 1 次提交
  11. 26 5月, 2016 1 次提交
    • P
      dma-helpers: change BlockBackend to opaque value in DMAIOFunc · 8a8e63eb
      Paolo Bonzini 提交于
      Callers of dma_blk_io have no way to pass extra data to the DMAIOFunc,
      because the original callback and opaque are gone by the time DMAIOFunc
      is called.  On the other hand, the BlockBackend is usually derived
      from those extra data that you could pass to the DMAIOFunc (in the
      next patch, that would be the SCSIRequest).
      
      So change DMAIOFunc's prototype, decoupling it from blk_aio_readv
      and blk_aio_writev's.  The new prototype loses the BlockBackend
      and gains an extra opaque value which, in the case of dma_blk_readv
      and dma_blk_writev, is of course used for the BlockBackend.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      8a8e63eb
  12. 12 5月, 2016 1 次提交
  13. 13 4月, 2016 2 次提交
    • P
      ide: really restart pending and in-flight atapi dma · 502356ee
      Pavel Butsykin 提交于
      Restart of ATAPI DMA used to be unreachable, because the request to do
      so wasn't indicated in bus->error_status due to the lack of spare bits, and
      ide_restart_bh() would return early doing nothing.
      
      This patch makes use of the observation that not all bit combinations were
      possible in ->error_status. In particular, IDE_RETRY_READ only made sense
      together with IDE_RETRY_DMA or IDE_RETRY_PIO. This allows to re-use
      IDE_RETRY_READ alone as an indicator of ATAPI DMA restart request.
      
      To makes things more uniform, ATAPI DMA gets its own value for ->dma_cmd.
      As a means against confusion, macros are added to test the state of
      ->error_status.
      
      The patch fixes the restart of both in-flight and pending ATAPI DMA,
      following the scheme similar to that of IDE DMA.
      
      [Including a fixup patch:
      Message-id: 1460465594-15777-1-git-send-email-pbutsykin@virtuozzo.com
      --js]
      Signed-off-by: NPavel Butsykin <pbutsykin@virtuozzo.com>
      Signed-off-by: NDenis V. Lunev <den@openvz.org>
      Reviewed-by: NRoman Kagan <rkagan@virtuozzo.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Message-id: 1459924806-306-4-git-send-email-den@openvz.org
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      502356ee
    • P
      ide: don't lose pending dma state · 218fd37c
      Pavel Butsykin 提交于
      If the migration occurs after the IDE DMA has been set up but before it
      has been initiated, the state gets lost upon save/restore. Specifically,
      ->dma_cb callback gets cleared, so, when the guest eventually starts bus
      mastering, the DMA never completes, causing the guest to time out the
      operation.
      
      OTOH all the infrastructure is already in place to restart the DMA if
      the migration happens while the DMA is in progress.
      
      So reuse that infrastructure, by setting bus->error_status based on
      ->dma_cmd in pre_save if ->dma_cb callback is already set but DMAING is
      clear. This will indicate the need for restart and make sure ->dma_cb
      is restored in ide_restart_bh(); howeover since DMAING is clear the state
      upon restore will be exactly "ready for DMA" as before the save.
      Signed-off-by: NPavel Butsykin <pbutsykin@virtuozzo.com>
      Reviewed-by: NRoman Kagan <rkagan@virtuozzo.com>
      Signed-off-by: NDenis V. Lunev <den@openvz.org>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Message-id: 1459924806-306-2-git-send-email-den@openvz.org
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      218fd37c
  14. 11 2月, 2016 1 次提交
  15. 18 11月, 2015 1 次提交
    • P
      ide: add support for IDEBufferedRequest · 1d8c11d6
      Peter Lieven 提交于
      this patch adds a new aio readv compatible function which copies
      all data through a bounce buffer. These buffered requests can be
      flagged as orphaned which means that their original callback has
      already been invoked and the request has just not been completed
      by the backend storage. The bounce buffer guarantees that guest
      memory corruption is avoided when such a orphaned request is
      completed by the backend at a later stage.
      
      This trick only works for read requests as a write request completed
      at a later stage might corrupt data as there is no way to control
      if and what data has already been written to the storage.
      Signed-off-by: NPeter Lieven <pl@kamp.de>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Message-id: 1447345846-15624-4-git-send-email-pl@kamp.de
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      1d8c11d6
  16. 07 11月, 2015 1 次提交
    • J
      ide: remove hardcoded 2GiB transactional limit · 9fbf0fa8
      John Snow 提交于
      Not that you can request a >2GiB transaction, but that's why checking
      for it makes no sense anymore.
      
      With the newer 'limit' parameter to prepare_buf, we no longer need a
      static limit. The maximum limit is still 2GiB, but the limit parameter
      is set to the current transaction size, which cannot surpass 32MiB
      (512 * 65536). If the PRDT surpasses the transactional size, then,
      we'll just carry out the normative underflow handling pathways instead
      of needing an extra, strange pathway that worries about hitting some
      logistical cap for the largest sglist we can support -- we'll never
      even attempt to build one that big anymore.
      Reported-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Acked-by: NStefan Hajnoczi <stefanha@redhat.com>
      Message-id: 1445902682-20051-1-git-send-email-jsnow@redhat.com
      9fbf0fa8
  17. 18 9月, 2015 2 次提交
    • J
      atapi: abort transfers with 0 byte limits · 9ef2e93f
      John Snow 提交于
      We're supposed to abort on transfers like this, unless we fill
      Word 125 of our IDENTIFY data with a default transfer size, which
      we don't currently do.
      
      This is an ATA error, not a SCSI/ATAPI one.
      See ATA8-ACS3 sections 7.17.6.49 or 7.21.5.
      
      If we don't do this, QEMU will loop forever trying to transfer
      zero bytes, which isn't particularly useful.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Message-id: 1442253685-23349-2-git-send-email-jsnow@redhat.com
      9ef2e93f
    • J
      ide: unify io_buffer_offset increments · aaeda4a3
      John Snow 提交于
      IDEState's io_buffer_offset was originally added to keep track of offsets
      in AHCI rather exclusively, but it was added to IDEState instead of an
      AHCI-specific structure.
      
      AHCI fakes all PIO transfers using DMA and a scatter-gather list. When
      the core or atapi layers invoke HBA-specific mechanisms for transfers,
      they do not always know that it is being backed by DMA or a sglist, so
      this offset is not always updated by the HBA code everywhere.
      
      If we modify it in dma_buf_commit, however, any HBA that needs to use
      this offset to manage operating on only part of a sglist will have
      access to it.
      
      This will fix ATAPI PIO transfers performed through the AHCI HBA,
      which were previously not modifying this value appropriately.
      
      This will fix ATAPI PIO transfers larger than one sector.
      Reported-by: NHannes Reinecke <hare@suse.de>
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Tested-by: NLaszlo Ersek <lersek@redhat.com>
      Message-id: 1440546331-29087-2-git-send-email-jsnow@redhat.com
      CC: qemu-stable@nongnu.org
      aaeda4a3
  18. 04 7月, 2015 2 次提交
    • J
      ahci: add rwerror=stop support for ncq · 7c03a691
      John Snow 提交于
      Handle NCQ failures for cases where we want to halt the VM on IO errors.
      Upon a VM state change, retry the halted NCQ commands.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Message-id: 1435767578-32743-7-git-send-email-jsnow@redhat.com
      7c03a691
    • J
      ide: add limit to .prepare_buf() · a718978e
      John Snow 提交于
      prepare_buf should not always grab as many descriptors
      as it can, sometimes it should self-limit.
      
      For example, an NCQ transfer of 1 sector with a PRDT that
      describes 4GiB of data should not copy 4GiB of data, it
      should just transfer that first 512 bytes.
      
      PIO is not affected, because the dma_buf_rw dma helpers
      already have a byte limit built-in to them, but DMA/NCQ
      will exhaust the entire list regardless of requested size.
      
      AHCI 1.3 specifies in section 6.1.6 Command List Underflow that
      NCQ is not required to detect underflow conditions. Non-NCQ
      pathways signal underflow by writing to the PRDBC field, which
      will already occur by writing the actual transferred byte count
      to the PRDBC, signaling the underflow.
      
      Our NCQ pathways aren't required to detect underflow, but since our DMA
      backend uses the size of the PRDT to determine the size of the transer,
      if our PRDT is bigger than the transaction (the underflow condition) it
      doesn't cost us anything to detect it and truncate the PRDT.
      
      This is a recoverable error and is not signaled to the guest, in either
      NCQ or normal DMA cases.
      
      For BMDMA, the existing pathways should see no guest-visible difference,
      but any bytes described in the overage will no longer be transferred
      before indicating to the guest that there was an underflow.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Message-id: 1435767578-32743-2-git-send-email-jsnow@redhat.com
      a718978e
  19. 10 3月, 2015 8 次提交
  20. 07 2月, 2015 1 次提交
    • D
      atapi migration: Throw recoverable error to avoid recovery · a71754e5
      Dr. David Alan Gilbert 提交于
      (With the previous atapi_dma flag recovery)
      If migration happens between the ATAPI command being written and the
      bmdma being started, the DMA is dropped.  Eventually the guest times
      out and recovers, but that can take many seconds.
      (This is rare, on a pingpong reading the CD continuously I hit
      this about ~1/30-1/50 migrates)
      
      I don't think we've got enough state to be able to recover safely
      at this point, so I throw a 'medium error, no seek complete'
      that I'm assuming guests will try and recover from an apparently
      dirty CD.
      
      OK, it's a hack, the real solution is probably to push a lot of
      ATAPI state into the migration stream, but this is a fix that
      works with no stream changes. Tested only on Linux (both RHEL5
      (pre-libata) and RHEL7).
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      a71754e5
  21. 13 1月, 2015 1 次提交
    • J
      ide: Implement VPD response for ATAPI · 9a502563
      John Snow 提交于
      SCSI devices have multiple kinds of queries they need to respond
      to, as defined in the "cmd inquiry" section in MMC-6 and SPC-3.
      
      Relevent sections:
      MMC-6 revision 2g:
            Non-VPD response data and pointer to SPC-3;
            Section 6.8 "Inquiry Command"
      SPC-3 revision 23:
            Inquiry command and error handling:
            Section 6.4 "INQUIRY command"
            VPD data pages format:
            Section 7.6 "Vital product data parameters"
      
      We implement these Vital Product Data queries for SCSI, but not for
      ATAPI through IDE. The result is that if you are looking for the WWN
      identifier via tools such as sg3_utils, you will be unable to query
      our CD/DVD rom device to obtain it.
      
      This patch adds the minimum number of mandatory responses as defined
      by SPC-3, which include the "supported pages" response (page 0x00)
      and the "Device Identification" response (page 0x83). It also correctly
      responds when it receives a request for an illegal page to improve
      error output from related tools.
      
      The Device ID page contains an arbitrary list of identification
      strings of various formats; the ID strings included in this patch
      were chosen to mimic those provided by the libata driver when
      emulating this SCSI query (model, serial, and wwn when present.)
      
      Example:
      
      # libata emulated response
      [root@localhost ~]# sg_inq --id /dev/sda
      VPD INQUIRY: Device Identification page
        Designation descriptor number 1, descriptor length: 24
          designator_type: vendor specific [0x0],  code_set: ASCII
          associated with the addressed logical unit
            vendor specific: QM00001
        Designation descriptor number 2, descriptor length: 72
          designator_type: T10 vendor identification,  code_set: ASCII
          associated with the addressed logical unit
            vendor id: ATA
            vendor specific: QEMU HARDDISK                           QM00001
      
      # QEMU generated ATAPI response, with WWN
      [root@localhost ~]# sg_inq --id /dev/sr0
      VPD INQUIRY: Device Identification page
        Designation descriptor number 1, descriptor length: 24
          designator_type: vendor specific [0x0],  code_set: ASCII
          associated with the addressed logical unit
            vendor specific: QM00005
        Designation descriptor number 2, descriptor length: 72
          designator_type: T10 vendor identification,  code_set: ASCII
          associated with the addressed logical unit
            vendor id: ATA
            vendor specific: QEMU DVD-ROM                            QM00005
        Designation descriptor number 3, descriptor length: 12
          designator_type: NAA,  code_set: Binary
          associated with the addressed logical unit
            NAA 5, IEEE Company_id: 0xc50
            Vendor Specific Identifier: 0x15ea71bb
            [0x5000c50015ea71bb]
      
      See also: hw/scsi/scsi-disk.c, scsi_disk_emulate_inquiry()
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      9a502563
  22. 14 11月, 2014 1 次提交
    • J
      ide: Correct handling of malformed/short PRDTs · 3251bdcf
      John Snow 提交于
      This impacts both BMDMA and AHCI HBA interfaces for IDE.
      Currently, we confuse the difference between a PRDT having
      "0 bytes" and a PRDT having "0 complete sectors."
      
      When we receive an incomplete sector, inconsistent error checking
      leads to an infinite loop wherein the call succeeds, but it
      didn't give us enough bytes -- leading us to re-call the
      DMA chain over and over again. This leads to, in the BMDMA case,
      leaked memory for short PRDTs, and infinite loops and resource
      usage in the AHCI case.
      
      The .prepare_buf() callback is reworked to return the number of
      bytes that it successfully prepared. 0 is a valid, non-error
      answer that means the table was empty and described no bytes.
      -1 indicates an error.
      
      Our current implementation uses the io_buffer in IDEState to
      ultimately describe the size of a prepared scatter-gather list.
      Even though the AHCI PRDT/SGList can be as large as 256GiB, the
      AHCI command header limits transactions to just 4GiB. ATA8-ACS3,
      however, defines the largest transaction to be an LBA48 command
      that transfers 65,536 sectors. With a 512 byte sector size, this
      is just 32MiB.
      
      Since our current state structures use the int type to describe
      the size of the buffer, and this state is migrated as int32, we
      are limited to describing 2GiB buffer sizes unless we change the
      migration protocol.
      
      For this reason, this patch begins to unify the assertions in the
      IDE pathways that the scatter-gather list provided by either the
      AHCI PRDT or the PCI BMDMA PRDs can only describe, at a maximum,
      2GiB. This should be resilient enough unless we need a sector
      size that exceeds 32KiB.
      
      Further, the likelihood of any guest operating system actually
      attempting to transfer this much data in a single operation is
      very slim.
      
      To this end, the IDEState variables have been updated to more
      explicitly clarify our maximum supported size. Callers to the
      prepare_buf callback have been reworked to understand the new
      return code, and all versions of the prepare_buf callback have
      been adjusted accordingly.
      
      Lastly, the ahci_populate_sglist helper, relied upon by the
      AHCI implementation of .prepare_buf() as well as the PCI
      implementation of the callback have had overflow assertions
      added to help make clear the reasonings behind the various
      type changes.
      
      [Added %d -> %"PRId64" fix John sent because off_pos changed from int to
      int64_t.
      --Stefan]
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1414785819-26209-4-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      3251bdcf
  23. 03 11月, 2014 1 次提交
    • J
      ahci: Update byte count after DMA completion · 659142ec
      John Snow 提交于
      Currently, DMA read/write operations neglect to update
      the byte count after a successful transfer like ATAPI
      DMA read or PIO read/write operations do.
      
      We correct this oversight by adding another callback into
      the IDEDMAOps structure. The commit callback is called
      whenever we are cleaning up a scatter-gather list.
      AHCI can register this callback in order to update post-
      transfer information such as byte count updates.
      
      We use this callback in AHCI to consolidate where we delete
      the SGlist as generated from the PRDT, as well as update the
      byte count after the transfer is complete.
      
      The QEMUSGList structure has an init flag added to it in order
      to make qemu_sglist_destroy a nop if it is called when
      there is no sglist, which simplifies cleanup and error paths.
      
      This patch fixes several AHCI problems, notably Non-NCQ modes
      of operation for Windows 7 as well as Hibernate support for Windows 7.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Tested-by: NMichael S. Tsirkin <mst@redhat.com>
      Message-id: 1412204151-18117-3-git-send-email-jsnow@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      659142ec
  24. 20 10月, 2014 3 次提交