On 2026/07/24 7:30, Connor Kite wrote:
Add a memory_isolation property to CryptoDevBackendVhostUser and
add add it as an optional member of CryptodevVhostUserProperties
in qapi.
This is needed to be able to specify memory isolation for
cryptodev-vhost-user objects, and the bool will eventually be
passed to vhost_user_init() in a future patch.
Signed-off-by: Connor Kite <[email protected]>
---
backends/cryptodev-vhost-user.c | 22 ++++++++++++++++++++++
qapi/qom.json | 6 +++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c
index cc478d9902..e0547c5d40 100644
--- a/backends/cryptodev-vhost-user.c
+++ b/backends/cryptodev-vhost-user.c
@@ -49,6 +49,7 @@ struct CryptoDevBackendVhostUser {
CharFrontend chr;
char *chr_name;
bool opened;
+ bool memory_isolation;
CryptoDevBackendVhost *vhost_crypto[MAX_CRYPTO_QUEUE_NUM];
};
@@ -392,6 +393,23 @@ static void cryptodev_vhost_user_finalize(Object *obj)
g_free(s->chr_name);
}
+static void cryptodev_vhost_user_set_mem_isolation(Object *obj, bool value,
+ Error **errp)
+{
+ CryptoDevBackendVhostUser *s =
+ CRYPTODEV_BACKEND_VHOST_USER(obj);
+
+ s->memory_isolation = value;
This setter should forbid setting once initialization finishes as done
in cryptodev_vhost_user_set_chardev() since the value is copied into
VhostUserState during initialization and setting this afterwards is
ineffective.
Regards,
Akihiko Odaki
+}
+
+static bool cryptodev_vhost_user_get_mem_isolation(Object *obj, Error **errp)
+{
+ CryptoDevBackendVhostUser *s =
+ CRYPTODEV_BACKEND_VHOST_USER(obj);
+
+ return s->memory_isolation;
+}
+
static void
cryptodev_vhost_user_class_init(ObjectClass *oc, const void *data)
{
@@ -407,6 +425,10 @@ cryptodev_vhost_user_class_init(ObjectClass *oc, const
void *data)
cryptodev_vhost_user_get_chardev,
cryptodev_vhost_user_set_chardev);
+ object_class_property_add_bool(oc, "memory-isolation",
+ cryptodev_vhost_user_get_mem_isolation,
+ cryptodev_vhost_user_set_mem_isolation);
+
}
static const TypeInfo cryptodev_vhost_user_info = {
diff --git a/qapi/qom.json b/qapi/qom.json
index c55776af7d..d7ca1b4203 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -350,11 +350,15 @@
# @chardev: the name of a Unix domain socket character device that
# connects to the vhost-user server
#
+# @memory-isolation: disables access from cryptodev to guest memory.
+# (default: false)
+#
# Since: 2.12
##
{ 'struct': 'CryptodevVhostUserProperties',
'base': 'CryptodevBackendProperties',
- 'data': { 'chardev': 'str' },
+ 'data': { 'chardev': 'str',
+ '*memory-isolation': 'bool' },
'if': 'CONFIG_VHOST_CRYPTO' }
##