1. 12 9月, 2011 6 次提交
    • M
      block: Clean up remaining users of "removable" · 2c6942fa
      Markus Armbruster 提交于
      BlockDriverState member removable is a confused mess.  It is true when
      an ide-cd, scsi-cd or floppy qdev is attached, or when the
      BlockDriverState was created with -drive if={floppy,sd} or -drive
      if={ide,scsi,xen,none},media=cdrom ("created removable"), except when
      an ide-hd, scsi-hd, scsi-generic or virtio-blk qdev is attached.
      
      Three users remain:
      
      1. eject_device(), via bdrv_is_removable() uses it to determine
         whether a block device can eject media.
      
      2. bdrv_info() is monitor command "info block".  QMP documentation
         says "true if the device is removable, false otherwise".  From the
         monitor user's point of view, the only sensible interpretation of
         "is removable" is "can eject media with monitor commands eject and
         change".
      
      A block device can eject media unless a device is attached that
      doesn't support it.  Switch the two users over to new
      bdrv_dev_has_removable_media() that returns exactly that.
      
      3. bdrv_getlength() uses to suppress its length cache when media can
         change (see commit 46a4e4e6).  Media change is either monitor
         command change (updates the length cache), monitor command eject
         (doesn't update the length cache, easily fixable), or physical
         media change (invalidates length cache, not so easily fixable).
      
      I'm refraining from improving anything here, because this series is
      long enough already.  Instead, I simply switch it over to
      bdrv_dev_has_removable_media() as well.
      
      This changes the behavior of the length cache and of monitor commands
      eject and change in two cases:
      
      a. drive not created removable, no device attached
      
         The commit makes the drive removable, and defeats the length cache.
      
         Example: -drive if=none
      
      b. drive created removable, but the attached drive is non-removable,
         and doesn't call bdrv_set_removable(..., 0) (most devices don't)
      
         The commit makes the drive non-removable, and enables the length
         cache.
      
         Example: -drive if=xen,media=cdrom -M xenpv
      
         The other non-removable devices that don't call
         bdrv_set_removable() can't currently use a drive created removable,
         either because they aren't qdevified, or because they lack a drive
         property.  Won't stay that way.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      2c6942fa
    • M
      block: Rename bdrv_set_locked() to bdrv_lock_medium() · 025e849a
      Markus Armbruster 提交于
      While there, make the locked parameter bool.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      025e849a
    • M
      block: Drop medium lock tracking, ask device models instead · f107639a
      Markus Armbruster 提交于
      Requires new BlockDevOps member is_medium_locked().  Implement for IDE
      and SCSI CD-ROMs.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      f107639a
    • M
      block: Leave enforcing tray lock to device models · fdec4404
      Markus Armbruster 提交于
      The device model knows best when to accept the guest's eject command.
      No need to detour through the block layer.
      
      bdrv_eject() can't fail anymore.  Make it void.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      fdec4404
    • M
      block: Drop tray status tracking, no longer used · 22cf56c4
      Markus Armbruster 提交于
      Commit 4be9762a is now completely redone.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      22cf56c4
    • M
      block: Revert entanglement of bdrv_is_inserted() with tray status · a1aff5bf
      Markus Armbruster 提交于
      Commit 4be9762a changed bdrv_is_inserted() to fail when the tray is
      open.  Unfortunately, there are two different kinds of users, with
      conflicting needs.
      
      1. Device models using bdrv_eject(), currently ide-cd and scsi-cd.
      They expect bdrv_is_inserted() to reflect the tray status.  Commit
      4be9762a makes them happy.
      
      2. Code that wants to know whether a BlockDriverState has media, such
      as find_image_format(), bdrv_flush_all().  Commit 4be9762a makes them
      unhappy.  In particular, it breaks flush on VM stop for media ejected
      by the guest.
      
      Revert the change to bdrv_is_inserted().  Check the tray status in the
      device models instead.
      
      Note on IDE: Since only ATAPI devices have a tray, and they don't
      accept ATA commands since the recent commit "ide: Reject ATA commands
      specific to drive kinds", checking in atapi.c suffices.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      a1aff5bf
  2. 06 9月, 2011 6 次提交
  3. 03 9月, 2011 1 次提交
    • S
      Use new macro QEMU_PACKED for packed structures · 541dc0d4
      Stefan Weil 提交于
      Most changes were made using these commands:
      
      git grep -la '__attribute__((packed))'|xargs perl -pi -e 's/__attribute__\(\(packed\)\)/QEMU_PACKED/'
      git grep -la '__attribute__ ((packed))'|xargs perl -pi -e 's/__attribute__ \(\(packed\)\)/QEMU_PACKED/'
      git grep -la '__attribute__((__packed__))'|xargs perl -pi -e 's/__attribute__\(\(__packed__\)\)/QEMU_PACKED/'
      git grep -la '__attribute__ ((__packed__))'|xargs perl -pi -e 's/__attribute__ \(\(__packed__\)\)/QEMU_PACKED/'
      git grep -la '__attribute((packed))'|xargs perl -pi -e 's/__attribute\(\(packed\)\)/QEMU_PACKED/'
      
      Whitespace in linux-user/syscall_defs.h was fixed manually
      to avoid warnings from scripts/checkpatch.pl.
      
      Manual changes were also applied to hw/pc.c.
      
      I did not fix indentation with tabs in block/vvfat.c.
      The patch will show 4 errors with scripts/checkpatch.pl.
      Signed-off-by: NStefan Weil <weil@mail.berlios.de>
      Signed-off-by: NBlue Swirl <blauwirbel@gmail.com>
      541dc0d4
  4. 27 8月, 2011 1 次提交
  5. 26 8月, 2011 1 次提交
    • C
      block: explicit I/O accounting · a597e79c
      Christoph Hellwig 提交于
      Decouple the I/O accounting from bdrv_aio_readv/writev/flush and
      make the hardware models call directly into the accounting helpers.
      
      This means:
       - we do not count internal requests from image formats in addition
         to guest originating I/O
       - we do not double count I/O ops if the device model handles it
         chunk wise
       - we only account I/O once it actuall is done
       - can extent I/O accounting to synchronous or coroutine I/O easily
       - implement I/O latency tracking easily (see the next patch)
      
      I've conveted the existing device model callers to the new model,
      device models that are using synchronous I/O and weren't accounted
      before haven't been updated yet.  Also scsi hasn't been converted
      to the end-to-end accounting as I want to defer that after the pending
      scsi layer overhaul.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      a597e79c
  6. 23 8月, 2011 3 次提交
  7. 22 8月, 2011 1 次提交
  8. 21 8月, 2011 1 次提交
  9. 04 8月, 2011 1 次提交
  10. 02 8月, 2011 4 次提交
    • K
      async: Remove AsyncContext · 384acbf4
      Kevin Wolf 提交于
      The purpose of AsyncContexts was to protect qcow and qcow2 against reentrancy
      during an emulated bdrv_read/write (which includes a qemu_aio_wait() call and
      can run AIO callbacks of different requests if it weren't for AsyncContexts).
      
      Now both qcow and qcow2 are protected by CoMutexes and AsyncContexts can be
      removed.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      384acbf4
    • K
      block: Add bdrv_co_readv/writev emulation · f9f05dc5
      Kevin Wolf 提交于
      In order to be able to call bdrv_co_readv/writev for drivers that don't
      implement the functions natively, add an emulation that uses the AIO functions
      to implement them.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      f9f05dc5
    • K
      block: Emulate AIO functions with bdrv_co_readv/writev · 68485420
      Kevin Wolf 提交于
      Use the bdrv_co_readv/writev callbacks to implement bdrv_aio_readv/writev and
      bdrv_read/write if a driver provides the coroutine version instead of the
      synchronous or AIO version.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      68485420
    • K
      block: Add bdrv_co_readv/writev · da1fa91d
      Kevin Wolf 提交于
      Add new block driver callbacks bdrv_co_readv/writev, which work on a
      QEMUIOVector like bdrv_aio_*, but don't need a callback. The function may only
      be called inside a coroutine, so a block driver implementing this interface can
      yield instead of blocking during I/O.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      da1fa91d
  11. 01 8月, 2011 4 次提交
  12. 19 7月, 2011 1 次提交
  13. 08 6月, 2011 2 次提交
  14. 19 5月, 2011 2 次提交
    • M
      block: Remove type hint, it's guest matter, doesn't belong here · 8d278467
      Markus Armbruster 提交于
      No users of bdrv_get_type_hint() left.  bdrv_set_type_hint() can make
      the media removable by side effect.  Make that explicit.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      8d278467
    • M
      block QMP: Deprecate query-block's "type", drop info block's "type=" · d8aeeb31
      Markus Armbruster 提交于
      query-block's specification documents response member "type" with
      values "hd", "cdrom", "floppy", "unknown".
      
      Its value is unreliable: a block device used as floppy has type
      "floppy" if created with if=floppy, but type "hd" if created with
      if=none.
      
      That's because with if=none, the type is at best a declaration of
      intent: the drive can be connected to any guest device.  Its type is
      really the guest device's business.  Reporting it here is wrong.
      
      No known user of QMP uses "type".  It's unlikely that any unknown
      users exist, because its value is useless unless you know how the
      block device was created.  But then you also know the true value.
      
      Fixing the broken value risks breaking (hypothetical!) clients that
      somehow rely on the current behavior.  Not fixing the value risks
      breaking (hypothetical!) clients that rely on the value to be
      accurate.  Can't entirely avoid hypothetical lossage.  Change the
      value to be always "unknown".
      
      This makes "info block" always report "type=unknown".  Pointless.
      Change it to not report the type.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      d8aeeb31
  15. 08 5月, 2011 1 次提交
  16. 06 5月, 2011 1 次提交
  17. 07 4月, 2011 3 次提交
    • S
      block: Do not cache device size for removable media · 46a4e4e6
      Stefan Hajnoczi 提交于
      The block layer caches the device size to avoid doing lseek(fd, 0,
      SEEK_END) every time this value is needed.  For removable media the
      device size becomes stale if a new medium is inserted.  This patch
      simply prevents device size caching for removable media.
      
      A smarter solution is to update the cached device size when a new medium
      is inserted.  Given that there are currently bugs with CD-ROM media
      change I do not want to implement that approach until we've gotten
      things correct first.
      Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      46a4e4e6
    • S
      trace: Trace bdrv_set_locked() · b8c6d095
      Stefan Hajnoczi 提交于
      It can be handy to know when the guest locks/unlocks the CD-ROM tray.
      This trace event makes that possible.
      Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      b8c6d095
    • R
      Do not delete BlockDriverState when deleting the drive · d22b2f41
      Ryan Harper 提交于
      When removing a drive from the host-side via drive_del we currently have
      the following path:
      
      drive_del
      qemu_aio_flush()
      bdrv_close()    // zaps bs->drv, which makes any subsequent I/O get
                      // dropped.  Works as designed
      drive_uninit()
      bdrv_delete()   // frees the bs.  Since the device is still connected to
                      // bs, any subsequent I/O is a use-after-free.
      
      The value of bs->drv becomes unpredictable on free.  As long as it
      remains null, I/O still gets dropped, however it could become non-null
      at any point after the free resulting SEGVs or other QEMU state
      corruption.
      
      To resolve this issue as simply as possible, we can chose to not
      actually delete the BlockDriverState pointer.  Since bdrv_close()
      handles setting the drv pointer to NULL, we just need to remove the
      BlockDriverState from the QLIST that is used to enumerate the block
      devices.  This is currently handled within bdrv_delete, so move this
      into its own function, bdrv_make_anon().
      
      The result is that we can now invoke drive_del, this closes the file
      descriptors and sets BlockDriverState->drv to NULL which prevents futher
      IO to the device, and since we do not free BlockDriverState, we don't
      have to worry about the copy retained in the block devices.
      
      We also don't attempt to remove the qdev property since we are no longer
      deleting the BlockDriverState on drives with associated drives.  This
      also allows for removing Drives with no devices associated either.
      Reported-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NRyan Harper <ryanh@us.ibm.com>
      Acked-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      d22b2f41
  18. 15 3月, 2011 1 次提交