[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 12/12] qapi/qom: Add class definition for rng-egd
From: |
Kevin Wolf |
Subject: |
[RFC PATCH 12/12] qapi/qom: Add class definition for rng-egd |
Date: |
Wed, 3 Nov 2021 18:30:02 +0100 |
Switch object creation to .instance_config and remove the property
setter that would only return an error after creation anyway.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qapi/qom.json | 12 ++++++------
backends/rng-egd.c | 18 +++++++-----------
2 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/qapi/qom.json b/qapi/qom.json
index 864c6a658b..fce24428f8 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -742,18 +742,18 @@
'parent': 'rng-backend' }
##
-# @RngEgdProperties:
+# @rng-egd:
#
-# Properties for rng-egd objects.
+# Random number generator backend connecting to an EGD-compatible daemon
#
# @chardev: the name of a character device backend that provides the connection
# to the RNG daemon
#
# Since: 1.3
##
-{ 'struct': 'RngEgdProperties',
- 'base': 'RngProperties',
- 'data': { 'chardev': 'str' } }
+{ 'class': 'rng-egd',
+ 'parent': 'rng-backend',
+ 'config': { 'chardev': 'str' } }
##
# @rng-random:
@@ -908,7 +908,7 @@
'if': 'CONFIG_LINUX' },
'qtest': 'QtestProperties',
'rng-builtin': 'qom-config:rng-builtin',
- 'rng-egd': 'RngEgdProperties',
+ 'rng-egd': 'qom-config:rng-egd',
'rng-random': { 'type': 'qom-config:rng-random',
'if': 'CONFIG_POSIX' },
'secret': 'SecretProperties',
diff --git a/backends/rng-egd.c b/backends/rng-egd.c
index 4de142b9dc..89255dc6fa 100644
--- a/backends/rng-egd.c
+++ b/backends/rng-egd.c
@@ -15,6 +15,7 @@
#include "chardev/char-fe.h"
#include "qapi/error.h"
#include "qapi/qmp/qerror.h"
+#include "qapi/qapi-qom-qom.h"
#include "qemu/module.h"
#include "qom/object.h"
@@ -110,17 +111,12 @@ static void rng_egd_opened(RngBackend *b, Error **errp)
rng_egd_chr_read, NULL, NULL, s, NULL, true);
}
-static void rng_egd_set_chardev(Object *obj, const char *value, Error **errp)
+bool qom_rng_egd_config(Object *obj, const char *chardev, Error **errp)
{
- RngBackend *b = RNG_BACKEND(obj);
- RngEgd *s = RNG_EGD(b);
+ RngEgd *s = RNG_EGD(obj);
- if (b->opened) {
- error_setg(errp, QERR_PERMISSION_DENIED);
- } else {
- g_free(s->chr_name);
- s->chr_name = g_strdup(value);
- }
+ s->chr_name = g_strdup(chardev);
+ return true;
}
static char *rng_egd_get_chardev(Object *obj, Error **errp)
@@ -149,8 +145,7 @@ static void rng_egd_class_init(ObjectClass *klass, void
*data)
rbc->request_entropy = rng_egd_request_entropy;
rbc->opened = rng_egd_opened;
- object_class_property_add_str(klass, "chardev",
- rng_egd_get_chardev, rng_egd_set_chardev);
+ object_class_property_add_str(klass, "chardev", rng_egd_get_chardev, NULL);
}
static const TypeInfo rng_egd_info = {
@@ -158,6 +153,7 @@ static const TypeInfo rng_egd_info = {
.parent = TYPE_RNG_BACKEND,
.instance_size = sizeof(RngEgd),
.class_init = rng_egd_class_init,
+ .instance_config = qom_rng_egd_marshal_config,
.instance_finalize = rng_egd_finalize,
};
--
2.31.1
- [RFC PATCH 03/12] qom: Make object_configure() public, (continued)
- [RFC PATCH 03/12] qom: Make object_configure() public, Kevin Wolf, 2021/11/03
- [RFC PATCH 04/12] qom: Add instance_config() to TypeInfo, Kevin Wolf, 2021/11/03
- [RFC PATCH 05/12] rng-random: Implement .instance_config, Kevin Wolf, 2021/11/03
- [RFC PATCH 06/12] rng-backend: Implement .instance_config, Kevin Wolf, 2021/11/03
- [RFC PATCH 07/12] qapi: Allow defining QOM classes, Kevin Wolf, 2021/11/03
- [RFC PATCH 08/12] qapi: Create qom-config:... type for classes, Kevin Wolf, 2021/11/03
- [RFC PATCH 09/12] qapi/qom: Convert rng-backend/random to class, Kevin Wolf, 2021/11/03
- [RFC PATCH 12/12] qapi/qom: Add class definition for rng-egd,
Kevin Wolf <=
- [RFC PATCH 11/12] qapi/qom: Add class definition for rng-builtin, Kevin Wolf, 2021/11/03
- [RFC PATCH 10/12] qapi: Generate QOM config marshalling code, Kevin Wolf, 2021/11/03
- Re: [RFC PATCH 00/12] QOM/QAPI integration part 1, Paolo Bonzini, 2021/11/03
- Re: [RFC PATCH 00/12] QOM/QAPI integration part 1, Damien Hedde, 2021/11/04