From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:40018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkDyd-0003Ys-O6 for qemu-devel@nongnu.org; Mon, 09 Jan 2012 07:05:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkDyT-0004vI-9q for qemu-devel@nongnu.org; Mon, 09 Jan 2012 07:05:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:12509) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkDyS-0004vC-U7 for qemu-devel@nongnu.org; Mon, 09 Jan 2012 07:05:13 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q09C5BKe009131 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 9 Jan 2012 07:05:11 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q09C5AmF026825 for ; Mon, 9 Jan 2012 07:05:10 -0500 From: Avi Kivity Date: Mon, 9 Jan 2012 14:04:54 +0200 Message-Id: <1326110694-5196-4-git-send-email-avi@redhat.com> In-Reply-To: <1326110694-5196-1-git-send-email-avi@redhat.com> References: <1326110694-5196-1-git-send-email-avi@redhat.com> Subject: [Qemu-devel] [PATCH 3/3] vhost: improve region filtering List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org vhost memory management doesn't care about non-memory (e.g. PIO) or non-RAM regions. Adjust the filtering to reflect that, and move it earlier so it applies to mem_sections too. Signed-off-by: Avi Kivity --- hw/vhost.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index d924fb0..19a7b5c 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -15,6 +15,7 @@ #include "hw/hw.h" #include "range.h" #include +#include "exec-memory.h" static void vhost_dev_sync_region(struct vhost_dev *dev, MemoryRegionSection *section, @@ -365,10 +366,6 @@ static void vhost_set_memory(MemoryListener *listener, int r; void *ram; - if (!memory_region_is_ram(section->mr)) { - return; - } - dev->mem = g_realloc(dev->mem, s); if (log_dirty) { @@ -430,12 +427,22 @@ static void vhost_set_memory(MemoryListener *listener, } } +static bool vhost_section(MemoryRegionSection *section) +{ + return section->address_space == get_system_memory() + && memory_region_is_ram(section->mr); +} + static void vhost_region_add(MemoryListener *listener, MemoryRegionSection *section) { struct vhost_dev *dev = container_of(listener, struct vhost_dev, memory_listener); + if (!vhost_section(section)) { + return; + } + ++dev->n_mem_sections; dev->mem_sections = g_renew(MemoryRegionSection, dev->mem_sections, dev->n_mem_sections); @@ -450,6 +457,10 @@ static void vhost_region_del(MemoryListener *listener, memory_listener); int i; + if (!vhost_section(section)) { + return; + } + vhost_set_memory(listener, section, false); for (i = 0; i < dev->n_mem_sections; ++i) { if (dev->mem_sections[i].offset_within_address_space -- 1.7.7.1