All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>
Subject: [PULL 12/14] qom: report & filter on security status in qom-list-types
Date: Thu, 17 Sep 2026 17:05:23 +0100	[thread overview]
Message-ID: <20260917160525.1275388-13-berrange@redhat.com> (raw)
In-Reply-To: <20260917160525.1275388-1-berrange@redhat.com>

This adds:

 * a new boolean 'secure' field to the type info returned by
   qom-list-types, which will be set if the type provides a
   security boundary

 * a new boolean 'secure' parameter to the arguments of
   qom-list-types, which can be used to filter types based
   on their security status

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 qapi/qom.json               | 13 +++++++++++--
 qom/qom-qmp-cmds.c          | 17 +++++++++++++++++
 tests/qtest/fuzz/qos_fuzz.c |  3 ++-
 3 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/qapi/qom.json b/qapi/qom.json
index 4a9b7f90884..5895c977503 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -210,12 +210,18 @@
 # @abstract: the type is abstract and can't be directly instantiated.
 #     Omitted if false.  (since 2.10)
 #
+# @secure: the type provides a security boundary.  Omitted if false.
+#     (since 11.2)
+#
 # @parent: Name of parent type, if any (since 2.10)
 #
 # Since: 1.1
 ##
 { 'struct': 'ObjectTypeInfo',
-  'data': { 'name': 'str', '*abstract': 'bool', '*parent': 'str' } }
+  'data': { 'name': 'str',
+            '*abstract': 'bool',
+            '*parent': 'str',
+            '*secure': 'bool' } }
 
 ##
 # @qom-list-types:
@@ -227,12 +233,15 @@
 #
 # @abstract: if true, include abstract types in the results
 #
+# @secure: if set, filter to only include types with matching security
+#     status (since 11.2)
+#
 # Returns: a list of types, or an empty list if no results are found
 #
 # Since: 1.1
 ##
 { 'command': 'qom-list-types',
-  'data': { '*implements': 'str', '*abstract': 'bool' },
+  'data': { '*implements': 'str', '*abstract': 'bool', '*secure': 'bool' },
   'returns': [ 'ObjectTypeInfo' ],
   'allow-preconfig': true }
 
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index b999e9f7238..f17389c7305 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -153,6 +153,8 @@ QObject *qmp_qom_get(const char *path, const char *property, Error **errp)
 
 typedef struct {
     ObjectTypeInfoList *list;
+    bool has_secure;
+    bool secure;
 } ObjectTypeInfoData;
 
 static void qom_list_types_tramp(ObjectClass *klass, void *opaque)
@@ -160,10 +162,21 @@ static void qom_list_types_tramp(ObjectClass *klass, void *opaque)
     ObjectTypeInfoData *data = opaque;
     ObjectTypeInfo *info;
     ObjectClass *parent = object_class_get_parent(klass);
+    bool secure = object_class_is_secure(klass);
+
+    if (data->has_secure &&
+        data->secure != secure) {
+        return;
+    }
 
     info = g_malloc0(sizeof(*info));
     info->name = g_strdup(object_class_get_name(klass));
     info->has_abstract = info->abstract = object_class_is_abstract(klass);
+    /*
+     * Set has_secure such that we omit the 'secure' attribute
+     * from the QMP response for insecure types
+     */
+    info->has_secure = info->secure = secure;
     if (parent) {
         info->parent = g_strdup(object_class_get_name(parent));
     }
@@ -174,10 +187,14 @@ static void qom_list_types_tramp(ObjectClass *klass, void *opaque)
 ObjectTypeInfoList *qmp_qom_list_types(const char *implements,
                                        bool has_abstract,
                                        bool abstract,
+                                       bool has_secure,
+                                       bool secure,
                                        Error **errp)
 {
     ObjectTypeInfoData data = {
         .list = NULL,
+        .has_secure = has_secure,
+        .secure = secure,
     };
 
     module_load_qom_all();
diff --git a/tests/qtest/fuzz/qos_fuzz.c b/tests/qtest/fuzz/qos_fuzz.c
index 9afe8bf6d8b..9ea6b1aef09 100644
--- a/tests/qtest/fuzz/qos_fuzz.c
+++ b/tests/qtest/fuzz/qos_fuzz.c
@@ -50,7 +50,8 @@ static void qos_set_machines_devices_available(void)
     machines_apply_to_node(mach_info);
     qapi_free_MachineInfoList(mach_info);
 
-    type_info = qmp_qom_list_types("device", true, true, &error_abort);
+    type_info = qmp_qom_list_types("device", true, true,
+                                   false, false, &error_abort);
     types_apply_to_node(type_info);
     qapi_free_ObjectTypeInfoList(type_info);
 }
-- 
2.55.0



  parent reply	other threads:[~2026-09-17 16:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 16:05 [PULL 00/14] QOM security status patches Daniel P. Berrangé
2026-09-17 16:05 ` [PULL 01/14] qom: add tracking of security state of object types Daniel P. Berrangé
2026-09-17 16:05 ` [PULL 02/14] qapi: add 'insecure-types' option for -compat argument Daniel P. Berrangé
2026-09-17 16:05 ` [PULL 03/14] qom: add helper API for checking object class security policy compliance Daniel P. Berrangé
2026-09-17 16:05 ` [PULL 04/14] system: check security for accelerator types Daniel P. Berrangé
2026-09-17 16:05 ` [PULL 05/14] system: report acclerator security status in help output Daniel P. Berrangé
2026-09-17 16:05 ` [PULL 06/14] system: check security for machine types Daniel P. Berrangé
2026-09-17 16:05 ` [PULL 07/14] system: report machine security status in help output Daniel P. Berrangé
2026-09-17 16:05 ` [PULL 08/14] system: check security of device types Daniel P. Berrangé
2026-09-17 16:05 ` [PULL 09/14] system: report device security status in help output Daniel P. Berrangé
2026-09-17 16:05 ` [PULL 10/14] hw/core: report security status in query-machines Daniel P. Berrangé
2026-09-17 16:05 ` [PULL 11/14] qom: refactor data passing for QOM list filtering Daniel P. Berrangé
2026-09-17 16:05 ` Daniel P. Berrangé [this message]
2026-09-17 16:05 ` [PULL 13/14] docs: expand security docs with info about security status Daniel P. Berrangé
2026-09-17 16:05 ` [PULL 14/14] machine: add helpers for declaring secure/insecure machine types Daniel P. Berrangé
2026-09-17 21:50 ` [PULL 00/14] QOM security status patches Richard Henderson

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=20260917160525.1275388-13-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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.