aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi/scsi-generic.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-08-28 17:08:13 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-08-28 17:08:13 +0100
commita6aebb38ba4682951ab04fe6d6e6b169bd9e4dca (patch)
tree7431ca40c5bc6882e9122326c7a2d6b140c5ba56 /hw/scsi/scsi-generic.c
parent38a01e55d268aeba68c84eea425252e7f810feaf (diff)
parentd1dd32af6f37e5bb8e6b2024d07fce74f510a668 (diff)
downloadqemu-a6aebb38ba4682951ab04fe6d6e6b169bd9e4dca.zip
qemu-a6aebb38ba4682951ab04fe6d6e6b169bd9e4dca.tar.gz
qemu-a6aebb38ba4682951ab04fe6d6e6b169bd9e4dca.tar.bz2
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
SCSI patches include bug fixes from Fam and Peter, improved error reporting from Fam and a fix for DPRINTF bitrot. Memory patches try again to initialize name from the QOM name. # gpg: Signature made Thu 28 Aug 2014 15:10:31 BST using RSA key ID 9B4D86F2 # gpg: Good signature from "Paolo Bonzini <pbonzini@redhat.com>" # gpg: aka "Paolo Bonzini <bonzini@gnu.org>" * remotes/bonzini/tags/for-upstream: memory: Lazy init name from QOM name as needed xen: hvm: Abstract away memory region name ref xen-hvm: Constify string virtio-scsi: Report error if num_queues is 0 or too large scsi-generic: remove superfluous DPRINTF avoid to break compiling block/iscsi: fix memory corruption on iscsi resize scsi-bus: Convert DeviceClass init to realize block: Pass errp in blkconf_geometry Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/scsi/scsi-generic.c')
-rw-r--r--hw/scsi/scsi-generic.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 0b2ff90..20587b4 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -303,9 +303,6 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *cmd)
SCSIDevice *s = r->req.dev;
int ret;
- DPRINTF("Command: lun=%d tag=0x%x len %zd data=0x%02x", lun, tag,
- r->req.cmd.xfer, cmd[0]);
-
#ifdef DEBUG_SCSI
{
int i;
@@ -386,49 +383,49 @@ static void scsi_generic_reset(DeviceState *dev)
scsi_device_purge_requests(s, SENSE_CODE(RESET));
}
-static void scsi_destroy(SCSIDevice *s)
+static void scsi_unrealize(SCSIDevice *s, Error **errp)
{
scsi_device_purge_requests(s, SENSE_CODE(NO_SENSE));
blockdev_mark_auto_del(s->conf.bs);
}
-static int scsi_generic_initfn(SCSIDevice *s)
+static void scsi_generic_realize(SCSIDevice *s, Error **errp)
{
int rc;
int sg_version;
struct sg_scsi_id scsiid;
if (!s->conf.bs) {
- error_report("drive property not set");
- return -1;
+ error_setg(errp, "drive property not set");
+ return;
}
if (bdrv_get_on_error(s->conf.bs, 0) != BLOCKDEV_ON_ERROR_ENOSPC) {
- error_report("Device doesn't support drive option werror");
- return -1;
+ error_setg(errp, "Device doesn't support drive option werror");
+ return;
}
if (bdrv_get_on_error(s->conf.bs, 1) != BLOCKDEV_ON_ERROR_REPORT) {
- error_report("Device doesn't support drive option rerror");
- return -1;
+ error_setg(errp, "Device doesn't support drive option rerror");
+ return;
}
/* check we are using a driver managing SG_IO (version 3 and after */
rc = bdrv_ioctl(s->conf.bs, SG_GET_VERSION_NUM, &sg_version);
if (rc < 0) {
- error_report("cannot get SG_IO version number: %s. "
- "Is this a SCSI device?",
- strerror(-rc));
- return -1;
+ error_setg(errp, "cannot get SG_IO version number: %s. "
+ "Is this a SCSI device?",
+ strerror(-rc));
+ return;
}
if (sg_version < 30000) {
- error_report("scsi generic interface too old");
- return -1;
+ error_setg(errp, "scsi generic interface too old");
+ return;
}
/* get LUN of the /dev/sg? */
if (bdrv_ioctl(s->conf.bs, SG_GET_SCSI_ID, &scsiid)) {
- error_report("SG_GET_SCSI_ID ioctl failed");
- return -1;
+ error_setg(errp, "SG_GET_SCSI_ID ioctl failed");
+ return;
}
/* define device state */
@@ -460,7 +457,6 @@ static int scsi_generic_initfn(SCSIDevice *s)
}
DPRINTF("block size %d\n", s->blocksize);
- return 0;
}
const SCSIReqOps scsi_generic_req_ops = {
@@ -501,8 +497,8 @@ static void scsi_generic_class_initfn(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass);
- sc->init = scsi_generic_initfn;
- sc->destroy = scsi_destroy;
+ sc->realize = scsi_generic_realize;
+ sc->unrealize = scsi_unrealize;
sc->alloc_req = scsi_new_request;
sc->parse_cdb = scsi_generic_parse_cdb;
dc->fw_name = "disk";