From patchwork Tue Jun 5 09:15:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 925357 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.ru Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 410R4K0Ml2z9s1R for ; Tue, 5 Jun 2018 19:16:00 +1000 (AEST) Received: from localhost ([::1]:45281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQ84M-0001nF-JL for incoming@patchwork.ozlabs.org; Tue, 05 Jun 2018 05:15:58 -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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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);