From: Avi Kivity <avi@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/3] vhost: improve region filtering
Date: Mon, 9 Jan 2012 14:04:54 +0200 [thread overview]
Message-ID: <1326110694-5196-4-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1326110694-5196-1-git-send-email-avi@redhat.com>
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 <avi@redhat.com>
---
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 <linux/vhost.h>
+#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
next prev parent reply other threads:[~2012-01-09 12:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-09 12:04 [Qemu-devel] [PATCH 0/3] Fix vhost after memory API breakage Avi Kivity
2012-01-09 12:04 ` [Qemu-devel] [PATCH 1/3] vhost: fix incorrect userspace address Avi Kivity
2012-01-09 13:28 ` Michael S. Tsirkin
2012-01-09 12:04 ` [Qemu-devel] [PATCH 2/3] vhost: fix mem_sections memory corruption Avi Kivity
2012-01-09 13:28 ` Michael S. Tsirkin
2012-01-09 12:04 ` Avi Kivity [this message]
2012-01-09 13:28 ` [Qemu-devel] [PATCH 3/3] vhost: improve region filtering Michael S. Tsirkin
2012-01-09 13:27 ` Avi Kivity
2012-01-09 13:32 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1326110694-5196-4-git-send-email-avi@redhat.com \
--to=avi@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.