From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zj1jy-0002B6-V1 for qemu-devel@nongnu.org; Mon, 05 Oct 2015 05:07:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zj1jt-0006EM-RR for qemu-devel@nongnu.org; Mon, 05 Oct 2015 05:07:26 -0400 Received: from e06smtp06.uk.ibm.com ([195.75.94.102]:42839) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zj1jt-0006EI-H5 for qemu-devel@nongnu.org; Mon, 05 Oct 2015 05:07:21 -0400 Received: from /spool/local by e06smtp06.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Oct 2015 10:07:20 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 74FA717D8059 for ; Mon, 5 Oct 2015 10:07:19 +0100 (BST) Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t9597IgA20709460 for ; Mon, 5 Oct 2015 09:07:18 GMT Received: from d06av07.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t9597Ibq013230 for ; Mon, 5 Oct 2015 03:07:18 -0600 From: Greg Kurz Date: Mon, 05 Oct 2015 11:07:16 +0200 Message-ID: <20151005090716.20420.21354.stgit@bahia.huguette.org> In-Reply-To: <20151005090710.20420.26941.stgit@bahia.huguette.org> References: <20151005090710.20420.26941.stgit@bahia.huguette.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 1/3] virtio-9p-coth: add release function and fix init error path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: aneesh.kumar@linux.vnet.ibm.com Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" This is preliminary work to support hotplug/unplug of virtio-9p-device. Signed-off-by: Greg Kurz --- hw/9pfs/virtio-9p-coth.c | 13 +++++++++---- hw/9pfs/virtio-9p-coth.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/virtio-9p-coth.c b/hw/9pfs/virtio-9p-coth.c index 8185c533c013..a4392586c9a2 100644 --- a/hw/9pfs/virtio-9p-coth.c +++ b/hw/9pfs/virtio-9p-coth.c @@ -66,10 +66,7 @@ int v9fs_init_worker_threads(void) } p->completed = g_async_queue_new(); if (!p->completed) { - /* - * We are going to terminate. - * So don't worry about cleanup - */ + g_thread_pool_free(p->pool, true, true); ret = -1; goto err_out; } @@ -80,3 +77,11 @@ err_out: pthread_sigmask(SIG_SETMASK, &oldset, NULL); return ret; } + +int v9fs_release_worker_threads(void) +{ + V9fsThPool *p = &v9fs_pool; + + g_thread_pool_free(p->pool, TRUE, TRUE); + g_async_queue_unref(p->completed); +} diff --git a/hw/9pfs/virtio-9p-coth.h b/hw/9pfs/virtio-9p-coth.h index 4f51b250d1d4..6502e422cea8 100644 --- a/hw/9pfs/virtio-9p-coth.h +++ b/hw/9pfs/virtio-9p-coth.h @@ -56,6 +56,7 @@ typedef struct V9fsThPool { extern void co_run_in_worker_bh(void *); extern int v9fs_init_worker_threads(void); +extern int v9fs_release_worker_threads(void); extern int v9fs_co_readlink(V9fsPDU *, V9fsPath *, V9fsString *); extern int v9fs_co_readdir_r(V9fsPDU *, V9fsFidState *, struct dirent *, struct dirent **result);