Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-reques…
Browse files Browse the repository at this point in the history
…t' into staging

Pull request

# gpg: Signature made Fri 25 Oct 2019 20:18:23 BST
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <[email protected]>" [full]
# gpg:                 aka "Stefan Hajnoczi <[email protected]>" [full]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha/tags/block-pull-request:
  yield_until_fd_readable: make it work with any AioContect
  virtio-blk: Add blk_drain() to virtio_blk_device_unrealize()

Signed-off-by: Peter Maydell <[email protected]>
  • Loading branch information
pm215 committed Oct 25, 2019
2 parents ee70fc2 + d154ef3 commit 856bd2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions hw/block/virtio-blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,7 @@ static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOBlock *s = VIRTIO_BLK(dev);

blk_drain(s->blk);
virtio_blk_data_plane_destroy(s->dataplane);
s->dataplane = NULL;
qemu_del_vm_change_state_handler(s->change);
Expand Down
7 changes: 5 additions & 2 deletions util/qemu-coroutine-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send)
}

typedef struct {
AioContext *ctx;
Coroutine *co;
int fd;
} FDYieldUntilData;

static void fd_coroutine_enter(void *opaque)
{
FDYieldUntilData *data = opaque;
qemu_set_fd_handler(data->fd, NULL, NULL, NULL);
aio_set_fd_handler(data->ctx, data->fd, false, NULL, NULL, NULL, NULL);
qemu_coroutine_enter(data->co);
}

Expand All @@ -83,8 +84,10 @@ void coroutine_fn yield_until_fd_readable(int fd)
FDYieldUntilData data;

assert(qemu_in_coroutine());
data.ctx = qemu_get_current_aio_context();
data.co = qemu_coroutine_self();
data.fd = fd;
qemu_set_fd_handler(fd, fd_coroutine_enter, NULL, &data);
aio_set_fd_handler(
data.ctx, fd, false, fd_coroutine_enter, NULL, NULL, &data);
qemu_coroutine_yield();
}

0 comments on commit 856bd2c

Please sign in to comment.