Skip to contentSkip to conversation

qom: Convert some properties to class properties

PATCH Superseded Eduardo Habkost 12 participants 61 messages Sep 21, 2020 – Nov 2, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover qom: Convert some properties to class properties

Class properties make QOM introspection simpler and easier, as it doesn't require an object to be instantiated. This series converts a few existing object_property_add*() calls to register class properties instead.

Eduardo Habkost (24):
cryptodev-vhost-user: Register "chardev" as class property
cryptodev-backend: Register "chardev" as class property
rng-egd: Register "chardev" as class property
rng-random: register "filename" as class property
vhost-user: Register "chardev" as class property
vexpress: Register "secure" as class property
rng: Register "opened" as class property
vexpress-a15: Register "virtualization" as class property
input-linux: Register properties as class properties
input-barrier: Register properties as class properties
tmp421: Register properties as class properties
s390x: Register all CPU properties as class properties
i386: Register most CPU properties as class properties
i386: Register feature bit properties as class properties arm/virt: Register most properties as class properties
virt: Register "its" as class property
cpu/core: Register core-id and nr-threads as class properties arm/cpu64: Register "aarch64" as class property
xlnx-zcu102: Register properties as class properties
machine: Register "memory-backend" as class property
vga-pci: Register "big-endian-framebuffer" as class property
i440fx: Register i440FX-pcihost properties as class properties
sifive_e: Register "revb" as class property
sifive_u: Register "start-in-flash" as class property

 target/s390x/internal.h         |  1 -
 backends/cryptodev-vhost-user.c | 13 ++---
 backends/cryptodev.c            |  8 +--
 backends/rng-egd.c              |  9 +--
 backends/rng-random.c           |  8 +--
 backends/rng.c                  |  8 +--
 backends/vhost-user.c           |  6 +-
 hw/arm/vexpress.c               | 25 +++++----
 hw/arm/virt.c                   | 88 ++++++++++++++++-------------
 hw/arm/xlnx-zcu102.c            | 25 +++++----
 hw/core/machine.c               | 12 ++--
 hw/cpu/core.c                   |  8 +--
 hw/display/vga-pci.c            | 12 ++--
 hw/misc/tmp421.c                | 30 +++++-----
 hw/pci-host/i440fx.c            | 32 +++++------
 hw/riscv/sifive_e.c             | 11 ++--
 hw/riscv/sifive_u.c             | 16 +++---
 target/arm/cpu64.c              | 16 ++----
 target/i386/cpu.c               | 99 +++++++++++++++++----------------
 target/s390x/cpu.c              |  1 -
 target/s390x/cpu_models.c       | 35 ++++++------
 ui/input-barrier.c              | 44 +++++++--------
 ui/input-linux.c                | 27 ++++-----
 23 files changed, 262 insertions(+), 272 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/24 cryptodev-vhost-user: Register "chardev" as class property

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: "Gonglei (Arei)" <[email protected]>
Cc: [email protected]

---
 backends/cryptodev-vhost-user.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
backends/cryptodev-vhost-user.c +5 -8
index 41089dede15..690738c6c95 100644
@@ -336,13 +336,6 @@ cryptodev_vhost_user_get_chardev(Object *obj, Error **errp)
     return NULL;
 }
 
-static void cryptodev_vhost_user_instance_int(Object *obj)
-{
-    object_property_add_str(obj, "chardev",
-                            cryptodev_vhost_user_get_chardev,
-                            cryptodev_vhost_user_set_chardev);
-}
-
 static void cryptodev_vhost_user_finalize(Object *obj)
 {
     CryptoDevBackendVhostUser *s =
@@ -363,13 +356,17 @@ cryptodev_vhost_user_class_init(ObjectClass *oc, void *data)
     bc->create_session = cryptodev_vhost_user_sym_create_session;
     bc->close_session = cryptodev_vhost_user_sym_close_session;
     bc->do_sym_op = NULL;
+
+    object_class_property_add_str(oc, "chardev",
+                                  cryptodev_vhost_user_get_chardev,
+                                  cryptodev_vhost_user_set_chardev);
+
 }
 
 static const TypeInfo cryptodev_vhost_user_info = {
     .name = TYPE_CRYPTODEV_BACKEND_VHOST_USER,
     .parent = TYPE_CRYPTODEV_BACKEND,
     .class_init = cryptodev_vhost_user_class_init,
-    .instance_init = cryptodev_vhost_user_instance_int,
     .instance_finalize = cryptodev_vhost_user_finalize,
     .instance_size = sizeof(CryptoDevBackendVhostUser),
 };
Signature · 1 line
2.26.2
Reviewed-by on v1 1/24
#2 lore raw

RE: [PATCH 01/24] cryptodev-vhost-user: Register "chardev" as class property

Quoted 12 lines

-----Original Message-----
From: Eduardo Habkost [mailto:[email protected]]
Sent: Tuesday, September 22, 2020 6:10 AM
To: [email protected]
Cc: Paolo Bonzini <[email protected]>; Daniel P. Berrange <[email protected]>; John Snow <[email protected]>; Gonglei (Arei) <[email protected]>
Subject: [PATCH 01/24] cryptodev-vhost-user: Register "chardev" as class property

Quoted 8 lines

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: "Gonglei (Arei)" <[email protected]>
Cc: [email protected]
---

Regards,
-Gonglei

Quoted 43 lines
 backends/cryptodev-vhost-user.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/backends/cryptodev-vhost-user.c index 41089dede15..690738c6c95 100644

backends/cryptodev-vhost-user.c +5 -7
@@ -336,13 +336,6 @@ cryptodev_vhost_user_get_chardev(Object *obj,
 Error **errp)
     return NULL;
 }
 
-static void cryptodev_vhost_user_instance_int(Object *obj) -{
-    object_property_add_str(obj, "chardev",
-                            cryptodev_vhost_user_get_chardev,
-                            cryptodev_vhost_user_set_chardev);
-}
-
 static void cryptodev_vhost_user_finalize(Object *obj)  {
     CryptoDevBackendVhostUser *s =
@@ -363,13 +356,17 @@ cryptodev_vhost_user_class_init(ObjectClass *oc,
 void *data)
     bc->create_session = cryptodev_vhost_user_sym_create_session;
     bc->close_session = cryptodev_vhost_user_sym_close_session;
     bc->do_sym_op = NULL;
+
+    object_class_property_add_str(oc, "chardev",
+                                  cryptodev_vhost_user_get_chardev,
+                                  cryptodev_vhost_user_set_chardev);
+
 }
 
 static const TypeInfo cryptodev_vhost_user_info = {
     .name = TYPE_CRYPTODEV_BACKEND_VHOST_USER,
     .parent = TYPE_CRYPTODEV_BACKEND,
     .class_init = cryptodev_vhost_user_class_init,
-    .instance_init = cryptodev_vhost_user_instance_int,
     .instance_finalize = cryptodev_vhost_user_finalize,
     .instance_size = sizeof(CryptoDevBackendVhostUser),

};
--
2.26.2

#3 lore raw

PATCH 2/24 cryptodev-backend: Register "chardev" as class property

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: "Gonglei (Arei)" <[email protected]>
Cc: [email protected]

---
 backends/cryptodev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
backends/cryptodev.c +4 -4
index ada4ebe78b1..3f141f61ed6 100644
@@ -206,10 +206,6 @@ cryptodev_backend_can_be_deleted(UserCreatable *uc)
 
 static void cryptodev_backend_instance_init(Object *obj)
 {
-    object_property_add(obj, "queues", "uint32",
-                          cryptodev_backend_get_queues,
-                          cryptodev_backend_set_queues,
-                          NULL, NULL);
     /* Initialize devices' queues property to 1 */
     object_property_set_int(obj, "queues", 1, NULL);
 }
@@ -230,6 +226,10 @@ cryptodev_backend_class_init(ObjectClass *oc, void *data)
     ucc->can_be_deleted = cryptodev_backend_can_be_deleted;
 
     QTAILQ_INIT(&crypto_clients);
+    object_class_property_add(oc, "queues", "uint32",
+                              cryptodev_backend_get_queues,
+                              cryptodev_backend_set_queues,
+                              NULL, NULL);
 }
 
 static const TypeInfo cryptodev_backend_info = {
Signature · 1 line
2.26.2
Reviewed-by on v1 2/24
#4 lore raw

RE: [PATCH 02/24] cryptodev-backend: Register "chardev" as class property

Quoted 15 lines

-----Original Message-----
From: Eduardo Habkost [mailto:[email protected]]
Sent: Tuesday, September 22, 2020 6:10 AM
To: [email protected]
Cc: Paolo Bonzini <[email protected]>; Daniel P. Berrange <[email protected]>; John Snow <[email protected]>; Gonglei (Arei) <[email protected]>
Subject: [PATCH 02/24] cryptodev-backend: Register "chardev" as class property

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Quoted 8 lines

---
Cc: "Gonglei (Arei)" <[email protected]>
Cc: [email protected]

---
 backends/cryptodev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Regards,
-Gonglei

Quoted 27 lines
backends/cryptodev.c index renamed from backends/cryptodev.c +0 -0

ada4ebe78b1..3f141f61ed6 100644

backends/cryptodev.c +0 -4
@@ -206,10 +206,6 @@ cryptodev_backend_can_be_deleted(UserCreatable
 *uc)
 
 static void cryptodev_backend_instance_init(Object *obj)  {
-    object_property_add(obj, "queues", "uint32",
-                          cryptodev_backend_get_queues,
-                          cryptodev_backend_set_queues,
-                          NULL, NULL);
     /* Initialize devices' queues property to 1 */
     object_property_set_int(obj, "queues", 1, NULL);  } @@ -230,6 +226,10
 @@ cryptodev_backend_class_init(ObjectClass *oc, void *data)
     ucc->can_be_deleted = cryptodev_backend_can_be_deleted;

     QTAILQ_INIT(&crypto_clients);
backends/cryptodev.c +4 -1
+    object_class_property_add(oc, "queues", "uint32",
+                              cryptodev_backend_get_queues,
+                              cryptodev_backend_set_queues,
+                              NULL, NULL);
 }
 
 static const TypeInfo cryptodev_backend_info = {
--

2.26.2

#5 lore raw

PATCH 3/24 rng-egd: Register "chardev" as class property

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Laurent Vivier <[email protected]>
Cc: Amit Shah <[email protected]>
Cc: [email protected]

---
 backends/rng-egd.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
backends/rng-egd.c +2 -7
index d905fe657c5..d3a8b1ebe2a 100644
@@ -137,12 +137,6 @@ static char *rng_egd_get_chardev(Object *obj, Error **errp)
     return NULL;
 }
 
-static void rng_egd_init(Object *obj)
-{
-    object_property_add_str(obj, "chardev",
-                            rng_egd_get_chardev, rng_egd_set_chardev);
-}
-
 static void rng_egd_finalize(Object *obj)
 {
     RngEgd *s = RNG_EGD(obj);
@@ -157,6 +151,8 @@ 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);
 }
 
 static const TypeInfo rng_egd_info = {
@@ -164,7 +160,6 @@ static const TypeInfo rng_egd_info = {
     .parent = TYPE_RNG_BACKEND,
     .instance_size = sizeof(RngEgd),
     .class_init = rng_egd_class_init,
-    .instance_init = rng_egd_init,
     .instance_finalize = rng_egd_finalize,
 };
 
Signature · 1 line
2.26.2
Reviewed-by on v1 3/24
#6 lore raw

Re: [PATCH 03/24] rng-egd: Register "chardev" as class property

Quoted 11 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Laurent Vivier <[email protected]>
Cc: Amit Shah <[email protected]>
Cc: [email protected]

---
 backends/rng-egd.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

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 :|
#7 lore raw

PATCH 4/24 rng-random: register "filename" as class property

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Laurent Vivier <[email protected]>
Cc: Amit Shah <[email protected]>
Cc: [email protected]

---
 backends/rng-random.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
backends/rng-random.c +4 -4
index 245b12ab245..7add272eddd 100644
@@ -108,10 +108,6 @@ static void rng_random_init(Object *obj)
 {
     RngRandom *s = RNG_RANDOM(obj);
 
-    object_property_add_str(obj, "filename",
-                            rng_random_get_filename,
-                            rng_random_set_filename);
-
     s->filename = g_strdup("/dev/urandom");
     s->fd = -1;
 }
@@ -134,6 +130,10 @@ static void rng_random_class_init(ObjectClass *klass, void *data)
 
     rbc->request_entropy = rng_random_request_entropy;
     rbc->opened = rng_random_opened;
+    object_class_property_add_str(klass, "filename",
+                                  rng_random_get_filename,
+                                  rng_random_set_filename);
+
 }
 
 static const TypeInfo rng_random_info = {
Signature · 1 line
2.26.2
Reviewed-by on v1 4/24
#8 lore raw

Re: [PATCH 04/24] rng-random: register "filename" as class property

Quoted 11 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Laurent Vivier <[email protected]>
Cc: Amit Shah <[email protected]>
Cc: [email protected]

---
 backends/rng-random.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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 :|
#9 lore raw

PATCH 5/24 vhost-user: Register "chardev" as class property

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: [email protected]

---
 backends/vhost-user.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
backends/vhost-user.c +3 -3
index 9e6e1985465..858fdeae26c 100644
@@ -175,9 +175,9 @@ static char *get_chardev(Object *obj, Error **errp)
     return NULL;
 }
 
-static void vhost_user_backend_init(Object *obj)
+static void vhost_user_backend_class_init(ObjectClass *oc, void *data)
 {
-    object_property_add_str(obj, "chardev", get_chardev, set_chardev);
+    object_class_property_add_str(oc, "chardev", get_chardev, set_chardev);
 }
 
 static void vhost_user_backend_finalize(Object *obj)
@@ -195,7 +195,7 @@ static const TypeInfo vhost_user_backend_info = {
     .name = TYPE_VHOST_USER_BACKEND,
     .parent = TYPE_OBJECT,
     .instance_size = sizeof(VhostUserBackend),
-    .instance_init = vhost_user_backend_init,
+    .class_init = vhost_user_backend_class_init,
     .instance_finalize = vhost_user_backend_finalize,
     .class_size = sizeof(VhostUserBackendClass),
 };
Signature · 1 line
2.26.2
Reviewed-by on v1 5/24
#10 lore raw

Re: [PATCH 05/24] vhost-user: Register "chardev" as class property

Quoted 5 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---

Quoted 37 lines
Cc "Michael S. Tsirkin" <[email protected]>
---
 backends/vhost-user.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
backends/vhost-user.c +2 -2
index 9e6e1985465..858fdeae26c 100644
@@ -175,9 +175,9 @@ static char *get_chardev(Object *obj, Error **errp)
     return NULL;
 }
 
-static void vhost_user_backend_init(Object *obj)
+static void vhost_user_backend_class_init(ObjectClass *oc, void *data)
 {
-    object_property_add_str(obj, "chardev", get_chardev, set_chardev);
+    object_class_property_add_str(oc, "chardev", get_chardev,
 set_chardev);
 }
 

static void vhost_user_backend_finalize(Object *obj)

backends/vhost-user.c +1 -2
@@ -195,7 +195,7 @@ static const TypeInfo vhost_user_backend_info = {
     .name = TYPE_VHOST_USER_BACKEND,
     .parent = TYPE_OBJECT,
     .instance_size = sizeof(VhostUserBackend),
-    .instance_init = vhost_user_backend_init,
+    .class_init = vhost_user_backend_class_init,
     .instance_finalize = vhost_user_backend_finalize,
     .class_size = sizeof(VhostUserBackendClass),
 };
--

2.26.2

Signature · 1 line
Marc-André Lureau
Reviewed-by on v1 5/24
#11 lore raw

Re: [PATCH 05/24] vhost-user: Register "chardev" as class property

In reply to Eduardo Habkost
Quoted 4 lines · On Mon, 21 Sep 2020 18:10:26 -0400 Eduardo Habkost <[email protected]> wrote:

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Quoted 32 lines

