From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YhfLT-00051z-SE for qemu-devel@nongnu.org; Mon, 13 Apr 2015 10:28:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YhfLP-0007AL-Rl for qemu-devel@nongnu.org; Mon, 13 Apr 2015 10:28:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59213) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YhfLP-0007AF-KT for qemu-devel@nongnu.org; Mon, 13 Apr 2015 10:28:11 -0400 Message-ID: <552BD273.9060105@redhat.com> Date: Mon, 13 Apr 2015 16:28:03 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1428934370-29695-1-git-send-email-liang.z.li@intel.com> In-Reply-To: <1428934370-29695-1-git-send-email-liang.z.li@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] xen-pt: Fix bug cause PCI devices re-attach failed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liang Li , qemu-devel@nongnu.org Cc: peter.crosthwaite@xilinx.com, xen-devel@lists.xensource.com, stefano.stabellini@eu.citrix.com, kevin.tian@intel.com, yang.z.zhang@intel.com, robert.hu@intel.com On 13/04/2015 16:12, Liang Li wrote: > 2. Do the attach and detach operation with a time interval. eg. 10s. > > The error message will not disappear if retry, in this case, it's > a bug. > > In the 'xen_pt_region_add' and 'xen_pt_region_del', we should only care > about the 'xen-pci-pt-*' memory region, this can avoid the region's > reference count is not equal with the dereference count when the > device is detached and prevent the device's related QemuOpts object from > being released properly, and then trigger the bug when the device is > re-attached. This doesn't explain _which_ region is causing the bug and how. Assuming this is the right fix, should you instead move the memory_region_ref/unref pair from xen_pt_region_add/del after this conditional: if (bar == -1 && (!s->msix || &s->msix->mmio != mr)) { return; } in xen_pt_region_update? Paolo