From: Tiwei Bie <tiwei.bie@intel.com>
To: mst@redhat.com, jasowang@redhat.com, alex.williamson@redhat.com,
pbonzini@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org,
virtio-dev@lists.oasis-open.org
Cc: cunming.liang@intel.com, dan.daly@intel.com,
jianfeng.tan@intel.com, zhihong.wang@intel.com,
xiao.w.wang@intel.com, tiwei.bie@intel.com
Subject: [virtio-dev] [PATCH v3 5/6] vhost: allow backends to filter memory sections
Date: Thu, 12 Apr 2018 23:12:31 +0800 [thread overview]
Message-ID: <20180412151232.17506-6-tiwei.bie@intel.com> (raw)
In-Reply-To: <20180412151232.17506-1-tiwei.bie@intel.com>
This patch introduces a vhost op for vhost backends to allow
them to filter the memory sections that they can handle.
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
hw/virtio/vhost-user.c | 11 +++++++++++
hw/virtio/vhost.c | 9 +++++++--
include/hw/virtio/vhost-backend.h | 4 ++++
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 9cea2c8c51..791e0a4763 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1622,6 +1622,16 @@ vhost_user_crypto_close_session(struct vhost_dev *dev, uint64_t session_id)
return 0;
}
+static bool vhost_user_mem_section_filter(struct vhost_dev *dev,
+ MemoryRegionSection *section)
+{
+ bool result;
+
+ result = memory_region_get_fd(section->mr) >= 0;
+
+ return result;
+}
+
VhostUserState *vhost_user_init(void)
{
VhostUserState *user = g_new0(struct VhostUserState, 1);
@@ -1663,4 +1673,5 @@ const VhostOps user_ops = {
.vhost_set_config = vhost_user_set_config,
.vhost_crypto_create_session = vhost_user_crypto_create_session,
.vhost_crypto_close_session = vhost_user_crypto_close_session,
+ .vhost_backend_mem_section_filter = vhost_user_mem_section_filter,
};
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index f51bf573d5..a939a38d97 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -382,7 +382,7 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev,
return r;
}
-static bool vhost_section(MemoryRegionSection *section)
+static bool vhost_section(struct vhost_dev *dev, MemoryRegionSection *section)
{
bool result;
bool log_dirty = memory_region_get_dirty_log_mask(section->mr) &
@@ -395,6 +395,11 @@ static bool vhost_section(MemoryRegionSection *section)
*/
result &= !log_dirty;
+ if (result && dev->vhost_ops->vhost_backend_mem_section_filter) {
+ result &=
+ dev->vhost_ops->vhost_backend_mem_section_filter(dev, section);
+ }
+
trace_vhost_section(section->mr->name, result);
return result;
}
@@ -628,7 +633,7 @@ static void vhost_region_addnop(MemoryListener *listener,
struct vhost_dev *dev = container_of(listener, struct vhost_dev,
memory_listener);
- if (!vhost_section(section)) {
+ if (!vhost_section(dev, section)) {
return;
}
vhost_region_add_section(dev, section);
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
index 5dac61f9ea..81283ec50f 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -101,6 +101,9 @@ typedef int (*vhost_crypto_create_session_op)(struct vhost_dev *dev,
typedef int (*vhost_crypto_close_session_op)(struct vhost_dev *dev,
uint64_t session_id);
+typedef bool (*vhost_backend_mem_section_filter_op)(struct vhost_dev *dev,
+ MemoryRegionSection *section);
+
typedef struct VhostOps {
VhostBackendType backend_type;
vhost_backend_init vhost_backend_init;
@@ -138,6 +141,7 @@ typedef struct VhostOps {
vhost_set_config_op vhost_set_config;
vhost_crypto_create_session_op vhost_crypto_create_session;
vhost_crypto_close_session_op vhost_crypto_close_session;
+ vhost_backend_mem_section_filter_op vhost_backend_mem_section_filter;
} VhostOps;
extern const VhostOps user_ops;
--
2.11.0
---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
next prev parent reply other threads:[~2018-04-12 15:14 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-12 15:12 [virtio-dev] [PATCH v3 0/6] Extend vhost-user to support registering external host notifiers Tiwei Bie
2018-04-12 15:12 ` [virtio-dev] [PATCH v3 1/6] vhost-user: add Net prefix to internal state structure Tiwei Bie
2018-04-12 15:12 ` [virtio-dev] [PATCH v3 2/6] vhost-user: introduce shared vhost-user state Tiwei Bie
2018-05-23 13:44 ` [virtio-dev] " Michael S. Tsirkin
2018-05-23 15:36 ` Michael S. Tsirkin
2018-05-23 15:43 ` Michael S. Tsirkin
2018-05-23 23:21 ` Tiwei Bie
2018-05-24 2:24 ` Tiwei Bie
2018-05-24 7:03 ` Tiwei Bie
2018-05-24 10:59 ` Tiwei Bie
2018-05-24 13:55 ` Michael S. Tsirkin
2018-05-24 14:54 ` Tiwei Bie
2018-05-24 14:30 ` Michael S. Tsirkin
2018-05-24 15:22 ` Tiwei Bie
2018-05-24 13:50 ` Michael S. Tsirkin
2018-04-12 15:12 ` [virtio-dev] [PATCH v3 3/6] vhost-user: support receiving file descriptors in slave_read Tiwei Bie
2018-05-23 21:25 ` [virtio-dev] " Michael S. Tsirkin
2018-05-23 23:12 ` Tiwei Bie
2018-05-24 13:48 ` Michael S. Tsirkin
2018-05-24 14:56 ` Tiwei Bie
2018-04-12 15:12 ` [virtio-dev] [PATCH v3 4/6] virtio: support setting memory region based host notifier Tiwei Bie
2018-04-12 15:12 ` Tiwei Bie [this message]
2018-04-12 15:12 ` [virtio-dev] [PATCH v3 6/6] vhost-user: support registering external host notifiers Tiwei Bie
2018-04-18 16:34 ` [virtio-dev] " Michael S. Tsirkin
2018-04-19 11:14 ` Tiwei Bie
2018-04-19 12:43 ` [virtio-dev] " Liang, Cunming
2018-04-19 13:02 ` Paolo Bonzini
2018-04-19 15:19 ` Michael S. Tsirkin
2018-04-19 15:51 ` Paolo Bonzini
2018-04-19 15:59 ` Michael S. Tsirkin
2018-04-19 16:07 ` Paolo Bonzini
2018-04-19 16:48 ` Michael S. Tsirkin
2018-04-19 16:24 ` Liang, Cunming
2018-04-19 16:55 ` Michael S. Tsirkin
2018-04-20 3:01 ` Liang, Cunming
2018-04-19 15:42 ` [virtio-dev] " Michael S. Tsirkin
2018-04-19 15:52 ` Paolo Bonzini
2018-04-19 16:34 ` Michael S. Tsirkin
2018-04-19 16:52 ` [virtio-dev] " Liang, Cunming
2018-04-19 16:59 ` Paolo Bonzini
2018-04-19 17:27 ` Michael S. Tsirkin
2018-04-19 17:35 ` Paolo Bonzini
2018-04-19 17:39 ` Michael S. Tsirkin
2018-04-19 17:00 ` [virtio-dev] " Michael S. Tsirkin
2018-04-19 23:05 ` [virtio-dev] " Liang, Cunming
2018-04-19 16:27 ` Liang, Cunming
2018-05-02 10:32 ` [virtio-dev] " Tiwei Bie
2018-05-16 1:41 ` [virtio-dev] Re: [PATCH v3 0/6] Extend vhost-user to " Michael S. Tsirkin
2018-05-16 1:56 ` Tiwei Bie
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=20180412151232.17506-6-tiwei.bie@intel.com \
--to=tiwei.bie@intel.com \
--cc=alex.williamson@redhat.com \
--cc=cunming.liang@intel.com \
--cc=dan.daly@intel.com \
--cc=jasowang@redhat.com \
--cc=jianfeng.tan@intel.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=virtio-dev@lists.oasis-open.org \
--cc=xiao.w.wang@intel.com \
--cc=zhihong.wang@intel.com \
/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.