diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2011-10-12 14:49:48 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2011-10-28 19:25:51 +0200 |
commit | fe0ed71279eb442b920f0080c763438dbaa09f74 (patch) | |
tree | 7fac229fb66d91cc9b6a721185def8e02e910a2d | |
parent | 6a58a3a6ebb738e4173f93ecc089b45dd57c7574 (diff) |
scsi-generic: check ioctl statuses when SG_IO succeeds
A succeeding ioctl does not imply that the SCSI command succeeded.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r-- | hw/scsi-generic.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c index 5ef4825392..c313749d7e 100644 --- a/hw/scsi-generic.c +++ b/hw/scsi-generic.c @@ -310,9 +310,9 @@ static int get_blocksize(BlockDriverState *bdrv) io_header.timeout = 6000; /* XXX */ ret = bdrv_ioctl(bdrv, SG_IO, &io_header); - if (ret < 0) + if (ret < 0 || io_header.driver_status || io_header.host_status) { return -1; - + } return (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7]; } @@ -341,9 +341,9 @@ static int get_stream_blocksize(BlockDriverState *bdrv) io_header.timeout = 6000; /* XXX */ ret = bdrv_ioctl(bdrv, SG_IO, &io_header); - if (ret < 0) + if (ret < 0 || io_header.driver_status || io_header.host_status) { return -1; - + } return (buf[9] << 16) | (buf[10] << 8) | buf[11]; } |