qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [v2] xen-pt: Fix PCI devices re-attach failed
@ 2015-01-13  2:40 Liang Li
  2015-01-13 11:57 ` Stefano Stabellini
  0 siblings, 1 reply; 2+ messages in thread
From: Liang Li @ 2015-01-13  2:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: yang.z.zhang, pbonzini, kevin.tian, Liang Li, stefano.stabellini

Use the 'xl pci-attach $DomU $BDF' command to attach more than
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.

If using the 'address_space_memory' as the parameter of
'memory_listener_register', 'xen_pt_region_del' will not be called
if the memory region's name is not 'xen-pci-pt-*' when the devices
is detached. This will cause the device's related QemuOpts object
not be released properly.

Using the device's address space can avoid such issue, because the
calling count of 'xen_pt_region_add' when attaching and the calling
count of 'xen_pt_region_del' when detaching is the same, so all the
memory region ref and unref by the 'xen_pt_region_add' and
'xen_pt_region_del' can be released properly.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reported-by: Longtao Pang <longtaox.pang@intel.com>
---
 hw/xen/xen_pt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
index c1bf357..f2893b2 100644
--- a/hw/xen/xen_pt.c
+++ b/hw/xen/xen_pt.c
@@ -736,7 +736,7 @@ static int xen_pt_initfn(PCIDevice *d)
     }
 
 out:
-    memory_listener_register(&s->memory_listener, &address_space_memory);
+    memory_listener_register(&s->memory_listener, &s->dev.bus_master_as);
     memory_listener_register(&s->io_listener, &address_space_io);
     XEN_PT_LOG(d,
                "Real physical device %02x:%02x.%d registered successfully!\n",
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [v2] xen-pt: Fix PCI devices re-attach failed
  2015-01-13  2:40 [Qemu-devel] [v2] xen-pt: Fix PCI devices re-attach failed Liang Li
@ 2015-01-13 11:57 ` Stefano Stabellini
  0 siblings, 0 replies; 2+ messages in thread
From: Stefano Stabellini @ 2015-01-13 11:57 UTC (permalink / raw)
  To: Liang Li; +Cc: yang.z.zhang, pbonzini, kevin.tian, qemu-devel,
	stefano.stabellini

On Tue, 13 Jan 2015, Liang Li wrote:
> Use the 'xl pci-attach $DomU $BDF' command to attach more than
> 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.
> 
> If using the 'address_space_memory' as the parameter of
> 'memory_listener_register', 'xen_pt_region_del' will not be called
> if the memory region's name is not 'xen-pci-pt-*' when the devices
> is detached. This will cause the device's related QemuOpts object
> not be released properly.
> 
> Using the device's address space can avoid such issue, because the
> calling count of 'xen_pt_region_add' when attaching and the calling
> count of 'xen_pt_region_del' when detaching is the same, so all the
> memory region ref and unref by the 'xen_pt_region_add' and
> 'xen_pt_region_del' can be released properly.
> 
> Signed-off-by: Liang Li <liang.z.li@intel.com>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> Reported-by: Longtao Pang <longtaox.pang@intel.com>

Added to my queue


>  hw/xen/xen_pt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
> index c1bf357..f2893b2 100644
> --- a/hw/xen/xen_pt.c
> +++ b/hw/xen/xen_pt.c
> @@ -736,7 +736,7 @@ static int xen_pt_initfn(PCIDevice *d)
>      }
>  
>  out:
> -    memory_listener_register(&s->memory_listener, &address_space_memory);
> +    memory_listener_register(&s->memory_listener, &s->dev.bus_master_as);
>      memory_listener_register(&s->io_listener, &address_space_io);
>      XEN_PT_LOG(d,
>                 "Real physical device %02x:%02x.%d registered successfully!\n",
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-13 11:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-13  2:40 [Qemu-devel] [v2] xen-pt: Fix PCI devices re-attach failed Liang Li
2015-01-13 11:57 ` Stefano Stabellini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).