@@ -25,6 +25,17 @@ void blkconf_serial(BlockConf *conf, char **serial)
}
}
+void blkconf_blocksizes(BlockConf *conf)
+{
+ BlockBackend *blk = conf->blk;
+ struct ProbeBlockSize blocksize = blk_probe_blocksizes(blk);
+
+ if (blocksize.rc == 0) {
+ conf->physical_block_size = blocksize.size.phys;
+ conf->logical_block_size = blocksize.size.log;
+ }
+}
+
void blkconf_geometry(BlockConf *conf, int *ptrans,
unsigned cyls_max, unsigned heads_max, unsigned
secs_max,
Error **errp)
@@ -121,6 +121,14 @@ void hd_geometry_guess(BlockBackend *blk,
int *ptrans)
{
int cylinders, heads, secs, translation;
+ struct ProbeGeometry geometry = blk_probe_geometry(blk);
+
+ if (geometry.rc == 0) {
+ *pcyls = geometry.geo.cylinders;
+ *psecs = geometry.geo.sectors;
+ *pheads = geometry.geo.heads;
+ goto done;
+ }
if (guess_disk_lchs(blk, &cylinders, &heads, &secs) < 0) {
/* no LCHS guess: use a standard physical disk geometry */
@@ -143,6 +151,7 @@ void hd_geometry_guess(BlockBackend *blk,
the logical geometry */
translation = BIOS_ATA_TRANSLATION_NONE;
}
+done:
if (ptrans) {
*ptrans = translation;
}
@@ -745,6 +745,7 @@ static void virtio_blk_device_realize(DeviceState
*dev, Error **errp)
error_propagate(errp, err);
return;
}
+ blkconf_blocksizes(&conf->conf);
virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK,
sizeof(struct virtio_blk_config));
@@ -63,6 +63,7 @@ void blkconf_serial(BlockConf *conf, char **serial);
void blkconf_geometry(BlockConf *conf, int *trans,
unsigned cyls_max, unsigned heads_max, unsigned
secs_max,
Error **errp);
+void blkconf_blocksizes(BlockConf *conf);
/* Hard disk geometry */