Received: from eggs.gnu.org ([2001:4830:134:3::10]:44744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zj1k6-0002Bd-Df for qemu-devel@nongnu.org; Mon, 05 Oct 2015 05:07:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zj1k1-0006Ft-8R for qemu-devel@nongnu.org; Mon, 05 Oct 2015 05:07:34 -0400 Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:45021) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zj1k0-0006Ff-UK for qemu-devel@nongnu.org; Mon, 05 Oct 2015 05:07:29 -0400 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Oct 2015 10:07:27 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 707981B08070 for ; Mon, 5 Oct 2015 10:07:25 +0100 (BST) Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t9597OrA35192856 for ; Mon, 5 Oct 2015 09:07:24 GMT Received: from d06av08.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t9597OCw011548 for ; Mon, 5 Oct 2015 03:07:24 -0600 From: Greg Kurz Date: Mon, 05 Oct 2015 11:07:23 +0200 Message-ID: <20151005090722.20420.71571.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 2/3] virtio-9p: add unrealize handler 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" If the user tries to hot unplug a virtio-9p device, it seems to succeed but in fact: - virtio-9p coroutines thread pool and async queue are leaked - QEMU crashes in virtio_vmstate_change() if the user tries to live migrate This patch brings hot unplug support to virtio-9p-device. It fixes both above issues. Signed-off-by: Greg Kurz --- hw/9pfs/virtio-9p-device.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 93a407c45926..ed133c40493a 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -138,6 +138,17 @@ out: v9fs_path_free(&path); } +static void virtio_9p_device_unrealize(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + V9fsState *s = VIRTIO_9P(dev); + + v9fs_release_worker_threads(); + g_free(s->ctx.fs_root); + g_free(s->tag); + virtio_cleanup(vdev); +} + /* virtio-9p device */ static Property virtio_9p_properties[] = { @@ -154,6 +165,7 @@ static void virtio_9p_class_init(ObjectClass *klass, void *data) dc->props = virtio_9p_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); vdc->realize = virtio_9p_device_realize; + vdc->unrealize = virtio_9p_device_unrealize; vdc->get_features = virtio_9p_get_features; vdc->get_config = virtio_9p_get_config; }