[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH] block: Fix qemu crash when using s
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-block] [Qemu-devel] [PATCH] block: Fix qemu crash when using scsi-block |
Date: |
Thu, 23 Nov 2017 18:17:04 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 |
On 23/11/2017 18:05, Deepa Srinivasan wrote:
> blk_aio_prwv() now takes a void pointer and the coroutine functions
> have been modified to cast it into QEMUIOVector if needed. It does
> not use an union in BlkRwCo since this leads to code - blk_aio_prwv()
> would have to write to the void pointer member, but coroutines would
> sometimes read the QEMUIOVector member. Paolo also suggested not
> using a union.
>
> Note that a similar issue exists in
> blk_ioctl()/blk_ioctl_entry()/blk_prw() where blk_prw() always
> creates the QEMUIOVector even if blk_ioctl()/blk_ioctl_entry() does
> not need a QEMUIOVector. This will need to be fixed separately to
> keep it consistent with the AIO path.
For that it's probably simplest to inline blk_prw into blk_ioctl and
remove all the cruft:
diff --git a/block/block-backend.c b/block/block-backend.c
index 45d9101be3..ceab3166bc 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1404,12 +1404,28 @@ static void blk_ioctl_entry(void *opaque)
{
BlkRwCo *rwco = opaque;
rwco->ret = blk_co_ioctl(rwco->blk, rwco->offset,
- rwco->qiov->iov[0].iov_base);
+ rwco->iobuf);
}
int blk_ioctl(BlockBackend *blk, unsigned long int req, void *buf)
{
- return blk_prw(blk, req, buf, 0, blk_ioctl_entry, 0);
+ BlkRwCo rwco = (BlkRwCo) {
+ .blk = blk,
+ .iobuf = buf,
+ .offset = req,
+ .ret = NOT_DONE,
+ };
+
+ if (qemu_in_coroutine()) {
+ /* Fast-path if already in coroutine context */
+ blk_ioctl_entry(&rwco);
+ } else {
+ Coroutine *co = qemu_coroutine_create(blk_ioctl_entry, &rwco);
+ bdrv_coroutine_enter(blk_bs(blk), co);
+ BDRV_POLL_WHILE(blk_bs(blk), rwco.ret == NOT_DONE);
+ }
+
+ return rwco.ret;
}
static void blk_aio_ioctl_entry(void *opaque)
Thanks,
Paolo
- [Qemu-block] [PATCH] block: Fix qemu crash when using scsi-block, Deepa Srinivasan, 2017/11/22
- Re: [Qemu-block] [PATCH] block: Fix qemu crash when using scsi-block, Paolo Bonzini, 2017/11/22
- Re: [Qemu-block] [PATCH] block: Fix qemu crash when using scsi-block, Kevin Wolf, 2017/11/22
- Re: [Qemu-block] [PATCH] block: Fix qemu crash when using scsi-block, Paolo Bonzini, 2017/11/22
- Re: [Qemu-block] [Qemu-devel] [PATCH] block: Fix qemu crash when using scsi-block, Deepa Srinivasan, 2017/11/22
- Re: [Qemu-block] [Qemu-devel] [PATCH] block: Fix qemu crash when using scsi-block, Paolo Bonzini, 2017/11/23
- [Qemu-block] [PATCH] block: Fix qemu crash when using scsi-block, Deepa Srinivasan, 2017/11/23
- Re: [Qemu-block] [Qemu-devel] [PATCH] block: Fix qemu crash when using scsi-block, Deepa Srinivasan, 2017/11/23
- Re: [Qemu-block] [Qemu-devel] [PATCH] block: Fix qemu crash when using scsi-block,
Paolo Bonzini <=
- Re: [Qemu-block] [Qemu-devel] [PATCH] block: Fix qemu crash when using scsi-block, Kevin Wolf, 2017/11/23
- Re: [Qemu-block] [Qemu-devel] [PATCH] block: Fix qemu crash when using scsi-block, Paolo Bonzini, 2017/11/23
- Re: [Qemu-block] [Qemu-devel] [PATCH] block: Fix qemu crash when using scsi-block, Kevin Wolf, 2017/11/23
- Re: [Qemu-block] [Qemu-devel] [PATCH] block: Fix qemu crash when using scsi-block, Deepa Srinivasan, 2017/11/27
Re: [Qemu-block] [PATCH] block: Fix qemu crash when using scsi-block, Stefan Hajnoczi, 2017/11/22