---
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: [email protected]

---
 backends/vhost-user.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
backends/vhost-user.c +3 -3
index 9e6e1985465..858fdeae26c 100644
@@ -175,9 +175,9 @@ static char *get_chardev(Object *obj, Error **errp)
     return NULL;
 }
 
-static void vhost_user_backend_init(Object *obj)
+static void vhost_user_backend_class_init(ObjectClass *oc, void *data)
 {
-    object_property_add_str(obj, "chardev", get_chardev, set_chardev);
+    object_class_property_add_str(oc, "chardev", get_chardev, set_chardev);
 }
 
 static void vhost_user_backend_finalize(Object *obj)
@@ -195,7 +195,7 @@ static const TypeInfo vhost_user_backend_info = {
     .name = TYPE_VHOST_USER_BACKEND,
     .parent = TYPE_OBJECT,
     .instance_size = sizeof(VhostUserBackend),
-    .instance_init = vhost_user_backend_init,
+    .class_init = vhost_user_backend_class_init,
     .instance_finalize = vhost_user_backend_finalize,
     .class_size = sizeof(VhostUserBackendClass),
 };
Reviewed-by on v1 5/24
#12 lore raw

Re: [PATCH 05/24] vhost-user: Register "chardev" as class property

In reply to Eduardo Habkost
Quoted 4 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Quoted 34 lines

---
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: [email protected]

---
 backends/vhost-user.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
backends/vhost-user.c +3 -3
index 9e6e1985465..858fdeae26c 100644
@@ -175,9 +175,9 @@ static char *get_chardev(Object *obj, Error **errp)
     return NULL;
 }
 
-static void vhost_user_backend_init(Object *obj)
+static void vhost_user_backend_class_init(ObjectClass *oc, void *data)
 {
-    object_property_add_str(obj, "chardev", get_chardev, set_chardev);
+    object_class_property_add_str(oc, "chardev", get_chardev, set_chardev);
 }
 
 static void vhost_user_backend_finalize(Object *obj)
@@ -195,7 +195,7 @@ static const TypeInfo vhost_user_backend_info = {
     .name = TYPE_VHOST_USER_BACKEND,
     .parent = TYPE_OBJECT,
     .instance_size = sizeof(VhostUserBackend),
-    .instance_init = vhost_user_backend_init,
+    .class_init = vhost_user_backend_class_init,
     .instance_finalize = vhost_user_backend_finalize,
     .class_size = sizeof(VhostUserBackendClass),
 };
Signature · 1 line
2.26.2
#13 lore raw

PATCH 6/24 vexpress: Register "secure" as class property

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

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

---
 hw/arm/vexpress.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
hw/arm/vexpress.c +6 -5
index 01bb4bba1ec..0cc35749d7d 100644
@@ -758,11 +758,6 @@ static void vexpress_instance_init(Object *obj)
 
     /* EL3 is enabled by default on vexpress */
     vms->secure = true;
-    object_property_add_bool(obj, "secure", vexpress_get_secure,
-                             vexpress_set_secure);
-    object_property_set_description(obj, "secure",
-                                    "Set on/off to enable/disable the ARM "
-                                    "Security Extensions (TrustZone)");
 }
 
 static void vexpress_a15_instance_init(Object *obj)
@@ -799,6 +794,12 @@ static void vexpress_class_init(ObjectClass *oc, void *data)
     mc->max_cpus = 4;
     mc->ignore_memory_transaction_failures = true;
     mc->default_ram_id = "vexpress.highmem";
+
+    object_class_property_add_bool(oc, "secure", vexpress_get_secure,
+                                   vexpress_set_secure);
+    object_class_property_set_description(oc, "secure",
+                                          "Set on/off to enable/disable the ARM "
+                                          "Security Extensions (TrustZone)");
 }
 
 static void vexpress_a9_class_init(ObjectClass *oc, void *data)
Signature · 1 line
2.26.2
#14 lore raw

PATCH 7/24 rng: Register "opened" as class property

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Laurent Vivier <[email protected]>
Cc: Amit Shah <[email protected]>
Cc: [email protected]

---
 backends/rng.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
backends/rng.c +4 -4
index 484f04e8916..3757b044855 100644
@@ -105,10 +105,6 @@ static void rng_backend_init(Object *obj)
     RngBackend *s = RNG_BACKEND(obj);
 
     QSIMPLEQ_INIT(&s->requests);
-
-    object_property_add_bool(obj, "opened",
-                             rng_backend_prop_get_opened,
-                             rng_backend_prop_set_opened);
 }
 
 static void rng_backend_finalize(Object *obj)
@@ -123,6 +119,10 @@ static void rng_backend_class_init(ObjectClass *oc, void *data)
     UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
 
     ucc->complete = rng_backend_complete;
+
+    object_class_property_add_bool(oc, "opened",
+                                   rng_backend_prop_get_opened,
+                                   rng_backend_prop_set_opened);
 }
 
 static const TypeInfo rng_backend_info = {
Signature · 1 line
2.26.2
Reviewed-by on v1 7/24
#15 lore raw

Re: [PATCH 07/24] rng: Register "opened" as class property

Quoted 11 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Laurent Vivier <[email protected]>
Cc: Amit Shah <[email protected]>
Cc: [email protected]

---
 backends/rng.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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 :|
#16 lore raw

PATCH 8/24 vexpress-a15: Register "virtualization" as class property

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

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

---
 hw/arm/vexpress.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
hw/arm/vexpress.c +8 -6
index 0cc35749d7d..13339302af5 100644
@@ -769,12 +769,6 @@ static void vexpress_a15_instance_init(Object *obj)
      * but can also be specifically set to on or off.
      */
     vms->virt = true;
-    object_property_add_bool(obj, "virtualization", vexpress_get_virt,
-                             vexpress_set_virt);
-    object_property_set_description(obj, "virtualization",
-                                    "Set on/off to enable/disable the ARM "
-                                    "Virtualization Extensions "
-                                    "(defaults to same as 'secure')");
 }
 
 static void vexpress_a9_instance_init(Object *obj)
@@ -822,6 +816,14 @@ static void vexpress_a15_class_init(ObjectClass *oc, void *data)
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
 
     vmc->daughterboard = &a15_daughterboard;
+
+    object_class_property_add_bool(oc, "virtualization", vexpress_get_virt,
+                                   vexpress_set_virt);
+    object_class_property_set_description(oc, "virtualization",
+                                          "Set on/off to enable/disable the ARM "
+                                          "Virtualization Extensions "
+                                          "(defaults to same as 'secure')");
+
 }
 
 static const TypeInfo vexpress_info = {
Signature · 1 line
2.26.2
Reviewed-by on v1 8/24
#17 lore raw

Re: [PATCH 08/24] vexpress-a15: Register "virtualization" as class property

Quoted 4 lines · On Mon, 21 Sep 2020 18:10:29 -0400 Eduardo Habkost <[email protected]> wrote:

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Quoted 40 lines

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

---
 hw/arm/vexpress.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
hw/arm/vexpress.c +8 -6
index 0cc35749d7d..13339302af5 100644
@@ -769,12 +769,6 @@ static void vexpress_a15_instance_init(Object *obj)
      * but can also be specifically set to on or off.
      */
     vms->virt = true;
-    object_property_add_bool(obj, "virtualization", vexpress_get_virt,
-                             vexpress_set_virt);
-    object_property_set_description(obj, "virtualization",
-                                    "Set on/off to enable/disable the ARM "
-                                    "Virtualization Extensions "
-                                    "(defaults to same as 'secure')");
 }
 
 static void vexpress_a9_instance_init(Object *obj)
@@ -822,6 +816,14 @@ static void vexpress_a15_class_init(ObjectClass *oc, void *data)
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
 
     vmc->daughterboard = &a15_daughterboard;
+
+    object_class_property_add_bool(oc, "virtualization", vexpress_get_virt,
+                                   vexpress_set_virt);
+    object_class_property_set_description(oc, "virtualization",
+                                          "Set on/off to enable/disable the ARM "
+                                          "Virtualization Extensions "
+                                          "(defaults to same as 'secure')");
+
 }
 
 static const TypeInfo vexpress_info = {
#18 lore raw

PATCH 9/24 input-linux: Register properties as class properties

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

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

---
 ui/input-linux.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
ui/input-linux.c +14 -13
index 5d501c8360c..cb86774a51e 100644
@@ -489,19 +489,6 @@ static void input_linux_set_grab_toggle(Object *obj, int value,
 
 static void input_linux_instance_init(Object *obj)
 {
-    object_property_add_str(obj, "evdev",
-                            input_linux_get_evdev,
-                            input_linux_set_evdev);
-    object_property_add_bool(obj, "grab_all",
-                             input_linux_get_grab_all,
-                             input_linux_set_grab_all);
-    object_property_add_bool(obj, "repeat",
-                             input_linux_get_repeat,
-                             input_linux_set_repeat);
-    object_property_add_enum(obj, "grab-toggle", "GrabToggleKeys",
-                             &GrabToggleKeys_lookup,
-                             input_linux_get_grab_toggle,
-                             input_linux_set_grab_toggle);
 }
 
 static void input_linux_class_init(ObjectClass *oc, void *data)
@@ -509,6 +496,20 @@ static void input_linux_class_init(ObjectClass *oc, void *data)
     UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
 
     ucc->complete = input_linux_complete;
+
+    object_class_property_add_str(oc, "evdev",
+                                  input_linux_get_evdev,
+                                  input_linux_set_evdev);
+    object_class_property_add_bool(oc, "grab_all",
+                                   input_linux_get_grab_all,
+                                   input_linux_set_grab_all);
+    object_class_property_add_bool(oc, "repeat",
+                                   input_linux_get_repeat,
+                                   input_linux_set_repeat);
+    object_class_property_add_enum(oc, "grab-toggle", "GrabToggleKeys",
+                                   &GrabToggleKeys_lookup,
+                                   input_linux_get_grab_toggle,
+                                   input_linux_set_grab_toggle);
 }
 
 static const TypeInfo input_linux_info = {
Signature · 1 line
2.26.2
Reviewed-by on v1 9/24
#19 lore raw

Re: [PATCH 09/24] input-linux: Register properties as class properties

Quoted 10 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

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

---
 ui/input-linux.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

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 :|
#20 lore raw

PATCH 10/24 input-barrier: Register properties as class properties

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

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

---
 ui/input-barrier.c | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)
ui/input-barrier.c +22 -22
index 87543a33993..9a196d0a33d 100644
@@ -689,28 +689,6 @@ static void input_barrier_instance_init(Object *obj)
     ib->y_origin = 0;
     ib->width = 1920;
     ib->height = 1080;
-
-    object_property_add_str(obj, "name",
-                            input_barrier_get_name,
-                            input_barrier_set_name);
-    object_property_add_str(obj, "server",
-                            input_barrier_get_server,
-                            input_barrier_set_server);
-    object_property_add_str(obj, "port",
-                            input_barrier_get_port,
-                            input_barrier_set_port);
-    object_property_add_str(obj, "x-origin",
-                            input_barrier_get_x_origin,
-                            input_barrier_set_x_origin);
-    object_property_add_str(obj, "y-origin",
-                            input_barrier_get_y_origin,
-                            input_barrier_set_y_origin);
-    object_property_add_str(obj, "width",
-                            input_barrier_get_width,
-                            input_barrier_set_width);
-    object_property_add_str(obj, "height",
-                            input_barrier_get_height,
-                            input_barrier_set_height);
 }
 
 static void input_barrier_class_init(ObjectClass *oc, void *data)
@@ -718,6 +696,28 @@ static void input_barrier_class_init(ObjectClass *oc, void *data)
     UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
 
     ucc->complete = input_barrier_complete;
+
+    object_class_property_add_str(oc, "name",
+                                  input_barrier_get_name,
+                                  input_barrier_set_name);
+    object_class_property_add_str(oc, "server",
+                                  input_barrier_get_server,
+                                  input_barrier_set_server);
+    object_class_property_add_str(oc, "port",
+                                  input_barrier_get_port,
+                                  input_barrier_set_port);
+    object_class_property_add_str(oc, "x-origin",
+                                  input_barrier_get_x_origin,
+                                  input_barrier_set_x_origin);
+    object_class_property_add_str(oc, "y-origin",
+                                  input_barrier_get_y_origin,
+                                  input_barrier_set_y_origin);
+    object_class_property_add_str(oc, "width",
+                                  input_barrier_get_width,
+                                  input_barrier_set_width);
+    object_class_property_add_str(oc, "height",
+                                  input_barrier_get_height,
+                                  input_barrier_set_height);
 }
 
 static const TypeInfo input_barrier_info = {
Signature · 1 line
2.26.2
Reviewed-by on v1 10/24
#21 lore raw

Re: [PATCH 10/24] input-barrier: Register properties as class properties

Quoted 10 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

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

---
 ui/input-barrier.c | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

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 :|
#22 lore raw

PATCH 11/24 tmp421: Register properties as class properties

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: [email protected]

---
 hw/misc/tmp421.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)
hw/misc/tmp421.c +13 -17
index 212d6e0e831..1c19a3a9713 100644
@@ -340,22 +340,6 @@ static void tmp421_realize(DeviceState *dev, Error **errp)
     tmp421_reset(&s->i2c);
 }
 
-static void tmp421_initfn(Object *obj)
-{
-    object_property_add(obj, "temperature0", "int",
-                        tmp421_get_temperature,
-                        tmp421_set_temperature, NULL, NULL);
-    object_property_add(obj, "temperature1", "int",
-                        tmp421_get_temperature,
-                        tmp421_set_temperature, NULL, NULL);
-    object_property_add(obj, "temperature2", "int",
-                        tmp421_get_temperature,
-                        tmp421_set_temperature, NULL, NULL);
-    object_property_add(obj, "temperature3", "int",
-                        tmp421_get_temperature,
-                        tmp421_set_temperature, NULL, NULL);
-}
-
 static void tmp421_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
@@ -368,6 +352,19 @@ static void tmp421_class_init(ObjectClass *klass, void *data)
     k->send = tmp421_tx;
     dc->vmsd = &vmstate_tmp421;
     sc->dev = (DeviceInfo *) data;
+
+    object_class_property_add(klass, "temperature0", "int",
+                              tmp421_get_temperature,
+                              tmp421_set_temperature, NULL, NULL);
+    object_class_property_add(klass, "temperature1", "int",
+                              tmp421_get_temperature,
+                              tmp421_set_temperature, NULL, NULL);
+    object_class_property_add(klass, "temperature2", "int",
+                              tmp421_get_temperature,
+                              tmp421_set_temperature, NULL, NULL);
+    object_class_property_add(klass, "temperature3", "int",
+                              tmp421_get_temperature,
+                              tmp421_set_temperature, NULL, NULL);
 }
 
 static const TypeInfo tmp421_info = {
@@ -375,7 +372,6 @@ static const TypeInfo tmp421_info = {
     .parent        = TYPE_I2C_SLAVE,
     .instance_size = sizeof(TMP421State),
     .class_size    = sizeof(TMP421Class),
-    .instance_init = tmp421_initfn,
     .abstract      = true,
 };
 
Signature · 1 line
2.26.2
Reviewed-by on v1 11/24
#23 lore raw

Re: [PATCH 11/24] tmp421: Register properties as class properties

Quoted 4 lines · On Mon, 21 Sep 2020 18:10:32 -0400 Eduardo Habkost <[email protected]> wrote:

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Quoted 61 lines

---
Cc: [email protected]

---
 hw/misc/tmp421.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)
hw/misc/tmp421.c +13 -17
index 212d6e0e831..1c19a3a9713 100644
@@ -340,22 +340,6 @@ static void tmp421_realize(DeviceState *dev, Error **errp)
     tmp421_reset(&s->i2c);
 }
 
