xen-pt: Fix PCI devices re-attach failed
PATCH 1/1 xen-pt: Fix PCI devices re-attach failed
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.
--- hw/xen/xen_pt.c | 4 ---- 1 file changed, 4 deletions(-)
hw/xen/xen_pt.c +0 -4
@@ -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 = {
Signature · 1 line
1.9.1
Quoted 5 lines · Liang Li
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:
Quoted 7 lines
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_addandxen_pt_region_delare not the same will cause the XenPCIPassthroughState and it's related QemuOpts object not be released properly.
Thanks for the patch!
Quoted 1 line
From this description, I don't quite understand why the
memory_region_ref and memory_region_unref calls are wrong. What do you mean by "The count of calling xen_pt_region_add and xen_pt_region_del are not the same"?
On unplug xen_pt_region_del does not get called?
Or the memory region argument is not exactly the same as the one initially passed to xen_pt_region_add?
Quoted 45 lines
Signed-off-by Liang Li <[email protected]>Reported-by Longtao Pang <[email protected]>--- hw/xen/xen_pt.c | 4 ---- 1 file changed, 4 deletions(-)hw/xen/xen_pt.c +0
-4@@ -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 = {Signature · 1 line
1.9.1
Quoted 25 lines
From: Stefano Stabellini
Sent: Monday, January 12, 2015 7:36 PMQuoted 5 lines · Liang Li
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:
Quoted 7 lines
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_addandxen_pt_region_delare not the same will cause the XenPCIPassthroughState and it's related QemuOpts object not be released properly.Thanks for the patch!
From this description, I don't quite understand why the
memory_region_refandmemory_region_unrefcalls are wrong. What do you
mean by "The count of callingxen_pt_region_addandxen_pt_region_delare not the same"?
Quoted 4 lines
On unplug
xen_pt_region_deldoes not get called?
Or the memory region argument is not exactly the same as the one initially passed toxen_pt_region_add?
agree. Liang, could you elaborate how the patch is associated with above explanation? :-)
Quoted 56 lines
hw/xen/xen_pt.c static void xen_pt_region_add(MemoryListener *l,
Quoted 12 lines
Signed-off-by Liang Li <[email protected]>Reported-by Longtao Pang <[email protected]>--- hw/xen/xen_pt.c | 4 ---- 1 file changed, 4 deletions(-)hw/xen/xen_pt.c +0
-0@@ -588,7 +588,6 @@ static void xen_pt_region_add(MemoryListener *l,MemoryRegionSection *sec)
hw/xen/xen_pt.c static void xen_pt_region_del(MemoryListener *l,
Quoted 8 lines
hw/xen/xen_pt.c +0
-1XenPCIPassthroughState *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)
hw/xen/xen_pt.c static void xen_pt_region_del(MemoryListener *l, MemoryRegionSection *sec)
Quoted 7 lines
hw/xen/xen_pt.c +0
-1memory_listener);xen_pt_region_update (s, sec, false); -memory_region_unref (sec->mr); } static void xen_pt_io_region_add(MemoryListener *l,MemoryRegionSection *sec)
hw/xen/xen_pt.c static void xen_pt_io_region_add(MemoryListener
Quoted 1 line
hw/xen/xen_pt.c +0
-0@@ -606,7 +604,6 @@ static void xen_pt_io_region_add(MemoryListener*l, MemoryRegionSection *sec)
hw/xen/xen_pt.c static void xen_pt_io_region_del(MemoryListener *l,
Quoted 8 lines
hw/xen/xen_pt.c +0
-1XenPCIPassthroughState *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)
Quoted 10 lines
hw/xen/xen_pt.c +0
-2io_listener);xen_pt_region_update (s, sec, false); -memory_region_unref (sec->mr); }static const MemoryListener xen_pt_memory_listener = { --1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
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.
The count of calling
xen_pt_region_addandxen_pt_region_delare not the same will cause the XenPCIPassthroughState and it's related QemuOpts object not be released properly.
Quoted 6 lines
Quoted 6 lines
Thanks for the patch!
From this description, I don't quite understand why the
memory_region_refandmemory_region_unrefcalls are wrong. What do you mean by "The count of callingxen_pt_region_addandxen_pt_region_delare not the same"?
I means for some memory regions , only the xen_pt_region_add callback function was called while the xen_pt_region_del was not called.
Quoted 7 lines
Quoted 4 lines
On unplug
xen_pt_region_deldoes not get called?
Or the memory region argument is not exactly the same as the one initially passed toxen_pt_region_add?agree. Liang, could you elaborate how the patch is associated with above explanation? :-)
I have verified the following patch can work too:
hw/xen/xen_pt.c +2 -1
@@ -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",
By further debugging, I found when using 'address_space_memory', 'xen_pt_region_del' won't be called when the memory region's name is not ' xen-pci-pt-*', when using
' s->dev.bus_master_as ', there is no such issue.
I think use the device related address space here is more reasonable, but I am not sure.
Could you give some suggestion?
Liang
Quoted 15 lines · Liang Z
hw/xen/xen_pt.c +2
-1@@ -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",
Quoted 6 lines
By further debugging, I found when using '
address_space_memory', 'xen_pt_region_del' won't be called when the memory region's name is not ' xen-pci-pt-*', when using
's->dev.bus_master_as', there is no such issue.I think use the device related address space here is more reasonable, but I am not sure.
Could you give some suggestion?
Yes, this patch makes sense. The listener will be called every time the command register is written.
Paolo
Quoted 20 lines · Paolo Bonzini
Quoted 19 lines · Liang Z
hw/xen/xen_pt.c +2
-1@@ -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",By further debugging, I found when using '
address_space_memory', 'xen_pt_region_del' won't be called when the memory region's name is not ' xen-pci-pt-*', when using
's->dev.bus_master_as', there is no such issue.
Quoted 5 lines
Quoted 2 lines
I think use the device related address space here is more reasonable, but I am not sure.
Could you give some suggestion?Yes, this patch makes sense. The listener will be called every time the command register is written.
Paolo, thanks for reviewing!
Liang, please resend with an appropriate patch description and sign-off-by line.