From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6Kyu-0001QE-NY for qemu-devel@nongnu.org; Tue, 08 Dec 2015 11:19:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6Kyt-0003fr-HT for qemu-devel@nongnu.org; Tue, 08 Dec 2015 11:19:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6Kyt-0003fm-CT for qemu-devel@nongnu.org; Tue, 08 Dec 2015 11:19:11 -0500 Date: Tue, 8 Dec 2015 18:19:08 +0200 From: "Michael S. Tsirkin" Message-ID: <20151208181746-mutt-send-email-mst@redhat.com> References: <20151208155457.27775.69441.stgit@bahia.huguette.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151208155457.27775.69441.stgit@bahia.huguette.org> Subject: Re: [Qemu-devel] [PATCH for-2.5] virtio-9p-device: add minimal unrealize handler List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: qemu-devel@nongnu.org, aneesh.kumar@linux.vnet.ibm.com On Tue, Dec 08, 2015 at 04:54:57PM +0100, Greg Kurz wrote: > Since commit 4652f1640e029e1f2433fa77ba6af285 "virtio-9p: add savevm handlers", > if the user hot-unplugs a quiescent 9p device and live migrates, the source > QEMU crashes before migration completetion... This happens because virtio-9p > devices have a realize handler which calls virtio_init() and register_savevm(). > Both calls store pointers to the device internals, that get dereferenced during > migration even if the device got unplugged. > > This patch simply adds an unrealize handler to perform minimal cleanup and > avoid the crash. Hot unplug of non-quiescent 9p devices is still not supported > in QEMU, and not supported by linux guests either. > > Signed-off-by: Greg Kurz Reviewed-by: Michael S. Tsirkin > --- > 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 944b5f5e9fcc..b42d3b30a027 100644 > --- a/hw/9pfs/virtio-9p-device.c > +++ b/hw/9pfs/virtio-9p-device.c > @@ -145,6 +145,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); > + > + virtio_cleanup(vdev); > + unregister_savevm(dev, "virtio-9p", s); > + g_free(s->ctx.fs_root); > + g_free(s->tag); > +} > + > /* virtio-9p device */ > > static Property virtio_9p_properties[] = { > @@ -161,6 +172,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; > }