-static void tmp421_initfn(Object *obj)
-{
-    object_property_add(obj, "temperature0", "int",
-                        tmp421_get_temperature,
-                        tmp421_set_temperature, NULL, NULL);
-    object_property_add(obj, "temperature1", "int",
-                        tmp421_get_temperature,
-                        tmp421_set_temperature, NULL, NULL);
-    object_property_add(obj, "temperature2", "int",
-                        tmp421_get_temperature,
-                        tmp421_set_temperature, NULL, NULL);
-    object_property_add(obj, "temperature3", "int",
-                        tmp421_get_temperature,
-                        tmp421_set_temperature, NULL, NULL);
-}
-
 static void tmp421_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
@@ -368,6 +352,19 @@ static void tmp421_class_init(ObjectClass *klass, void *data)
     k->send = tmp421_tx;
     dc->vmsd = &vmstate_tmp421;
     sc->dev = (DeviceInfo *) data;
+
+    object_class_property_add(klass, "temperature0", "int",
+                              tmp421_get_temperature,
+                              tmp421_set_temperature, NULL, NULL);
+    object_class_property_add(klass, "temperature1", "int",
+                              tmp421_get_temperature,
+                              tmp421_set_temperature, NULL, NULL);
+    object_class_property_add(klass, "temperature2", "int",
+                              tmp421_get_temperature,
+                              tmp421_set_temperature, NULL, NULL);
+    object_class_property_add(klass, "temperature3", "int",
+                              tmp421_get_temperature,
+                              tmp421_set_temperature, NULL, NULL);
 }
 
 static const TypeInfo tmp421_info = {
@@ -375,7 +372,6 @@ static const TypeInfo tmp421_info = {
     .parent        = TYPE_I2C_SLAVE,
     .instance_size = sizeof(TMP421State),
     .class_size    = sizeof(TMP421Class),
-    .instance_init = tmp421_initfn,
     .abstract      = true,
 };
 
#24 lore raw

PATCH 12/24 s390x: Register all CPU properties as class properties

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Cornelia Huck <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Halil Pasic <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 target/s390x/internal.h   |  1 -
 target/s390x/cpu.c        |  1 -
 target/s390x/cpu_models.c | 35 ++++++++++++++++-------------------
 3 files changed, 16 insertions(+), 21 deletions(-)
target/s390x/internal.h +0 -1
index b1e0ebf67f8..bac0d3c67b2 100644
@@ -260,7 +260,6 @@ static inline void s390_cpu_unhalt(S390CPU *cpu)
 
 
 /* cpu_models.c */
-void s390_cpu_model_register_props(Object *obj);
 void s390_cpu_model_class_register_props(ObjectClass *oc);
 void s390_realize_cpu_model(CPUState *cs, Error **errp);
 ObjectClass *s390_cpu_class_by_name(const char *name);
target/s390x/cpu.c +0 -1
index 749cd548f0f..1dc45ca11b9 100644
@@ -302,7 +302,6 @@ static void s390_cpu_initfn(Object *obj)
         timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu);
     s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu);
 #endif
-    s390_cpu_model_register_props(obj);
 }
 
 static void s390_cpu_finalize(Object *obj)
target/s390x/cpu_models.c +16 -19
index c2af2261743..b97e9596ab0 100644
@@ -1089,25 +1089,6 @@ static void set_feature_group(Object *obj, Visitor *v, const char *name,
     }
 }
 
-void s390_cpu_model_register_props(Object *obj)
-{
-    S390FeatGroup group;
-    S390Feat feat;
-
-    for (feat = 0; feat < S390_FEAT_MAX; feat++) {
-        const S390FeatDef *def = s390_feat_def(feat);
-        object_property_add(obj, def->name, "bool", get_feature,
-                            set_feature, NULL, (void *) feat);
-        object_property_set_description(obj, def->name, def->desc);
-    }
-    for (group = 0; group < S390_FEAT_GROUP_MAX; group++) {
-        const S390FeatGroupDef *def = s390_feat_group_def(group);
-        object_property_add(obj, def->name, "bool", get_feature_group,
-                            set_feature_group, NULL, (void *) group);
-        object_property_set_description(obj, def->name, def->desc);
-    }
-}
-
 static void s390_cpu_model_initfn(Object *obj)
 {
     S390CPU *cpu = S390_CPU(obj);
@@ -1215,11 +1196,27 @@ static char *get_description(Object *obj, Error **errp)
 
 void s390_cpu_model_class_register_props(ObjectClass *oc)
 {
+    S390FeatGroup group;
+    S390Feat feat;
+
     object_class_property_add_bool(oc, "migration-safe", get_is_migration_safe,
                                    NULL);
     object_class_property_add_bool(oc, "static", get_is_static,
                                    NULL);
     object_class_property_add_str(oc, "description", get_description, NULL);
+
+    for (feat = 0; feat < S390_FEAT_MAX; feat++) {
+        const S390FeatDef *def = s390_feat_def(feat);
+        object_class_property_add(oc, def->name, "bool", get_feature,
+                                  set_feature, NULL, (void *) feat);
+        object_class_property_set_description(oc, def->name, def->desc);
+    }
+    for (group = 0; group < S390_FEAT_GROUP_MAX; group++) {
+        const S390FeatGroupDef *def = s390_feat_group_def(group);
+        object_class_property_add(oc, def->name, "bool", get_feature_group,
+                                  set_feature_group, NULL, (void *) group);
+        object_class_property_set_description(oc, def->name, def->desc);
+    }
 }
 
 #ifdef CONFIG_KVM
Signature · 1 line
2.26.2
Reviewed-by on v1 12/24
#25 lore raw

Re: [PATCH 12/24] s390x: Register all CPU properties as class properties

Quoted 88 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Cornelia Huck <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Halil Pasic <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 target/s390x/internal.h   |  1 -
 target/s390x/cpu.c        |  1 -
 target/s390x/cpu_models.c | 35 ++++++++++++++++-------------------
 3 files changed, 16 insertions(+), 21 deletions(-)
target/s390x/internal.h +0 -1
index b1e0ebf67f8..bac0d3c67b2 100644
@@ -260,7 +260,6 @@ static inline void s390_cpu_unhalt(S390CPU *cpu)
 
 
 /* cpu_models.c */
-void s390_cpu_model_register_props(Object *obj);
 void s390_cpu_model_class_register_props(ObjectClass *oc);
 void s390_realize_cpu_model(CPUState *cs, Error **errp);
 ObjectClass *s390_cpu_class_by_name(const char *name);
target/s390x/cpu.c +0 -1
index 749cd548f0f..1dc45ca11b9 100644
@@ -302,7 +302,6 @@ static void s390_cpu_initfn(Object *obj)
         timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu);
     s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu);
 #endif
-    s390_cpu_model_register_props(obj);
 }
 
 static void s390_cpu_finalize(Object *obj)
target/s390x/cpu_models.c +6 -19
index c2af2261743..b97e9596ab0 100644
@@ -1089,25 +1089,6 @@ static void set_feature_group(Object *obj, Visitor *v, const char *name,
     }
 }
 
-void s390_cpu_model_register_props(Object *obj)
-{
-    S390FeatGroup group;
-    S390Feat feat;
-
-    for (feat = 0; feat < S390_FEAT_MAX; feat++) {
-        const S390FeatDef *def = s390_feat_def(feat);
-        object_property_add(obj, def->name, "bool", get_feature,
-                            set_feature, NULL, (void *) feat);
-        object_property_set_description(obj, def->name, def->desc);
-    }
-    for (group = 0; group < S390_FEAT_GROUP_MAX; group++) {
-        const S390FeatGroupDef *def = s390_feat_group_def(group);
-        object_property_add(obj, def->name, "bool", get_feature_group,
-                            set_feature_group, NULL, (void *) group);
-        object_property_set_description(obj, def->name, def->desc);
-    }
-}
-
 static void s390_cpu_model_initfn(Object *obj)
 {
     S390CPU *cpu = S390_CPU(obj);
@@ -1215,11 +1196,27 @@ static char *get_description(Object *obj, Error **errp)
 
 void s390_cpu_model_class_register_props(ObjectClass *oc)
 {
+    S390FeatGroup group;
+    S390Feat feat;
+
     object_class_property_add_bool(oc, "migration-safe", get_is_migration_safe,
                                    NULL);
     object_class_property_add_bool(oc, "static", get_is_static,
                                    NULL);
     object_class_property_add_str(oc, "description", get_description, NULL);
+
+    for (feat = 0; feat < S390_FEAT_MAX; feat++) {
+        const S390FeatDef *def = s390_feat_def(feat);

target/s390x/cpu_models.c static char *get_description(Object *obj, Error **errp) · line 1219

Quoted 10 lines
target/s390x/cpu_models.c +10 -0
+        object_class_property_add(oc, def->name, "bool", get_feature,
+                                  set_feature, NULL, (void *) feat);
+        object_class_property_set_description(oc, def->name, def->desc);
+    }
+    for (group = 0; group < S390_FEAT_GROUP_MAX; group++) {
+        const S390FeatGroupDef *def = s390_feat_group_def(group);
+        object_class_property_add(oc, def->name, "bool", get_feature_group,
+                                  set_feature_group, NULL, (void *) group);
+        object_class_property_set_description(oc, def->name, def->desc);
+    }

It would be even nicer to only register what's actually valid for a CPU generation - but it's tricky for host/max, where that is determined later at runtime.

Signature · 3 lines
Thanks,

David / dhildenb
Acked-by on v1 12/24
#26 lore raw

Re: [PATCH 12/24] s390x: Register all CPU properties as class properties

In reply to Eduardo Habkost
Quoted 13 lines · On Mon, 21 Sep 2020 18:10:33 -0400 Eduardo Habkost <[email protected]> wrote:

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Cornelia Huck <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Halil Pasic <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: [email protected]
Cc: [email protected]

Quoted 5 lines
---
 target/s390x/internal.h   |  1 -
 target/s390x/cpu.c        |  1 -
 target/s390x/cpu_models.c | 35 ++++++++++++++++-------------------
 3 files changed, 16 insertions(+), 21 deletions(-)

I presume that this patch is supposed to go with the complete series? (Have not looked.)

#27 lore raw

PATCH 13/24 i386: Register most CPU properties as class properties

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]

---
 target/i386/cpu.c | 66 ++++++++++++++++++++++++-----------------------
 1 file changed, 34 insertions(+), 32 deletions(-)
target/i386/cpu.c +34 -32
index 1c58f764dcb..66792f28ba7 100644
@@ -6922,44 +6922,12 @@ static void x86_cpu_initfn(Object *obj)
     env->nr_dies = 1;
     cpu_set_cpustate_pointers(cpu);
 
-    object_property_add(obj, "family", "int",
-                        x86_cpuid_version_get_family,
-                        x86_cpuid_version_set_family, NULL, NULL);
-    object_property_add(obj, "model", "int",
-                        x86_cpuid_version_get_model,
-                        x86_cpuid_version_set_model, NULL, NULL);
-    object_property_add(obj, "stepping", "int",
-                        x86_cpuid_version_get_stepping,
-                        x86_cpuid_version_set_stepping, NULL, NULL);
-    object_property_add_str(obj, "vendor",
-                            x86_cpuid_get_vendor,
-                            x86_cpuid_set_vendor);
-    object_property_add_str(obj, "model-id",
-                            x86_cpuid_get_model_id,
-                            x86_cpuid_set_model_id);
-    object_property_add(obj, "tsc-frequency", "int",
-                        x86_cpuid_get_tsc_freq,
-                        x86_cpuid_set_tsc_freq, NULL, NULL);
     object_property_add(obj, "feature-words", "X86CPUFeatureWordInfo",
                         x86_cpu_get_feature_words,
                         NULL, NULL, (void *)env->features);
     object_property_add(obj, "filtered-features", "X86CPUFeatureWordInfo",
                         x86_cpu_get_feature_words,
                         NULL, NULL, (void *)cpu->filtered_features);
-    /*
-     * The "unavailable-features" property has the same semantics as
-     * CpuDefinitionInfo.unavailable-features on the "query-cpu-definitions"
-     * QMP command: they list the features that would have prevented the
-     * CPU from running if the "enforce" flag was set.
-     */
-    object_property_add(obj, "unavailable-features", "strList",
-                        x86_cpu_get_unavailable_features,
-                        NULL, NULL, NULL);
-
-#if !defined(CONFIG_USER_ONLY)
-    object_property_add(obj, "crash-information", "GuestPanicInformation",
-                        x86_cpu_get_crash_info_qom, NULL, NULL, NULL);
-#endif
 
     for (w = 0; w < FEATURE_WORDS; w++) {
         int bitnr;
@@ -7308,6 +7276,40 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     cc->disas_set_info = x86_disas_set_info;
 
     dc->user_creatable = true;
+
+    object_class_property_add(oc, "family", "int",
+                              x86_cpuid_version_get_family,
+                              x86_cpuid_version_set_family, NULL, NULL);
+    object_class_property_add(oc, "model", "int",
+                              x86_cpuid_version_get_model,
+                              x86_cpuid_version_set_model, NULL, NULL);
+    object_class_property_add(oc, "stepping", "int",
+                              x86_cpuid_version_get_stepping,
+                              x86_cpuid_version_set_stepping, NULL, NULL);
+    object_class_property_add_str(oc, "vendor",
+                                  x86_cpuid_get_vendor,
+                                  x86_cpuid_set_vendor);
+    object_class_property_add_str(oc, "model-id",
+                                  x86_cpuid_get_model_id,
+                                  x86_cpuid_set_model_id);
+    object_class_property_add(oc, "tsc-frequency", "int",
+                              x86_cpuid_get_tsc_freq,
+                              x86_cpuid_set_tsc_freq, NULL, NULL);
+    /*
+     * The "unavailable-features" property has the same semantics as
+     * CpuDefinitionInfo.unavailable-features on the "query-cpu-definitions"
+     * QMP command: they list the features that would have prevented the
+     * CPU from running if the "enforce" flag was set.
+     */
+    object_class_property_add(oc, "unavailable-features", "strList",
+                              x86_cpu_get_unavailable_features,
+                              NULL, NULL, NULL);
+
+#if !defined(CONFIG_USER_ONLY)
+    object_class_property_add(oc, "crash-information", "GuestPanicInformation",
+                              x86_cpu_get_crash_info_qom, NULL, NULL, NULL);
+#endif
+
 }
 
 static const TypeInfo x86_cpu_type_info = {
Signature · 1 line
2.26.2
#28 lore raw

Re: [PATCH 13/24] i386: Register most CPU properties as class properties

Quoted 37 lines · On Mon, 21 Sep 2020 18:10:34 -0400 Eduardo Habkost <[email protected]> wrote:

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]

---
 target/i386/cpu.c | 66 ++++++++++++++++++++++++-----------------------
 1 file changed, 34 insertions(+), 32 deletions(-)
target/i386/cpu.c +0 -16
index 1c58f764dcb..66792f28ba7 100644
@@ -6922,44 +6922,12 @@ static void x86_cpu_initfn(Object *obj)
     env->nr_dies = 1;
     cpu_set_cpustate_pointers(cpu);
 
-    object_property_add(obj, "family", "int",
-                        x86_cpuid_version_get_family,
-                        x86_cpuid_version_set_family, NULL, NULL);
-    object_property_add(obj, "model", "int",
-                        x86_cpuid_version_get_model,
-                        x86_cpuid_version_set_model, NULL, NULL);
-    object_property_add(obj, "stepping", "int",
-                        x86_cpuid_version_get_stepping,
-                        x86_cpuid_version_set_stepping, NULL, NULL);
-    object_property_add_str(obj, "vendor",
-                            x86_cpuid_get_vendor,
-                            x86_cpuid_set_vendor);
-    object_property_add_str(obj, "model-id",
-                            x86_cpuid_get_model_id,
-                            x86_cpuid_set_model_id);
-    object_property_add(obj, "tsc-frequency", "int",

target/i386/cpu.c static void x86_cpu_initfn(Object *obj) · line 6932

Quoted 10 lines
target/i386/cpu.c +0 -2
-                        x86_cpuid_get_tsc_freq,
-                        x86_cpuid_set_tsc_freq, NULL, NULL);
 
 
     object_property_add(obj, "feature-words", "X86CPUFeatureWordInfo",
                         x86_cpu_get_feature_words,
                         NULL, NULL, (void *)env->features);
     object_property_add(obj, "filtered-features", "X86CPUFeatureWordInfo",
                         x86_cpu_get_feature_words,
                         NULL, NULL, (void *)cpu->filtered_features);

I'm just curious why these weren't moved as well?

Quoted 58 lines
target/i386/cpu.c +0 -14
-    /*
-     * The "unavailable-features" property has the same semantics as
-     * CpuDefinitionInfo.unavailable-features on the "query-cpu-definitions"
-     * QMP command: they list the features that would have prevented the
-     * CPU from running if the "enforce" flag was set.
-     */
-    object_property_add(obj, "unavailable-features", "strList",
-                        x86_cpu_get_unavailable_features,
-                        NULL, NULL, NULL);
-
-#if !defined(CONFIG_USER_ONLY)
-    object_property_add(obj, "crash-information", "GuestPanicInformation",
-                        x86_cpu_get_crash_info_qom, NULL, NULL, NULL);
-#endif
 
     for (w = 0; w < FEATURE_WORDS; w++) {
         int bitnr;
target/i386/cpu.c +34 -0
@@ -7308,6 +7276,40 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     cc->disas_set_info = x86_disas_set_info;
 
     dc->user_creatable = true;
+
+    object_class_property_add(oc, "family", "int",
+                              x86_cpuid_version_get_family,
+                              x86_cpuid_version_set_family, NULL, NULL);
+    object_class_property_add(oc, "model", "int",
+                              x86_cpuid_version_get_model,
+                              x86_cpuid_version_set_model, NULL, NULL);
+    object_class_property_add(oc, "stepping", "int",
+                              x86_cpuid_version_get_stepping,
+                              x86_cpuid_version_set_stepping, NULL, NULL);
+    object_class_property_add_str(oc, "vendor",
+                                  x86_cpuid_get_vendor,
+                                  x86_cpuid_set_vendor);
+    object_class_property_add_str(oc, "model-id",
+                                  x86_cpuid_get_model_id,
+                                  x86_cpuid_set_model_id);
+    object_class_property_add(oc, "tsc-frequency", "int",
+                              x86_cpuid_get_tsc_freq,
+                              x86_cpuid_set_tsc_freq, NULL, NULL);
+    /*
+     * The "unavailable-features" property has the same semantics as
+     * CpuDefinitionInfo.unavailable-features on the "query-cpu-definitions"
+     * QMP command: they list the features that would have prevented the
+     * CPU from running if the "enforce" flag was set.
+     */
+    object_class_property_add(oc, "unavailable-features", "strList",
+                              x86_cpu_get_unavailable_features,
+                              NULL, NULL, NULL);
+
+#if !defined(CONFIG_USER_ONLY)
+    object_class_property_add(oc, "crash-information", "GuestPanicInformation",
+                              x86_cpu_get_crash_info_qom, NULL, NULL, NULL);
+#endif
+
 }
 
 static const TypeInfo x86_cpu_type_info = {
#29 lore raw

Re: [PATCH 13/24] i386: Register most CPU properties as class properties

Quoted 44 lines · Igor Mammedov
Quoted 39 lines · On Mon, 21 Sep 2020 18:10:34 -0400 Eduardo Habkost <[email protected]> wrote:

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]

---
 target/i386/cpu.c | 66 ++++++++++++++++++++++++-----------------------
 1 file changed, 34 insertions(+), 32 deletions(-)
target/i386/cpu.c +0 -18
index 1c58f764dcb..66792f28ba7 100644
@@ -6922,44 +6922,12 @@ static void x86_cpu_initfn(Object *obj)
     env->nr_dies = 1;
     cpu_set_cpustate_pointers(cpu);
 
-    object_property_add(obj, "family", "int",
-                        x86_cpuid_version_get_family,
-                        x86_cpuid_version_set_family, NULL, NULL);
-    object_property_add(obj, "model", "int",
-                        x86_cpuid_version_get_model,
-                        x86_cpuid_version_set_model, NULL, NULL);
-    object_property_add(obj, "stepping", "int",
-                        x86_cpuid_version_get_stepping,
-                        x86_cpuid_version_set_stepping, NULL, NULL);
-    object_property_add_str(obj, "vendor",
-                            x86_cpuid_get_vendor,
-                            x86_cpuid_set_vendor);
-    object_property_add_str(obj, "model-id",
-                            x86_cpuid_get_model_id,
-                            x86_cpuid_set_model_id);
-    object_property_add(obj, "tsc-frequency", "int",
-                        x86_cpuid_get_tsc_freq,
-                        x86_cpuid_set_tsc_freq, NULL, NULL);
Quoted 8 lines

target/i386/cpu.c static void x86_cpu_initfn(Object *obj) · line 6930

Quoted 6 lines
target/i386/cpu.c +0 -0
     object_property_add(obj, "feature-words", "X86CPUFeatureWordInfo",
                         x86_cpu_get_feature_words,
                         NULL, NULL, (void *)env->features);
     object_property_add(obj, "filtered-features", "X86CPUFeatureWordInfo",
                         x86_cpu_get_feature_words,
                         NULL, NULL, (void *)cpu->filtered_features);

I'm just curious why these weren't moved as well?

Because of the (void*) arguments that need a pointer to the instance.

Signature · 1 line
Eduardo
Reviewed-by on v1 13/24
#30 lore raw

Re: [PATCH 13/24] i386: Register most CPU properties as class properties

In reply to Eduardo Habkost
Quoted 4 lines · On Mon, 21 Sep 2020 18:10:34 -0400 Eduardo Habkost <[email protected]> wrote:

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Quoted 99 lines

---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]

