Message ID | 1374762197-7261-19-git-send-email-pbonzini@redhat.com |
---|---|
State | New |
Headers | show |
Am 25.07.2013 um 16:23 hat Paolo Bonzini geschrieben: > Protocols return raw data, so you can assume the offsets to pass > through unchanged. > > Reviewed-by: Eric Blake <eblake@redhat.com> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Not really objecting, but is this useful? In formats, BDRV_BLOCK_OFFSET_VALID means that the given offset is valid for bs->file, which is something that protocols simply don't have. You can do it like you do here, but actually this information is redundant. Do you make use of it for anything? Kevin
----- Original Message ----- > From: "Kevin Wolf" <kwolf@redhat.com> > To: "Paolo Bonzini" <pbonzini@redhat.com> > Cc: qemu-devel@nongnu.org, stefanha@redhat.com, eblake@redhat.com, pl@kamp.de > Sent: Wednesday, July 31, 2013 11:12:27 AM > Subject: Re: [PATCH v3 18/19] block: add default get_block_status implementation for protocols > > Am 25.07.2013 um 16:23 hat Paolo Bonzini geschrieben: > > Protocols return raw data, so you can assume the offsets to pass > > through unchanged. > > > > Reviewed-by: Eric Blake <eblake@redhat.com> > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > > Not really objecting, but is this useful? > > In formats, BDRV_BLOCK_OFFSET_VALID means that the given offset is valid > for bs->file, which is something that protocols simply don't have. You > can do it like you do here, but actually this information is redundant. > > Do you make use of it for anything? It is used by format=raw. I could do it in raw.c, but some protocols are opened directly without the "raw" veneer on top. Paolo
diff --git a/block.c b/block.c index fc1da56..8738937 100644 --- a/block.c +++ b/block.c @@ -3005,7 +3005,11 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, if (!bs->drv->bdrv_co_get_block_status) { *pnum = nb_sectors; - return BDRV_BLOCK_DATA; + ret = BDRV_BLOCK_DATA; + if (bs->drv->protocol_name) { + ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE); + } + return ret; } ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum);