From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: [PATCH] qemu-kvm: fix crash on reboot with vhost-net Date: Mon, 26 Apr 2010 16:37:43 +0300 Message-ID: <20100426133743.GA16573@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: amit.shah@redhat.com, quintela@redhat.com, kraxel@redhat.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:40126 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750876Ab0DZNl2 (ORCPT ); Mon, 26 Apr 2010 09:41:28 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o3QDfRc8013172 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 26 Apr 2010 09:41:27 -0400 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: When vhost-net is disabled on reboot, we set msix mask notifier to NULL to disable further mask/unmask notifications. Code currently tries to pass this NULL to notifier, leading to a crash. The right thing to do is: - if vector is masked, we don't need to notify backend, just disable future notifications - if vector is unmasked, invoke callback to unassign backend, then disable future notifications Signed-off-by: Michael S. Tsirkin --- Note: this patch is for qemu-kvm, the code in question is not in qemu.git. hw/msix.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/msix.c b/hw/msix.c index 3ec8805..43361b5 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -613,9 +613,18 @@ int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque) if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector]) return 0; - if (dev->msix_mask_notifier) - r = dev->msix_mask_notifier(dev, vector, opaque, - msix_is_masked(dev, vector)); + if (dev->msix_mask_notifier && !msix_is_masked(dev, vector)) { + /* Switching notifiers while vector is unmasked: + * mask the old one, unmask the new one. */ + if (dev->msix_mask_notifier_opaque[vector]) { + r = dev->msix_mask_notifier(dev, vector, + dev->msix_mask_notifier_opaque[vector], + 1); + } + if (r >= 0 && opaque) { + r = dev->msix_mask_notifier(dev, vector, opaque, 0); + } + } if (r >= 0) dev->msix_mask_notifier_opaque[vector] = opaque; return r; -- 1.7.1.rc1.22.g3163