block-backend: allow blk_prw from coroutine context
qcow2_create2 calls this. Do not run a nested event loop, as that breaks when aio_co_wake tries to queue the coroutine on the co_queue_wakeup list of the currently running one. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-id: 20170213135235.12274-4-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
		
							parent
							
								
									0c330a734b
								
							
						
					
					
						commit
						35f106e684
					
				@ -880,7 +880,6 @@ static int blk_prw(BlockBackend *blk, int64_t offset, uint8_t *buf,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    QEMUIOVector qiov;
 | 
					    QEMUIOVector qiov;
 | 
				
			||||||
    struct iovec iov;
 | 
					    struct iovec iov;
 | 
				
			||||||
    Coroutine *co;
 | 
					 | 
				
			||||||
    BlkRwCo rwco;
 | 
					    BlkRwCo rwco;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    iov = (struct iovec) {
 | 
					    iov = (struct iovec) {
 | 
				
			||||||
@ -897,9 +896,14 @@ static int blk_prw(BlockBackend *blk, int64_t offset, uint8_t *buf,
 | 
				
			|||||||
        .ret    = NOT_DONE,
 | 
					        .ret    = NOT_DONE,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    co = qemu_coroutine_create(co_entry, &rwco);
 | 
					    if (qemu_in_coroutine()) {
 | 
				
			||||||
 | 
					        /* Fast-path if already in coroutine context */
 | 
				
			||||||
 | 
					        co_entry(&rwco);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        Coroutine *co = qemu_coroutine_create(co_entry, &rwco);
 | 
				
			||||||
        qemu_coroutine_enter(co);
 | 
					        qemu_coroutine_enter(co);
 | 
				
			||||||
        BDRV_POLL_WHILE(blk_bs(blk), rwco.ret == NOT_DONE);
 | 
					        BDRV_POLL_WHILE(blk_bs(blk), rwco.ret == NOT_DONE);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return rwco.ret;
 | 
					    return rwco.ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user