On 10/24/2011 05:10 PM, Kevin Wolf wrote:
> - bdrv_get_geometry(s->qdev.conf.bs,&nb_sectors);
> - nb_sectors /= s->cluster_size;
> - if (nb_sectors) {
> - nb_sectors--;
> + if (s->qdev.blocksize) {
When would it be 0? And wouldn't we crash with a zero blocksize anyway?
blocksize can be zero when passing through a removable medium and no
medium has ever been inserted in the disk since the guest was started.
In practice it won't crash because the guest will always send READ
CAPACITY first, will see a unit attention condition, and will not
attempt a read.
A more complete solution involves asking raw-posix for the logical block
size (right now logical_block_size acts as both the emulated and host
block size). This would also be useful to make cache=none work with
4k-sector disks without manually specifying logical_block_size.
However, it's not 1.0 material.
Paolo