From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Markus Armbruster" <armbru@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH v4 03/14] qom: add helper API for checking object class security policy compliance
Date: Thu, 10 Sep 2026 11:36:17 +0100 [thread overview]
Message-ID: <20260910103628.2326622-4-berrange@redhat.com> (raw)
In-Reply-To: <20260910103628.2326622-1-berrange@redhat.com>
This helper simply avoids a verbose code pattern being repeated for
many callers.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
include/qom/object.h | 13 +++++++++++++
qom/object.c | 9 +++++++++
2 files changed, 22 insertions(+)
diff --git a/include/qom/object.h b/include/qom/object.h
index 687ceb6bba..3285218664 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -2405,6 +2405,19 @@ Object *object_property_add_new_container(Object *obj, const char *name);
char *object_property_help(const char *name, const char *type,
QObject *defval, const char *description);
+/**
+ * object_class_check_security:
+ * @klass: the object class to check
+ * @errp: a pointer to an Error that is filled if not compliant
+ *
+ * Check whether the object class @klass complies with the
+ * currently requested security policy. Reports an error
+ * in @errp if not compliant.
+ *
+ * Returns: true if compliant, false if an error was raised
+ */
+bool object_class_check_security(ObjectClass *klass, Error **errp);
+
G_DEFINE_AUTOPTR_CLEANUP_FUNC(Object, object_unref)
#endif
diff --git a/qom/object.c b/qom/object.c
index 32736a0111..41b1ec81d4 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -23,6 +23,7 @@
#include "qapi/qobject-input-visitor.h"
#include "qapi/forward-visitor.h"
#include "qapi/qapi-builtin-visit.h"
+#include "qapi/compat-policy.h"
#include "qobject/qdict.h"
#include "qobject/qjson.h"
#include "qemu/id.h"
@@ -3149,6 +3150,14 @@ void object_class_property_set_description(ObjectClass *klass,
op->description = g_strdup(description);
}
+bool object_class_check_security(ObjectClass *klass, Error **errp)
+{
+ return compat_policy_check_security(&compat_policy,
+ object_class_get_name(klass),
+ object_class_is_secure(klass),
+ errp);
+}
+
static void object_class_init(ObjectClass *klass, const void *data)
{
object_class_property_add_str(klass, "type", object_get_type,
--
2.55.0
next prev parent reply other threads:[~2026-09-10 10:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 10:36 [PATCH v4 00/14] Encode object type security status in code Daniel P. Berrangé
2026-09-10 10:36 ` [PATCH v4 01/14] qom: add tracking of security state of object types Daniel P. Berrangé
2026-09-10 10:36 ` [PATCH v4 02/14] qapi: add 'insecure-types' option for -compat argument Daniel P. Berrangé
2026-09-10 10:36 ` Daniel P. Berrangé [this message]
2026-09-10 10:36 ` [PATCH v4 04/14] system: check security for accelerator types Daniel P. Berrangé
2026-09-10 10:36 ` [PATCH v4 05/14] system: report acclerator security status in help output Daniel P. Berrangé
2026-09-10 10:36 ` [PATCH v4 06/14] system: check security for machine types Daniel P. Berrangé
2026-09-10 10:36 ` [PATCH v4 07/14] system: report machine security status in help output Daniel P. Berrangé
2026-09-10 10:36 ` [PATCH v4 08/14] system: check security of device types Daniel P. Berrangé
2026-09-10 10:36 ` [PATCH v4 09/14] system: report device security status in help output Daniel P. Berrangé
2026-09-10 10:36 ` [PATCH v4 10/14] hw/core: report security status in query-machines Daniel P. Berrangé
2026-09-10 10:36 ` [PATCH v4 11/14] qom: refactor data passing for QOM list filtering Daniel P. Berrangé
2026-09-10 10:36 ` [PATCH v4 12/14] qom: report & filter on security status in qom-list-types Daniel P. Berrangé
2026-09-10 10:36 ` [PATCH v4 13/14] docs: expand security docs with info about security status Daniel P. Berrangé
2026-09-10 10:36 ` [PATCH v4 14/14] machine: add helpers for declaring secure/insecure machine types Daniel P. Berrangé
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=20260910103628.2326622-4-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=armbru@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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.