From nobody Sun Apr 28 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528190222226337.9131720495392; Tue, 5 Jun 2018 02:17:02 -0700 (PDT) Received: from localhost ([::1]:45289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQ85H-0002hI-VF for importer@patchew.org; Tue, 05 Jun 2018 05:16:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQ83i-0001kx-Ds for qemu-devel@nongnu.org; Tue, 05 Jun 2018 05:15:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQ83e-0004Vt-DH for qemu-devel@nongnu.org; Tue, 05 Jun 2018 05:15:18 -0400 Received: from [107.173.13.209] (port=41403 helo=ozlabs.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQ83e-0004VH-0G for qemu-devel@nongnu.org; Tue, 05 Jun 2018 05:15:14 -0400 Received: from vpl1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id C0D8CAE80011; Tue, 5 Jun 2018 05:14:06 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Tue, 5 Jun 2018 19:15:08 +1000 Message-Id: <20180605091508.14129-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [RFC PATCH qemu] qdev: Use "string" for QOM string properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For QOM properties QEMU uses "string", for example: {"execute": "qom-list", "arguments": {"path": "/machine"}} [{'return': [{'type': 'string', 'name': 'append'}, {'type': 'string', 'nam= e': '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=3Dvnet0"): {"execute": "qom-list", "arguments": {"path": "/machine/peripheral/vnet0"}} ret=3D[{'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 --- 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 =3D { - .name =3D "str", + .name =3D "string", .release =3D release_string, .get =3D get_string, .set =3D 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, } =20 name =3D 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 : pro= p->info->get, NULL, NULL, @@ -711,6 +711,7 @@ void qdev_property_add_static(DeviceState *dev, Propert= y *prop, { Error *local_err =3D NULL; Object *obj =3D OBJECT(dev); + const char *proptype; =20 if (prop->info->create) { prop->info->create(obj, prop, &local_err); @@ -723,7 +724,11 @@ void qdev_property_add_static(DeviceState *dev, Proper= ty *prop, if (!prop->info->get && !prop->info->set) { return; } - object_property_add(obj, prop->name, prop->info->name, + proptype =3D prop->info->name; + if (0 =3D=3D strncmp(proptype, "str", 3)) { + proptype =3D "string"; + } + object_property_add(obj, prop->name, proptype, prop->info->get, prop->info->set, prop->info->release, prop, &local_err); --=20 2.11.0