From patchwork Mon Apr 26 13:37:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 95069 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3QDfVMD029993 for ; Mon, 26 Apr 2010 13:41:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751371Ab0DZNl2 (ORCPT ); Mon, 26 Apr 2010 09:41:28 -0400 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 Received: from redhat.com (vpn1-5-123.ams2.redhat.com [10.36.5.123]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o3QDfOE1024564; Mon, 26 Apr 2010 09:41:25 -0400 Date: Mon, 26 Apr 2010 16:37:43 +0300 From: "Michael S. Tsirkin" To: amit.shah@redhat.com, quintela@redhat.com, kraxel@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH] qemu-kvm: fix crash on reboot with vhost-net Message-ID: <20100426133743.GA16573@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 26 Apr 2010 13:41:37 +0000 (UTC) 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;