---
 target/i386/cpu.c | 66 ++++++++++++++++++++++++-----------------------
 1 file changed, 34 insertions(+), 32 deletions(-)
target/i386/cpu.c +34 -32
index 1c58f764dcb..66792f28ba7 100644
@@ -6922,44 +6922,12 @@ static void x86_cpu_initfn(Object *obj)
     env->nr_dies = 1;
     cpu_set_cpustate_pointers(cpu);
 
-    object_property_add(obj, "family", "int",
-                        x86_cpuid_version_get_family,
-                        x86_cpuid_version_set_family, NULL, NULL);
-    object_property_add(obj, "model", "int",
-                        x86_cpuid_version_get_model,
-                        x86_cpuid_version_set_model, NULL, NULL);
-    object_property_add(obj, "stepping", "int",
-                        x86_cpuid_version_get_stepping,
-                        x86_cpuid_version_set_stepping, NULL, NULL);
-    object_property_add_str(obj, "vendor",
-                            x86_cpuid_get_vendor,
-                            x86_cpuid_set_vendor);
-    object_property_add_str(obj, "model-id",
-                            x86_cpuid_get_model_id,
-                            x86_cpuid_set_model_id);
-    object_property_add(obj, "tsc-frequency", "int",
-                        x86_cpuid_get_tsc_freq,
-                        x86_cpuid_set_tsc_freq, NULL, NULL);
     object_property_add(obj, "feature-words", "X86CPUFeatureWordInfo",
                         x86_cpu_get_feature_words,
                         NULL, NULL, (void *)env->features);
     object_property_add(obj, "filtered-features", "X86CPUFeatureWordInfo",
                         x86_cpu_get_feature_words,
                         NULL, NULL, (void *)cpu->filtered_features);
-    /*
-     * The "unavailable-features" property has the same semantics as
-     * CpuDefinitionInfo.unavailable-features on the "query-cpu-definitions"
-     * QMP command: they list the features that would have prevented the
-     * CPU from running if the "enforce" flag was set.
-     */
-    object_property_add(obj, "unavailable-features", "strList",
-                        x86_cpu_get_unavailable_features,
-                        NULL, NULL, NULL);
-
-#if !defined(CONFIG_USER_ONLY)
-    object_property_add(obj, "crash-information", "GuestPanicInformation",
-                        x86_cpu_get_crash_info_qom, NULL, NULL, NULL);
-#endif
 
     for (w = 0; w < FEATURE_WORDS; w++) {
         int bitnr;
@@ -7308,6 +7276,40 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     cc->disas_set_info = x86_disas_set_info;
 
     dc->user_creatable = true;
+
+    object_class_property_add(oc, "family", "int",
+                              x86_cpuid_version_get_family,
+                              x86_cpuid_version_set_family, NULL, NULL);
+    object_class_property_add(oc, "model", "int",
+                              x86_cpuid_version_get_model,
+                              x86_cpuid_version_set_model, NULL, NULL);
+    object_class_property_add(oc, "stepping", "int",
+                              x86_cpuid_version_get_stepping,
+                              x86_cpuid_version_set_stepping, NULL, NULL);
+    object_class_property_add_str(oc, "vendor",
+                                  x86_cpuid_get_vendor,
+                                  x86_cpuid_set_vendor);
+    object_class_property_add_str(oc, "model-id",
+                                  x86_cpuid_get_model_id,
+                                  x86_cpuid_set_model_id);
+    object_class_property_add(oc, "tsc-frequency", "int",
+                              x86_cpuid_get_tsc_freq,
+                              x86_cpuid_set_tsc_freq, NULL, NULL);
+    /*
+     * The "unavailable-features" property has the same semantics as
+     * CpuDefinitionInfo.unavailable-features on the "query-cpu-definitions"
+     * QMP command: they list the features that would have prevented the
+     * CPU from running if the "enforce" flag was set.
+     */
+    object_class_property_add(oc, "unavailable-features", "strList",
+                              x86_cpu_get_unavailable_features,
+                              NULL, NULL, NULL);
+
+#if !defined(CONFIG_USER_ONLY)
+    object_class_property_add(oc, "crash-information", "GuestPanicInformation",
+                              x86_cpu_get_crash_info_qom, NULL, NULL, NULL);
+#endif
+
 }
 
 static const TypeInfo x86_cpu_type_info = {
#31 lore raw

PATCH 14/24 i386: Register feature bit properties as class properties

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]

---
 target/i386/cpu.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)
