1. 15 5月, 2018 1 次提交
  2. 14 3月, 2018 1 次提交
  3. 08 3月, 2018 1 次提交
    • D
      block: Fix qemu crash when using scsi-block · c060332c
      Deepa Srinivasan 提交于
      Starting qemu with the following arguments causes qemu to segfault:
      ... -device lsi,id=lsi0 -drive file=iscsi:<...>,format=raw,if=none,node-name=
      iscsi1 -device scsi-block,bus=lsi0.0,id=<...>,drive=iscsi1
      
      This patch fixes blk_aio_ioctl() so it does not pass stack addresses to
      blk_aio_ioctl_entry() which may be invoked after blk_aio_ioctl() returns. More
      details about the bug follow.
      
      blk_aio_ioctl() invokes blk_aio_prwv() with blk_aio_ioctl_entry as the
      coroutine parameter. blk_aio_prwv() ultimately calls aio_co_enter().
      
      When blk_aio_ioctl() is executed from within a coroutine context (e.g.
      iscsi_bh_cb()), aio_co_enter() adds the coroutine (blk_aio_ioctl_entry) to
      the current coroutine's wakeup queue. blk_aio_ioctl() then returns.
      
      When blk_aio_ioctl_entry() executes later, it accesses an invalid pointer:
      ....
          BlkRwCo *rwco = &acb->rwco;
      
          rwco->ret = blk_co_ioctl(rwco->blk, rwco->offset,
                                   rwco->qiov->iov[0].iov_base);  <--- qiov is
                                                                       invalid here
      ...
      
      In the case when blk_aio_ioctl() is called from a non-coroutine context,
      blk_aio_ioctl_entry() executes immediately. But if bdrv_co_ioctl() calls
      qemu_coroutine_yield(), blk_aio_ioctl() will return. When the coroutine
      execution is complete, control returns to blk_aio_ioctl_entry() after the call
      to blk_co_ioctl(). There is no invalid reference after this point, but the
      function is still holding on to invalid pointers.
      
      The fix is to change blk_aio_prwv() to accept a void pointer for the IO buffer
      rather than a QEMUIOVector. blk_aio_prwv() passes this through in BlkRwCo and the
      coroutine function casts it to QEMUIOVector or uses the void pointer directly.
      Signed-off-by: NDeepa Srinivasan <deepa.srinivasan@oracle.com>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Reviewed-by: NMark Kanda <mark.kanda@oracle.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      c060332c
  4. 06 3月, 2018 1 次提交
  5. 03 3月, 2018 2 次提交
  6. 09 2月, 2018 2 次提交
  7. 08 2月, 2018 1 次提交
  8. 21 11月, 2017 1 次提交
  9. 18 11月, 2017 1 次提交
    • M
      block: Make bdrv_next() keep strong references · 5e003f17
      Max Reitz 提交于
      On one hand, it is a good idea for bdrv_next() to return a strong
      reference because ideally nearly every pointer should be refcounted.
      This fixes intermittent failure of iotest 194.
      
      On the other, it is absolutely necessary for bdrv_next() itself to keep
      a strong reference to both the BB (in its first phase) and the BDS (at
      least in the second phase) because when called the next time, it will
      dereference those objects to get a link to the next one.  Therefore, it
      needs these objects to stay around until then.  Just storing the pointer
      to the next in the iterator is not really viable because that pointer
      might become invalid as well.
      
      Both arguments taken together means we should probably just invoke
      bdrv_ref() and blk_ref() in bdrv_next().  This means we have to assert
      that bdrv_next() is always called from the main loop, but that was
      probably necessary already before this patch and judging from the
      callers, it also looks to actually be the case.
      
      Keeping these strong references means however that callers need to give
      them up if they decide to abort the iteration early.  They can do so
      through the new bdrv_next_cleanup() function.
      Suggested-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20171110172545.32609-1-mreitz@redhat.com
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      5e003f17
  10. 13 11月, 2017 4 次提交
    • A
      block: Leave valid throttle timers when removing a BDS from a backend · c89bcf3a
      Alberto Garcia 提交于
      If a BlockBackend has I/O limits set then its ThrottleGroupMember
      structure uses the AioContext from its attached BlockDriverState.
      Those two contexts must be kept in sync manually. This is not
      ideal and will be fixed in the future by removing the throttling
      configuration from the BlockBackend and storing it in an implicit
      filter node instead, but for now we have to live with this.
      
      When you remove the BlockDriverState from the backend then the
      throttle timers are destroyed. If a new BlockDriverState is later
      inserted then they are created again using the new AioContext.
      
      There are a couple of problems with this:
      
         a) The code manipulates the timers directly, leaving the
            ThrottleGroupMember.aio_context field in an inconsisent state.
      
         b) If you remove the I/O limits (e.g by destroying the backend)
            when the timers are gone then throttle_group_unregister_tgm()
            will attempt to destroy them again, crashing QEMU.
      
      While b) could be fixed easily by allowing the timers to be freed
      twice, this would result in a situation in which we can no longer
      guarantee that a valid ThrottleState has a valid AioContext and
      timers.
      
      This patch ensures that the timers and AioContext are always valid
      when I/O limits are set, regardless of whether the BlockBackend has a
      BlockDriverState inserted or not.
      
      [Fixed "There'a" typo as suggested by Max Reitz <mreitz@redhat.com>
      --Stefan]
      Reported-by: Nsochin jiang <sochin.jiang@huawei.com>
      Signed-off-by: NAlberto Garcia <berto@igalia.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: e089c66e7c20289b046d782cea4373b765c5bc1d.1510339534.git.berto@igalia.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      c89bcf3a
    • A
      block: Check for inserted BlockDriverState in blk_io_limits_disable() · 48bf7ea8
      Alberto Garcia 提交于
      When you set I/O limits using block_set_io_throttle or the command
      line throttling.* options they are kept in the BlockBackend regardless
      of whether a BlockDriverState is attached to the backend or not.
      
      Therefore when removing the limits using blk_io_limits_disable() we
      need to check if there's a BDS before attempting to drain it, else it
      will crash QEMU. This can be reproduced very easily using HMP:
      
           (qemu) drive_add 0 if=none,throttling.iops-total=5000
           (qemu) drive_del none0
      Reported-by: Nsochin jiang <sochin.jiang@huawei.com>
      Signed-off-by: NAlberto Garcia <berto@igalia.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 0d3a67ce8d948bb33e08672564714dcfb76a3d8c.1510339534.git.berto@igalia.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      48bf7ea8
    • S
      throttle-groups: drain before detaching ThrottleState · dc868fb0
      Stefan Hajnoczi 提交于
      I/O requests hang after stop/cont commands at least since QEMU 2.10.0
      with -drive iops=100:
      
        (guest)$ dd if=/dev/zero of=/dev/vdb oflag=direct count=1000
        (qemu) stop
        (qemu) cont
        ...I/O is stuck...
      
      This happens because blk_set_aio_context() detaches the ThrottleState
      while requests may still be in flight:
      
        if (tgm->throttle_state) {
            throttle_group_detach_aio_context(tgm);
            throttle_group_attach_aio_context(tgm, new_context);
        }
      
      This patch encloses the detach/attach calls in a drained region so no
      I/O request is left hanging.  Also add assertions so we don't make the
      same mistake again in the future.
      Reported-by: NYongxue Hong <yhong@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NAlberto Garcia <berto@igalia.com>
      Message-id: 20171110151934.16883-1-stefanha@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      dc868fb0
    • Z
      block: all I/O should be completed before removing throttle timers. · 632a7735
      Zhengui 提交于
      In blk_remove_bs, all I/O should be completed before removing throttle
      timers. If there has inflight I/O, removing throttle timers here will
      cause the inflight I/O never return.
      This patch add bdrv_drained_begin before throttle_timers_detach_aio_context
      to let all I/O completed before removing throttle timers.
      
      [Moved declaration of bs as suggested by Alberto Garcia
      <berto@igalia.com>.
      --Stefan]
      Signed-off-by: NZhengui <lizhengui@huawei.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NAlberto Garcia <berto@igalia.com>
      Message-id: 1508564040-120700-1-git-send-email-lizhengui@huawei.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      632a7735
  11. 05 9月, 2017 3 次提交
  12. 23 8月, 2017 2 次提交
  13. 15 8月, 2017 1 次提交
  14. 18 7月, 2017 2 次提交
  15. 11 7月, 2017 2 次提交
  16. 26 6月, 2017 1 次提交
  17. 16 6月, 2017 3 次提交
  18. 09 6月, 2017 1 次提交
  19. 11 5月, 2017 2 次提交
  20. 28 4月, 2017 1 次提交
  21. 27 4月, 2017 1 次提交
  22. 11 4月, 2017 2 次提交
    • E
      throttle: Remove block from group on hot-unplug · 1606e4cf
      Eric Blake 提交于
      When a block device that is part of a throttle group is hot-unplugged,
      we forgot to remove it from the throttle group. This leaves stale
      memory around, and causes an easily reproducible crash:
      
      $ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -nographic -qmp stdio \
      -device virtio-scsi-pci,bus=pci.0 -drive \
      id=drive_image2,if=none,format=raw,file=file2,bps=512000,iops=100,group=foo \
      -device scsi-hd,id=image2,drive=drive_image2 -drive \
      id=drive_image3,if=none,format=raw,file=file3,bps=512000,iops=100,group=foo \
      -device scsi-hd,id=image3,drive=drive_image3
      {'execute':'qmp_capabilities'}
      {'execute':'device_del','arguments':{'id':'image3'}}
      {'execute':'system_reset'}
      
      Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1428810Suggested-by: NAlberto Garcia <berto@igalia.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-id: 20170406190847.29347-1-eblake@redhat.com
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      1606e4cf
    • F
      block: Use bdrv_coroutine_enter to start I/O coroutines · e92f0e19
      Fam Zheng 提交于
      BDRV_POLL_WHILE waits for the started I/O by releasing bs's ctx then polling
      the main context, which relies on the yielded coroutine continuing on bs->ctx
      before notifying qemu_aio_context with bdrv_wakeup().
      
      Thus, using qemu_coroutine_enter to start I/O is wrong because if the coroutine
      is entered from main loop, co->ctx will be qemu_aio_context, as a result of the
      "release, poll, acquire" loop of BDRV_POLL_WHILE, race conditions happen when
      both main thread and the iothread access the same BDS:
      
        main loop                                iothread
      -----------------------------------------------------------------------
        blockdev_snapshot
          aio_context_acquire(bs->ctx)
                                                 virtio_scsi_data_plane_handle_cmd
          bdrv_drained_begin(bs->ctx)
          bdrv_flush(bs)
            bdrv_co_flush(bs)                      aio_context_acquire(bs->ctx).enter
              ...
              qemu_coroutine_yield(co)
            BDRV_POLL_WHILE()
              aio_context_release(bs->ctx)
                                                   aio_context_acquire(bs->ctx).return
                                                     ...
                                                       aio_co_wake(co)
              aio_poll(qemu_aio_context)               ...
                co_schedule_bh_cb()                    ...
                  qemu_coroutine_enter(co)             ...
      
                    /* (A) bdrv_co_flush(bs)           /* (B) I/O on bs */
                            continues... */
                                                   aio_context_release(bs->ctx)
              aio_context_acquire(bs->ctx)
      
      Note that in above case, bdrv_drained_begin() doesn't do the "release,
      poll, acquire" in BDRV_POLL_WHILE, because bs->in_flight == 0.
      
      Fix this by using bdrv_coroutine_enter and enter coroutine in the right
      context.
      
      iotests 109 output is updated because the coroutine reenter flow during
      mirror job complete is different (now through co_queue_wakeup, instead
      of the unconditional qemu_coroutine_switch before), making the end job
      len different.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Acked-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      e92f0e19
  23. 07 4月, 2017 1 次提交
    • K
      block: Ignore guest dev permissions during incoming migration · d35ff5e6
      Kevin Wolf 提交于
      Usually guest devices don't like other writers to the same image, so
      they use blk_set_perm() to prevent this from happening. In the migration
      phase before the VM is actually running, though, they don't have a
      problem with writes to the image. On the other hand, storage migration
      needs to be able to write to the image in this phase, so the restrictive
      blk_set_perm() call of qdev devices breaks it.
      
      This patch flags all BlockBackends with a qdev device as
      blk->disable_perm during incoming migration, which means that the
      requested permissions are stored in the BlockBackend, but not actually
      applied to its root node yet.
      
      Once migration has finished and the VM should be resumed, the
      permissions are applied. If they cannot be applied (e.g. because the NBD
      server used for block migration hasn't been shut down), resuming the VM
      fails.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Tested-by: NKashyap Chamarthy <kchamart@redhat.com>
      d35ff5e6
  24. 23 3月, 2017 1 次提交
  25. 07 3月, 2017 1 次提交
  26. 01 3月, 2017 1 次提交