All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH qemu] qdev: Use "string" for QOM string properties
@ 2018-06-05  9:15 Alexey Kardashevskiy
  2018-06-05  9:29 ` Daniel P. Berrangé
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Kardashevskiy @ 2018-06-05  9:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alexey Kardashevskiy

For QOM properties QEMU uses "string", for example:

{"execute": "qom-list", "arguments": {"path": "/machine"}}
[{'return': [{'type': 'string', 'name': 'append'},  {'type': 'string', 'name': 'kernel'}]

However for the device properties copied from DEVICE_CLASS(class)->props,
"str" is used for a type (vnet0 is "-device virtio-net-pci,id=vnet0"):

{"execute": "qom-list", "arguments": {"path": "/machine/peripheral/vnet0"}}
ret=[{'return': [{'name': 'tx', 'type': 'str'}]

This changes string type when adding them to QOM property list so
we get one string type in QMP.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---

Not a huge improvement and might actually break something but since
I got that far I decided to post this anyway :)

The alternatives are: 1) do nothing 2) do this:

 const PropertyInfo qdev_prop_string = {
-    .name  = "str",
+    .name  = "string",
     .release = release_string,
     .get   = get_string,
     .set   = set_string,
 };


---
 hw/core/qdev.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index f6f9247..2895693 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -687,7 +687,7 @@ static void qdev_property_add_legacy(DeviceState *dev, Property *prop,
     }
 
     name = g_strdup_printf("legacy-%s", prop->name);
-    object_property_add(OBJECT(dev), name, "str",
+    object_property_add(OBJECT(dev), name, "string",
                         prop->info->print ? qdev_get_legacy_property : prop->info->get,
                         NULL,
                         NULL,
@@ -711,6 +711,7 @@ void qdev_property_add_static(DeviceState *dev, Property *prop,
 {
     Error *local_err = NULL;
     Object *obj = OBJECT(dev);
+    const char *proptype;
 
     if (prop->info->create) {
         prop->info->create(obj, prop, &local_err);
@@ -723,7 +724,11 @@ void qdev_property_add_static(DeviceState *dev, Property *prop,
         if (!prop->info->get && !prop->info->set) {
             return;
         }
-        object_property_add(obj, prop->name, prop->info->name,
+        proptype = prop->info->name;
+        if (0 == strncmp(proptype, "str", 3)) {
+            proptype = "string";
+        }
+        object_property_add(obj, prop->name, proptype,
                             prop->info->get, prop->info->set,
                             prop->info->release,
                             prop, &local_err);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-07  8:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-05  9:15 [Qemu-devel] [RFC PATCH qemu] qdev: Use "string" for QOM string properties Alexey Kardashevskiy
2018-06-05  9:29 ` Daniel P. Berrangé
2018-06-07  8:43   ` Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.