qemu/0315-scsi-avoid-assertion-failure-on-VERIFY-command.patch

64 lines
1.9 KiB
Diff
Raw Normal View History

From eb8dbec969a5d32053e95f4c42c17c470d0558e7 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Mon, 8 Apr 2013 18:50:15 +0200
Subject: [PATCH] scsi: avoid assertion failure on VERIFY command
A verify command is not an actual read (we do not implement
compare mode) and thus does not have an AIOCB attached. Do
not crash in scsi_dma_complete.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit ef8489d45927a6d35b214365e4b39ab311b48f2a)
---
hw/scsi-disk.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index c9c983a..1d9cdd1 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -242,14 +242,15 @@ done:
}
}
-static void scsi_dma_complete(void *opaque, int ret)
+static void scsi_dma_complete_noio(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 (r->req.aiocb != NULL) {
+ r->req.aiocb = NULL;
+ bdrv_acct_done(s->qdev.conf.bs, &r->acct);
+ }
if (r->req.io_canceled) {
goto done;
}
@@ -275,6 +276,14 @@ done:
}
}
+static void scsi_dma_complete(void *opaque, int ret)
+{
+ SCSIDiskReq *r = (SCSIDiskReq *)opaque;
+
+ assert(r->req.aiocb != NULL);
+ scsi_dma_complete_noio(opaque, ret);
+}
+
static void scsi_read_complete(void * opaque, int ret)
{
SCSIDiskReq *r = (SCSIDiskReq *)opaque;
@@ -494,7 +503,7 @@ static void scsi_write_data(SCSIRequest *req)
if (r->req.cmd.buf[0] == VERIFY_10 || r->req.cmd.buf[0] == VERIFY_12 ||
r->req.cmd.buf[0] == VERIFY_16) {
if (r->req.sg) {
- scsi_dma_complete(r, 0);
+ scsi_dma_complete_noio(r, 0);
} else {
scsi_write_complete(r, 0);
}