Skip to contentSkip to conversation

QOM instance_size cleanups and fixes

PATCH In review Eduardo Habkost 4 participants 8 messages Aug 26, 2020 – Aug 31, 2020 Crypto API

lore
Share & tools
lore
#0 lore raw

cover QOM instance_size cleanups and fixes

Additional batch of fixes to code setting instance_size on QOM types.

Eduardo Habkost (4):
tosa-ssp: No need to override instance_size
hda-audio: Set instance_size at base class
slavio_misc: Correct instance_size
tls-cipher-suites: Correct instance_size

 crypto/tls-cipher-suites.c | 2 +-
 hw/arm/tosa.c              | 1 -
 hw/audio/hda-codec.c       | 4 +---
 hw/misc/slavio_misc.c      | 2 +-
 4 files changed, 3 insertions(+), 6 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/4 tosa-ssp: No need to override instance_size

TYPE_SSI_SLAVE already sets instance_size=sizeof(SSISlave), there's no need to override it.

---
Cc: Andrzej Zaborowski <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 hw/arm/tosa.c | 1 -
 1 file changed, 1 deletion(-)
hw/arm/tosa.c +0 -1
index e29566f7b3..2c5a8a50a1 100644
@@ -311,7 +311,6 @@ static void tosa_ssp_class_init(ObjectClass *klass, void *data)
 static const TypeInfo tosa_ssp_info = {
     .name          = "tosa-ssp",
     .parent        = TYPE_SSI_SLAVE,
-    .instance_size = sizeof(SSISlave),
     .class_init    = tosa_ssp_class_init,
 };
 
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/4 hda-audio: Set instance_size at base class

In reply to Eduardo Habkost

Setting instance_size correctly at the base class will help us avoid mistakes when declaring new subclasses.

---
Cc: Gerd Hoffmann <[email protected]>
Cc: [email protected]

---
 hw/audio/hda-codec.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
hw/audio/hda-codec.c +1 -3
index cbd92b72f2..2d16448181 100644
@@ -898,6 +898,7 @@ static void hda_audio_base_class_init(ObjectClass *klass, void *data)
 static const TypeInfo hda_audio_info = {
     .name          = TYPE_HDA_AUDIO,
     .parent        = TYPE_HDA_CODEC_DEVICE,
+    .instance_size = sizeof(HDAAudioState),
     .class_init    = hda_audio_base_class_init,
     .abstract      = true,
 };
@@ -914,7 +915,6 @@ static void hda_audio_output_class_init(ObjectClass *klass, void *data)
 static const TypeInfo hda_audio_output_info = {
     .name          = "hda-output",
     .parent        = TYPE_HDA_AUDIO,
-    .instance_size = sizeof(HDAAudioState),
     .class_init    = hda_audio_output_class_init,
 };
 
@@ -930,7 +930,6 @@ static void hda_audio_duplex_class_init(ObjectClass *klass, void *data)
 static const TypeInfo hda_audio_duplex_info = {
     .name          = "hda-duplex",
     .parent        = TYPE_HDA_AUDIO,
-    .instance_size = sizeof(HDAAudioState),
     .class_init    = hda_audio_duplex_class_init,
 };
 
@@ -946,7 +945,6 @@ static void hda_audio_micro_class_init(ObjectClass *klass, void *data)
 static const TypeInfo hda_audio_micro_info = {
     .name          = "hda-micro",
     .parent        = TYPE_HDA_AUDIO,
-    .instance_size = sizeof(HDAAudioState),
     .class_init    = hda_audio_micro_class_init,
 };
 
Signature · 1 line
2.26.2
Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] hda-audio: Set instance_size at base class

In reply to Eduardo Habkost
Quoted 5 lines · Eduardo Habkost

Setting instance_size correctly at the base class will help us avoid mistakes when declaring new subclasses.

---

Quoted 51 lines
---
 hw/audio/hda-codec.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
