[PATCH RFC v2 13/13] net/vhost-user: add memory isolation
Connor Kite <[email protected]>
| Newsgroups | org.nongnu.qemu-devel,dev.linux.lists.virtio-fs |
|---|---|
| Message-ID | <[email protected]> |
Add a memory-isolation property to NetdevPassOptions and NetDevVhostUserOptions in net.json. This property will be used for vhost-user devices to disable access to guest memory from vhost-user backends. Signed-off-by: Connor Kite <[email protected]> --- net/passt.c | 5 +++++ net/vhost-user.c | 3 +++ qapi/net.json | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/net/passt.c b/net/passt.c index 35ec6ad6de..7bcd47ad32 100644 --- a/net/passt.c +++ b/net/passt.c @@ -741,6 +741,11 @@ int net_init_passt(const Netdev *netdev, const char *name, if (netdev->u.passt.has_vhost_user && netdev->u.passt.vhost_user) { bool memory_isolation = false; + if (netdev->u.passt.has_memory_isolation && + netdev->u.passt.memory_isolation) { + memory_isolation = true; + } + if (net_passt_vhost_user_init(s, memory_isolation, errp) == -1) { qemu_del_net_client(nc); return -1; diff --git a/net/vhost-user.c b/net/vhost-user.c index b6ee9ed297..bd33decadf 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -477,6 +477,9 @@ int net_init_vhost_user(const Netdev *netdev, const char *name, return -1; } + memory_isolation = vhost_user_opts->has_memory_isolation ? + vhost_user_opts->memory_isolation : false; + return net_vhost_user_init(peer, "vhost_user", name, chr, queues, memory_isolation); } diff --git a/qapi/net.json b/qapi/net.json index 1a6382825c..add7cb5408 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -213,6 +213,9 @@ # # @param: parameter to pass to passt command # +# @memory-isolation: isolate guest memory from vhost-user back-end +# (default: false) (Since 11.2) +# # Since: 10.1 ## { 'struct': 'NetdevPasstOptions', @@ -250,7 +253,8 @@ '*ipv6': 'bool', '*tcp-ports': ['PasstPortForward'], '*udp-ports': ['PasstPortForward'], - '*param': ['PasstParameter'] }, + '*param': ['PasstParameter'], + '*memory-isolation': 'bool'}, 'if': 'CONFIG_PASST' } ## @@ -685,13 +689,17 @@ # @queues: number of queues to be created for multiqueue vhost-user # (default: 1) (Since 2.5) # +# @memory-isolation: isolate guest memory from vhost-user back-end +# (default: false) (Since 11.2) +# # Since: 2.1 ## { 'struct': 'NetdevVhostUserOptions', 'data': { - 'chardev': 'str', - '*vhostforce': 'bool', - '*queues': 'int' } } + 'chardev': 'str', + '*vhostforce': 'bool', + '*queues': 'int', + '*memory-isolation': 'bool' } } ## # @NetdevVhostVDPAOptions: -- 2.43.0