From nobody Thu Apr 25 12:01:44 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 1502387642005999.0048492494163; Thu, 10 Aug 2017 10:54:02 -0700 (PDT) Received: from localhost ([::1]:54532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfrei-0002YR-TF for importer@patchew.org; Thu, 10 Aug 2017 13:54:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfrbC-00088l-8M for qemu-devel@nongnu.org; Thu, 10 Aug 2017 13:50:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfrbA-0004WR-Sl for qemu-devel@nongnu.org; Thu, 10 Aug 2017 13:50:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60024) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dfrbA-0004UZ-MX for qemu-devel@nongnu.org; Thu, 10 Aug 2017 13:50:20 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9794F4B95; Thu, 10 Aug 2017 17:50:19 +0000 (UTC) Received: from localhost (ovpn-116-36.ams2.redhat.com [10.36.116.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B9655D966; Thu, 10 Aug 2017 17:50:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9794F4B95 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Thu, 10 Aug 2017 18:48:22 +0100 Message-Id: <20170810174824.9580-2-stefanha@redhat.com> In-Reply-To: <20170810174824.9580-1-stefanha@redhat.com> References: <20170810174824.9580-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 10 Aug 2017 17:50:19 +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] [PULL for-2.10 1/3] 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: Peter Maydell , Stefan Hajnoczi 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 Message-id: 20170809160212.29976-2-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- 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.4 From nobody Thu Apr 25 12:01:44 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 1502387672725419.6878930443861; Thu, 10 Aug 2017 10:54:32 -0700 (PDT) Received: from localhost ([::1]:54536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfrfD-00031i-Iu for importer@patchew.org; Thu, 10 Aug 2017 13:54:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfrbC-00088g-55 for qemu-devel@nongnu.org; Thu, 10 Aug 2017 13:50:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfrb8-0004Rv-Oc for qemu-devel@nongnu.org; Thu, 10 Aug 2017 13:50:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38340) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dfrb8-0004KI-I6 for qemu-devel@nongnu.org; Thu, 10 Aug 2017 13:50:18 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E81D47BE37; Thu, 10 Aug 2017 17:50:15 +0000 (UTC) Received: from localhost (ovpn-116-36.ams2.redhat.com [10.36.116.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DB7A96560; Thu, 10 Aug 2017 17:50:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E81D47BE37 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Thu, 10 Aug 2017 18:48:23 +0100 Message-Id: <20170810174824.9580-3-stefanha@redhat.com> In-Reply-To: <20170810174824.9580-1-stefanha@redhat.com> References: <20170810174824.9580-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 10 Aug 2017 17:50:16 +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] [PULL for-2.10 2/3] 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 , Peter Maydell , John Snow , Stefan Hajnoczi 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 Message-id: 20170809160212.29976-3-stefanha@redhat.com 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.4 From nobody Thu Apr 25 12:01:44 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 1502387542351289.3702594132741; Thu, 10 Aug 2017 10:52:22 -0700 (PDT) Received: from localhost ([::1]:54524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfrd7-0000vC-5g for importer@patchew.org; Thu, 10 Aug 2017 13:52:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfrbN-0008FZ-4O for qemu-devel@nongnu.org; Thu, 10 Aug 2017 13:50:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfrbJ-0004ht-U6 for qemu-devel@nongnu.org; Thu, 10 Aug 2017 13:50:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dfrbJ-0004gt-No for qemu-devel@nongnu.org; Thu, 10 Aug 2017 13:50:29 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9B5EF2C96FA; Thu, 10 Aug 2017 17:50:28 +0000 (UTC) Received: from localhost (ovpn-116-36.ams2.redhat.com [10.36.116.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52F565C6D7; Thu, 10 Aug 2017 17:50:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9B5EF2C96FA Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Thu, 10 Aug 2017 18:48:24 +0100 Message-Id: <20170810174824.9580-4-stefanha@redhat.com> In-Reply-To: <20170810174824.9580-1-stefanha@redhat.com> References: <20170810174824.9580-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 10 Aug 2017 17:50:28 +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] [PULL for-2.10 3/3] virtio-blk: handle blk_getlength() errors 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: Peter Maydell , Stefan Hajnoczi 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" If blk_getlength() fails in virtio_blk_update_config() consider the disk image length to be 0 bytes. Signed-off-by: Stefan Hajnoczi Reviewed-by: Fam Zheng Message-id: 20170808122251.29815-1-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- hw/block/virtio-blk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index b750bd8b53..a16ac75090 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -730,6 +730,7 @@ static void virtio_blk_update_config(VirtIODevice *vdev= , uint8_t *config) BlockConf *conf =3D &s->conf.conf; struct virtio_blk_config blkcfg; uint64_t capacity; + int64_t length; int blk_size =3D conf->logical_block_size; =20 blk_get_geometry(s->blk, &capacity); @@ -752,7 +753,8 @@ static void virtio_blk_update_config(VirtIODevice *vdev= , uint8_t *config) * divided by 512 - instead it is the amount of blk_size blocks * per track (cylinder). */ - if (blk_getlength(s->blk) / conf->heads / conf->secs % blk_size) { + length =3D blk_getlength(s->blk); + if (length > 0 && length / conf->heads / conf->secs % blk_size) { blkcfg.geometry.sectors =3D conf->secs & ~s->sector_mask; } else { blkcfg.geometry.sectors =3D conf->secs; --=20 2.13.4