From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Williamson Subject: Re: [PATCH] virtio-pci: mask notifier error handling fixups Date: Tue, 18 Jan 2011 08:29:13 -0700 Message-ID: <1295364553.30628.7.camel@x201> References: <20110118134257.GA30044@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: "Michael S. Tsirkin" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:22831 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750823Ab1ARP3S (ORCPT ); Tue, 18 Jan 2011 10:29:18 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0IFTFfU012730 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Jan 2011 10:29:16 -0500 In-Reply-To: <20110118134257.GA30044@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, 2011-01-18 at 15:42 +0200, Michael S. Tsirkin wrote: > Fix virtio-pci error handling in the mask notifiers: be careful to undo > exactly what we did so far. > > Reported-by: Alex Williamson > Signed-off-by: Michael S. Tsirkin > --- Looks right. Acked-by: Alex Williamson > hw/virtio-pci.c | 12 ++++++++++++ > 1 files changed, 12 insertions(+), 0 deletions(-) > > diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c > index bf3cf4f..dd8887a 100644 > --- a/hw/virtio-pci.c > +++ b/hw/virtio-pci.c > @@ -612,6 +612,9 @@ static int virtio_pci_mask_notifier(PCIDevice *dev, unsigned vector, > return 0; > undo: > while (--n >= 0) { > + if (virtio_queue_vector(vdev, n) != vector) { > + continue; > + } > virtio_pci_mask_vq(dev, vector, virtio_get_queue(vdev, n), !masked); > } > return r; > @@ -681,9 +684,18 @@ static int virtio_pci_set_guest_notifiers(void *opaque, bool assign) > > assign_error: > /* We get here on assignment failure. Recover by undoing for VQs 0 .. n. */ > + if (assign) { > + msix_unset_mask_notifier(&proxy->pci_dev); > + } > + > while (--n >= 0) { > virtio_pci_set_guest_notifier(opaque, n, !assign); > } > + > + if (!assign) { > + msix_set_mask_notifier(&proxy->pci_dev, > + virtio_pci_mask_notifier); > + } > return r; > } >