From patchwork Wed Dec 24 08:56:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Liang Z" X-Patchwork-Id: 423877 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CFC3140082 for ; Wed, 24 Dec 2014 20:05:09 +1100 (AEDT) Received: from localhost ([::1]:47483 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3hsQ-0002xV-Cw for incoming@patchwork.ozlabs.org; Wed, 24 Dec 2014 04:05:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3hs9-0002f9-2F for qemu-devel@nongnu.org; Wed, 24 Dec 2014 04:04:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y3hs5-0007Nc-SD for qemu-devel@nongnu.org; Wed, 24 Dec 2014 04:04:49 -0500 Received: from mga11.intel.com ([192.55.52.93]:18518) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3hs5-0007NN-Mj for qemu-devel@nongnu.org; Wed, 24 Dec 2014 04:04:45 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 24 Dec 2014 01:04:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,637,1413270000"; d="scan'208";a="642317690" Received: from lil.sh.intel.com (HELO localhost) ([10.239.159.161]) by fmsmga001.fm.intel.com with ESMTP; 24 Dec 2014 01:04:18 -0800 From: Liang Li To: qemu-devel@nongnu.org, xen-devel@lists.xensource.com Date: Wed, 24 Dec 2014 16:56:57 +0800 Message-Id: <1419411417-23354-1-git-send-email-liang.z.li@intel.com> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Cc: Liang Li , stefano.stabellini@eu.citrix.com, mtosatti@redhat.com, mst@redhat.com, aliguori@amazon.com, robert.hu@intel.com, yang.z.zhang@intel.com, pbonzini@redhat.com, rth@twiddle.net Subject: [Qemu-devel] [PATCH] xen-pt: Fix PCI devices re-attach failed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the 'xl pci-attach $DomU $BDF' command to attach more then one PCI devices to the guest, then detach the devices with 'xl pci-detach $DomU $BDF', after that, re-attach these PCI devices again, an error message will be reported like following: libxl: error: libxl_qmp.c:287:qmp_handle_error_response: receive an error message from QMP server: Duplicate ID 'pci-pt-03_10.1' for device. The count of calling xen_pt_region_add and xen_pt_region_del are not the same will cause the XenPCIPassthroughState and it's related QemuOpts object not be released properly. Signed-off-by: Liang Li Reported-by: Longtao Pang --- hw/xen/xen_pt.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index c1bf357..523b8a2 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -588,7 +588,6 @@ static void xen_pt_region_add(MemoryListener *l, MemoryRegionSection *sec) XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState, memory_listener); - memory_region_ref(sec->mr); xen_pt_region_update(s, sec, true); } @@ -598,7 +597,6 @@ static void xen_pt_region_del(MemoryListener *l, MemoryRegionSection *sec) memory_listener); xen_pt_region_update(s, sec, false); - memory_region_unref(sec->mr); } static void xen_pt_io_region_add(MemoryListener *l, MemoryRegionSection *sec) @@ -606,7 +604,6 @@ static void xen_pt_io_region_add(MemoryListener *l, MemoryRegionSection *sec) XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState, io_listener); - memory_region_ref(sec->mr); xen_pt_region_update(s, sec, true); } @@ -616,7 +613,6 @@ static void xen_pt_io_region_del(MemoryListener *l, MemoryRegionSection *sec) io_listener); xen_pt_region_update(s, sec, false); - memory_region_unref(sec->mr); } static const MemoryListener xen_pt_memory_listener = {