From patchwork Wed Jun 5 08:33:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 248976 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 767A12C008A for ; Wed, 5 Jun 2013 18:33:57 +1000 (EST) Received: from localhost ([::1]:41326 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uk9AJ-0007Ll-IU for incoming@patchwork.ozlabs.org; Wed, 05 Jun 2013 04:33:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uk99t-0007ED-4B for qemu-devel@nongnu.org; Wed, 05 Jun 2013 04:33:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uk99m-0001ST-Rp for qemu-devel@nongnu.org; Wed, 05 Jun 2013 04:33:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54615) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uk99m-0001SB-LX for qemu-devel@nongnu.org; Wed, 05 Jun 2013 04:33:22 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r558XLPh008484 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 5 Jun 2013 04:33:21 -0400 Received: from localhost (dhcp-64-106.muc.redhat.com [10.32.64.106]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r558XJcm027119; Wed, 5 Jun 2013 04:33:20 -0400 From: Stefan Hajnoczi To: Date: Wed, 5 Jun 2013 10:33:14 +0200 Message-Id: <1370421194-27049-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , dron@redhat.com, Markus Armbruster , Stefan Hajnoczi , Paolo Bonzini Subject: [Qemu-devel] [PATCH v2] blockdev: reset werror/rerror on drive_del 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 Paolo Bonzini suggested the following test case: 1. Launch a guest and wait at the GRUB boot menu: qemu-system-x86_64 -enable-kvm -m 1024 \ -drive if=none,cache=none,file=test.img,id=foo,werror=stop,rerror=stop -device virtio-blk-pci,drive=foo,id=virtio0,addr=4 2. Hot unplug the device: (qemu) drive_del foo 3. Select the first boot menu entry Without this patch the guest pauses due to ENOMEDIUM. The guest is stuck in a continuous pause loop since the I/O request is retried and fails immediately again when the guest is resumed. With this patch the error is reported to the guest. Note that this scenario actually happens sometimes during libvirt disk hot unplug, where device_del is followed by drive_del. I/O may still be submitted to the drive after drive_del if the guest does not process the PCI hot unplug notification. Reported-by: Dafna Ron Signed-off-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf --- blockdev.c | 4 ++++ hmp-commands.hx | 2 ++ 2 files changed, 6 insertions(+) diff --git a/blockdev.c b/blockdev.c index d1ec99a..6eb81a3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1180,6 +1180,10 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) */ if (bdrv_get_attached_dev(bs)) { bdrv_make_anon(bs); + + /* Further I/O must not pause the guest */ + bdrv_set_on_error(bs, BLOCKDEV_ON_ERROR_REPORT, + BLOCKDEV_ON_ERROR_REPORT); } else { drive_uninit(drive_get_by_blockdev(bs)); } diff --git a/hmp-commands.hx b/hmp-commands.hx index 9cea415..4f5a3fd 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -185,6 +185,8 @@ Remove host block device. The result is that guest generated IO is no longer submitted against the host device underlying the disk. Once a drive has been deleted, the QEMU Block layer returns -EIO which results in IO errors in the guest for applications that are reading/writing to the device. +These errors are always reported to the guest, regardless of the drive's error +actions (drive options rerror, werror). ETEXI {