Received: from eggs.gnu.org ([2001:4830:134:3::10]:37881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsWxj-0006UX-Tx for qemu-devel@nongnu.org; Fri, 07 Oct 2016 11:21:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bsWxe-00080S-11 for qemu-devel@nongnu.org; Fri, 07 Oct 2016 11:21:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsWxd-00080I-Qz for qemu-devel@nongnu.org; Fri, 07 Oct 2016 11:21:21 -0400 Date: Fri, 7 Oct 2016 16:21:17 +0100 From: Stefan Hajnoczi Message-ID: <20161007152117.GD1831@stefanha-x1.localdomain> References: <147575953018.4745.3158241454234330045.stgit@bahia> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Q0rSlbzrZN6k9QnT" Content-Disposition: inline In-Reply-To: <147575953018.4745.3158241454234330045.stgit@bahia> Subject: Re: [Qemu-devel] [PATCH] virtio-9p: add reset handler List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: qemu-devel@nongnu.org, "Aneesh Kumar K.V" , "Michael S. Tsirkin" --Q0rSlbzrZN6k9QnT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 06, 2016 at 03:12:10PM +0200, Greg Kurz wrote: > Virtio devices should implement the VirtIODevice->reset() function to > perform necessary cleanup actions and to bring the device to a quiescent > state. >=20 > In the case of the virtio-9p device, this means: > - emptying the list of active PDUs (i.e. draining all in-flight I/O) > - freeing all fids (i.e. close open file descriptors and free memory) >=20 > That's what this patch does. >=20 > The reset handler first waits for all active PDUs to complete. Since > completion happens in the QEMU global aio context, we just have to > loop around aio_poll() until the active list is empty. >=20 > The freeing part involves some actions to be performed on the backend, > like closing file descriptors or flushing extended attributes to the > underlying filesystem. The virtfs_reset() function already does the > job: it calls free_fid() for all open fids not involved in an ongoing > I/O operation. We are sure this is the case since we have drained > the PDU active list. >=20 > The current code implements all backend accesses with coroutines, but we > want to stay synchronous on the reset path. We can either change the > current code to be able to run when not in coroutine context, or create > a coroutine context and wait for virtfs_reset() to complete. This patch > goes for the latter because it results in simpler code. >=20 > Note that we also need to create a dummy PDU because it is also an API > to pass the FsContext pointer to all backend callbacks. >=20 > Signed-off-by: Greg Kurz > --- > hw/9pfs/9p.c | 31 +++++++++++++++++++++++++++++++ > hw/9pfs/9p.h | 1 + > hw/9pfs/virtio-9p-device.c | 8 ++++++++ > 3 files changed, 40 insertions(+) Reviewed-by: Stefan Hajnoczi --Q0rSlbzrZN6k9QnT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJX971tAAoJEJykq7OBq3PIdosH/RmYrqFonBsriaNoCV5b9QFm lzHPxQFu9PWaontIiQVLwssPtO1QNhmzitKrr2PqmG7QqSXf3+UGxPPM4GpzlppG WIbqqOr6jofrFswfWW3hydRVvEGKLOohZgpOnbXa2YCXipVQUoAKUdVMfXZ1158B DVjnC+pY4RS3zUQy3hbgxv0WORVDIJj3yeImHfU7LXOZp9M2OwS19jJtFvEVzDe7 4uxgAObHy/rPWh3wRlUDBJ2QWdfcxVPhJTbr0lMzbJXdDh+Fe/e9Hez45CgpQvoU FyYxVupglJSrfTzRgAong2uebf8HlPMhYatFrpc+ooFl8nBzw2aoRHXjd+c/DGY= =8+0L -----END PGP SIGNATURE----- --Q0rSlbzrZN6k9QnT--