From patchwork Thu Aug 9 13:38:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 176133 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 849862C00E0 for ; Fri, 10 Aug 2012 00:40:58 +1000 (EST) Received: from localhost ([::1]:33455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzSxw-000321-W8 for incoming@patchwork.ozlabs.org; Thu, 09 Aug 2012 09:39:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzSxa-0002Sk-Mb for qemu-devel@nongnu.org; Thu, 09 Aug 2012 09:39:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzSxU-0003sI-Qh for qemu-devel@nongnu.org; Thu, 09 Aug 2012 09:39:34 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:34613) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzSxU-0003qC-K1 for qemu-devel@nongnu.org; Thu, 09 Aug 2012 09:39:28 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp12so868953pbb.4 for ; Thu, 09 Aug 2012 06:39:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=XRtFQNIyKmTtovTlBtO6sfJQ41SDjorR9ZI0JOTJxcs=; b=IPzY/qnE9JxctHYpclt1mQ0eO3vLLuDGVIoYOqmnCX7FXWqsKpa4xZAyTzMCKBfQQK VdvxQ2nEZcD3YoLMZ5QzsC9IBFEX76lWnoR29cfDHmxH6eDtaTp1p1H66h3HlJVgJA9j JcAy4L1D0IAsjk1w/dJZ7Gw3H2qQCElnIiV6eRDwOyxoWxI1xxlvWECkK/LAoSC6HV/1 J45Q8+0Yo9B7OX8sss2PSVPZAftcWVrZmrbWgi+4VUVGFiZ0Euw1ii0c09j/Mk7gHFXt /3VZVl9VklX1uPmU7JBWskF1e7icdLY+e+LoODYnXLpKVZaAeFclDebJ4cEu80xzPQuB AD4w== Received: by 10.68.218.162 with SMTP id ph2mr4378474pbc.21.1344519568254; Thu, 09 Aug 2012 06:39:28 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id qa2sm788320pbb.21.2012.08.09.06.39.25 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Aug 2012 06:39:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2012 15:38:28 +0200 Message-Id: <1344519511-18147-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1344519511-18147-1-git-send-email-pbonzini@redhat.com> References: <1344519511-18147-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Subject: [Qemu-devel] [PATCH 4/7] virtio-scsi: do not compare 32-bit QEMU tags against 64-bit virtio-scsi tags X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch fixes a problem in handling task management functions in virtio-scsi. The cause of the problem is a mismatch between the size of the tag in QEMU (32-bit) and virtio-scsi (64-bit). Changing the QEMU size is hard because the migration format uses 32 bits to store the tag; so just don't use the QEMU tag (virtio-scsi only uses the tag for task management functions anyway) and look up the full 64-bit tag in the hba_private field. The reproducer is a bit obscure. If you cause an I/O timeout (for example with rerror=stop and doing 'cont' on the monitor continuously without fixing the error), sooner or later the guest will try to abort the command and reissue it. At this point, QEMU will report _two_ errors instead of one when you hit 'c', because the first error has not been canceled correctly. Signed-off-by: Paolo Bonzini --- hw/virtio-scsi.c | 10 ++++++++-- 1 file modificato, 8 inserzioni(+), 2 rimozioni(-) diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index c4a5b22..5f737ac 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -305,11 +305,17 @@ static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) goto incorrect_lun; } QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) { - if (r->tag == req->req.tmf->tag) { + VirtIOSCSIReq *cmd_req = r->hba_private; + if (cmd_req && cmd_req->req.cmd->tag == req->req.tmf->tag) { break; } } - if (r && r->hba_private) { + if (r) { + /* + * Assert that the request has not been completed yet, we + * check for it in the loop above. + */ + assert(r->hba_private); if (req->req.tmf->subtype == VIRTIO_SCSI_T_TMF_QUERY_TASK) { /* "If the specified command is present in the task set, then * return a service response set to FUNCTION SUCCEEDED".