Revision 136be99e hw/virtio-blk.c
b/hw/virtio-blk.c | ||
---|---|---|
491 | 491 |
stw_raw(&blkcfg.min_io_size, s->conf->min_io_size / blk_size); |
492 | 492 |
stw_raw(&blkcfg.opt_io_size, s->conf->opt_io_size / blk_size); |
493 | 493 |
blkcfg.heads = heads; |
494 |
blkcfg.sectors = secs & ~s->sector_mask; |
|
494 |
/* |
|
495 |
* We must ensure that the block device capacity is a multiple of |
|
496 |
* the logical block size. If that is not the case, lets use |
|
497 |
* sector_mask to adopt the geometry to have a correct picture. |
|
498 |
* For those devices where the capacity is ok for the given geometry |
|
499 |
* we dont touch the sector value of the geometry, since some devices |
|
500 |
* (like s390 dasd) need a specific value. Here the capacity is already |
|
501 |
* cyls*heads*secs*blk_size and the sector value is not block size |
|
502 |
* divided by 512 - instead it is the amount of blk_size blocks |
|
503 |
* per track (cylinder). |
|
504 |
*/ |
|
505 |
if (bdrv_getlength(s->bs) / heads / secs % blk_size) { |
|
506 |
blkcfg.sectors = secs & ~s->sector_mask; |
|
507 |
} else { |
|
508 |
blkcfg.sectors = secs; |
|
509 |
} |
|
495 | 510 |
blkcfg.size_max = 0; |
496 | 511 |
blkcfg.physical_block_exp = get_physical_block_exp(s->conf); |
497 | 512 |
blkcfg.alignment_offset = 0; |
Also available in: Unified diff