From patchwork Sun Nov 17 15:50:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Franciosi X-Patchwork-Id: 11248463 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 972C014DB for ; Sun, 17 Nov 2019 15:51:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1605320730 for ; Sun, 17 Nov 2019 15:51:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nutanix.com header.i=@nutanix.com header.b="o7WgXc8Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1605320730 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nutanix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:54312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iWMq9-0003Wj-Kx for patchwork-qemu-devel@patchwork.kernel.org; Sun, 17 Nov 2019 10:51:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58638) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iWMoy-0002aU-HE for qemu-devel@nongnu.org; Sun, 17 Nov 2019 10:50:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iWMov-0002Fh-Jl for qemu-devel@nongnu.org; Sun, 17 Nov 2019 10:50:39 -0500 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]:33816) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iWMov-0002FC-CI for qemu-devel@nongnu.org; Sun, 17 Nov 2019 10:50:37 -0500 Received: from pps.filterd (m0127842.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAHFnjZj017138; Sun, 17 Nov 2019 07:50:34 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=proofpoint20171006; bh=8maHzqqMqxYszW+ziLW8saTI1QCTI/xMXklvosv5uhA=; b=o7WgXc8Q4PSccSl0onhIPQVAQhdMkxhGrExtdeZBRmM0pj0XJVUC9Vu72XdX8g2aVlTV qcWcwmmo7TN80HqV/7aOa1j3i9/4Mn0P4NuumMOPBs8Q9eFXVioemUu8UU/adQZMQ7Oq /ait9oT+MinFdgs4GQYHWHRnfIu+8xUCzZPPUGcWLHA5m7icGtJQuWrn9movRp+FdNZB E1RCewuG1uHmCjmNJYDNFSAexkek6KXABfAnYLWKwESlucOpMWIGVcbQpnLzAqhxkhH2 Ml8Tpc4gsJgUUl/zCj8Dlztd1e30+oI1pn/ksN1wnwACMIWWTh+eYm46RHUFLbRAQeb/ Cg== Received: from nam05-dm3-obe.outbound.protection.outlook.com (mail-dm3nam05lp2056.outbound.protection.outlook.com [104.47.49.56]) by mx0b-002c1b01.pphosted.com with ESMTP id 2waham1m39-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 17 Nov 2019 07:50:34 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jMxHMVImEYPC/H/KSoc95NXqq0JjCIU/KkfDTkdyAMtN+Uuuxog05fdZO3ZH47CKFSx2VPBamRSapue2y7/ioIr0gBVu/fP7HrGN7rO/gKCwJyC98dZPCrW0DHvXwXr3XkvcrRHQoPWDplTLNGXBmyj+vXagz6bJnUk8pBHBwJRzYHFsTM9urSGugc532xjba0OVUBm2Bw4xXivd7x2sh8PJ5/gIUSDIuI5ndTG1TYU4ETW54f5NLFwSOWQ2Q6mPq+DffGaewwobFcoRdb+juM1z10vqw8b4Jic5ar1cvUG/Ee6hzpTAUGlEbZT9YVdpiWnDuA3bejDP8o+2uNx+jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8maHzqqMqxYszW+ziLW8saTI1QCTI/xMXklvosv5uhA=; b=f1MkdZFSAOqdPQSIzXdnhAvHLnQ1HBR7PKmMVHlw4+cNZjUGthS0pXwXJQjbSxSQzhc7m7ofa5h7WVxjzbrbYl7CtdLltsOoJEqmkjx6cHWIqevApGO7ynHxKhgUaV3ENrrGIJLxg/3QRCHnDFMgAwfGI6yVJZgQozHA8YbYszrQ6DIOBTyZ2Uiy2szyXaQBeTnoSfzsstbgrXsLC5E9o7mCDkrKEilrle4i7orPUM9v9g4GZD26M24EEPtyPE50Rl2jcg3HvovAm0qVVBqEK5x0gzNWH+ZcpxKAQEOlrqDCvNON+8aJAHZO1BiyexXg7ca1YclC9f6MtbGLXeIf7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from MWHPR02MB2656.namprd02.prod.outlook.com (10.168.206.142) by MWHPR02MB2320.namprd02.prod.outlook.com (10.168.244.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.28; Sun, 17 Nov 2019 15:50:32 +0000 Received: from MWHPR02MB2656.namprd02.prod.outlook.com ([fe80::f801:763d:e7fc:6bf]) by MWHPR02MB2656.namprd02.prod.outlook.com ([fe80::f801:763d:e7fc:6bf%7]) with mapi id 15.20.2451.029; Sun, 17 Nov 2019 15:50:32 +0000 From: Felipe Franciosi To: Markus Armbruster , Stefan Hajnoczi Subject: [PATCH] qom/object: enable setter for uint types Thread-Topic: [PATCH] qom/object: enable setter for uint types Thread-Index: AQHVnV6+rh+t6rwLkkm4RGhtQRwtag== Date: Sun, 17 Nov 2019 15:50:32 +0000 Message-ID: <20191117072839.34390-1-felipe@nutanix.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR02CA0047.namprd02.prod.outlook.com (2603:10b6:a03:54::24) To MWHPR02MB2656.namprd02.prod.outlook.com (2603:10b6:300:45::14) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [94.197.121.27] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 67811ff3-ad23-4437-5108-08d76b75e00b x-ms-traffictypediagnostic: MWHPR02MB2320: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-proofpoint-crosstenant: true x-ms-oob-tlc-oobclassifiers: OLM:249; x-forefront-prvs: 02243C58C6 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39850400004)(396003)(366004)(346002)(376002)(136003)(199004)(189003)(1076003)(5660300002)(99286004)(26005)(186003)(107886003)(478600001)(256004)(386003)(486006)(6506007)(316002)(102836004)(476003)(2616005)(52116002)(50226002)(8676002)(110136005)(54906003)(81156014)(81166006)(8936002)(36756003)(6512007)(66066001)(4326008)(6116002)(14454004)(3846002)(86362001)(71190400001)(71200400001)(66476007)(66556008)(66446008)(64756008)(66946007)(2906002)(6486002)(30864003)(305945005)(25786009)(6436002)(7736002)(64030200001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR02MB2320; H:MWHPR02MB2656.namprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nutanix.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: cG92ESw6BH87Y5vY8hV3YJ8e9vJxffgNoWx3fM+aAdlynZkHpSxS//49pbd43Zh7OnRHGAoDztlk3Lp4LWrW3zuGkIxhCKD2w0VVrtny+U3qkw0B6Sk/SpjYvNwkos8BX1ALHMhEJrUQtgMhuC8cbr8gFhMj8wB81Y9OUM6cogOFprUfS0eARq6ySkQuhq/MfE+klePj3zEUDkEV6zjY0qALQiW8WeVag+AXqfulvRdtiy1Gau9j3hOOmwgCgfMt1od0DPJHr/dZhaua0gpDU+uxUU30vucX0FHicIencJc5uY45fhgk6e3/v63e4lOce3axH1c4uPOAqMEG3erbysd0y8DpnpBKDgsJ6f24jMCZ3Q+mSB498rVm6LUQUaiK4fdVZxbhLQATQN7bOMIZR2mMIo/Zj5z1EvNdQaRFHowr0I7iV0Fv0vd57KB9W7dm MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67811ff3-ad23-4437-5108-08d76b75e00b X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Nov 2019 15:50:32.8209 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: lrbdRSaDT55afa2c7yGsZv8ujoXmXkiJjXFfRjMDr75t+RYgrXPsSU7fUnchpBMLaOUkRgvgNuNjRr6q3bLfsK+xTbuyIvSEKkeK/xfQXvU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR02MB2320 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-17_03:2019-11-15,2019-11-17 signatures=0 X-Proofpoint-Spam-Reason: safe X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.155.12 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "qemu-devel@nongnu.org" , Felipe Franciosi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Traditionally, the uint-specific property helpers only offer getters. When adding object (or class) uint types, one must therefore use the generic property helper if a setter is needed. This enhances the uint-specific property helper APIs by adding a 'readonly' field and modifying all users of that API to set this parameter to true. If 'readonly' is false, though, the helper will add an automatic setter for the value. Signed-off-by: Felipe Franciosi Reviewed-by: Stefan Hajnoczi --- hw/acpi/ich9.c | 4 +- hw/acpi/pcihp.c | 6 +-- hw/acpi/piix4.c | 12 +++--- hw/isa/lpc_ich9.c | 4 +- hw/ppc/spapr_drc.c | 2 +- include/qom/object.h | 28 ++++++++---- qom/object.c | 100 ++++++++++++++++++++++++++++++++----------- ui/console.c | 3 +- 8 files changed, 111 insertions(+), 48 deletions(-) diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 2034dd749e..94dc5147ce 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -454,12 +454,12 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp) pm->s4_val = 2; object_property_add_uint32_ptr(obj, ACPI_PM_PROP_PM_IO_BASE, - &pm->pm_io_base, errp); + &pm->pm_io_base, true, errp); object_property_add(obj, ACPI_PM_PROP_GPE0_BLK, "uint32", ich9_pm_get_gpe0_blk, NULL, NULL, pm, NULL); object_property_add_uint32_ptr(obj, ACPI_PM_PROP_GPE0_BLK_LEN, - &gpe0_len, errp); + &gpe0_len, true, errp); object_property_add_bool(obj, "memory-hotplug-support", ich9_pm_get_memory_hotplug_support, ich9_pm_set_memory_hotplug_support, diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 8413348a33..70bc1408e6 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -80,7 +80,7 @@ static void *acpi_set_bsel(PCIBus *bus, void *opaque) *bus_bsel = (*bsel_alloc)++; object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, - bus_bsel, &error_abort); + bus_bsel, true, &error_abort); } return bsel_alloc; @@ -373,9 +373,9 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *s, PCIBus *root_bus, memory_region_add_subregion(address_space_io, s->io_base, &s->io); object_property_add_uint16_ptr(owner, ACPI_PCIHP_IO_BASE_PROP, &s->io_base, - &error_abort); + true, &error_abort); object_property_add_uint16_ptr(owner, ACPI_PCIHP_IO_LEN_PROP, &s->io_len, - &error_abort); + true, &error_abort); } const VMStateDescription vmstate_acpi_pcihp_pci_status = { diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 93aec2dd2c..032ba11e62 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -443,17 +443,17 @@ static void piix4_pm_add_propeties(PIIX4PMState *s) static const uint16_t sci_int = 9; object_property_add_uint8_ptr(OBJECT(s), ACPI_PM_PROP_ACPI_ENABLE_CMD, - &acpi_enable_cmd, NULL); + &acpi_enable_cmd, true, NULL); object_property_add_uint8_ptr(OBJECT(s), ACPI_PM_PROP_ACPI_DISABLE_CMD, - &acpi_disable_cmd, NULL); + &acpi_disable_cmd, true, NULL); object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_GPE0_BLK, - &gpe0_blk, NULL); + &gpe0_blk, true, NULL); object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_GPE0_BLK_LEN, - &gpe0_blk_len, NULL); + &gpe0_blk_len, true, NULL); object_property_add_uint16_ptr(OBJECT(s), ACPI_PM_PROP_SCI_INT, - &sci_int, NULL); + &sci_int, true, NULL); object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_PM_IO_BASE, - &s->io_base, NULL); + &s->io_base, true, NULL); } static void piix4_pm_realize(PCIDevice *dev, Error **errp) diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index 17c292e306..5555ce3342 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -645,9 +645,9 @@ static void ich9_lpc_add_properties(ICH9LPCState *lpc) ich9_lpc_get_sci_int, NULL, NULL, NULL, NULL); object_property_add_uint8_ptr(OBJECT(lpc), ACPI_PM_PROP_ACPI_ENABLE_CMD, - &acpi_enable_cmd, NULL); + &acpi_enable_cmd, true, NULL); object_property_add_uint8_ptr(OBJECT(lpc), ACPI_PM_PROP_ACPI_DISABLE_CMD, - &acpi_disable_cmd, NULL); + &acpi_disable_cmd, true, NULL); ich9_pm_add_properties(OBJECT(lpc), &lpc->pm, NULL); } diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 62f1a42592..76f389f56a 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -553,7 +553,7 @@ static void spapr_dr_connector_instance_init(Object *obj) SpaprDrc *drc = SPAPR_DR_CONNECTOR(obj); SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); - object_property_add_uint32_ptr(obj, "id", &drc->id, NULL); + object_property_add_uint32_ptr(obj, "id", &drc->id, true, NULL); object_property_add(obj, "index", "uint32", prop_get_index, NULL, NULL, NULL, NULL); object_property_add(obj, "fdt", "struct", prop_get_fdt, diff --git a/include/qom/object.h b/include/qom/object.h index 128d00c77f..8fc28ed0c9 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1584,60 +1584,72 @@ void object_class_property_add_tm(ObjectClass *klass, const char *name, * @obj: the object to add a property to * @name: the name of the property * @v: pointer to value + * @readonly: don't add setter for value * @errp: if an error occurs, a pointer to an area to store the error * * Add an integer property in memory. This function will add a * property of type 'uint8'. */ void object_property_add_uint8_ptr(Object *obj, const char *name, - const uint8_t *v, Error **errp); + const uint8_t *v, bool readonly, + Error **errp); void object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name, - const uint8_t *v, Error **errp); + const uint8_t *v, bool readonly, + Error **errp); /** * object_property_add_uint16_ptr: * @obj: the object to add a property to * @name: the name of the property * @v: pointer to value + * @readonly: don't add setter for value * @errp: if an error occurs, a pointer to an area to store the error * * Add an integer property in memory. This function will add a * property of type 'uint16'. */ void object_property_add_uint16_ptr(Object *obj, const char *name, - const uint16_t *v, Error **errp); + const uint16_t *v, bool readonly, + Error **errp); void object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name, - const uint16_t *v, Error **errp); + const uint16_t *v, bool readonly, + Error **errp); /** * object_property_add_uint32_ptr: * @obj: the object to add a property to * @name: the name of the property * @v: pointer to value + * @readonly: don't add setter for value * @errp: if an error occurs, a pointer to an area to store the error * * Add an integer property in memory. This function will add a * property of type 'uint32'. */ void object_property_add_uint32_ptr(Object *obj, const char *name, - const uint32_t *v, Error **errp); + const uint32_t *v, bool readonly, + Error **errp); void object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name, - const uint32_t *v, Error **errp); + const uint32_t *v, bool readonly, + Error **errp); /** * object_property_add_uint64_ptr: * @obj: the object to add a property to * @name: the name of the property * @v: pointer to value + * @readonly: don't add setter for value * @errp: if an error occurs, a pointer to an area to store the error * * Add an integer property in memory. This function will add a * property of type 'uint64'. */ void object_property_add_uint64_ptr(Object *obj, const char *name, - const uint64_t *v, Error **Errp); + const uint64_t *v, bool readonly, + Error **Errp); void object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name, - const uint64_t *v, Error **Errp); + const uint64_t *v, bool readonly, + Error **Errp); /** * object_property_add_alias: diff --git a/qom/object.c b/qom/object.c index d51b57fba1..f60b164a62 100644 --- a/qom/object.c +++ b/qom/object.c @@ -2326,6 +2326,13 @@ static void property_get_uint8_ptr(Object *obj, Visitor *v, const char *name, visit_type_uint8(v, name, &value, errp); } +static void property_set_uint8_ptr(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + uint8_t *value = opaque; + visit_type_uint8(v, name, value, errp); +} + static void property_get_uint16_ptr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -2333,6 +2340,13 @@ static void property_get_uint16_ptr(Object *obj, Visitor *v, const char *name, visit_type_uint16(v, name, &value, errp); } +static void property_set_uint16_ptr(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + uint16_t *value = opaque; + visit_type_uint16(v, name, value, errp); +} + static void property_get_uint32_ptr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -2340,6 +2354,13 @@ static void property_get_uint32_ptr(Object *obj, Visitor *v, const char *name, visit_type_uint32(v, name, &value, errp); } +static void property_set_uint32_ptr(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + uint32_t *value = opaque; + visit_type_uint32(v, name, value, errp); +} + static void property_get_uint64_ptr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -2347,60 +2368,91 @@ static void property_get_uint64_ptr(Object *obj, Visitor *v, const char *name, visit_type_uint64(v, name, &value, errp); } +static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + uint64_t *value = opaque; + visit_type_uint64(v, name, value, errp); +} + void object_property_add_uint8_ptr(Object *obj, const char *name, - const uint8_t *v, Error **errp) + const uint8_t *v, bool readonly, + Error **errp) { - object_property_add(obj, name, "uint8", property_get_uint8_ptr, - NULL, NULL, (void *)v, errp); + object_property_add(obj, name, "uint8", + property_get_uint8_ptr, + readonly ? NULL : property_set_uint8_ptr, + NULL, (void *)v, errp); } void object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name, - const uint8_t *v, Error **errp) + const uint8_t *v, bool readonly, + Error **errp) { - object_class_property_add(klass, name, "uint8", property_get_uint8_ptr, - NULL, NULL, (void *)v, errp); + object_class_property_add(klass, name, "uint8", + property_get_uint8_ptr, + readonly ? NULL : property_set_uint8_ptr, + NULL, (void *)v, errp); } void object_property_add_uint16_ptr(Object *obj, const char *name, - const uint16_t *v, Error **errp) + const uint16_t *v, bool readonly, + Error **errp) { - object_property_add(obj, name, "uint16", property_get_uint16_ptr, - NULL, NULL, (void *)v, errp); + object_property_add(obj, name, "uint16", + property_get_uint16_ptr, + readonly ? NULL : property_set_uint16_ptr, + NULL, (void *)v, errp); } void object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name, - const uint16_t *v, Error **errp) + const uint16_t *v, bool readonly, + Error **errp) { - object_class_property_add(klass, name, "uint16", property_get_uint16_ptr, - NULL, NULL, (void *)v, errp); + object_class_property_add(klass, name, "uint16", + property_get_uint16_ptr, + readonly ? NULL : property_set_uint16_ptr, + NULL, (void *)v, errp); } void object_property_add_uint32_ptr(Object *obj, const char *name, - const uint32_t *v, Error **errp) + const uint32_t *v, bool readonly, + Error **errp) { - object_property_add(obj, name, "uint32", property_get_uint32_ptr, - NULL, NULL, (void *)v, errp); + object_property_add(obj, name, "uint32", + property_get_uint32_ptr, + readonly ? NULL : property_set_uint32_ptr, + NULL, (void *)v, errp); } void object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name, - const uint32_t *v, Error **errp) + const uint32_t *v, bool readonly, + Error **errp) { - object_class_property_add(klass, name, "uint32", property_get_uint32_ptr, - NULL, NULL, (void *)v, errp); + object_class_property_add(klass, name, "uint32", + property_get_uint32_ptr, + readonly ? NULL : property_set_uint32_ptr, + NULL, (void *)v, errp); } void object_property_add_uint64_ptr(Object *obj, const char *name, - const uint64_t *v, Error **errp) + const uint64_t *v, bool readonly, + Error **errp) { - object_property_add(obj, name, "uint64", property_get_uint64_ptr, - NULL, NULL, (void *)v, errp); + object_property_add(obj, name, "uint64", + property_get_uint64_ptr, + property_set_uint64_ptr, + NULL, (void *)v, errp); } void object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name, - const uint64_t *v, Error **errp) + const uint64_t *v, bool readonly, + Error **errp) { - object_class_property_add(klass, name, "uint64", property_get_uint64_ptr, - NULL, NULL, (void *)v, errp); + object_class_property_add(klass, name, "uint64", + property_get_uint64_ptr, + readonly ? NULL : property_set_uint64_ptr, + NULL, (void *)v, errp); } typedef struct { diff --git a/ui/console.c b/ui/console.c index 82d1ddac9c..3375c33d71 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1296,8 +1296,7 @@ static QemuConsole *new_console(DisplayState *ds, console_type_t console_type, object_property_allow_set_link, OBJ_PROP_LINK_STRONG, &error_abort); - object_property_add_uint32_ptr(obj, "head", - &s->head, &error_abort); + object_property_add_uint32_ptr(obj, "head", &s->head, true, &error_abort); if (!active_console || ((active_console->console_type != GRAPHIC_CONSOLE) && (console_type == GRAPHIC_CONSOLE))) {