From patchwork Thu Oct 13 11:03:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 119426 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DF077B6F8B for ; Thu, 13 Oct 2011 22:06:13 +1100 (EST) Received: from localhost ([::1]:51484 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REJ73-0000S1-2V for incoming@patchwork.ozlabs.org; Thu, 13 Oct 2011 07:06:09 -0400 Received: from eggs.gnu.org ([140.186.70.92]:55421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REJ5s-0006ks-Rc for qemu-devel@nongnu.org; Thu, 13 Oct 2011 07:04:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1REJ5r-0004HT-HB for qemu-devel@nongnu.org; Thu, 13 Oct 2011 07:04:56 -0400 Received: from mail-ww0-f41.google.com ([74.125.82.41]:62261) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REJ5r-0004GI-Cp for qemu-devel@nongnu.org; Thu, 13 Oct 2011 07:04:55 -0400 Received: by mail-ww0-f41.google.com with SMTP id 10so7744201wwf.4 for ; Thu, 13 Oct 2011 04:04:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=gSrIMlUhDnb1HaBbk31FFZ0yJPNG70wdpQqBmObkGC4=; b=eSrg51IxBietlrRCS5BMDI6IP/a1qw2v8kfqDfwMupS7xMhBQALDzYPoYgjabQVKUe Gj/rBNfzEvvzBVx8dZPQm+WmV5ePWkGsRwlNpDlpoOE+gsX+bXUYhY3z9MK7oNQbAftd ezuFBT/u4nOzQEbmdJy/01vCVOOvsemu+EuzA= Received: by 10.216.134.1 with SMTP id r1mr3778129wei.109.1318503895088; Thu, 13 Oct 2011 04:04:55 -0700 (PDT) Received: from localhost.localdomain (nat-pool-mxp-t.redhat.com. [209.132.186.18]) by mx.google.com with ESMTPS id g20sm5290288wbp.13.2011.10.13.04.04.54 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Oct 2011 04:04:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 13 Oct 2011 13:03:55 +0200 Message-Id: <1318503845-11473-26-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1318503845-11473-1-git-send-email-pbonzini@redhat.com> References: <1318503845-11473-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.41 Subject: [Qemu-devel] [PATCH 25/35] scsi-generic: check ioctl statuses when SG_IO succeeds 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 A succeeding ioctl does not imply that the SCSI command succeeded. Signed-off-by: Paolo Bonzini --- hw/scsi-generic.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c index da104a6..9043eea 100644 --- a/hw/scsi-generic.c +++ b/hw/scsi-generic.c @@ -311,7 +311,7 @@ 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]; @@ -342,7 +342,7 @@ 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];