From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, jasowang@redhat.com, fnu.vikram@xilinx.com,
berrange@redhat.com, pisa@cmp.felk.cvut.cz
Subject: [PATCH 1/4] crypto: Move USER_CREATABLE to secret_common base class
Date: Mon, 30 Nov 2020 11:56:12 +0100 [thread overview]
Message-ID: <20201130105615.21799-2-kwolf@redhat.com> (raw)
In-Reply-To: <20201130105615.21799-1-kwolf@redhat.com>
Instead of duplicating the code for user creatable objects in secret and
secret_keyring, move it to the common base clase secret_common. As the
base class is abstract, it won't become user creatable itself.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
crypto/secret.c | 14 --------------
crypto/secret_common.c | 15 +++++++++++++++
crypto/secret_keyring.c | 14 --------------
3 files changed, 15 insertions(+), 28 deletions(-)
diff --git a/crypto/secret.c b/crypto/secret.c
index 281cb81f0f..44eaff16f6 100644
--- a/crypto/secret.c
+++ b/crypto/secret.c
@@ -107,13 +107,6 @@ qcrypto_secret_prop_get_file(Object *obj,
}
-static void
-qcrypto_secret_complete(UserCreatable *uc, Error **errp)
-{
- object_property_set_bool(OBJECT(uc), "loaded", true, errp);
-}
-
-
static void
qcrypto_secret_finalize(Object *obj)
{
@@ -129,9 +122,6 @@ qcrypto_secret_class_init(ObjectClass *oc, void *data)
QCryptoSecretCommonClass *sic = QCRYPTO_SECRET_COMMON_CLASS(oc);
sic->load_data = qcrypto_secret_load_data;
- UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
- ucc->complete = qcrypto_secret_complete;
-
object_class_property_add_str(oc, "data",
qcrypto_secret_prop_get_data,
qcrypto_secret_prop_set_data);
@@ -148,10 +138,6 @@ static const TypeInfo qcrypto_secret_info = {
.instance_finalize = qcrypto_secret_finalize,
.class_size = sizeof(QCryptoSecretClass),
.class_init = qcrypto_secret_class_init,
- .interfaces = (InterfaceInfo[]) {
- { TYPE_USER_CREATABLE },
- { }
- }
};
diff --git a/crypto/secret_common.c b/crypto/secret_common.c
index b03d530867..35b82cb531 100644
--- a/crypto/secret_common.c
+++ b/crypto/secret_common.c
@@ -268,6 +268,13 @@ qcrypto_secret_prop_get_keyid(Object *obj,
}
+static void
+qcrypto_secret_complete(UserCreatable *uc, Error **errp)
+{
+ object_property_set_bool(OBJECT(uc), "loaded", true, errp);
+}
+
+
static void
qcrypto_secret_finalize(Object *obj)
{
@@ -281,6 +288,10 @@ qcrypto_secret_finalize(Object *obj)
static void
qcrypto_secret_class_init(ObjectClass *oc, void *data)
{
+ UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
+
+ ucc->complete = qcrypto_secret_complete;
+
object_class_property_add_bool(oc, "loaded",
qcrypto_secret_prop_get_loaded,
qcrypto_secret_prop_set_loaded);
@@ -390,6 +401,10 @@ static const TypeInfo qcrypto_secret_info = {
.class_size = sizeof(QCryptoSecretCommonClass),
.class_init = qcrypto_secret_class_init,
.abstract = true,
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_USER_CREATABLE },
+ { }
+ }
};
diff --git a/crypto/secret_keyring.c b/crypto/secret_keyring.c
index 10d8bc48a0..1b7edec84a 100644
--- a/crypto/secret_keyring.c
+++ b/crypto/secret_keyring.c
@@ -102,22 +102,12 @@ qcrypto_secret_prop_get_key(Object *obj, Visitor *v,
}
-static void
-qcrypto_secret_keyring_complete(UserCreatable *uc, Error **errp)
-{
- object_property_set_bool(OBJECT(uc), "loaded", true, errp);
-}
-
-
static void
qcrypto_secret_keyring_class_init(ObjectClass *oc, void *data)
{
QCryptoSecretCommonClass *sic = QCRYPTO_SECRET_COMMON_CLASS(oc);
sic->load_data = qcrypto_secret_keyring_load_data;
- UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
- ucc->complete = qcrypto_secret_keyring_complete;
-
object_class_property_add(oc, "serial", "int32_t",
qcrypto_secret_prop_get_key,
qcrypto_secret_prop_set_key,
@@ -130,10 +120,6 @@ static const TypeInfo qcrypto_secret_info = {
.name = TYPE_QCRYPTO_SECRET_KEYRING,
.instance_size = sizeof(QCryptoSecretKeyring),
.class_init = qcrypto_secret_keyring_class_init,
- .interfaces = (InterfaceInfo[]) {
- { TYPE_USER_CREATABLE },
- { }
- }
};
--
2.28.0
next prev parent reply other threads:[~2020-11-30 10:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-30 10:56 [PATCH 0/4] User creatable object property setting fixes Kevin Wolf
2020-11-30 10:56 ` Kevin Wolf [this message]
2020-11-30 10:56 ` [PATCH 2/4] crypto: Forbid broken unloading of secrets Kevin Wolf
2020-11-30 10:56 ` [PATCH 3/4] crypto: Fix memory leaks in set_loaded for tls-* Kevin Wolf
2020-11-30 10:56 ` [PATCH 4/4] can-host: Fix crash when 'canbus' property is not set Kevin Wolf
2020-12-07 10:30 ` [PATCH 0/4] User creatable object property setting fixes 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=20201130105615.21799-2-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=berrange@redhat.com \
--cc=fnu.vikram@xilinx.com \
--cc=jasowang@redhat.com \
--cc=pisa@cmp.felk.cvut.cz \
--cc=qemu-devel@nongnu.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.