target/i386/cpu.c +16 -17
index 66792f28ba7..1aba87e0a5b 100644
@@ -6819,16 +6819,17 @@ static void x86_cpu_release_bit_prop(Object *obj, const char *name,
  * multiple bits in the same FeatureWord. In that case, the getter will return
  * true only if all bits are set.
  */
-static void x86_cpu_register_bit_prop(X86CPU *cpu,
+static void x86_cpu_register_bit_prop(X86CPUClass *xcc,
                                       const char *prop_name,
                                       FeatureWord w,
                                       int bitnr)
 {
+    ObjectClass *oc = OBJECT_CLASS(xcc);
     BitProperty *fp;
     ObjectProperty *op;
     uint64_t mask = (1ULL << bitnr);
 
-    op = object_property_find(OBJECT(cpu), prop_name, NULL);
+    op = object_class_property_find(oc, prop_name, NULL);
     if (op) {
         fp = op->opaque;
         assert(fp->w == w);
@@ -6837,14 +6838,14 @@ static void x86_cpu_register_bit_prop(X86CPU *cpu,
         fp = g_new0(BitProperty, 1);
         fp->w = w;
         fp->mask = mask;
-        object_property_add(OBJECT(cpu), prop_name, "bool",
-                            x86_cpu_get_bit_prop,
-                            x86_cpu_set_bit_prop,
-                            x86_cpu_release_bit_prop, fp);
+        object_class_property_add(oc, prop_name, "bool",
+                                  x86_cpu_get_bit_prop,
+                                  x86_cpu_set_bit_prop,
+                                  x86_cpu_release_bit_prop, fp);
     }
 }
 
-static void x86_cpu_register_feature_bit_props(X86CPU *cpu,
+static void x86_cpu_register_feature_bit_props(X86CPUClass *xcc,
                                                FeatureWord w,
                                                int bitnr)
 {
@@ -6863,7 +6864,7 @@ static void x86_cpu_register_feature_bit_props(X86CPU *cpu,
     /* aliases don't use "|" delimiters anymore, they are registered
      * manually using object_property_add_alias() */
     assert(!strchr(name, '|'));
-    x86_cpu_register_bit_prop(cpu, name, w, bitnr);
+    x86_cpu_register_bit_prop(xcc, name, w, bitnr);
 }
 
 #if !defined(CONFIG_USER_ONLY)
@@ -6917,7 +6918,6 @@ static void x86_cpu_initfn(Object *obj)
     X86CPU *cpu = X86_CPU(obj);
     X86CPUClass *xcc = X86_CPU_GET_CLASS(obj);
     CPUX86State *env = &cpu->env;
-    FeatureWord w;
 
     env->nr_dies = 1;
     cpu_set_cpustate_pointers(cpu);
@@ -6929,14 +6929,6 @@ static void x86_cpu_initfn(Object *obj)
                         x86_cpu_get_feature_words,
                         NULL, NULL, (void *)cpu->filtered_features);
 
-    for (w = 0; w < FEATURE_WORDS; w++) {
-        int bitnr;
-
-        for (bitnr = 0; bitnr < 64; bitnr++) {
-            x86_cpu_register_feature_bit_props(cpu, w, bitnr);
-        }
-    }
-
     object_property_add_alias(obj, "sse3", obj, "pni");
     object_property_add_alias(obj, "pclmuldq", obj, "pclmulqdq");
     object_property_add_alias(obj, "sse4-1", obj, "sse4.1");
@@ -7221,6 +7213,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     X86CPUClass *xcc = X86_CPU_CLASS(oc);
     CPUClass *cc = CPU_CLASS(oc);
     DeviceClass *dc = DEVICE_CLASS(oc);
+    FeatureWord w;
 
     device_class_set_parent_realize(dc, x86_cpu_realizefn,
                                     &xcc->parent_realize);
@@ -7310,6 +7303,12 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
                               x86_cpu_get_crash_info_qom, NULL, NULL, NULL);
 #endif
 
+    for (w = 0; w < FEATURE_WORDS; w++) {
+        int bitnr;
+        for (bitnr = 0; bitnr < 64; bitnr++) {
+            x86_cpu_register_feature_bit_props(xcc, w, bitnr);
+        }
+    }
 }
 
 static const TypeInfo x86_cpu_type_info = {
Signature · 1 line
2.26.2
Reviewed-by on v1 14/24
#32 lore raw

Re: [PATCH 14/24] i386: Register feature bit properties as class properties

Quoted 9 lines · On Mon, 21 Sep 2020 18:10:35 -0400 Eduardo Habkost <[email protected]> wrote:

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]

Quoted 101 lines
---
 target/i386/cpu.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)
target/i386/cpu.c +16 -17
index 66792f28ba7..1aba87e0a5b 100644
@@ -6819,16 +6819,17 @@ static void x86_cpu_release_bit_prop(Object *obj, const char *name,
  * multiple bits in the same FeatureWord. In that case, the getter will return
  * true only if all bits are set.
  */
-static void x86_cpu_register_bit_prop(X86CPU *cpu,
+static void x86_cpu_register_bit_prop(X86CPUClass *xcc,
                                       const char *prop_name,
                                       FeatureWord w,
                                       int bitnr)
 {
+    ObjectClass *oc = OBJECT_CLASS(xcc);
     BitProperty *fp;
     ObjectProperty *op;
     uint64_t mask = (1ULL << bitnr);
 
-    op = object_property_find(OBJECT(cpu), prop_name, NULL);
+    op = object_class_property_find(oc, prop_name, NULL);
     if (op) {
         fp = op->opaque;
         assert(fp->w == w);
@@ -6837,14 +6838,14 @@ static void x86_cpu_register_bit_prop(X86CPU *cpu,
         fp = g_new0(BitProperty, 1);
         fp->w = w;
         fp->mask = mask;
-        object_property_add(OBJECT(cpu), prop_name, "bool",
-                            x86_cpu_get_bit_prop,
-                            x86_cpu_set_bit_prop,
-                            x86_cpu_release_bit_prop, fp);
+        object_class_property_add(oc, prop_name, "bool",
+                                  x86_cpu_get_bit_prop,
+                                  x86_cpu_set_bit_prop,
+                                  x86_cpu_release_bit_prop, fp);
     }
 }
 
-static void x86_cpu_register_feature_bit_props(X86CPU *cpu,
+static void x86_cpu_register_feature_bit_props(X86CPUClass *xcc,
                                                FeatureWord w,
                                                int bitnr)
 {
@@ -6863,7 +6864,7 @@ static void x86_cpu_register_feature_bit_props(X86CPU *cpu,
     /* aliases don't use "|" delimiters anymore, they are registered
      * manually using object_property_add_alias() */
     assert(!strchr(name, '|'));
-    x86_cpu_register_bit_prop(cpu, name, w, bitnr);
+    x86_cpu_register_bit_prop(xcc, name, w, bitnr);
 }
 
 #if !defined(CONFIG_USER_ONLY)
@@ -6917,7 +6918,6 @@ static void x86_cpu_initfn(Object *obj)
     X86CPU *cpu = X86_CPU(obj);
     X86CPUClass *xcc = X86_CPU_GET_CLASS(obj);
     CPUX86State *env = &cpu->env;
-    FeatureWord w;
 
     env->nr_dies = 1;
     cpu_set_cpustate_pointers(cpu);
@@ -6929,14 +6929,6 @@ static void x86_cpu_initfn(Object *obj)
                         x86_cpu_get_feature_words,
                         NULL, NULL, (void *)cpu->filtered_features);
 
-    for (w = 0; w < FEATURE_WORDS; w++) {
-        int bitnr;
-
-        for (bitnr = 0; bitnr < 64; bitnr++) {
-            x86_cpu_register_feature_bit_props(cpu, w, bitnr);
-        }
-    }
-
     object_property_add_alias(obj, "sse3", obj, "pni");
     object_property_add_alias(obj, "pclmuldq", obj, "pclmulqdq");
     object_property_add_alias(obj, "sse4-1", obj, "sse4.1");
@@ -7221,6 +7213,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     X86CPUClass *xcc = X86_CPU_CLASS(oc);
     CPUClass *cc = CPU_CLASS(oc);
     DeviceClass *dc = DEVICE_CLASS(oc);
+    FeatureWord w;
 
     device_class_set_parent_realize(dc, x86_cpu_realizefn,
                                     &xcc->parent_realize);
@@ -7310,6 +7303,12 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
                               x86_cpu_get_crash_info_qom, NULL, NULL, NULL);
 #endif
 
+    for (w = 0; w < FEATURE_WORDS; w++) {
+        int bitnr;
+        for (bitnr = 0; bitnr < 64; bitnr++) {
+            x86_cpu_register_feature_bit_props(xcc, w, bitnr);
+        }
+    }
 }
 
 static const TypeInfo x86_cpu_type_info = {
#33 lore raw

Re: [PATCH 14/24] i386: Register feature bit properties as class properties

In reply to Eduardo Habkost
Quoted 39 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]

---
 target/i386/cpu.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)
target/i386/cpu.c +3 -2
index 66792f28ba7..1aba87e0a5b 100644
@@ -6819,16 +6819,17 @@ static void x86_cpu_release_bit_prop(Object *obj, const char *name,
  * multiple bits in the same FeatureWord. In that case, the getter will return
  * true only if all bits are set.
  */
-static void x86_cpu_register_bit_prop(X86CPU *cpu,
+static void x86_cpu_register_bit_prop(X86CPUClass *xcc,
                                       const char *prop_name,
                                       FeatureWord w,
                                       int bitnr)
 {
+    ObjectClass *oc = OBJECT_CLASS(xcc);
     BitProperty *fp;
     ObjectProperty *op;
     uint64_t mask = (1ULL << bitnr);
 
-    op = object_property_find(OBJECT(cpu), prop_name, NULL);
+    op = object_class_property_find(oc, prop_name, NULL);
     if (op) {
         fp = op->opaque;
         assert(fp->w == w);
@@ -6837,14 +6838,14 @@ static void x86_cpu_register_bit_prop(X86CPU *cpu,
         fp = g_new0(BitProperty, 1);

target/i386/cpu.c static void x86_cpu_register_bit_prop(X86CPU *cpu, · line 6844

Quoted 10 lines
target/i386/cpu.c +4 -4
         fp->w = w;
         fp->mask = mask;
-        object_property_add(OBJECT(cpu), prop_name, "bool",
-                            x86_cpu_get_bit_prop,
-                            x86_cpu_set_bit_prop,
-                            x86_cpu_release_bit_prop, fp);
+        object_class_property_add(oc, prop_name, "bool",
+                                  x86_cpu_get_bit_prop,
+                                  x86_cpu_set_bit_prop,
+                                  x86_cpu_release_bit_prop, fp);

This one is broken. x86_cpu_release_bit_prop() frees fp, and now fp should never be freed. The release function shouldn't be set.

I will send a new version of this patch later.

Quoted 1 line

[...]

Signature · 1 line
Eduardo
#34 lore raw

PATCH 15/24 arm/virt: Register most properties as class properties

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

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

---
 hw/arm/virt.c | 76 +++++++++++++++++++++++++++------------------------
 1 file changed, 41 insertions(+), 35 deletions(-)
hw/arm/virt.c +41 -35
index acf9bfbecea..d1ab660fa60 100644
@@ -2443,6 +2443,47 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
         NULL, NULL);
     object_class_property_set_description(oc, "acpi",
         "Enable ACPI");
+    object_class_property_add_bool(oc, "secure", virt_get_secure,
+                                   virt_set_secure);
+    object_class_property_set_description(oc, "secure",
+                                                "Set on/off to enable/disable the ARM "
+                                                "Security Extensions (TrustZone)");
+
+    object_class_property_add_bool(oc, "virtualization", virt_get_virt,
+                                   virt_set_virt);
+    object_class_property_set_description(oc, "virtualization",
+                                          "Set on/off to enable/disable emulating a "
+                                          "guest CPU which implements the ARM "
+                                          "Virtualization Extensions");
+
+    object_class_property_add_bool(oc, "highmem", virt_get_highmem,
+                                   virt_set_highmem);
+    object_class_property_set_description(oc, "highmem",
+                                          "Set on/off to enable/disable using "
+                                          "physical address space above 32 bits");
+
+    object_class_property_add_str(oc, "gic-version", virt_get_gic_version,
+                                  virt_set_gic_version);
+    object_class_property_set_description(oc, "gic-version",
+                                          "Set GIC version. "
+                                          "Valid values are 2, 3, host and max");
+
+    object_class_property_add_str(oc, "iommu", virt_get_iommu, virt_set_iommu);
+    object_class_property_set_description(oc, "iommu",
+                                          "Set the IOMMU type. "
+                                          "Valid values are none and smmuv3");
+
+    object_class_property_add_bool(oc, "ras", virt_get_ras,
+                                   virt_set_ras);
+    object_class_property_set_description(oc, "ras",
+                                          "Set on/off to enable/disable reporting host memory errors "
+                                          "to a KVM guest using ACPI and guest external abort exceptions");
+
+    object_class_property_add_bool(oc, "mte", virt_get_mte, virt_set_mte);
+    object_class_property_set_description(oc, "mte",
+                                          "Set on/off to enable/disable emulating a "
+                                          "guest CPU which implements the ARM "
+                                          "Memory Tagging Extension");
 }
 
 static void virt_instance_init(Object *obj)
@@ -2455,34 +2496,13 @@ static void virt_instance_init(Object *obj)
      * boot UEFI blobs which assume no TrustZone support.
      */
     vms->secure = false;
-    object_property_add_bool(obj, "secure", virt_get_secure,
-                             virt_set_secure);
-    object_property_set_description(obj, "secure",
-                                    "Set on/off to enable/disable the ARM "
-                                    "Security Extensions (TrustZone)");
 
     /* EL2 is also disabled by default, for similar reasons */
     vms->virt = false;
-    object_property_add_bool(obj, "virtualization", virt_get_virt,
-                             virt_set_virt);
-    object_property_set_description(obj, "virtualization",
-                                    "Set on/off to enable/disable emulating a "
-                                    "guest CPU which implements the ARM "
-                                    "Virtualization Extensions");
 
     /* High memory is enabled by default */
     vms->highmem = true;
-    object_property_add_bool(obj, "highmem", virt_get_highmem,
-                             virt_set_highmem);
-    object_property_set_description(obj, "highmem",
-                                    "Set on/off to enable/disable using "
-                                    "physical address space above 32 bits");
     vms->gic_version = VIRT_GIC_VERSION_NOSEL;
-    object_property_add_str(obj, "gic-version", virt_get_gic_version,
-                        virt_set_gic_version);
-    object_property_set_description(obj, "gic-version",
-                                    "Set GIC version. "
-                                    "Valid values are 2, 3, host and max");
 
     vms->highmem_ecam = !vmc->no_highmem_ecam;
 
@@ -2500,26 +2520,12 @@ static void virt_instance_init(Object *obj)
 
     /* Default disallows iommu instantiation */
     vms->iommu = VIRT_IOMMU_NONE;
-    object_property_add_str(obj, "iommu", virt_get_iommu, virt_set_iommu);
-    object_property_set_description(obj, "iommu",
-                                    "Set the IOMMU type. "
-                                    "Valid values are none and smmuv3");
 
     /* Default disallows RAS instantiation */
     vms->ras = false;
-    object_property_add_bool(obj, "ras", virt_get_ras,
-                             virt_set_ras);
-    object_property_set_description(obj, "ras",
-                                    "Set on/off to enable/disable reporting host memory errors "
-                                    "to a KVM guest using ACPI and guest external abort exceptions");
 
     /* MTE is disabled by default.  */
     vms->mte = false;
-    object_property_add_bool(obj, "mte", virt_get_mte, virt_set_mte);
-    object_property_set_description(obj, "mte",
-                                    "Set on/off to enable/disable emulating a "
-                                    "guest CPU which implements the ARM "
-                                    "Memory Tagging Extension");
 
     vms->irqmap = a15irqmap;
 
Signature · 1 line
2.26.2
Reviewed-by on v1 15/24
#35 lore raw

Re: [PATCH 15/24] arm/virt: Register most properties as class properties

Quoted 4 lines · On Mon, 21 Sep 2020 18:10:36 -0400 Eduardo Habkost <[email protected]> wrote:

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Quoted 122 lines

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

---
 hw/arm/virt.c | 76 +++++++++++++++++++++++++++------------------------
 1 file changed, 41 insertions(+), 35 deletions(-)
hw/arm/virt.c +41 -35
index acf9bfbecea..d1ab660fa60 100644
@@ -2443,6 +2443,47 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
         NULL, NULL);
     object_class_property_set_description(oc, "acpi",
         "Enable ACPI");
+    object_class_property_add_bool(oc, "secure", virt_get_secure,
+                                   virt_set_secure);
+    object_class_property_set_description(oc, "secure",
+                                                "Set on/off to enable/disable the ARM "
+                                                "Security Extensions (TrustZone)");
+
+    object_class_property_add_bool(oc, "virtualization", virt_get_virt,
+                                   virt_set_virt);
+    object_class_property_set_description(oc, "virtualization",
+                                          "Set on/off to enable/disable emulating a "
+                                          "guest CPU which implements the ARM "
+                                          "Virtualization Extensions");
+
+    object_class_property_add_bool(oc, "highmem", virt_get_highmem,
+                                   virt_set_highmem);
+    object_class_property_set_description(oc, "highmem",
+                                          "Set on/off to enable/disable using "
+                                          "physical address space above 32 bits");
+
+    object_class_property_add_str(oc, "gic-version", virt_get_gic_version,
+                                  virt_set_gic_version);
+    object_class_property_set_description(oc, "gic-version",
+                                          "Set GIC version. "
+                                          "Valid values are 2, 3, host and max");
+
+    object_class_property_add_str(oc, "iommu", virt_get_iommu, virt_set_iommu);
+    object_class_property_set_description(oc, "iommu",
+                                          "Set the IOMMU type. "
+                                          "Valid values are none and smmuv3");
+
+    object_class_property_add_bool(oc, "ras", virt_get_ras,
+                                   virt_set_ras);
+    object_class_property_set_description(oc, "ras",
+                                          "Set on/off to enable/disable reporting host memory errors "
+                                          "to a KVM guest using ACPI and guest external abort exceptions");
+
+    object_class_property_add_bool(oc, "mte", virt_get_mte, virt_set_mte);
+    object_class_property_set_description(oc, "mte",
+                                          "Set on/off to enable/disable emulating a "
+                                          "guest CPU which implements the ARM "
+                                          "Memory Tagging Extension");
 }
 
 static void virt_instance_init(Object *obj)
@@ -2455,34 +2496,13 @@ static void virt_instance_init(Object *obj)
      * boot UEFI blobs which assume no TrustZone support.
      */
     vms->secure = false;
-    object_property_add_bool(obj, "secure", virt_get_secure,
-                             virt_set_secure);
-    object_property_set_description(obj, "secure",
-                                    "Set on/off to enable/disable the ARM "
-                                    "Security Extensions (TrustZone)");
 
     /* EL2 is also disabled by default, for similar reasons */
     vms->virt = false;
-    object_property_add_bool(obj, "virtualization", virt_get_virt,
-                             virt_set_virt);
-    object_property_set_description(obj, "virtualization",
-                                    "Set on/off to enable/disable emulating a "
-                                    "guest CPU which implements the ARM "
-                                    "Virtualization Extensions");
 
     /* High memory is enabled by default */
     vms->highmem = true;
-    object_property_add_bool(obj, "highmem", virt_get_highmem,
-                             virt_set_highmem);
-    object_property_set_description(obj, "highmem",
-                                    "Set on/off to enable/disable using "
-                                    "physical address space above 32 bits");
     vms->gic_version = VIRT_GIC_VERSION_NOSEL;
-    object_property_add_str(obj, "gic-version", virt_get_gic_version,
-                        virt_set_gic_version);
-    object_property_set_description(obj, "gic-version",
-                                    "Set GIC version. "
-                                    "Valid values are 2, 3, host and max");
 
     vms->highmem_ecam = !vmc->no_highmem_ecam;
 
@@ -2500,26 +2520,12 @@ static void virt_instance_init(Object *obj)
 
     /* Default disallows iommu instantiation */
     vms->iommu = VIRT_IOMMU_NONE;
-    object_property_add_str(obj, "iommu", virt_get_iommu, virt_set_iommu);
-    object_property_set_description(obj, "iommu",
-                                    "Set the IOMMU type. "
-                                    "Valid values are none and smmuv3");
 
     /* Default disallows RAS instantiation */
     vms->ras = false;
-    object_property_add_bool(obj, "ras", virt_get_ras,
-                             virt_set_ras);
-    object_property_set_description(obj, "ras",
-                                    "Set on/off to enable/disable reporting host memory errors "
-                                    "to a KVM guest using ACPI and guest external abort exceptions");
 
     /* MTE is disabled by default.  */
     vms->mte = false;
-    object_property_add_bool(obj, "mte", virt_get_mte, virt_set_mte);
-    object_property_set_description(obj, "mte",
-                                    "Set on/off to enable/disable emulating a "
-                                    "guest CPU which implements the ARM "
-                                    "Memory Tagging Extension");
 
     vms->irqmap = a15irqmap;
 
#36 lore raw

PATCH 16/24 virt: Register "its" as class property

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Note: "its" is currently registered conditionally, but this makes the feature be registered unconditionally. The only side effect is that it will be now possible to set its=on on virt-2.7 and older.

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

---
 hw/arm/virt.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
hw/arm/virt.c +7 -5
index d1ab660fa60..986b75a6b89 100644
@@ -2484,6 +2484,13 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
                                           "Set on/off to enable/disable emulating a "
                                           "guest CPU which implements the ARM "
                                           "Memory Tagging Extension");
+
+    object_class_property_add_bool(oc, "its", virt_get_its,
+                                   virt_set_its);
+    object_class_property_set_description(oc, "its",
+                                          "Set on/off to enable/disable "
+                                          "ITS instantiation");
+
 }
 
 static void virt_instance_init(Object *obj)
@@ -2511,11 +2518,6 @@ static void virt_instance_init(Object *obj)
     } else {
         /* Default allows ITS instantiation */
         vms->its = true;
-        object_property_add_bool(obj, "its", virt_get_its,
-                                 virt_set_its);
-        object_property_set_description(obj, "its",
-                                        "Set on/off to enable/disable "
-                                        "ITS instantiation");
     }
 
     /* Default disallows iommu instantiation */
Signature · 1 line
2.26.2
Reviewed-by on v1 16/24
#37 lore raw

Re: [PATCH 16/24] virt: Register "its" as class property

Quoted 9 lines · On Mon, 21 Sep 2020 18:10:37 -0400 Eduardo Habkost <[email protected]> wrote:

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Note: "its" is currently registered conditionally, but this makes the feature be registered unconditionally. The only side effect is that it will be now possible to set its=on on virt-2.7 and older.

Quoted 38 lines

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

---
 hw/arm/virt.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
hw/arm/virt.c +7 -5
index d1ab660fa60..986b75a6b89 100644
@@ -2484,6 +2484,13 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
                                           "Set on/off to enable/disable emulating a "
                                           "guest CPU which implements the ARM "
                                           "Memory Tagging Extension");
