Received: from eggs.gnu.org ([2001:4830:134:3::10]:35035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ws6Ys-0007TU-A3 for qemu-devel@nongnu.org; Wed, 04 Jun 2014 04:28:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ws6Yk-00055r-QY for qemu-devel@nongnu.org; Wed, 04 Jun 2014 04:28:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7132) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ws6Yk-00055Z-ID for qemu-devel@nongnu.org; Wed, 04 Jun 2014 04:28:34 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s548SXC6026331 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 4 Jun 2014 04:28:33 -0400 Date: Wed, 4 Jun 2014 10:28:31 +0200 From: Kevin Wolf Message-ID: <20140604082831.GB3851@noname.str.redhat.com> References: <1401804987-31085-1-git-send-email-pbonzini@redhat.com> <20140603143719.GD3264@noname.str.redhat.com> <538DEF19.80802@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <538DEF19.80802@redhat.com> Subject: Re: [Qemu-devel] [PATCH] block: asynchronously stop the VM on I/O errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Am 03.06.2014 um 17:51 hat Paolo Bonzini geschrieben: > Il 03/06/2014 16:37, Kevin Wolf ha scritto: > > Am 03.06.2014 um 16:16 hat Paolo Bonzini geschrieben: > >> With virtio-blk dataplane, I/O errors might occur while QEMU is > >> not in the main I/O thread. However, it's invalid to call vm_stop > >> when we're neither in a VCPU thread nor in the main I/O thread, > >> even if we were to take the iothread mutex around it. > >> > >> To avoid this problem, simply raise a request to the main I/O thread, > >> similar to what QEMU does when vm_stop is called from a CPU thread. > >> We know that bdrv_error_action is called from an AIO callback, and > >> the moment at which the callback will fire is not well-defined; it > >> depends on the moment at which the disk or OS finishes the operation, > >> which can happen at any time. > >> > >> Note that QEMU is certainly not in a CPU thread and we do not need to > >> call cpu_stop_current() like vm_stop() does. > > > > Do I understand correctly that this is not a fundamental truth of qemu's > > operation, but holds true only because the drivers that do support > > rerror/werror all use bdrv_aio_readv/writev(), which guarantees that a > > BH is used in error cases? Otherwise I think an I/O handler in a vcpu > > thread could directly call into the block layer and fail immediately > > (might happen for example if we added rerror/werror support to ATAPI). > > > > By delaying the actual state change, does this break the invariant that > > bs->iostatus is BLOCK_DEVICE_IO_STATUS_OK while the VM is running? > > These two comments are actually related, in that the invariant was > already not respected if an I/O handler in a VCPU thread could fail > immediately. Oh, right, I somehow expected that vm_stop() waits for the CPU to be stopped before it returns, but that's not what it does. > Breaking this invariant means that you have a very small window where > {'execute':'cont'} would actually not restart the VM. I think this > should be fixed by dropping the request in vm_start, like this: > [...] Sounds like an option. Do we need to send a QEVENT_STOP/QEVENT_RESUME pair? If we don't, the client will still notice a difference to a real stop and resume. > Also, I think that bdrv_emit_qmp_error_event is placed wrong. > It should be called only after setting the iostatus, otherwise > there is a small window where the iostatus is "no error" but > the event has been generated already. Yes, I agree. The documentation for this event actually answers my above question: Note: If action is "stop", a STOP event will eventually follow the BLOCK_IO_ERROR event. Perhaps we should also change the documentation of the "stop" value to clarify that the VM may not actually be stopped yet. It currently reads like this: "stop": error caused VM to be stopped Kevin