aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2014-08-12 10:12:54 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2014-08-26 13:20:44 +0200
commit5ff5efb46c4526f111e14c2247609f1c56f0f8f3 (patch)
tree9c3a6652abe1500ea0f79818241c6a806ad508d7 /hw
parent2656eb7c599e306b95bad82b1372fc49ba3088f6 (diff)
block: Pass errp in blkconf_geometry
This allows us to pass error information to caller. Reviewed-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/block/block.c18
-rw-r--r--hw/block/virtio-blk.c7
-rw-r--r--hw/ide/qdev.c11
-rw-r--r--hw/scsi/scsi-disk.c11
4 files changed, 28 insertions, 19 deletions
diff --git a/hw/block/block.c b/hw/block/block.c
index 33dd3f33b6..b6a6dc6baa 100644
--- a/hw/block/block.c
+++ b/hw/block/block.c
@@ -22,8 +22,9 @@ void blkconf_serial(BlockConf *conf, char **serial)
}
}
-int blkconf_geometry(BlockConf *conf, int *ptrans,
- unsigned cyls_max, unsigned heads_max, unsigned secs_max)
+void blkconf_geometry(BlockConf *conf, int *ptrans,
+ unsigned cyls_max, unsigned heads_max, unsigned secs_max,
+ Error **errp)
{
DriveInfo *dinfo;
@@ -46,17 +47,16 @@ int blkconf_geometry(BlockConf *conf, int *ptrans,
}
if (conf->cyls || conf->heads || conf->secs) {
if (conf->cyls < 1 || conf->cyls > cyls_max) {
- error_report("cyls must be between 1 and %u", cyls_max);
- return -1;
+ error_setg(errp, "cyls must be between 1 and %u", cyls_max);
+ return;
}
if (conf->heads < 1 || conf->heads > heads_max) {
- error_report("heads must be between 1 and %u", heads_max);
- return -1;
+ error_setg(errp, "heads must be between 1 and %u", heads_max);
+ return;
}
if (conf->secs < 1 || conf->secs > secs_max) {
- error_report("secs must be between 1 and %u", secs_max);
- return -1;
+ error_setg(errp, "secs must be between 1 and %u", secs_max);
+ return;
}
}
- return 0;
}
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 302c39e2be..0b68a1781d 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -728,9 +728,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOBlock *s = VIRTIO_BLK(dev);
VirtIOBlkConf *blk = &(s->blk);
-#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
Error *err = NULL;
-#endif
static int virtio_blk_id;
if (!blk->conf.bs) {
@@ -744,8 +742,9 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
blkconf_serial(&blk->conf, &blk->serial);
s->original_wce = bdrv_enable_write_cache(blk->conf.bs);
- if (blkconf_geometry(&blk->conf, NULL, 65535, 255, 255) < 0) {
- error_setg(errp, "Error setting geometry");
+ blkconf_geometry(&blk->conf, NULL, 65535, 255, 255, &err);
+ if (err) {
+ error_propagate(errp, err);
return;
}
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 6e475e6970..b4a467116e 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -151,6 +151,7 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
{
IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
IDEState *s = bus->ifs + dev->unit;
+ Error *err = NULL;
if (dev->conf.discard_granularity == -1) {
dev->conf.discard_granularity = 512;
@@ -161,9 +162,13 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
}
blkconf_serial(&dev->conf, &dev->serial);
- if (kind != IDE_CD
- && blkconf_geometry(&dev->conf, &dev->chs_trans, 65536, 16, 255) < 0) {
- return -1;
+ if (kind != IDE_CD) {
+ blkconf_geometry(&dev->conf, &dev->chs_trans, 65536, 16, 255, &err);
+ if (err) {
+ error_report("%s", error_get_pretty(err));
+ error_free(err);
+ return -1;
+ }
}
if (ide_init_drive(s, dev->conf.bs, kind,
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index d55521dcf6..b7ebdd766a 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2237,6 +2237,7 @@ static void scsi_disk_unit_attention_reported(SCSIDevice *dev)
static int scsi_initfn(SCSIDevice *dev)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
+ Error *err = NULL;
if (!s->qdev.conf.bs) {
error_report("drive property not set");
@@ -2250,9 +2251,13 @@ static int scsi_initfn(SCSIDevice *dev)
}
blkconf_serial(&s->qdev.conf, &s->serial);
- if (dev->type == TYPE_DISK
- && blkconf_geometry(&dev->conf, NULL, 65535, 255, 255) < 0) {
- return -1;
+ if (dev->type == TYPE_DISK) {
+ blkconf_geometry(&dev->conf, NULL, 65535, 255, 255, &err);
+ if (err) {
+ error_report("%s", error_get_pretty(err));
+ error_free(err);
+ return -1;
+ }
}
if (s->qdev.conf.discard_granularity == -1) {