+
+    object_class_property_add_bool(oc, "its", virt_get_its,
+                                   virt_set_its);
+    object_class_property_set_description(oc, "its",
+                                          "Set on/off to enable/disable "
+                                          "ITS instantiation");
+
 }
 
 static void virt_instance_init(Object *obj)
@@ -2511,11 +2518,6 @@ static void virt_instance_init(Object *obj)
     } else {
         /* Default allows ITS instantiation */
         vms->its = true;
-        object_property_add_bool(obj, "its", virt_get_its,
-                                 virt_set_its);
-        object_property_set_description(obj, "its",
-                                        "Set on/off to enable/disable "
-                                        "ITS instantiation");
     }
 
     /* Default disallows iommu instantiation */
#38 lore raw

Re: [PATCH 16/24] virt: Register "its" as class property

In reply to Eduardo Habkost
Quoted 37 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Note: "its" is currently registered conditionally, but this makes the feature be registered unconditionally. The only side effect is that it will be now possible to set its=on on virt-2.7 and older.

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

---
 hw/arm/virt.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
hw/arm/virt.c +7 -0
index d1ab660fa60..986b75a6b89 100644
@@ -2484,6 +2484,13 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
                                           "Set on/off to enable/disable emulating a "
                                           "guest CPU which implements the ARM "
                                           "Memory Tagging Extension");
+
+    object_class_property_add_bool(oc, "its", virt_get_its,
+                                   virt_set_its);
+    object_class_property_set_description(oc, "its",
+                                          "Set on/off to enable/disable "
+                                          "ITS instantiation");
+
 }
 
 static void virt_instance_init(Object *obj)

hw/arm/virt.c static void virt_instance_init(Object *obj) · line 2521

Quoted 9 lines
hw/arm/virt.c +0 -5
@@ -2511,11 +2518,6 @@ static void virt_instance_init(Object *obj)
     } else {
         /* Default allows ITS instantiation */
         vms->its = true;
-        object_property_add_bool(obj, "its", virt_get_its,
-                                 virt_set_its);
-        object_property_set_description(obj, "its",
-                                        "Set on/off to enable/disable "
-                                        "ITS instantiation");
     }

This leaves the code reading

  if (vmc->no_its) {
      vms->its = false;
  } else {
      vms->its = true;

}

which is more simply written "vms->its = !vmc->no_its;"

thanks
-- PMM

#39 lore raw

PATCH 17/24 cpu/core: Register core-id and nr-threads as class properties

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: [email protected]

---
 hw/cpu/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/cpu/core.c +4 -4
index 3a659291eae..92d3b2fbad6 100644
@@ -69,10 +69,6 @@ static void cpu_core_instance_init(Object *obj)
     MachineState *ms = MACHINE(qdev_get_machine());
     CPUCore *core = CPU_CORE(obj);
 
-    object_property_add(obj, "core-id", "int", core_prop_get_core_id,
-                        core_prop_set_core_id, NULL, NULL);
-    object_property_add(obj, "nr-threads", "int", core_prop_get_nr_threads,
-                        core_prop_set_nr_threads, NULL, NULL);
     core->nr_threads = ms->smp.threads;
 }
 
@@ -81,6 +77,10 @@ static void cpu_core_class_init(ObjectClass *oc, void *data)
     DeviceClass *dc = DEVICE_CLASS(oc);
 
     set_bit(DEVICE_CATEGORY_CPU, dc->categories);
+    object_class_property_add(oc, "core-id", "int", core_prop_get_core_id,
+                              core_prop_set_core_id, NULL, NULL);
+    object_class_property_add(oc, "nr-threads", "int", core_prop_get_nr_threads,
+                              core_prop_set_nr_threads, NULL, NULL);
 }
 
 static const TypeInfo cpu_core_type_info = {
Signature · 1 line
2.26.2
Reviewed-by on v1 17/24
#40 lore raw

Re: [PATCH 17/24] cpu/core: Register core-id and nr-threads as class properties

Quoted 4 lines · On Mon, 21 Sep 2020 18:10:38 -0400 Eduardo Habkost <[email protected]> wrote:

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Quoted 32 lines

---
Cc: [email protected]

---
 hw/cpu/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/cpu/core.c +4 -4
index 3a659291eae..92d3b2fbad6 100644
@@ -69,10 +69,6 @@ static void cpu_core_instance_init(Object *obj)
     MachineState *ms = MACHINE(qdev_get_machine());
     CPUCore *core = CPU_CORE(obj);
 
-    object_property_add(obj, "core-id", "int", core_prop_get_core_id,
-                        core_prop_set_core_id, NULL, NULL);
-    object_property_add(obj, "nr-threads", "int", core_prop_get_nr_threads,
-                        core_prop_set_nr_threads, NULL, NULL);
     core->nr_threads = ms->smp.threads;
 }
 
@@ -81,6 +77,10 @@ static void cpu_core_class_init(ObjectClass *oc, void *data)
     DeviceClass *dc = DEVICE_CLASS(oc);
 
     set_bit(DEVICE_CATEGORY_CPU, dc->categories);
+    object_class_property_add(oc, "core-id", "int", core_prop_get_core_id,
+                              core_prop_set_core_id, NULL, NULL);
+    object_class_property_add(oc, "nr-threads", "int", core_prop_get_nr_threads,
+                              core_prop_set_nr_threads, NULL, NULL);
 }
 
 static const TypeInfo cpu_core_type_info = {
#41 lore raw

PATCH 18/24 arm/cpu64: Register "aarch64" as class property

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

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

---
 target/arm/cpu64.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
target/arm/cpu64.c +6 -10
index 3c2b3d95993..349c9fa3a3a 100644
@@ -758,15 +758,6 @@ static void aarch64_cpu_set_aarch64(Object *obj, bool value, Error **errp)
     }
 }
 
-static void aarch64_cpu_initfn(Object *obj)
-{
-    object_property_add_bool(obj, "aarch64", aarch64_cpu_get_aarch64,
-                             aarch64_cpu_set_aarch64);
-    object_property_set_description(obj, "aarch64",
-                                    "Set on/off to enable/disable aarch64 "
-                                    "execution state ");
-}
-
 static void aarch64_cpu_finalizefn(Object *obj)
 {
 }
@@ -786,6 +777,12 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data)
     cc->gdb_num_core_regs = 34;
     cc->gdb_core_xml_file = "aarch64-core.xml";
     cc->gdb_arch_name = aarch64_gdb_arch_name;
+
+    object_class_property_add_bool(oc, "aarch64", aarch64_cpu_get_aarch64,
+                                   aarch64_cpu_set_aarch64);
+    object_class_property_set_description(oc, "aarch64",
+                                          "Set on/off to enable/disable aarch64 "
+                                          "execution state ");
 }
 
 static void aarch64_cpu_instance_init(Object *obj)
@@ -823,7 +820,6 @@ static const TypeInfo aarch64_cpu_type_info = {
     .name = TYPE_AARCH64_CPU,
     .parent = TYPE_ARM_CPU,
     .instance_size = sizeof(ARMCPU),
-    .instance_init = aarch64_cpu_initfn,
     .instance_finalize = aarch64_cpu_finalizefn,
     .abstract = true,
     .class_size = sizeof(AArch64CPUClass),
Signature · 1 line
2.26.2
Reviewed-by on v1 18/24
#42 lore raw

Re: [PATCH 18/24] arm/cpu64: Register "aarch64" as class property

Quoted 4 lines · On Mon, 21 Sep 2020 18:10:39 -0400 Eduardo Habkost <[email protected]> wrote:

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Quoted 49 lines

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

---
 target/arm/cpu64.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
target/arm/cpu64.c +6 -10
index 3c2b3d95993..349c9fa3a3a 100644
@@ -758,15 +758,6 @@ static void aarch64_cpu_set_aarch64(Object *obj, bool value, Error **errp)
     }
 }
 
-static void aarch64_cpu_initfn(Object *obj)
-{
-    object_property_add_bool(obj, "aarch64", aarch64_cpu_get_aarch64,
-                             aarch64_cpu_set_aarch64);
-    object_property_set_description(obj, "aarch64",
-                                    "Set on/off to enable/disable aarch64 "
-                                    "execution state ");
-}
-
 static void aarch64_cpu_finalizefn(Object *obj)
 {
 }
@@ -786,6 +777,12 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data)
     cc->gdb_num_core_regs = 34;
     cc->gdb_core_xml_file = "aarch64-core.xml";
     cc->gdb_arch_name = aarch64_gdb_arch_name;
+
+    object_class_property_add_bool(oc, "aarch64", aarch64_cpu_get_aarch64,
+                                   aarch64_cpu_set_aarch64);
+    object_class_property_set_description(oc, "aarch64",
+                                          "Set on/off to enable/disable aarch64 "
+                                          "execution state ");
 }
 
 static void aarch64_cpu_instance_init(Object *obj)
@@ -823,7 +820,6 @@ static const TypeInfo aarch64_cpu_type_info = {
     .name = TYPE_AARCH64_CPU,
     .parent = TYPE_ARM_CPU,
     .instance_size = sizeof(ARMCPU),
-    .instance_init = aarch64_cpu_initfn,
     .instance_finalize = aarch64_cpu_finalizefn,
     .abstract = true,
     .class_size = sizeof(AArch64CPUClass),
#43 lore raw

PATCH 19/24 xlnx-zcu102: Register properties as class properties

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Alistair Francis <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 hw/arm/xlnx-zcu102.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
hw/arm/xlnx-zcu102.c +13 -12
index 19d5a4d4e0e..4deb96bfcc1 100644
@@ -208,20 +208,8 @@ static void xlnx_zcu102_machine_instance_init(Object *obj)
 
     /* Default to secure mode being disabled */
     s->secure = false;
-    object_property_add_bool(obj, "secure", zcu102_get_secure,
-                             zcu102_set_secure);
-    object_property_set_description(obj, "secure",
-                                    "Set on/off to enable/disable the ARM "
-                                    "Security Extensions (TrustZone)");
-
     /* Default to virt (EL2) being disabled */
     s->virt = false;
-    object_property_add_bool(obj, "virtualization", zcu102_get_virt,
-                             zcu102_set_virt);
-    object_property_set_description(obj, "virtualization",
-                                    "Set on/off to enable/disable emulating a "
-                                    "guest CPU which implements the ARM "
-                                    "Virtualization Extensions");
 }
 
 static void xlnx_zcu102_machine_class_init(ObjectClass *oc, void *data)
@@ -237,6 +225,19 @@ static void xlnx_zcu102_machine_class_init(ObjectClass *oc, void *data)
     mc->max_cpus = XLNX_ZYNQMP_NUM_APU_CPUS + XLNX_ZYNQMP_NUM_RPU_CPUS;
     mc->default_cpus = XLNX_ZYNQMP_NUM_APU_CPUS;
     mc->default_ram_id = "ddr-ram";
+
+    object_class_property_add_bool(oc, "secure", zcu102_get_secure,
+                                   zcu102_set_secure);
+    object_class_property_set_description(oc, "secure",
+                                          "Set on/off to enable/disable the ARM "
+                                          "Security Extensions (TrustZone)");
+
+    object_class_property_add_bool(oc, "virtualization", zcu102_get_virt,
+                                   zcu102_set_virt);
+    object_class_property_set_description(oc, "virtualization",
+                                          "Set on/off to enable/disable emulating a "
+                                          "guest CPU which implements the ARM "
+                                          "Virtualization Extensions");
 }
 
 static const TypeInfo xlnx_zcu102_machine_init_typeinfo = {
Signature · 1 line
2.26.2
Reviewed-by on v1 19/24
#44 lore raw

Re: [PATCH 19/24] xlnx-zcu102: Register properties as class properties

Quoted 5 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Alistair

Quoted 59 lines

---
Cc: Alistair Francis <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 hw/arm/xlnx-zcu102.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
hw/arm/xlnx-zcu102.c +13 -13
index 19d5a4d4e0e..4deb96bfcc1 100644
@@ -208,20 +208,8 @@ static void xlnx_zcu102_machine_instance_init(Object *obj)
 
     /* Default to secure mode being disabled */
     s->secure = false;
-    object_property_add_bool(obj, "secure", zcu102_get_secure,
-                             zcu102_set_secure);
-    object_property_set_description(obj, "secure",
-                                    "Set on/off to enable/disable the ARM "
-                                    "Security Extensions (TrustZone)");
-
     /* Default to virt (EL2) being disabled */
     s->virt = false;
-    object_property_add_bool(obj, "virtualization", zcu102_get_virt,
-                             zcu102_set_virt);
-    object_property_set_description(obj, "virtualization",
-                                    "Set on/off to enable/disable emulating a "
-                                    "guest CPU which implements the ARM "
-                                    "Virtualization Extensions");
 }
 
 static void xlnx_zcu102_machine_class_init(ObjectClass *oc, void *data)
@@ -237,6 +225,19 @@ static void xlnx_zcu102_machine_class_init(ObjectClass *oc, void *data)
     mc->max_cpus = XLNX_ZYNQMP_NUM_APU_CPUS + XLNX_ZYNQMP_NUM_RPU_CPUS;
     mc->default_cpus = XLNX_ZYNQMP_NUM_APU_CPUS;
     mc->default_ram_id = "ddr-ram";
+
+    object_class_property_add_bool(oc, "secure", zcu102_get_secure,
+                                   zcu102_set_secure);
+    object_class_property_set_description(oc, "secure",
+                                          "Set on/off to enable/disable the ARM "
+                                          "Security Extensions (TrustZone)");
+
+    object_class_property_add_bool(oc, "virtualization", zcu102_get_virt,
+                                   zcu102_set_virt);
+    object_class_property_set_description(oc, "virtualization",
+                                          "Set on/off to enable/disable emulating a "
+                                          "guest CPU which implements the ARM "
+                                          "Virtualization Extensions");
 }
 
 static const TypeInfo xlnx_zcu102_machine_init_typeinfo = {
--

2.26.2

#45 lore raw

PATCH 20/24 machine: Register "memory-backend" as class property

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Eduardo Habkost <[email protected]>
Cc: Marcel Apfelbaum <[email protected]>
Cc: [email protected]

---
 hw/core/machine.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
hw/core/machine.c +6 -6
index ea26d612374..675ca6d651c 100644
@@ -874,6 +874,12 @@ static void machine_class_init(ObjectClass *oc, void *data)
         machine_get_memory_encryption, machine_set_memory_encryption);
     object_class_property_set_description(oc, "memory-encryption",
         "Set memory encryption object to use");
