From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH for-4.5] libxl: Fix if{} nesting in do_pci_remove Date: Mon, 5 Jan 2015 11:39:53 -0500 Message-ID: <20150105163953.GA15497@l.oracle.com> References: <21674.46102.230057.321870@mariner.uk.xensource.com> <1420475676-19080-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1420475676-19080-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: George Dunlap , Sander Eikelenboom , xen-devel@lists.xensource.com, Ian Jackson List-Id: xen-devel@lists.xenproject.org On Mon, Jan 05, 2015 at 04:34:36PM +0000, Ian Jackson wrote: > From: Ian Jackson > > do_pci_remove contained this: > > if (type == LIBXL_DOMAIN_TYPE_HVM) { > [stuff] > } else if (type != LIBXL_DOMAIN_TYPE_PV) > abort(); > { > > This is bizarre, and not correct. The effect is that HVM guests end > up running both the proper code and that intended for PV guests. This > causes (amongst other things) trouble when PCI devices are > hot-unplugged from HVM guests. > > This bug was introduced in abfb006f "tools/libxl: explicitly grant > access to needed I/O-memory ranges". > > This is clear candidate for Xen 4.5, being a bugfix to an important > feature. > > Reported-by: Boris Ostrovsky > Signed-off-by: Ian Jackson > Tested-by: Robert Hu > CC: Konrad Wilk RElease-Acked-by: Konrad Rzeszutek Wilk > CC: Sander Eikelenboom > CC: George Dunlap > --- > tools/libxl/libxl_pci.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c > index 316643c..9ae37fa 100644 > --- a/tools/libxl/libxl_pci.c > +++ b/tools/libxl/libxl_pci.c > @@ -1247,9 +1247,9 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid, > rc = ERROR_FAIL; > goto out_fail; > } > - } else if (type != LIBXL_DOMAIN_TYPE_PV) > - abort(); > - { > + } else { > + assert(type == LIBXL_DOMAIN_TYPE_PV); > + > char *sysfs_path = libxl__sprintf(gc, SYSFS_PCI_DEV"/"PCI_BDF"/resource", pcidev->domain, > pcidev->bus, pcidev->dev, pcidev->func); > FILE *f = fopen(sysfs_path, "r"); > -- > 1.7.10.4 >