hw/audio/hda-codec.c +1 -0
index cbd92b72f2..2d16448181 100644
@@ -898,6 +898,7 @@ static void hda_audio_base_class_init(ObjectClass
 *klass, void *data)
 static const TypeInfo hda_audio_info = {
     .name          = TYPE_HDA_AUDIO,
     .parent        = TYPE_HDA_CODEC_DEVICE,
+    .instance_size = sizeof(HDAAudioState),
     .class_init    = hda_audio_base_class_init,
     .abstract      = true,

};

hw/audio/hda-codec.c +0 -4
@@ -914,7 +915,6 @@ static void hda_audio_output_class_init(ObjectClass
 *klass, void *data)
 static const TypeInfo hda_audio_output_info = {
     .name          = "hda-output",
     .parent        = TYPE_HDA_AUDIO,
-    .instance_size = sizeof(HDAAudioState),
     .class_init    = hda_audio_output_class_init,
 };
@@ -930,7 +930,6 @@ static void hda_audio_duplex_class_init(ObjectClass
 *klass, void *data)
 static const TypeInfo hda_audio_duplex_info = {
     .name          = "hda-duplex",
     .parent        = TYPE_HDA_AUDIO,
-    .instance_size = sizeof(HDAAudioState),
     .class_init    = hda_audio_duplex_class_init,
 };
@@ -946,7 +945,6 @@ static void hda_audio_micro_class_init(ObjectClass
 *klass, void *data)
 static const TypeInfo hda_audio_micro_info = {
     .name          = "hda-micro",
     .parent        = TYPE_HDA_AUDIO,
-    .instance_size = sizeof(HDAAudioState),
     .class_init    = hda_audio_micro_class_init,
 };
 
--

2.26.2

#5 lore raw

PATCH 3/4 slavio_misc: Correct instance_size

In reply to Eduardo Habkost

TYPE_APC was using the wrong struct for instance_size. Luckily this never caused any problems because MiscState is larger than APCState.

---
Cc: Mark Cave-Ayland <[email protected]>
Cc: [email protected]

---
 hw/misc/slavio_misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/slavio_misc.c +1 -1
index 279b38dfc7..6d10cd078f 100644
@@ -499,7 +499,7 @@ static const TypeInfo slavio_misc_info = {
 static const TypeInfo apc_info = {
     .name          = TYPE_APC,
     .parent        = TYPE_SYS_BUS_DEVICE,
-    .instance_size = sizeof(MiscState),
+    .instance_size = sizeof(APCState),
     .instance_init = apc_init,
 };
 
Signature · 1 line
2.26.2
#6 lore raw

PATCH 4/4 tls-cipher-suites: Correct instance_size

In reply to Eduardo Habkost

We do have a QCryptoTLSCipherSuites struct. It must be used when setting instance_size of the QOM type. Luckily this never caused problems because the QCryptoTLSCipherSuites struct has only a parent_obj field and nothing else.

---
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: [email protected]

---
 crypto/tls-cipher-suites.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/tls-cipher-suites.c +1 -1
index 0d305b684b..55fb5f7c19 100644
@@ -108,7 +108,7 @@ static void qcrypto_tls_cipher_suites_class_init(ObjectClass *oc, void *data)
 static const TypeInfo qcrypto_tls_cipher_suites_info = {
     .parent = TYPE_QCRYPTO_TLS_CREDS,
     .name = TYPE_QCRYPTO_TLS_CIPHER_SUITES,
-    .instance_size = sizeof(QCryptoTLSCreds),
+    .instance_size = sizeof(QCryptoTLSCipherSuites),
     .class_size = sizeof(QCryptoTLSCredsClass),
     .class_init = qcrypto_tls_cipher_suites_class_init,
     .interfaces = (InterfaceInfo[]) {
Signature · 1 line
2.26.2
Reviewed-by on v1 4/4
#7 lore raw

Re: [PATCH 4/4] tls-cipher-suites: Correct instance_size

Quoted 5 lines · Eduardo Habkost

We do have a QCryptoTLSCipherSuites struct. It must be used when setting instance_size of the QOM type. Luckily this never caused problems because the QCryptoTLSCipherSuites struct has only a parent_obj field and nothing else.

Quoted 7 lines

---
Cc: "Daniel P. Berrangé" <[email protected]>
Cc: [email protected]

---
 crypto/tls-cipher-suites.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|