+
+    object_class_property_add_str(oc, "memory-backend",
+                                  machine_get_memdev, machine_set_memdev);
+    object_class_property_set_description(oc, "memory-backend",
+                                          "Set RAM backend"
+                                          "Valid value is ID of hostmem based backend");
 }
 
 static void machine_class_base_init(ObjectClass *oc, void *data)
@@ -925,12 +931,6 @@ static void machine_initfn(Object *obj)
                                         "Table (HMAT)");
     }
 
-    object_property_add_str(obj, "memory-backend",
-                            machine_get_memdev, machine_set_memdev);
-    object_property_set_description(obj, "memory-backend",
-                                    "Set RAM backend"
-                                    "Valid value is ID of hostmem based backend");
-
     /* Register notifier when init is done for sysbus sanity checks */
     ms->sysbus_notifier.notify = machine_init_notify;
     qemu_add_machine_init_done_notifier(&ms->sysbus_notifier);
Signature · 1 line
2.26.2
Reviewed-by on v1 20/24
#46 lore raw

Re: [PATCH 20/24] machine: Register "memory-backend" as class property

Quoted 8 lines · On Mon, 21 Sep 2020 18:10:41 -0400 Eduardo Habkost <[email protected]> wrote:

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Eduardo Habkost <[email protected]>
Cc: Marcel Apfelbaum <[email protected]>
Cc: [email protected]

Quoted 34 lines
---
 hw/core/machine.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
hw/core/machine.c +6 -6
index ea26d612374..675ca6d651c 100644
@@ -874,6 +874,12 @@ static void machine_class_init(ObjectClass *oc, void *data)
         machine_get_memory_encryption, machine_set_memory_encryption);
     object_class_property_set_description(oc, "memory-encryption",
         "Set memory encryption object to use");
+
+    object_class_property_add_str(oc, "memory-backend",
+                                  machine_get_memdev, machine_set_memdev);
+    object_class_property_set_description(oc, "memory-backend",
+                                          "Set RAM backend"
+                                          "Valid value is ID of hostmem based backend");
 }
 
 static void machine_class_base_init(ObjectClass *oc, void *data)
@@ -925,12 +931,6 @@ static void machine_initfn(Object *obj)
                                         "Table (HMAT)");
     }
 
-    object_property_add_str(obj, "memory-backend",
-                            machine_get_memdev, machine_set_memdev);
-    object_property_set_description(obj, "memory-backend",
-                                    "Set RAM backend"
-                                    "Valid value is ID of hostmem based backend");
-
     /* Register notifier when init is done for sysbus sanity checks */
     ms->sysbus_notifier.notify = machine_init_notify;
     qemu_add_machine_init_done_notifier(&ms->sysbus_notifier);
#47 lore raw

PATCH 21/24 vga-pci: Register "big-endian-framebuffer" as class property

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

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

---
 hw/display/vga-pci.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
hw/display/vga-pci.c +4 -8
index 3b45fa3bad0..b2a7d03c5d5 100644
@@ -269,13 +269,6 @@ static void pci_std_vga_realize(PCIDevice *dev, Error **errp)
     }
 }
 
-static void pci_std_vga_init(Object *obj)
-{
-    /* Expose framebuffer byteorder via QOM */
-    object_property_add_bool(obj, "big-endian-framebuffer",
-                             vga_get_big_endian_fb, vga_set_big_endian_fb);
-}
-
 static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp)
 {
     PCIVGAState *d = PCI_VGA(dev);
@@ -388,6 +381,10 @@ static void vga_class_init(ObjectClass *klass, void *data)
     k->class_id = PCI_CLASS_DISPLAY_VGA;
     device_class_set_props(dc, vga_pci_properties);
     dc->hotpluggable = false;
+
+    /* Expose framebuffer byteorder via QOM */
+    object_class_property_add_bool(klass, "big-endian-framebuffer",
+                                   vga_get_big_endian_fb, vga_set_big_endian_fb);
 }
 
 static void secondary_class_init(ObjectClass *klass, void *data)
@@ -405,7 +402,6 @@ static void secondary_class_init(ObjectClass *klass, void *data)
 static const TypeInfo vga_info = {
     .name          = "VGA",
     .parent        = TYPE_PCI_VGA,
-    .instance_init = pci_std_vga_init,
     .class_init    = vga_class_init,
 };
 
Signature · 1 line
2.26.2
Reviewed-by on v1 21/24
#48 lore raw

Re: [PATCH 21/24] vga-pci: Register "big-endian-framebuffer" as class property

Quoted 5 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---

Quoted 53 lines
---
 hw/display/vga-pci.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
hw/display/vga-pci.c +0 -7
index 3b45fa3bad0..b2a7d03c5d5 100644
@@ -269,13 +269,6 @@ static void pci_std_vga_realize(PCIDevice *dev, Error
 **errp)
     }
 }
 
-static void pci_std_vga_init(Object *obj)
-{
-    /* Expose framebuffer byteorder via QOM */
-    object_property_add_bool(obj, "big-endian-framebuffer",
-                             vga_get_big_endian_fb,
 vga_set_big_endian_fb);
-}
-
 static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp)
 {
     PCIVGAState *d = PCI_VGA(dev);
hw/display/vga-pci.c +4 -0
@@ -388,6 +381,10 @@ static void vga_class_init(ObjectClass *klass, void
 *data)
     k->class_id = PCI_CLASS_DISPLAY_VGA;
     device_class_set_props(dc, vga_pci_properties);
     dc->hotpluggable = false;
+
+    /* Expose framebuffer byteorder via QOM */
+    object_class_property_add_bool(klass, "big-endian-framebuffer",
+                                   vga_get_big_endian_fb,
 vga_set_big_endian_fb);
 }

static void secondary_class_init(ObjectClass *klass, void *data)

hw/display/vga-pci.c +0 -2
@@ -405,7 +402,6 @@ static void secondary_class_init(ObjectClass *klass,
 void *data)
 static const TypeInfo vga_info = {
     .name          = "VGA",
     .parent        = TYPE_PCI_VGA,
-    .instance_init = pci_std_vga_init,
     .class_init    = vga_class_init,
 };
 
--

2.26.2

Signature · 1 line
Marc-André Lureau
#49 lore raw

PATCH 22/24 i440fx: Register i440FX-pcihost properties as class properties

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Marcel Apfelbaum <[email protected]>
Cc: [email protected]

---
 hw/pci-host/i440fx.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
hw/pci-host/i440fx.c +16 -16
index 93c62235ca7..4454ba06621 100644
@@ -212,22 +212,6 @@ static void i440fx_pcihost_initfn(Object *obj)
                           "pci-conf-idx", 4);
     memory_region_init_io(&s->data_mem, obj, &pci_host_data_le_ops, s,
                           "pci-conf-data", 4);
-
-    object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "uint32",
-                        i440fx_pcihost_get_pci_hole_start,
-                        NULL, NULL, NULL);
-
-    object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_END, "uint32",
-                        i440fx_pcihost_get_pci_hole_end,
-                        NULL, NULL, NULL);
-
-    object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_START, "uint64",
-                        i440fx_pcihost_get_pci_hole64_start,
-                        NULL, NULL, NULL);
-
-    object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_END, "uint64",
-                        i440fx_pcihost_get_pci_hole64_end,
-                        NULL, NULL, NULL);
 }
 
 static void i440fx_pcihost_realize(DeviceState *dev, Error **errp)
@@ -403,6 +387,22 @@ static void i440fx_pcihost_class_init(ObjectClass *klass, void *data)
     device_class_set_props(dc, i440fx_props);
     /* Reason: needs to be wired up by pc_init1 */
     dc->user_creatable = false;
+
+    object_class_property_add(klass, PCI_HOST_PROP_PCI_HOLE_START, "uint32",
+                              i440fx_pcihost_get_pci_hole_start,
+                              NULL, NULL, NULL);
+
+    object_class_property_add(klass, PCI_HOST_PROP_PCI_HOLE_END, "uint32",
+                              i440fx_pcihost_get_pci_hole_end,
+                              NULL, NULL, NULL);
+
+    object_class_property_add(klass, PCI_HOST_PROP_PCI_HOLE64_START, "uint64",
+                              i440fx_pcihost_get_pci_hole64_start,
+                              NULL, NULL, NULL);
+
+    object_class_property_add(klass, PCI_HOST_PROP_PCI_HOLE64_END, "uint64",
+                              i440fx_pcihost_get_pci_hole64_end,
+                              NULL, NULL, NULL);
 }
 
 static const TypeInfo i440fx_pcihost_info = {
Signature · 1 line
2.26.2
Reviewed-by on v1 22/24
#50 lore raw

Re: [PATCH 22/24] i440fx: Register i440FX-pcihost properties as class properties

Quoted 8 lines · On Mon, 21 Sep 2020 18:10:43 -0400 Eduardo Habkost <[email protected]> wrote:

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Marcel Apfelbaum <[email protected]>
Cc: [email protected]

Quoted 54 lines
---
 hw/pci-host/i440fx.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
hw/pci-host/i440fx.c +16 -16
index 93c62235ca7..4454ba06621 100644
@@ -212,22 +212,6 @@ static void i440fx_pcihost_initfn(Object *obj)
                           "pci-conf-idx", 4);
     memory_region_init_io(&s->data_mem, obj, &pci_host_data_le_ops, s,
                           "pci-conf-data", 4);
-
-    object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "uint32",
-                        i440fx_pcihost_get_pci_hole_start,
-                        NULL, NULL, NULL);
-
-    object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_END, "uint32",
-                        i440fx_pcihost_get_pci_hole_end,
-                        NULL, NULL, NULL);
-
-    object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_START, "uint64",
-                        i440fx_pcihost_get_pci_hole64_start,
-                        NULL, NULL, NULL);
-
-    object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_END, "uint64",
-                        i440fx_pcihost_get_pci_hole64_end,
-                        NULL, NULL, NULL);
 }
 
 static void i440fx_pcihost_realize(DeviceState *dev, Error **errp)
@@ -403,6 +387,22 @@ static void i440fx_pcihost_class_init(ObjectClass *klass, void *data)
     device_class_set_props(dc, i440fx_props);
     /* Reason: needs to be wired up by pc_init1 */
     dc->user_creatable = false;
+
+    object_class_property_add(klass, PCI_HOST_PROP_PCI_HOLE_START, "uint32",
+                              i440fx_pcihost_get_pci_hole_start,
+                              NULL, NULL, NULL);
+
+    object_class_property_add(klass, PCI_HOST_PROP_PCI_HOLE_END, "uint32",
+                              i440fx_pcihost_get_pci_hole_end,
+                              NULL, NULL, NULL);
+
+    object_class_property_add(klass, PCI_HOST_PROP_PCI_HOLE64_START, "uint64",
+                              i440fx_pcihost_get_pci_hole64_start,
+                              NULL, NULL, NULL);
+
+    object_class_property_add(klass, PCI_HOST_PROP_PCI_HOLE64_END, "uint64",
+                              i440fx_pcihost_get_pci_hole64_end,
+                              NULL, NULL, NULL);
 }
 
 static const TypeInfo i440fx_pcihost_info = {
Reviewed-by on v1 22/24
#51 lore raw

Re: [PATCH 22/24] i440fx: Register i440FX-pcihost properties as class properties

In reply to Eduardo Habkost
Quoted 4 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Quoted 60 lines

---
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Marcel Apfelbaum <[email protected]>
Cc: [email protected]

---
 hw/pci-host/i440fx.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
hw/pci-host/i440fx.c +16 -16
index 93c62235ca7..4454ba06621 100644
@@ -212,22 +212,6 @@ static void i440fx_pcihost_initfn(Object *obj)
                           "pci-conf-idx", 4);
     memory_region_init_io(&s->data_mem, obj, &pci_host_data_le_ops, s,
                           "pci-conf-data", 4);
-
-    object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "uint32",
-                        i440fx_pcihost_get_pci_hole_start,
-                        NULL, NULL, NULL);
-
-    object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_END, "uint32",
-                        i440fx_pcihost_get_pci_hole_end,
-                        NULL, NULL, NULL);
-
-    object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_START, "uint64",
-                        i440fx_pcihost_get_pci_hole64_start,
-                        NULL, NULL, NULL);
-
-    object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_END, "uint64",
-                        i440fx_pcihost_get_pci_hole64_end,
-                        NULL, NULL, NULL);
 }
 
 static void i440fx_pcihost_realize(DeviceState *dev, Error **errp)
@@ -403,6 +387,22 @@ static void i440fx_pcihost_class_init(ObjectClass *klass, void *data)
     device_class_set_props(dc, i440fx_props);
     /* Reason: needs to be wired up by pc_init1 */
     dc->user_creatable = false;
+
+    object_class_property_add(klass, PCI_HOST_PROP_PCI_HOLE_START, "uint32",
+                              i440fx_pcihost_get_pci_hole_start,
+                              NULL, NULL, NULL);
+
+    object_class_property_add(klass, PCI_HOST_PROP_PCI_HOLE_END, "uint32",
+                              i440fx_pcihost_get_pci_hole_end,
+                              NULL, NULL, NULL);
+
+    object_class_property_add(klass, PCI_HOST_PROP_PCI_HOLE64_START, "uint64",
+                              i440fx_pcihost_get_pci_hole64_start,
+                              NULL, NULL, NULL);
+
+    object_class_property_add(klass, PCI_HOST_PROP_PCI_HOLE64_END, "uint64",
+                              i440fx_pcihost_get_pci_hole64_end,
+                              NULL, NULL, NULL);
 }
 
 static const TypeInfo i440fx_pcihost_info = {
Signature · 1 line
2.26.2
#52 lore raw

PATCH 23/24 sifive_e: Register "revb" as class property

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Palmer Dabbelt <[email protected]>
Cc: Alistair Francis <[email protected]>
Cc: Sagar Karandikar <[email protected]>
Cc: Bastian Koppelmann <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 hw/riscv/sifive_e.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
hw/riscv/sifive_e.c +6 -5
index 40bbf530d49..9fe0c12df64 100644
@@ -137,11 +137,6 @@ static void sifive_e_machine_instance_init(Object *obj)
     SiFiveEState *s = RISCV_E_MACHINE(obj);
 
     s->revb = false;
-    object_property_add_bool(obj, "revb", sifive_e_machine_get_revb,
-                             sifive_e_machine_set_revb);
-    object_property_set_description(obj, "revb",
-                                    "Set on to tell QEMU that it should model "
-                                    "the revB HiFive1 board");
 }
 
 static void sifive_e_machine_class_init(ObjectClass *oc, void *data)
@@ -152,6 +147,12 @@ static void sifive_e_machine_class_init(ObjectClass *oc, void *data)
     mc->init = sifive_e_machine_init;
     mc->max_cpus = 1;
     mc->default_cpu_type = SIFIVE_E_CPU;
