From nobody Sat May 4 06:23:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502295093860444.12650188139264; Wed, 9 Aug 2017 09:11:33 -0700 (PDT) Received: from localhost ([::1]:48822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfTa0-0001O4-MP for importer@patchew.org; Wed, 09 Aug 2017 12:11:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfTRH-0002gK-Qn for qemu-devel@nongnu.org; Wed, 09 Aug 2017 12:02:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfTRG-0007K8-TP for qemu-devel@nongnu.org; Wed, 09 Aug 2017 12:02:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42820) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dfTRE-0007J1-Dm; Wed, 09 Aug 2017 12:02:28 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 51139C04E523; Wed, 9 Aug 2017 16:02:27 +0000 (UTC) Received: from localhost (ovpn-116-128.ams2.redhat.com [10.36.116.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id B87F57E5DA; Wed, 9 Aug 2017 16:02:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 51139C04E523 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Wed, 9 Aug 2017 17:02:11 +0100 Message-Id: <20170809160212.29976-2-stefanha@redhat.com> In-Reply-To: <20170809160212.29976-1-stefanha@redhat.com> References: <20170809160212.29976-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 09 Aug 2017 16:02:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/2] IDE: Do not flush empty CDROM drives X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, "Dr . David Alan Gilbert" , P J P , Stefan Hajnoczi , Paolo Bonzini , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The block backend changed in a way that flushing empty CDROM drives now crashes. Amend IDE to avoid doing so until the root problem can be addressed for 2.11. Original patch by John Snow . Reported-by: Kieron Shorrock Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- hw/ide/core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 0b48b64d3a..bea39536b0 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -1063,7 +1063,15 @@ static void ide_flush_cache(IDEState *s) s->status |=3D BUSY_STAT; ide_set_retry(s); block_acct_start(blk_get_stats(s->blk), &s->acct, 0, BLOCK_ACCT_FLUSH); - s->pio_aiocb =3D blk_aio_flush(s->blk, ide_flush_cb, s); + + if (blk_bs(s->blk)) { + s->pio_aiocb =3D blk_aio_flush(s->blk, ide_flush_cb, s); + } else { + /* XXX blk_aio_flush() crashes when blk_bs(blk) is NULL, remove th= is + * temporary workaround when blk_aio_*() functions handle NULL blk= _bs. + */ + ide_flush_cb(s, 0); + } } =20 static void ide_cfata_metadata_inquiry(IDEState *s) --=20 2.13.3 From nobody Sat May 4 06:23:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502295160274226.51861609645334; Wed, 9 Aug 2017 09:12:40 -0700 (PDT) Received: from localhost ([::1]:48832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfTb5-0001xC-1X for importer@patchew.org; Wed, 09 Aug 2017 12:12:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfTRW-0002t5-Uv for qemu-devel@nongnu.org; Wed, 09 Aug 2017 12:02:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfTRS-0007Pu-U2 for qemu-devel@nongnu.org; Wed, 09 Aug 2017 12:02:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34124) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dfTRI-0007Kn-BR; Wed, 09 Aug 2017 12:02:32 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3E67613F1C7; Wed, 9 Aug 2017 16:02:31 +0000 (UTC) Received: from localhost (ovpn-116-128.ams2.redhat.com [10.36.116.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5E1C6EE33; Wed, 9 Aug 2017 16:02:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3E67613F1C7 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Wed, 9 Aug 2017 17:02:12 +0100 Message-Id: <20170809160212.29976-3-stefanha@redhat.com> In-Reply-To: <20170809160212.29976-1-stefanha@redhat.com> References: <20170809160212.29976-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 09 Aug 2017 16:02:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] IDE: test flush on empty CDROM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, "Dr . David Alan Gilbert" , P J P , Stefan Hajnoczi , Paolo Bonzini , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Kevin Wolf Signed-off-by: Kevin Wolf Signed-off-by: John Snow Reviewed-by: Eric Blake Signed-off-by: Stefan Hajnoczi --- tests/ide-test.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/ide-test.c b/tests/ide-test.c index bfd79ddbdc..aa9de065fc 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -689,6 +689,24 @@ static void test_flush_nodev(void) ide_test_quit(); } =20 +static void test_flush_empty_drive(void) +{ + QPCIDevice *dev; + QPCIBar bmdma_bar, ide_bar; + + ide_test_start("-device ide-cd,bus=3Dide.0"); + dev =3D get_pci_device(&bmdma_bar, &ide_bar); + + /* FLUSH CACHE command on device 0 */ + qpci_io_writeb(dev, ide_bar, reg_device, 0); + qpci_io_writeb(dev, ide_bar, reg_command, CMD_FLUSH_CACHE); + + /* Just testing that qemu doesn't crash... */ + + free_pci_device(dev); + ide_test_quit(); +} + static void test_pci_retry_flush(void) { test_retry_flush("pc"); @@ -954,6 +972,7 @@ int main(int argc, char **argv) =20 qtest_add_func("/ide/flush", test_flush); qtest_add_func("/ide/flush/nodev", test_flush_nodev); + qtest_add_func("/ide/flush/empty_drive", test_flush_empty_drive); qtest_add_func("/ide/flush/retry_pci", test_pci_retry_flush); qtest_add_func("/ide/flush/retry_isa", test_isa_retry_flush); =20 --=20 2.13.3