From patchwork Fri Jun 7 11:58:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 249668 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 E3C192C007A for ; Fri, 7 Jun 2013 21:59:32 +1000 (EST) Received: from localhost ([::1]:35891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkvKN-0000jk-2h for incoming@patchwork.ozlabs.org; Fri, 07 Jun 2013 07:59:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkvJp-0000hE-0S for qemu-devel@nongnu.org; Fri, 07 Jun 2013 07:59:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkvJl-0004Ca-4P for qemu-devel@nongnu.org; Fri, 07 Jun 2013 07:58:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41943) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkvJk-0004CW-RG for qemu-devel@nongnu.org; Fri, 07 Jun 2013 07:58:53 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r57BwqEp032706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Jun 2013 07:58:52 -0400 Received: from localhost (ovpn-112-30.ams2.redhat.com [10.36.112.30]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r57BwogM017563; Fri, 7 Jun 2013 07:58:51 -0400 From: Stefan Hajnoczi To: Date: Fri, 7 Jun 2013 13:58:20 +0200 Message-Id: <1370606325-10680-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1370606325-10680-1-git-send-email-stefanha@redhat.com> References: <1370606325-10680-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Anthony Liguori , Stefan Hajnoczi Subject: [Qemu-devel] [PULL 01/26] 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 b9b2d10..9937311 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 {