[Qemu-devel] [PATCH] vhost: skip RAM device memory sections

ZhiPeng Lu posted 1 patch 6 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1491614650-5144-1-git-send-email-lu.zhipeng@zte.com.cn
Test checkpatch passed
Test docker failed
Test s390x failed
hw/virtio/vhost.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[Qemu-devel] [PATCH] vhost: skip RAM device memory sections
Posted by ZhiPeng Lu 6 years, 11 months ago
A RAM device represents a mapping to a physical device, such as to a PCI
* MMIO BAR of an vfio-pci assigned device.
Vhost listens to this region,and increases the region's reference count
while passthrough?for?network adapters (Physical Function, PF or Virtual Function, VF).
After detaching   network adapters with  vhost backend dirver or vhost user dirver,
it unregister vhost listen function  by memory_listener_unregister.
After detaching the passthrough pf  or vf,
the RAM device region's reference by  vhost listener increated can not be released,
due to vhost listen function does not exist.So let's just skip RAM device memory.

Signed-off-by: ZhiPeng Lu <lu.zhipeng@zte.com.cn>
---
 hw/virtio/vhost.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 613494d..c1ff98f 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -611,7 +611,8 @@ static void vhost_set_memory(MemoryListener *listener,
 static bool vhost_section(MemoryRegionSection *section)
 {
     return memory_region_is_ram(section->mr) &&
-        !memory_region_is_rom(section->mr);
+        !memory_region_is_rom(section->mr) &&
+        !memory_region_is_skip_dump(section->mr);
 }
 
 static void vhost_begin(MemoryListener *listener)
-- 
1.8.3.1



Re: [Qemu-devel] [PATCH] vhost: skip RAM device memory sections
Posted by Michael S. Tsirkin 6 years, 11 months ago
On Sat, Apr 08, 2017 at 09:24:10AM +0800, ZhiPeng Lu wrote:
> A RAM device represents a mapping to a physical device, such as to a PCI
> * MMIO BAR of an vfio-pci assigned device.
> Vhost listens to this region,and increases the region's reference count
> while passthrough?for?network adapters (Physical Function, PF or Virtual Function, VF).
> After detaching   network adapters with  vhost backend dirver or vhost user dirver,
> it unregister vhost listen function  by memory_listener_unregister.

Shouldn't that drop all references? That might be a cleaner fix.

> After detaching the passthrough pf  or vf,
> the RAM device region's reference by  vhost listener increated can not be released,
> due to vhost listen function does not exist.So let's just skip RAM device memory.
> 
> Signed-off-by: ZhiPeng Lu <lu.zhipeng@zte.com.cn>
> ---
>  hw/virtio/vhost.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index 613494d..c1ff98f 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -611,7 +611,8 @@ static void vhost_set_memory(MemoryListener *listener,
>  static bool vhost_section(MemoryRegionSection *section)
>  {
>      return memory_region_is_ram(section->mr) &&
> -        !memory_region_is_rom(section->mr);
> +        !memory_region_is_rom(section->mr) &&
> +        !memory_region_is_skip_dump(section->mr);
>  }
>  
>  static void vhost_begin(MemoryListener *listener)
> -- 
> 1.8.3.1
>