+
+    object_class_property_add_bool(oc, "revb", sifive_e_machine_get_revb,
+                                   sifive_e_machine_set_revb);
+    object_class_property_set_description(oc, "revb",
+                                          "Set on to tell QEMU that it should model "
+                                          "the revB HiFive1 board");
 }
 
 static const TypeInfo sifive_e_machine_typeinfo = {
Signature · 1 line
2.26.2
Reviewed-by on v1 23/24
#53 lore raw

Re: [PATCH 23/24] sifive_e: Register "revb" as class property

Quoted 5 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Alistair

Quoted 44 lines

---
Cc: Palmer Dabbelt <[email protected]>
Cc: Alistair Francis <[email protected]>
Cc: Sagar Karandikar <[email protected]>
Cc: Bastian Koppelmann <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 hw/riscv/sifive_e.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
hw/riscv/sifive_e.c +6 -6
index 40bbf530d49..9fe0c12df64 100644
@@ -137,11 +137,6 @@ static void sifive_e_machine_instance_init(Object *obj)
     SiFiveEState *s = RISCV_E_MACHINE(obj);
 
     s->revb = false;
-    object_property_add_bool(obj, "revb", sifive_e_machine_get_revb,
-                             sifive_e_machine_set_revb);
-    object_property_set_description(obj, "revb",
-                                    "Set on to tell QEMU that it should model "
-                                    "the revB HiFive1 board");
 }
 
 static void sifive_e_machine_class_init(ObjectClass *oc, void *data)
@@ -152,6 +147,12 @@ static void sifive_e_machine_class_init(ObjectClass *oc, void *data)
     mc->init = sifive_e_machine_init;
     mc->max_cpus = 1;
     mc->default_cpu_type = SIFIVE_E_CPU;
+
+    object_class_property_add_bool(oc, "revb", sifive_e_machine_get_revb,
+                                   sifive_e_machine_set_revb);
+    object_class_property_set_description(oc, "revb",
+                                          "Set on to tell QEMU that it should model "
+                                          "the revB HiFive1 board");
 }
 
 static const TypeInfo sifive_e_machine_typeinfo = {
--

2.26.2

#54 lore raw

PATCH 24/24 sifive_u: Register "start-in-flash" as class property

In reply to Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

---
Cc: Palmer Dabbelt <[email protected]>
Cc: Alistair Francis <[email protected]>
Cc: Sagar Karandikar <[email protected]>
Cc: Bastian Koppelmann <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 hw/riscv/sifive_u.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
hw/riscv/sifive_u.c +8 -8
index 4f12a93188d..0f0fab9a47b 100644
@@ -568,14 +568,6 @@ static void sifive_u_machine_instance_init(Object *obj)
     SiFiveUState *s = RISCV_U_MACHINE(obj);
 
     s->start_in_flash = false;
-    object_property_add_bool(obj, "start-in-flash",
-                             sifive_u_machine_get_start_in_flash,
-                             sifive_u_machine_set_start_in_flash);
-    object_property_set_description(obj, "start-in-flash",
-                                    "Set on to tell QEMU's ROM to jump to "
-                                    "flash. Otherwise QEMU will jump to DRAM "
-                                    "or L2LIM depending on the msel value");
-
     s->msel = 0;
     object_property_add(obj, "msel", "uint32",
                         sifive_u_machine_get_uint32_prop,
@@ -599,6 +591,14 @@ static void sifive_u_machine_class_init(ObjectClass *oc, void *data)
     mc->max_cpus = SIFIVE_U_MANAGEMENT_CPU_COUNT + SIFIVE_U_COMPUTE_CPU_COUNT;
     mc->min_cpus = SIFIVE_U_MANAGEMENT_CPU_COUNT + 1;
     mc->default_cpus = mc->min_cpus;
+
+    object_class_property_add_bool(oc, "start-in-flash",
+                                   sifive_u_machine_get_start_in_flash,
+                                   sifive_u_machine_set_start_in_flash);
+    object_class_property_set_description(oc, "start-in-flash",
+                                          "Set on to tell QEMU's ROM to jump to "
+                                          "flash. Otherwise QEMU will jump to DRAM "
+                                          "or L2LIM depending on the msel value");
 }
 
 static const TypeInfo sifive_u_machine_typeinfo = {
Signature · 1 line
2.26.2
Reviewed-by on v1 24/24
#55 lore raw

Re: [PATCH 24/24] sifive_u: Register "start-in-flash" as class property

Quoted 5 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as they don't require an object to be instantiated.

Alistair

Quoted 49 lines

---
Cc: Palmer Dabbelt <[email protected]>
Cc: Alistair Francis <[email protected]>
Cc: Sagar Karandikar <[email protected]>
Cc: Bastian Koppelmann <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 hw/riscv/sifive_u.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
hw/riscv/sifive_u.c +8 -9
index 4f12a93188d..0f0fab9a47b 100644
@@ -568,14 +568,6 @@ static void sifive_u_machine_instance_init(Object *obj)
     SiFiveUState *s = RISCV_U_MACHINE(obj);
 
     s->start_in_flash = false;
-    object_property_add_bool(obj, "start-in-flash",
-                             sifive_u_machine_get_start_in_flash,
-                             sifive_u_machine_set_start_in_flash);
-    object_property_set_description(obj, "start-in-flash",
-                                    "Set on to tell QEMU's ROM to jump to "
-                                    "flash. Otherwise QEMU will jump to DRAM "
-                                    "or L2LIM depending on the msel value");
-
     s->msel = 0;
     object_property_add(obj, "msel", "uint32",
                         sifive_u_machine_get_uint32_prop,
@@ -599,6 +591,14 @@ static void sifive_u_machine_class_init(ObjectClass *oc, void *data)
     mc->max_cpus = SIFIVE_U_MANAGEMENT_CPU_COUNT + SIFIVE_U_COMPUTE_CPU_COUNT;
     mc->min_cpus = SIFIVE_U_MANAGEMENT_CPU_COUNT + 1;
     mc->default_cpus = mc->min_cpus;
+
+    object_class_property_add_bool(oc, "start-in-flash",
+                                   sifive_u_machine_get_start_in_flash,
+                                   sifive_u_machine_set_start_in_flash);
+    object_class_property_set_description(oc, "start-in-flash",
+                                          "Set on to tell QEMU's ROM to jump to "
+                                          "flash. Otherwise QEMU will jump to DRAM "
+                                          "or L2LIM depending on the msel value");
 }
 
 static const TypeInfo sifive_u_machine_typeinfo = {
--

2.26.2

#56 lore raw
In reply to Eduardo Habkost
Quoted 6 lines · Eduardo Habkost <[email protected]> 于2020年9月22日周二 上午6:11写道:

Class properties make QOM introspection simpler and easier, as it doesn't require an object to be instantiated. This series converts a few existing object_property_add*() calls to register class properties instead.

Hello Eduardo,

IIUC, most of the properties can be dev-spec or class-spec.
Do we have any principle or rule to specify the property to be dev or class?

Maybe if the property which is always the same between instances can be a class-property?

Thanks,
Li Qiang

Quoted 55 lines

Eduardo Habkost (24):
cryptodev-vhost-user: Register "chardev" as class property
cryptodev-backend: Register "chardev" as class property
rng-egd: Register "chardev" as class property
rng-random: register "filename" as class property
vhost-user: Register "chardev" as class property
vexpress: Register "secure" as class property
rng: Register "opened" as class property
vexpress-a15: Register "virtualization" as class property
input-linux: Register properties as class properties
input-barrier: Register properties as class properties
tmp421: Register properties as class properties
s390x: Register all CPU properties as class properties
i386: Register most CPU properties as class properties
i386: Register feature bit properties as class properties arm/virt: Register most properties as class properties
virt: Register "its" as class property
cpu/core: Register core-id and nr-threads as class properties arm/cpu64: Register "aarch64" as class property
xlnx-zcu102: Register properties as class properties
machine: Register "memory-backend" as class property
vga-pci: Register "big-endian-framebuffer" as class property
i440fx: Register i440FX-pcihost properties as class properties
sifive_e: Register "revb" as class property
sifive_u: Register "start-in-flash" as class property

 target/s390x/internal.h         |  1 -
 backends/cryptodev-vhost-user.c | 13 ++---
 backends/cryptodev.c            |  8 +--
 backends/rng-egd.c              |  9 +--
 backends/rng-random.c           |  8 +--
 backends/rng.c                  |  8 +--
 backends/vhost-user.c           |  6 +-
 hw/arm/vexpress.c               | 25 +++++----
 hw/arm/virt.c                   | 88 ++++++++++++++++-------------
 hw/arm/xlnx-zcu102.c            | 25 +++++----
 hw/core/machine.c               | 12 ++--
 hw/cpu/core.c                   |  8 +--
 hw/display/vga-pci.c            | 12 ++--
 hw/misc/tmp421.c                | 30 +++++-----
 hw/pci-host/i440fx.c            | 32 +++++------
 hw/riscv/sifive_e.c             | 11 ++--
 hw/riscv/sifive_u.c             | 16 +++---
 target/arm/cpu64.c              | 16 ++----
 target/i386/cpu.c               | 99 +++++++++++++++++----------------
 target/s390x/cpu.c              |  1 -
 target/s390x/cpu_models.c       | 35 ++++++------
 ui/input-barrier.c              | 44 +++++++--------
 ui/input-linux.c                | 27 ++++-----
 23 files changed, 262 insertions(+), 272 deletions(-)

--
2.26.2

#57 lore raw
Quoted 8 lines · Li Qiang
Quoted 6 lines · Eduardo Habkost <[email protected]> 于2020年9月22日周二 上午6:11写道:

Class properties make QOM introspection simpler and easier, as it doesn't require an object to be instantiated. This series converts a few existing object_property_add*() calls to register class properties instead.

Quoted 7 lines

Hello Eduardo,

IIUC, most of the properties can be dev-spec or class-spec.
Do we have any principle or rule to specify the property to be dev or class?

Maybe if the property which is always the same between instances can be a class-property?

If you are talking about having the same value, this is not the use case for class properties. Registering a class property just means all instances of the object will have that property (but each instance can have the property set to a different value), and makes this information available for introspection before instantiating the object.

Signature · 1 line
Eduardo
#58 lore raw
In reply to Eduardo Habkost
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===

C linker for the host machine: cc ld.bfd 2.27-43
Host machine cpu family: x86_64
Host machine cpu: x86_64
../src/meson.build:10: WARNING: Module unstable-keyval has no backwards or forwards compatibility and might not exist in future releases. Program sh found: YES
Program python3 found: YES (/usr/bin/python3)
Configuring ninjatool using configuration
---
Running test qtest-x86_64: qos-test
Broken pipe
../src/tests/qtest/libqtest.c:175: kill_qemu() detected QEMU death from signal 7 (Bus error) (core dumped)
ERROR qtest-x86_64: device-introspect-test - too few tests run (expected 6, got 5)
make: *** [run-test-151] Error 1
make: *** Waiting for unfinished jobs....

Looking for expected file 'tests/data/acpi/microvm/FACP'
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--rm', '--label', 'com.qemu.instance.uuid=1012ee92264940698a9ece48329b2072', '-u', '1003', '--security-opt', 'seccomp=unconfined', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-h2ifbdcv/src/docker-src.2020-09-21-22.55.00.16625:/var/tmp/qemu:z,ro', 'qemu/centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=1012ee92264940698a9ece48329b2072
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-h2ifbdcv/src'
make: *** [docker-run-test-quick@centos7] Error 2

real 7m22.647s
user 0m20.149s

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#59 lore raw
In reply to Eduardo Habkost
Quoted 22 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as it doesn't require an object to be instantiated. This series converts a few existing object_property_add*() calls to register class properties instead.

Eduardo Habkost (24):
cryptodev-vhost-user: Register "chardev" as class property
cryptodev-backend: Register "chardev" as class property
rng-egd: Register "chardev" as class property
rng-random: register "filename" as class property
vhost-user: Register "chardev" as class property
vexpress: Register "secure" as class property
rng: Register "opened" as class property
vexpress-a15: Register "virtualization" as class property
input-linux: Register properties as class properties
input-barrier: Register properties as class properties
tmp421: Register properties as class properties
s390x: Register all CPU properties as class properties
i386: Register most CPU properties as class properties
i386: Register feature bit properties as class properties arm/virt: Register most properties as class properties
virt: Register "its" as class property

Quoted 8 lines

cpu/core: Register core-id and nr-threads as class properties arm/cpu64: Register "aarch64" as class property
xlnx-zcu102: Register properties as class properties
machine: Register "memory-backend" as class property
vga-pci: Register "big-endian-framebuffer" as class property
i440fx: Register i440FX-pcihost properties as class properties
sifive_e: Register "revb" as class property
sifive_u: Register "start-in-flash" as class property

I'm queueing the following:

[PATCH 01/24] cryptodev-vhost-user: Register "chardev" as class property [PATCH 02/24] cryptodev-backend: Register "chardev" as class property [PATCH 12/24] s390x: Register all CPU properties as class properties [PATCH 17/24] cpu/core: Register core-id and nr-threads as class properties [PATCH 19/24] xlnx-zcu102: Register properties as class properties [PATCH 20/24] machine: Register "memory-backend" as class property [PATCH 22/24] i440fx: Register i440FX-pcihost properties as class properties [PATCH 23/24] sifive_e: Register "revb" as class property
[PATCH 24/24] sifive_u: Register "start-in-flash" as class property

The remaining patches still need reviews.

Signature · 1 line
Eduardo
#60 lore raw
Quoted 44 lines · Eduardo Habkost
Quoted 22 lines · Eduardo Habkost

Class properties make QOM introspection simpler and easier, as it doesn't require an object to be instantiated. This series converts a few existing object_property_add*() calls to register class properties instead.

Eduardo Habkost (24):
cryptodev-vhost-user: Register "chardev" as class property
cryptodev-backend: Register "chardev" as class property
rng-egd: Register "chardev" as class property
rng-random: register "filename" as class property
vhost-user: Register "chardev" as class property
vexpress: Register "secure" as class property
rng: Register "opened" as class property
vexpress-a15: Register "virtualization" as class property
input-linux: Register properties as class properties
input-barrier: Register properties as class properties
tmp421: Register properties as class properties
s390x: Register all CPU properties as class properties
i386: Register most CPU properties as class properties
i386: Register feature bit properties as class properties arm/virt: Register most properties as class properties
virt: Register "its" as class property

Quoted 8 lines

cpu/core: Register core-id and nr-threads as class properties arm/cpu64: Register "aarch64" as class property
xlnx-zcu102: Register properties as class properties
machine: Register "memory-backend" as class property
vga-pci: Register "big-endian-framebuffer" as class property
i440fx: Register i440FX-pcihost properties as class properties
sifive_e: Register "revb" as class property
sifive_u: Register "start-in-flash" as class property

I'm queueing the following:

[PATCH 01/24] cryptodev-vhost-user: Register "chardev" as class property [PATCH 02/24] cryptodev-backend: Register "chardev" as class property [PATCH 12/24] s390x: Register all CPU properties as class properties [PATCH 17/24] cpu/core: Register core-id and nr-threads as class properties [PATCH 19/24] xlnx-zcu102: Register properties as class properties [PATCH 20/24] machine: Register "memory-backend" as class property [PATCH 22/24] i440fx: Register i440FX-pcihost properties as class properties [PATCH 23/24] sifive_e: Register "revb" as class property
[PATCH 24/24] sifive_u: Register "start-in-flash" as class property

Quoted 1 line

The remaining patches still need reviews.

Queueing:

[PATCH 03/24] rng-egd: Register "chardev" as class property [PATCH 04/24] rng-random: register "filename" as class property [PATCH 07/24] rng: Register "opened" as class property [PATCH 09/24] input-linux: Register properties as class properties [PATCH 10/24] input-barrier: Register properties as class properties [PATCH 13/24] i386: Register most CPU properties as class properties [PATCH 14/24] i386: Register feature bit properties as class properties

Waiting for reviews on:

[PATCH 05/24] vhost-user: Register "chardev" as class property [PATCH 06/24] vexpress: Register "secure" as class property [PATCH 08/24] vexpress-a15: Register "virtualization" as class property [PATCH 11/24] tmp421: Register properties as class properties [PATCH 15/24] arm/virt: Register most properties as class properties [PATCH 16/24] virt: Register "its" as class property
[PATCH 18/24] arm/cpu64: Register "aarch64" as class property [PATCH 21/24] vga-pci: Register "big-endian-framebuffer" as class property

Signature · 1 line
Eduardo