aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi-disk.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-08-09 11:33:26 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2012-08-09 15:35:45 +0200
commit46e3f30e3c81e23c07f16b2193dfb6928646c205 (patch)
treed59f960951f068fe69185faf170fb4e9ebc870e2 /hw/scsi-disk.c
parent4dd7c82cdbabe54386ef31939f865469a095c9c3 (diff)
downloadqemu-46e3f30e3c81e23c07f16b2193dfb6928646c205.zip
qemu-46e3f30e3c81e23c07f16b2193dfb6928646c205.tar.gz
qemu-46e3f30e3c81e23c07f16b2193dfb6928646c205.tar.bz2
scsi-disk: more assertions and resets for aiocb
Leaving the aiocb to a non-NULL value leads to an assertion failure when rerror/werror are set to stop or enospc, and the operation is retried. scsi-disk checks that the aiocb member is NULL before filling it. This patch correctly resets the aiocb to NULL values everywhere, and adds the dual assertion that the aiocb was non-NULL before calling bdrv_acct_done. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/scsi-disk.c')
-rw-r--r--hw/scsi-disk.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index a9c7279..9af9d18 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -175,6 +175,8 @@ static void scsi_aio_complete(void *opaque, int ret)
SCSIDiskReq *r = (SCSIDiskReq *)opaque;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
+ assert(r->req.aiocb != NULL);
+ r->req.aiocb = NULL;
bdrv_acct_done(s->qdev.conf.bs, &r->acct);
if (ret < 0) {
@@ -238,10 +240,9 @@ static void scsi_dma_complete(void *opaque, int ret)
SCSIDiskReq *r = (SCSIDiskReq *)opaque;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
- if (r->req.aiocb != NULL) {
- r->req.aiocb = NULL;
- bdrv_acct_done(s->qdev.conf.bs, &r->acct);
- }
+ assert(r->req.aiocb != NULL);
+ r->req.aiocb = NULL;
+ bdrv_acct_done(s->qdev.conf.bs, &r->acct);
if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) {
@@ -270,10 +271,9 @@ static void scsi_read_complete(void * opaque, int ret)
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
int n;
- if (r->req.aiocb != NULL) {
- r->req.aiocb = NULL;
- bdrv_acct_done(s->qdev.conf.bs, &r->acct);
- }
+ assert(r->req.aiocb != NULL);
+ r->req.aiocb = NULL;
+ bdrv_acct_done(s->qdev.conf.bs, &r->acct);
if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) {