* [Qemu-devel] Fwd: [PATCH v2 5/6] geometry: Call backend function to detect geometry and blocksize
[not found] <1416327001-22278-6-git-send-email-tumanova@linux.vnet.ibm.com>
@ 2014-11-18 16:16 ` Ekaterina Tumanova
0 siblings, 0 replies; only message in thread
From: Ekaterina Tumanova @ 2014-11-18 16:16 UTC (permalink / raw)
To: qemu-devel
copying to mail list
-------- Forwarded Message --------
Subject: [PATCH v2 5/6] geometry: Call backend function to detect
geometry and blocksize
Date: Tue, 18 Nov 2014 17:10:00 +0100
From: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
To: armbru@redhat.com, pbonzini@redhat.com, stefanha@redhat.com,
kwolf@redhat.com
CC: borntraeger@de.ibm.com, cornelia.huck@de.ibm.com,
dahi@linux.vnet.ibm.com, mihajlov@linux.vnet.ibm.com, Ekaterina Tumanova
<tumanova@linux.vnet.ibm.com>
hd_geometry_guess function autodetects the drive geometry. This patch
adds a block backend call, that probes the backing device geometry.
If the inner driver method is implemented and succeeds (currently only
DASDs),
the blkconf_geometry will pass-through the backing device geometry.
Signed-off-by: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
---
hw/block/block.c | 11 +++++++++++
hw/block/hd-geometry.c | 9 +++++++++
hw/block/virtio-blk.c | 1 +
include/hw/block/block.h | 1 +
4 files changed, 22 insertions(+)
diff --git a/hw/block/block.c b/hw/block/block.c
index a625773..f1d29bc 100644
--- a/hw/block/block.c
+++ b/hw/block/block.c
@@ -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)
diff --git a/hw/block/hd-geometry.c b/hw/block/hd-geometry.c
index 6fcf74d..4972114 100644
--- a/hw/block/hd-geometry.c
+++ b/hw/block/hd-geometry.c
@@ -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;
}
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index b19b102..6f01565 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -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));
diff --git a/include/hw/block/block.h b/include/hw/block/block.h
index 0d0ce9a..856bf75 100644
--- a/include/hw/block/block.h
+++ b/include/hw/block/block.h
@@ -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 */
--
1.8.5.5
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-11-18 16:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1416327001-22278-6-git-send-email-tumanova@linux.vnet.ibm.com>
2014-11-18 16:16 ` [Qemu-devel] Fwd: [PATCH v2 5/6] geometry: Call backend function to detect geometry and blocksize Ekaterina Tumanova
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.