From patchwork Thu Oct 29 22:02:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316604 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAA14C2D0A3 for ; Thu, 29 Oct 2020 22:07:51 +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 1F1312075E for ; Thu, 29 Oct 2020 22:07:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dLYaQ7lX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F1312075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYG5F-000898-Sp for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:07:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG0f-0002uk-LL for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59220) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG0d-0006XY-NF for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604008981; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yK8fXoNijGvJkZCHAg77qM5UoYs33ZIDnUj+ZyGBd5s=; b=dLYaQ7lXmFMpuKqy8eCGhfPVNx+r10hUeyFqRFQQnUUgED/flDZ9mTUfa3a9/Xg0hvc4vc o4Kg51iCY5/dZrh2jz4PBOyoBg+bIeQ4aFZBcX+Pu9zBdD7FwChMSDDVrSsnocgUdn3lE8 7RgFh5YcESIm8vkW/kmSNgesCsDyMGo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-113-5y66PHdcOUGyzEwcOpxhfw-1; Thu, 29 Oct 2020 18:02:58 -0400 X-MC-Unique: 5y66PHdcOUGyzEwcOpxhfw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1BEF49CC0B; Thu, 29 Oct 2020 22:02:57 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB33C5D9D3; Thu, 29 Oct 2020 22:02:56 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 02/36] cpu: Move cpu_common_props to hw/core/cpu.c Date: Thu, 29 Oct 2020 18:02:12 -0400 Message-Id: <20201029220246.472693-3-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" There's no reason to keep the property list separate from the CPU class code. Move the variable to hw/core/cpu.c and make it static. Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


--
Marc-André Lureau
--- Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: qemu-devel@nongnu.org --- include/hw/core/cpu.h | 1 - cpu.c | 15 --------------- hw/core/cpu.c | 15 +++++++++++++++ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 9c3a45ad7b..2bc8429559 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -1119,7 +1119,6 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx); void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...) GCC_FMT_ATTR(2, 3); -extern Property cpu_common_props[]; void cpu_exec_initfn(CPUState *cpu); void cpu_exec_realizefn(CPUState *cpu, Error **errp); void cpu_exec_unrealizefn(CPUState *cpu); diff --git a/cpu.c b/cpu.c index 0be5dcb6f3..0c485cdf2d 100644 --- a/cpu.c +++ b/cpu.c @@ -144,21 +144,6 @@ void cpu_exec_unrealizefn(CPUState *cpu) #endif } -Property cpu_common_props[] = { -#ifndef CONFIG_USER_ONLY - /* Create a memory property for softmmu CPU object, - * so users can wire up its memory. (This can't go in hw/core/cpu.c - * because that file is compiled only once for both user-mode - * and system builds.) The default if no link is set up is to use - * the system address space. - */ - DEFINE_PROP_LINK("memory", CPUState, memory, TYPE_MEMORY_REGION, - MemoryRegion *), -#endif - DEFINE_PROP_BOOL("start-powered-off", CPUState, start_powered_off, false), - DEFINE_PROP_END_OF_LIST(), -}; - void cpu_exec_initfn(CPUState *cpu) { cpu->as = NULL; diff --git a/hw/core/cpu.c b/hw/core/cpu.c index 576fa1d7ba..5c89c858aa 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -393,6 +393,21 @@ static vaddr cpu_adjust_watchpoint_address(CPUState *cpu, vaddr addr, int len) return addr; } +static Property cpu_common_props[] = { +#ifndef CONFIG_USER_ONLY + /* Create a memory property for softmmu CPU object, + * so users can wire up its memory. (This can't go in hw/core/cpu.c + * because that file is compiled only once for both user-mode + * and system builds.) The default if no link is set up is to use + * the system address space. + */ + DEFINE_PROP_LINK("memory", CPUState, memory, TYPE_MEMORY_REGION, + MemoryRegion *), +#endif + DEFINE_PROP_BOOL("start-powered-off", CPUState, start_powered_off, false), + DEFINE_PROP_END_OF_LIST(), +}; + static void cpu_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); From patchwork Thu Oct 29 22:02:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64216C4742C for ; Thu, 29 Oct 2020 22:07:56 +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 CB8C02087E for ; Thu, 29 Oct 2020 22:07:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZTQvgrZO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB8C02087E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYG5K-0008MH-P3 for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:07:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG0p-000323-5V for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:54615) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG0m-0006YJ-4K for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604008987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YqXty0Hhjl2IAAgQwDKLPITrFdXxEQfGBBXtWrSqdXg=; b=ZTQvgrZO1LCRSDh9gaynXgAgKnw/tzgizIgdiOBxZDYLx+G8nF9O+hb8NVuPkU4A0ZPEPX 3YLWcvc63hMJ+madRXBMv+Wn/DlV9WX0gFTjc8gFRXll+RerWrx/iQAZNEMpLwxxYknkVC Ss3c6SHHkY4fXnG6Uhoxnpg6/mN6/KA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-294-Wz30tt5VOwWnTtT6P5IgIg-1; Thu, 29 Oct 2020 18:03:03 -0400 X-MC-Unique: Wz30tt5VOwWnTtT6P5IgIg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3CFC31018F84; Thu, 29 Oct 2020 22:03:02 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id C59731975F; Thu, 29 Oct 2020 22:03:01 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 05/36] sparc: Check dev->realized at sparc_set_nwindows() Date: Thu, 29 Oct 2020 18:02:15 -0400 Message-Id: <20201029220246.472693-6-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 01:47:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Mark Cave-Ayland , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Artyom Tarasenko Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" sparc_set_nwindows() is one of the very few property setters that don't check dev->realized, and there's no reason for it to be special. Check dev->realized like the other setters. Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

--
Marc-André Lureau
--- Cc: Mark Cave-Ayland Cc: Artyom Tarasenko Cc: qemu-devel@nongnu.org --- target/sparc/cpu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index cf21efd85f..8ecb20e55f 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -798,11 +798,17 @@ static void sparc_get_nwindows(Object *obj, Visitor *v, const char *name, static void sparc_set_nwindows(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { + DeviceState *dev = DEVICE(obj); const int64_t min = MIN_NWINDOWS; const int64_t max = MAX_NWINDOWS; SPARCCPU *cpu = SPARC_CPU(obj); int64_t value; + if (dev->realized) { + qdev_prop_set_after_realize(dev, name, errp); + return; + } + if (!visit_type_int(v, name, &value, errp)) { return; } From patchwork Thu Oct 29 22:02:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CA29C2D0A3 for ; Thu, 29 Oct 2020 22:05:30 +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 CA59720838 for ; Thu, 29 Oct 2020 22:05:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="E1DuD9tz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA59720838 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYG2y-0004rW-GE for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:05:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG0m-0002wP-DK for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48955) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG0h-0006Y8-00 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604008986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tMyj+yLLsuoC33V6ByrjXJuM5TMj0lzUZ7QO9e+FUJE=; b=E1DuD9tzl79xwwuzRtc+2QGIrgWBTtArm1Kw/tBRXbHu17zIahMDE0i7iJpR1dZeQ/P1Dl 8sb76YwgprslYw4+sqhDCzusKGKfuTb4ngeNW4cFmdZvlgywQBP3xaHrYc/MKYPmvyer8V WDRzsIjd6S/QZt1JXAQOBaYk+oYx7LU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-145-XpMw6JjSNVO4eFF_Btb8EA-1; Thu, 29 Oct 2020 18:03:04 -0400 X-MC-Unique: XpMw6JjSNVO4eFF_Btb8EA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6E3A39CC02 for ; Thu, 29 Oct 2020 22:03:03 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3598D60C17; Thu, 29 Oct 2020 22:03:03 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 06/36] qdev: Don't use dev->id on set_size32() error message Date: Thu, 29 Oct 2020 18:02:16 -0400 Message-Id: <20201029220246.472693-7-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" All other qdev property error messages use "." instead of ".". Change set_size32() for consistency, and to make the code not specific to TYPE_DEVICE. Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>



--
Marc-André Lureau
--- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- hw/core/qdev-properties.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 67ae19df05..daf844c2d3 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -542,7 +542,7 @@ static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque, error_setg(errp, "Property %s.%s doesn't take value %" PRIu64 " (maximum: %u)", - dev->id ? : "", name, value, UINT32_MAX); + object_get_typename(obj), name, value, UINT32_MAX); return; } From patchwork Thu Oct 29 22:02:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316602 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B128C2D0A3 for ; Thu, 29 Oct 2020 22:10:01 +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 8357D2075E for ; Thu, 29 Oct 2020 22:10:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M2m/grPV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8357D2075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYG7L-00034l-A1 for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:09:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG0n-0002yp-N9 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG0m-0006YK-1Z for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604008987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tAM7xYCyGMCOzIDu0PHt5yIiFGpsggoFjf1K1OhATs8=; b=M2m/grPVEJ9trwPhEVTZ3OXw8NF5x8GAT+82QSv65YVD7/QRPO2/Q5BM9stNVExVfepK0e N+GitxUaTqVEa+tG/LNvxJGpDd3kFTwGTpTqXGj49Qtg61Rpy8qKO2pPmH2pYDpDUJbAx7 +ndqA5kK70f6SjeUfT5R8pbdGTm+VB8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-157-QYPHd_eUO22r27DssGOT4Q-1; Thu, 29 Oct 2020 18:03:05 -0400 X-MC-Unique: QYPHd_eUO22r27DssGOT4Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8EDF10E2192 for ; Thu, 29 Oct 2020 22:03:04 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A8C25D9D3; Thu, 29 Oct 2020 22:03:04 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 07/36] qdev: Make PropertyInfo.print method get Object* argument Date: Thu, 29 Oct 2020 18:02:17 -0400 Message-Id: <20201029220246.472693-8-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Make the code more generic and not specific to TYPE_DEVICE. Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


--
Marc-André Lureau
--- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- include/hw/qdev-properties.h | 2 +- hw/core/qdev-properties-system.c | 3 ++- hw/core/qdev-properties.c | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index db7ce51dd5..0ea822e6a7 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -32,7 +32,7 @@ struct PropertyInfo { const char *name; const char *description; const QEnumLookup *enum_table; - int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len); + int (*print)(Object *obj, Property *prop, char *dest, size_t len); void (*set_default_value)(ObjectProperty *op, const Property *prop); void (*create)(ObjectClass *oc, Property *prop); ObjectPropertyAccessor *get; diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index b81a4e8d14..d0fb063a49 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -801,9 +801,10 @@ invalid: g_free(str); } -static int print_pci_devfn(DeviceState *dev, Property *prop, char *dest, +static int print_pci_devfn(Object *obj, Property *prop, char *dest, size_t len) { + DeviceState *dev = DEVICE(obj); int32_t *ptr = qdev_get_prop_ptr(dev, prop); if (*ptr == -1) { diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index daf844c2d3..b6cf53e929 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -988,13 +988,12 @@ static void qdev_get_legacy_property(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - DeviceState *dev = DEVICE(obj); Property *prop = opaque; char buffer[1024]; char *ptr = buffer; - prop->info->print(dev, prop, buffer, sizeof(buffer)); + prop->info->print(obj, prop, buffer, sizeof(buffer)); visit_type_str(v, name, &ptr, errp); } From patchwork Thu Oct 29 22:02:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316600 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8197FC2D0A3 for ; Thu, 29 Oct 2020 22:12:13 +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 D9E07206CA for ; Thu, 29 Oct 2020 22:12:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CzKSu3PV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9E07206CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYG9S-0006Y9-4O for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:12:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG0n-0002z5-RQ for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50228) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG0m-0006YU-3w for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604008988; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1kDCf8oi17+eqObCGQGkMjPNBVRKUZzmaaMtICo8ucU=; b=CzKSu3PVDfm89W+Z64h66UXWay4YTnXx6ox3SA3SD5rcdM4rZ3hqijyAgAPoJzheFl5le1 2inl0c9gxYAhPWEA0iXU/CLq9EKNI64QJ88vrBTC16cNiYi4LkSQ2SXm12TMZqk5hfDL1W BQUTZbLBa3sCwJSodnTKz3RVbuL3be8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-281-I79x39D1PpCDQd5vUEXwVg-1; Thu, 29 Oct 2020 18:03:07 -0400 X-MC-Unique: I79x39D1PpCDQd5vUEXwVg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 415909CC07 for ; Thu, 29 Oct 2020 22:03:06 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAFA660C17; Thu, 29 Oct 2020 22:03:05 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 08/36] qdev: Make bit_prop_set() get Object* argument Date: Thu, 29 Oct 2020 18:02:18 -0400 Message-Id: <20201029220246.472693-9-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Make the code more generic and not specific to TYPE_DEVICE. Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


--
Marc-André Lureau
--- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- hw/core/qdev-properties.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index b6cf53e929..3a4638f4de 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -92,8 +92,9 @@ static uint32_t qdev_get_prop_mask(Property *prop) return 0x1 << prop->bitnr; } -static void bit_prop_set(DeviceState *dev, Property *props, bool val) +static void bit_prop_set(Object *obj, Property *props, bool val) { + DeviceState *dev = DEVICE(obj); uint32_t *p = qdev_get_prop_ptr(dev, props); uint32_t mask = qdev_get_prop_mask(props); if (val) { @@ -129,7 +130,7 @@ static void prop_set_bit(Object *obj, Visitor *v, const char *name, if (!visit_type_bool(v, name, &value, errp)) { return; } - bit_prop_set(dev, prop, value); + bit_prop_set(obj, prop, value); } static void set_default_value_bool(ObjectProperty *op, const Property *prop) @@ -153,8 +154,9 @@ static uint64_t qdev_get_prop_mask64(Property *prop) return 0x1ull << prop->bitnr; } -static void bit64_prop_set(DeviceState *dev, Property *props, bool val) +static void bit64_prop_set(Object *obj, Property *props, bool val) { + DeviceState *dev = DEVICE(obj); uint64_t *p = qdev_get_prop_ptr(dev, props); uint64_t mask = qdev_get_prop_mask64(props); if (val) { @@ -190,7 +192,7 @@ static void prop_set_bit64(Object *obj, Visitor *v, const char *name, if (!visit_type_bool(v, name, &value, errp)) { return; } - bit64_prop_set(dev, prop, value); + bit64_prop_set(obj, prop, value); } const PropertyInfo qdev_prop_bit64 = { From patchwork Thu Oct 29 22:02:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316598 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC6E4C2D0A3 for ; Thu, 29 Oct 2020 22:14:11 +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 38789206CA for ; Thu, 29 Oct 2020 22:14:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JkPPek9K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38789206CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYGBO-0001Vj-40 for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:14:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG0x-0003Kc-Fu for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28104) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG0u-0006ZN-LG for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604008999; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+SZZYhSE2rpTgLRMeYs39Kq9SIu/LUpzeiN/rszhjA4=; b=JkPPek9KUkj1Fuaw2FhXvkYD0UnZW2CrHvQo2C+PBjjjv6nAbUywBrYMMRRUviFovpcXZw t+Rq2W1akxrSUmD6d/rjFxI31XnjlyQYcX6Zn/RlR96tjPkDQPfsYhfxgJPHy1ligIQMIx ArH/cHYEbvRLXowIEToDBznp/TPAF+0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-419-yWraVOmoPVyzDAoNkDCSKQ-1; Thu, 29 Oct 2020 18:03:18 -0400 X-MC-Unique: yWraVOmoPVyzDAoNkDCSKQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E260D1018F78 for ; Thu, 29 Oct 2020 22:03:16 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DEDD5C1C4; Thu, 29 Oct 2020 22:03:16 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 11/36] qdev: Make check_prop_still_unset() get Object* argument Date: Thu, 29 Oct 2020 18:02:21 -0400 Message-Id: <20201029220246.472693-12-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Make the code more generic and not specific to TYPE_DEVICE. Signed-off-by: Eduardo Habkost Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

 Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


--
Marc-André Lureau
--- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- hw/core/qdev-properties-system.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index af1339e562..85dd38db0f 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -32,11 +32,11 @@ #include "hw/pci/pci.h" #include "util/block-helpers.h" -static bool check_prop_still_unset(DeviceState *dev, const char *name, +static bool check_prop_still_unset(Object *obj, const char *name, const void *old_val, const char *new_val, Error **errp) { - const GlobalProperty *prop = qdev_find_global_prop(OBJECT(dev), name); + const GlobalProperty *prop = qdev_find_global_prop(obj, name); if (!old_val) { return true; @@ -105,7 +105,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const char *name, * TODO Should this really be an error? If no, the old value * needs to be released before we store the new one. */ - if (!check_prop_still_unset(dev, name, *ptr, str, errp)) { + if (!check_prop_still_unset(obj, name, *ptr, str, errp)) { return; } @@ -247,7 +247,7 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque, * TODO Should this really be an error? If no, the old value * needs to be released before we store the new one. */ - if (!check_prop_still_unset(dev, name, be->chr, str, errp)) { + if (!check_prop_still_unset(obj, name, be->chr, str, errp)) { return; } @@ -429,7 +429,7 @@ static void set_netdev(Object *obj, Visitor *v, const char *name, * TODO Should this really be an error? If no, the old value * needs to be released before we store the new one. */ - if (!check_prop_still_unset(dev, name, ncs[i], str, errp)) { + if (!check_prop_still_unset(obj, name, ncs[i], str, errp)) { goto out; } From patchwork Thu Oct 29 22:02:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316596 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17B24C2D0A3 for ; Thu, 29 Oct 2020 22:17:12 +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 70447206CB for ; Thu, 29 Oct 2020 22:17:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="W8H1YuDO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70447206CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYGEI-00055O-C8 for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:17:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG14-0003Pg-SJ for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33919) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG11-0006Zt-Uy for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604009004; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NctMuJLA1Rf4RgP5PRiGy0e4/n5BNGh0iuXOJxgJ/F4=; b=W8H1YuDOtmYJirHco0p9LilqNxfX5e5zI+M49asbfYp3MqAAicTzPrcv9RIaY+pw+Gigyu yAVELLiaURQHrhqnHV/mxffzSdKlclmHA7sAGjAXXsTbeybtoTEbdWZa/lgPT5dYCVHepW h4TlzHK0xhVQyc1dvn3tM5Ot6L7FQMc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-393-4v5942gfNqqpLZGQYDAWhA-1; Thu, 29 Oct 2020 18:03:22 -0400 X-MC-Unique: 4v5942gfNqqpLZGQYDAWhA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D830835B47; Thu, 29 Oct 2020 22:03:21 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id C70EA5B4C4; Thu, 29 Oct 2020 22:03:17 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 12/36] qdev: Make error_set_from_qdev_prop_error() get Object* argument Date: Thu, 29 Oct 2020 18:02:22 -0400 Message-Id: <20201029220246.472693-13-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action 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: Thomas Huth , "Daniel P. Berrange" , David Hildenbrand , John Snow , Cornelia Huck , Markus Armbruster , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Make the code more generic and not specific to TYPE_DEVICE. Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

What about dropping _qdev from the function name too?

Also, I am not sure it's a well designed function.. I would rather have 3 different helper functions than dispatching with an errno... Might be worth a TODO note :)

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


--
Marc-André Lureau
--- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: Cornelia Huck Cc: Thomas Huth Cc: Richard Henderson Cc: David Hildenbrand Cc: Halil Pasic Cc: Christian Borntraeger Cc: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org --- include/hw/qdev-properties.h | 2 +- hw/core/qdev-properties-system.c | 10 +++++----- hw/core/qdev-properties.c | 10 +++++----- hw/s390x/css.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 7620095fed..530286e869 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -309,7 +309,7 @@ const GlobalProperty *qdev_find_global_prop(Object *obj, const char *name); int qdev_prop_check_globals(void); void qdev_prop_set_globals(DeviceState *dev); -void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev, +void error_set_from_qdev_prop_error(Error **errp, int ret, Object *obj, Property *prop, const char *value); /** diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 85dd38db0f..fca1b694ca 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -352,7 +352,7 @@ static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque, return; inval: - error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str); + error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str); g_free(str); } @@ -440,7 +440,7 @@ static void set_netdev(Object *obj, Visitor *v, const char *name, peers_ptr->queues = queues; out: - error_set_from_qdev_prop_error(errp, err, dev, prop, str); + error_set_from_qdev_prop_error(errp, err, obj, prop, str); g_free(str); } @@ -492,7 +492,7 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name, card->state = state; out: - error_set_from_qdev_prop_error(errp, err, dev, prop, str); + error_set_from_qdev_prop_error(errp, err, obj, prop, str); g_free(str); } @@ -790,7 +790,7 @@ static void set_pci_devfn(Object *obj, Visitor *v, const char *name, return; invalid: - error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str); + error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str); g_free(str); } @@ -913,7 +913,7 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name, return; inval: - error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str); + error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str); g_free(str); } diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 41482d83d1..5e010afdb8 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -581,7 +581,7 @@ static void set_uuid(Object *obj, Visitor *v, const char *name, void *opaque, if (!strcmp(str, UUID_VALUE_AUTO)) { qemu_uuid_generate(uuid); } else if (qemu_uuid_parse(str, uuid) < 0) { - error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str); + error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str); } g_free(str); } @@ -735,22 +735,22 @@ static Property *qdev_prop_find(DeviceState *dev, const char *name) return NULL; } -void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev, +void error_set_from_qdev_prop_error(Error **errp, int ret, Object *obj, Property *prop, const char *value) { switch (ret) { case -EEXIST: error_setg(errp, "Property '%s.%s' can't take value '%s', it's in use", - object_get_typename(OBJECT(dev)), prop->name, value); + object_get_typename(obj), prop->name, value); break; default: case -EINVAL: error_setg(errp, QERR_PROPERTY_VALUE_BAD, - object_get_typename(OBJECT(dev)), prop->name, value); + object_get_typename(obj), prop->name, value); break; case -ENOENT: error_setg(errp, "Property '%s.%s' can't find value '%s'", - object_get_typename(OBJECT(dev)), prop->name, value); + object_get_typename(obj), prop->name, value); break; case 0: break; diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 2b8f33fec2..38fd46b9a9 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -2390,7 +2390,7 @@ static void set_css_devid(Object *obj, Visitor *v, const char *name, num = sscanf(str, "%2x.%1x%n.%4x%n", &cssid, &ssid, &n1, &devid, &n2); if (num != 3 || (n2 - n1) != 5 || strlen(str) != n2) { - error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str); + error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str); goto out; } if ((cssid > MAX_CSSID) || (ssid > MAX_SSID)) { From patchwork Thu Oct 29 22:02:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316594 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0E28C2D0A3 for ; Thu, 29 Oct 2020 22:19:16 +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 4954920FC3 for ; Thu, 29 Oct 2020 22:19:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bMpHTDHM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4954920FC3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYGGJ-0008OS-2e for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:19:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG1J-0003V7-JC for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50661) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG1F-0006b5-Bu for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604009014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1ozq5c29ToMtZxIRD7Q8p4k7GFhu4PcpfAP54MD07co=; b=bMpHTDHMzkZk2sKivqnWxVRoS0trNN8gxF84Dlm1f+uy9O0dadBDewHB5Fxm/6sdExqf35 p6qGHYJSFMO6iOMA7rZWRbemf0mYR0aj1nDLrSX9N5SNpg4FiImiNdxqiNF9dBBgZZy0qg hH9TYj5inn1syo8v9EEq0mNFBwETz0U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-568-lkZv34lnNp2JL_nI0GYTYg-1; Thu, 29 Oct 2020 18:03:32 -0400 X-MC-Unique: lkZv34lnNp2JL_nI0GYTYg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CEECE8030BD for ; Thu, 29 Oct 2020 22:03:31 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90EC76EF68; Thu, 29 Oct 2020 22:03:31 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 17/36] qdev: Separate generic and device-specific property registration Date: Thu, 29 Oct 2020 18:02:27 -0400 Message-Id: <20201029220246.472693-18-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 01:47:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" qdev_class_add_property() and qdev_property_add_static() will have code that's specific for device types. object_class_property_add_static(), object_class_add_static_props(), and object_property_add_static() will be generic and part of the QOM static property API. The declarations for the new functions are being added to qdev-properties.h, but they will be moved to a QOM header later. Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau --- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- hw/core/qdev-prop-internal.h | 11 +++++++++++ include/hw/qdev-properties.h | 24 ++++++++++++++++++++++++ hw/core/qdev-properties.c | 36 ++++++++++++++++++++++++++++-------- 3 files changed, 63 insertions(+), 8 deletions(-) diff --git a/hw/core/qdev-prop-internal.h b/hw/core/qdev-prop-internal.h index 9cf5cc1d51..858f844504 100644 --- a/hw/core/qdev-prop-internal.h +++ b/hw/core/qdev-prop-internal.h @@ -27,4 +27,15 @@ void qdev_propinfo_get_int32(Object *obj, Visitor *v, const char *name, void qdev_propinfo_get_size32(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp); +/** + * object_property_add_static: Add a static property to an object instance + * @obj: object instance + * @prop: property definition + * + * This function should not be used in new code. Please add class properties + * instead, using object_class_add_static_props(). + */ +ObjectProperty * +object_property_add_static(Object *obj, Property *prop); + #endif diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 7f8e4daade..c94301c349 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -275,6 +275,30 @@ extern const PropertyInfo qdev_prop_pcie_link_width; #define DEFINE_PROP_END_OF_LIST() \ {} +/** + * object_class_property_add_static: Add a static property to object class + * @oc: object class + * @prop: property definition + * + * Add a property to an object class based on the property definition + * at @prop. + * + * The property definition at @prop should be defined using the + * ``DEFINE_PROP`` family of macros. *@prop must exist for the + * life time of @oc. + */ +ObjectProperty * +object_class_property_add_static(ObjectClass *oc, Property *prop); + +/** + * object_class_add_static_props: Add multiple static properties to object class + * @oc: object class + * @props: property definition array, terminated by DEFINED_PROP_END_OF_LIST() + * + * Add properties from @props using object_class_property_add_static() + */ +void object_class_add_static_props(ObjectClass *oc, Property *props); + /* * Set properties between creation and realization. * diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index ad685f371d..68b1666e14 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -885,9 +885,9 @@ const PropertyInfo qdev_prop_link = { .create = create_link_property, }; -void qdev_property_add_static(DeviceState *dev, Property *prop) +ObjectProperty * +object_property_add_static(Object *obj, Property *prop) { - Object *obj = OBJECT(dev); ObjectProperty *op; assert(!prop->info->create); @@ -907,11 +907,13 @@ void qdev_property_add_static(DeviceState *dev, Property *prop) op->init(obj, op); } } + + return op; } -static void qdev_class_add_property(DeviceClass *klass, Property *prop) +ObjectProperty * +object_class_property_add_static(ObjectClass *oc, Property *prop) { - ObjectClass *oc = OBJECT_CLASS(klass); ObjectProperty *op; if (prop->info->create) { @@ -931,6 +933,21 @@ static void qdev_class_add_property(DeviceClass *klass, Property *prop) object_class_property_set_description(oc, prop->name, prop->info->description); } + return op; +} + +void object_class_add_static_props(ObjectClass *oc, Property *props) +{ + Property *prop; + + for (prop = props; prop && prop->name; prop++) { + object_class_property_add_static(oc, prop); + } +} + +void qdev_property_add_static(DeviceState *dev, Property *prop) +{ + object_property_add_static(OBJECT(dev), prop); } /** @@ -979,16 +996,19 @@ static void qdev_class_add_legacy_property(DeviceClass *dc, Property *prop) NULL, NULL, prop); } -void device_class_set_props(DeviceClass *dc, Property *props) +static void qdev_class_add_legacy_properties(DeviceClass *dc, Property *props) { Property *prop; - - dc->props_ = props; for (prop = props; prop && prop->name; prop++) { qdev_class_add_legacy_property(dc, prop); - qdev_class_add_property(dc, prop); } } +void device_class_set_props(DeviceClass *dc, Property *props) +{ + dc->props_ = props; + qdev_class_add_legacy_properties(dc, props); + object_class_add_static_props(OBJECT_CLASS(dc), props); +} void qdev_alias_all_properties(DeviceState *target, Object *source) { From patchwork Thu Oct 29 22:02:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04CD5C2D0A3 for ; Thu, 29 Oct 2020 22:10:42 +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 35A072075E for ; Thu, 29 Oct 2020 22:10:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iAz+0zCP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 35A072075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYG7z-0003Zt-UO for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:10:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG1M-0003Xj-Al for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:58166) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG1H-0006bK-8J for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604009018; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B+p7rRmridN4HPSmGA8f7ZIuPV/a/xPDCBMShnMFMuI=; b=iAz+0zCPQpC3SClkS5Zemd1vnuf3ZeH0UKesb0UtWwyxBOUpJweNiMzBcQyTJYHYVDy6Ax WqaJLVWpsd24iRGrbd17KR1+Qtb3W0h5+86VCnehba29NyiZ7jaa8MdFXwxYupGx4QN2ml bNT2d5HwcxojN9PbzXJwKOkXQxZHkRA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-558-19VNaPlWN3ysGuorlavbZQ-1; Thu, 29 Oct 2020 18:03:36 -0400 X-MC-Unique: 19VNaPlWN3ysGuorlavbZQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79D9A8030CC for ; Thu, 29 Oct 2020 22:03:35 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 392B219646; Thu, 29 Oct 2020 22:03:35 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 20/36] qdev: Reuse object_property_add_static() when adding array elements Date: Thu, 29 Oct 2020 18:02:30 -0400 Message-Id: <20201029220246.472693-21-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 01:47:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reuse function instead of calling object_property_add() directly. We need to hack ObjectProperty.release to make sure we will free the array property. Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

that seems to be right, but could use more eyes... somebody may have an idea of simplification.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

--- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- hw/core/qdev-properties.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 1f06dfb5d5..4fec9cb73b 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -600,7 +600,6 @@ static ArrayElementProperty *array_element_new(Object *obj, { char *propname = g_strdup_printf("%s[%d]", arrayname, index); ArrayElementProperty *arrayprop = g_new0(ArrayElementProperty, 1); - arrayprop->release = array_len_prop->arrayinfo->release; arrayprop->propname = propname; arrayprop->prop.info = array_len_prop->arrayinfo; arrayprop->prop.name = propname; @@ -632,12 +631,12 @@ static void object_property_add_array_element(Object *obj, Property *array_len_prop, ArrayElementProperty *prop) { - object_property_add(obj, prop->prop.name, - prop->prop.info->name, - static_prop_getter(prop->prop.info), - static_prop_setter(prop->prop.info), - array_element_release, - prop); + ObjectProperty *op = object_property_add_static(obj, &prop->prop); + + assert((void *)prop == (void *)&prop->prop); + prop->release = op->release; + /* array_element_release() will call the original release function */ + op->release = array_element_release; } static void set_prop_arraylen(Object *obj, Visitor *v, const char *name, From patchwork Thu Oct 29 22:02:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9539EC4741F for ; Thu, 29 Oct 2020 22:12:44 +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 DF136206CA for ; Thu, 29 Oct 2020 22:12:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="I2BQOF9j" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF136206CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYG9y-00071g-Pe for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:12:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG1M-0003Yt-MZ for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:55227) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG1H-0006bS-96 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604009019; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QUxh+dAMr7asfgASVssXiGfljD2JvuaH/LJeEOqBzHc=; b=I2BQOF9jnxr3T023GcPUcsEPOMbkCWUxn/rsYTU0pf2ci5uqWyOC1kUvXRt/PHxr7pbymg SB9W9fbKEqoMD2j3hrLF0XRYfn33ICpJAdLCoiJu3dRI2i+IyVz6ESuHkJ/Lb2JXnuRQIr YMj/IB3QvFqetMqcD8XkQ1TkpnTcfMA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-367-fUCgkL_bOcqkT2zPyglrwg-1; Thu, 29 Oct 2020 18:03:37 -0400 X-MC-Unique: fUCgkL_bOcqkT2zPyglrwg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E058A802B66 for ; Thu, 29 Oct 2020 22:03:36 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0CEF5DA2A; Thu, 29 Oct 2020 22:03:36 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 21/36] qom: Add allow_set callback to ObjectProperty Date: Thu, 29 Oct 2020 18:02:31 -0400 Message-Id: <20201029220246.472693-22-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Note that this doesn't replace the check callback at object*_property_add_link() (yet), because currently the link property check callback needs to get the property value as argument (despite this not being necessary in most cases). Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>



--
Marc-André Lureau
--- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- include/qom/object.h | 16 ++++++++++++++++ qom/object.c | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index d378f13a11..24e591d954 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -86,6 +86,21 @@ typedef void (ObjectPropertyRelease)(Object *obj, */ typedef void (ObjectPropertyInit)(Object *obj, ObjectProperty *prop); +/** + * typedef ObjectPropertyAllowSet: + * @obj: the object that owns the property + * @prop: the property being set + * @errp: pointer to error information + * + * Called when a property is being set. + * + * If return value is false, it will prevent the property from + * being changed. Error information should be filled in @errp + * if return vlaue is false. + */ +typedef bool (ObjectPropertyAllowSet)(Object *obj, ObjectProperty *prop, + Error **errp); + struct ObjectProperty { char *name; @@ -96,6 +111,7 @@ struct ObjectProperty ObjectPropertyResolve *resolve; ObjectPropertyRelease *release; ObjectPropertyInit *init; + ObjectPropertyAllowSet *allow_set; void *opaque; QObject *defval; }; diff --git a/qom/object.c b/qom/object.c index 1065355233..20726e4584 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1395,6 +1395,10 @@ bool object_property_set(Object *obj, const char *name, Visitor *v, error_setg(errp, QERR_PERMISSION_DENIED); return false; } + if (prop->allow_set && !prop->allow_set(obj, prop, errp)) { + return false; + } + prop->set(obj, v, name, prop->opaque, &err); error_propagate(errp, err); return !err; From patchwork Thu Oct 29 22:02:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316592 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E1C9C4742C for ; Thu, 29 Oct 2020 22:22:32 +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 5ACF32072C for ; Thu, 29 Oct 2020 22:22:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XolIXxIT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5ACF32072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYGJS-0003hp-7J for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:22:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG1N-0003bd-Pc for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46931) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG1J-0006bp-68 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604009022; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6QqF1h0jHtaWAY24awHawid96gubhZ/Hd9VL48o+QVI=; b=XolIXxITardbo+R1fAbMd6I2tont+lnAJiHBjdaCdkWeYA1v/5E0OCtrKc8QiJxBkr/UiZ n2cnLPB/T02X6jKwlTGesGDIdQbU/I+9bj8IxtKTt36osup1FzIYJxGsiNejBjo05jAM+C Bflil/WWsmUmpvOMa5FFXceCVKBeLv8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-96-x69HVDdzMF-_3zP7ImKn_Q-1; Thu, 29 Oct 2020 18:03:40 -0400 X-MC-Unique: x69HVDdzMF-_3zP7ImKn_Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74BE78030CC for ; Thu, 29 Oct 2020 22:03:39 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D3AA1002D48; Thu, 29 Oct 2020 22:03:39 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 23/36] qdev: Make qdev_propinfo_get_uint16() static Date: Thu, 29 Oct 2020 18:02:33 -0400 Message-Id: <20201029220246.472693-24-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 01:47:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" There are no users of the function outside qdev-properties.c. Make function static and rename it to get_uint16(). Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
 
--- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- hw/core/qdev-prop-internal.h | 2 -- hw/core/qdev-properties.c | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/core/qdev-prop-internal.h b/hw/core/qdev-prop-internal.h index 49bf557fd5..c8006a21c7 100644 --- a/hw/core/qdev-prop-internal.h +++ b/hw/core/qdev-prop-internal.h @@ -20,8 +20,6 @@ void qdev_propinfo_set_default_value_int(ObjectProperty *op, void qdev_propinfo_set_default_value_uint(ObjectProperty *op, const Property *prop); -void qdev_propinfo_get_uint16(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp); void qdev_propinfo_get_int32(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp); void qdev_propinfo_get_size32(Object *obj, Visitor *v, const char *name, diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 4cb8baa6a0..5189626c09 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -296,8 +296,8 @@ const PropertyInfo qdev_prop_uint8 = { /* --- 16bit integer --- */ -void qdev_propinfo_get_uint16(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) +static void get_uint16(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) { Property *prop = opaque; uint16_t *ptr = qdev_get_prop_ptr(obj, prop); @@ -316,7 +316,7 @@ static void set_uint16(Object *obj, Visitor *v, const char *name, const PropertyInfo qdev_prop_uint16 = { .name = "uint16", - .get = qdev_propinfo_get_uint16, + .get = get_uint16, .set = set_uint16, .set_default_value = qdev_propinfo_set_default_value_uint, }; From patchwork Thu Oct 29 22:02:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2EABC2D0A3 for ; Thu, 29 Oct 2020 22:14:49 +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 04136214F1 for ; Thu, 29 Oct 2020 22:14:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Q8VhfoUx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04136214F1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYGBy-00020a-5J for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:14:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG1O-0003ea-Ug for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:37550) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG1J-0006c3-8h for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:03:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604009023; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1DdZBB4EDlaaZxGBRJRdKw7c/rep5ZMVUi4EkmGtpg8=; b=Q8VhfoUxyOpxC9Qv4utlhIfbnCcwd4gWzghAE/aOdAenqant5Ff78Bzmh/oEJIvY8OM7P+ vbDwD9aWDs/hyIzqwitA8QQ6l4ZiSsncR0n1/ZLt6nXQk5x0Mh0xWyfFteU0XIJcuLqe2Z dKnSs4oYGWFUR3cTpANU2FUhnGIviZA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-412-dNdBBI3pM_Ooqh_Z0FKdKA-1; Thu, 29 Oct 2020 18:03:41 -0400 X-MC-Unique: dNdBBI3pM_Ooqh_Z0FKdKA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8A25118BA280 for ; Thu, 29 Oct 2020 22:03:40 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40E2B60C17; Thu, 29 Oct 2020 22:03:40 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 24/36] qdev: Rename qdev_propinfo_* to object_propinfo_* Date: Thu, 29 Oct 2020 18:02:34 -0400 Message-Id: <20201029220246.472693-25-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 01:47:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" These functions will be moved to be part of QOM, so rename them. Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

 
--- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- hw/core/qdev-prop-internal.h | 28 +++++++++---------- hw/core/qdev-properties-system.c | 48 ++++++++++++++++---------------- hw/core/qdev-properties.c | 48 ++++++++++++++++---------------- 3 files changed, 62 insertions(+), 62 deletions(-) diff --git a/hw/core/qdev-prop-internal.h b/hw/core/qdev-prop-internal.h index c8006a21c7..41ec9e8942 100644 --- a/hw/core/qdev-prop-internal.h +++ b/hw/core/qdev-prop-internal.h @@ -8,22 +8,22 @@ #ifndef HW_CORE_QDEV_PROP_INTERNAL_H #define HW_CORE_QDEV_PROP_INTERNAL_H -void qdev_propinfo_get_enum(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp); -void qdev_propinfo_set_enum(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp); +void object_propinfo_get_enum(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp); +void object_propinfo_set_enum(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp); -void qdev_propinfo_set_default_value_enum(ObjectProperty *op, - const Property *prop); -void qdev_propinfo_set_default_value_int(ObjectProperty *op, - const Property *prop); -void qdev_propinfo_set_default_value_uint(ObjectProperty *op, - const Property *prop); +void object_propinfo_set_default_value_enum(ObjectProperty *op, + const Property *prop); +void object_propinfo_set_default_value_int(ObjectProperty *op, + const Property *prop); +void object_propinfo_set_default_value_uint(ObjectProperty *op, + const Property *prop); -void qdev_propinfo_get_int32(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp); -void qdev_propinfo_get_size32(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp); +void object_propinfo_get_int32(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp); +void object_propinfo_get_size32(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp); /** * object_property_add_static: Add a static property to an object instance diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 60a45f5620..d9355053d2 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -535,9 +535,9 @@ QEMU_BUILD_BUG_ON(sizeof(LostTickPolicy) != sizeof(int)); const PropertyInfo qdev_prop_losttickpolicy = { .name = "LostTickPolicy", .enum_table = &LostTickPolicy_lookup, - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, }; /* --- blocksize --- */ @@ -566,9 +566,9 @@ const PropertyInfo qdev_prop_blocksize = { .name = "size", .description = "A power of two between " MIN_BLOCK_SIZE_STR " and " MAX_BLOCK_SIZE_STR, - .get = qdev_propinfo_get_size32, + .get = object_propinfo_get_size32, .set = set_blocksize, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, }; /* --- Block device error handling policy --- */ @@ -580,9 +580,9 @@ const PropertyInfo qdev_prop_blockdev_on_error = { .description = "Error handling policy, " "report/ignore/enospc/stop/auto", .enum_table = &BlockdevOnError_lookup, - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, }; /* --- BIOS CHS translation */ @@ -594,9 +594,9 @@ const PropertyInfo qdev_prop_bios_chs_trans = { .description = "Logical CHS translation algorithm, " "auto/none/lba/large/rechs", .enum_table = &BiosAtaTranslation_lookup, - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, }; /* --- FDC default drive types */ @@ -606,9 +606,9 @@ const PropertyInfo qdev_prop_fdc_drive_type = { .description = "FDC drive type, " "144/288/120/none/auto", .enum_table = &FloppyDriveType_lookup, - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, }; /* --- MultiFDCompression --- */ @@ -618,9 +618,9 @@ const PropertyInfo qdev_prop_multifd_compression = { .description = "multifd_compression values, " "none/zlib/zstd", .enum_table = &MultiFDCompression_lookup, - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, }; /* --- Reserved Region --- */ @@ -764,9 +764,9 @@ const PropertyInfo qdev_prop_pci_devfn = { .name = "int32", .description = "Slot and optional function number, example: 06.0 or 06", .print = print_pci_devfn, - .get = qdev_propinfo_get_int32, + .get = object_propinfo_get_int32, .set = set_pci_devfn, - .set_default_value = qdev_propinfo_set_default_value_int, + .set_default_value = object_propinfo_set_default_value_int, }; /* --- pci host address --- */ @@ -879,9 +879,9 @@ const PropertyInfo qdev_prop_off_auto_pcibar = { .name = "OffAutoPCIBAR", .description = "off/auto/bar0/bar1/bar2/bar3/bar4/bar5", .enum_table = &OffAutoPCIBAR_lookup, - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, }; /* --- PCIELinkSpeed 2_5/5/8/16 -- */ @@ -951,7 +951,7 @@ const PropertyInfo qdev_prop_pcie_link_speed = { .enum_table = &PCIELinkSpeed_lookup, .get = get_prop_pcielinkspeed, .set = set_prop_pcielinkspeed, - .set_default_value = qdev_propinfo_set_default_value_enum, + .set_default_value = object_propinfo_set_default_value_enum, }; /* --- PCIELinkWidth 1/2/4/8/12/16/32 -- */ @@ -1039,5 +1039,5 @@ const PropertyInfo qdev_prop_pcie_link_width = { .enum_table = &PCIELinkWidth_lookup, .get = get_prop_pcielinkwidth, .set = set_prop_pcielinkwidth, - .set_default_value = qdev_propinfo_set_default_value_enum, + .set_default_value = object_propinfo_set_default_value_enum, }; diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 5189626c09..e4aba2b237 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -93,7 +93,7 @@ static ObjectPropertyAccessor *static_prop_setter(const PropertyInfo *info) return info->set ? static_prop_set : NULL; } -void qdev_propinfo_get_enum(Object *obj, Visitor *v, const char *name, +void object_propinfo_get_enum(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; @@ -102,7 +102,7 @@ void qdev_propinfo_get_enum(Object *obj, Visitor *v, const char *name, visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp); } -void qdev_propinfo_set_enum(Object *obj, Visitor *v, const char *name, +void object_propinfo_set_enum(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; @@ -111,7 +111,7 @@ void qdev_propinfo_set_enum(Object *obj, Visitor *v, const char *name, visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp); } -void qdev_propinfo_set_default_value_enum(ObjectProperty *op, +void object_propinfo_set_default_value_enum(ObjectProperty *op, const Property *prop) { object_property_set_default_str(op, @@ -120,9 +120,9 @@ void qdev_propinfo_set_default_value_enum(ObjectProperty *op, const PropertyInfo qdev_prop_enum = { .name = "enum", - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, }; /* Bit */ @@ -275,13 +275,13 @@ static void set_uint8(Object *obj, Visitor *v, const char *name, void *opaque, visit_type_uint8(v, name, ptr, errp); } -void qdev_propinfo_set_default_value_int(ObjectProperty *op, +void object_propinfo_set_default_value_int(ObjectProperty *op, const Property *prop) { object_property_set_default_int(op, prop->defval.i); } -void qdev_propinfo_set_default_value_uint(ObjectProperty *op, +void object_propinfo_set_default_value_uint(ObjectProperty *op, const Property *prop) { object_property_set_default_uint(op, prop->defval.u); @@ -291,7 +291,7 @@ const PropertyInfo qdev_prop_uint8 = { .name = "uint8", .get = get_uint8, .set = set_uint8, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, }; /* --- 16bit integer --- */ @@ -318,7 +318,7 @@ const PropertyInfo qdev_prop_uint16 = { .name = "uint16", .get = get_uint16, .set = set_uint16, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, }; /* --- 32bit integer --- */ @@ -341,7 +341,7 @@ static void set_uint32(Object *obj, Visitor *v, const char *name, visit_type_uint32(v, name, ptr, errp); } -void qdev_propinfo_get_int32(Object *obj, Visitor *v, const char *name, +void object_propinfo_get_int32(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; @@ -363,14 +363,14 @@ const PropertyInfo qdev_prop_uint32 = { .name = "uint32", .get = get_uint32, .set = set_uint32, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, }; const PropertyInfo qdev_prop_int32 = { .name = "int32", - .get = qdev_propinfo_get_int32, + .get = object_propinfo_get_int32, .set = set_int32, - .set_default_value = qdev_propinfo_set_default_value_int, + .set_default_value = object_propinfo_set_default_value_int, }; /* --- 64bit integer --- */ @@ -415,14 +415,14 @@ const PropertyInfo qdev_prop_uint64 = { .name = "uint64", .get = get_uint64, .set = set_uint64, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, }; const PropertyInfo qdev_prop_int64 = { .name = "int64", .get = get_int64, .set = set_int64, - .set_default_value = qdev_propinfo_set_default_value_int, + .set_default_value = object_propinfo_set_default_value_int, }; /* --- string --- */ @@ -474,14 +474,14 @@ const PropertyInfo qdev_prop_on_off_auto = { .name = "OnOffAuto", .description = "on/off/auto", .enum_table = &OnOffAuto_lookup, - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, }; /* --- 32bit unsigned int 'size' type --- */ -void qdev_propinfo_get_size32(Object *obj, Visitor *v, const char *name, +void object_propinfo_get_size32(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Property *prop = opaque; @@ -515,9 +515,9 @@ static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque, const PropertyInfo qdev_prop_size32 = { .name = "size", - .get = qdev_propinfo_get_size32, + .get = object_propinfo_get_size32, .set = set_size32, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, }; /* --- UUID --- */ @@ -686,7 +686,7 @@ const PropertyInfo qdev_prop_arraylen = { .name = "uint32", .get = get_uint32, .set = set_prop_arraylen, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, }; /* --- public helpers --- */ @@ -885,7 +885,7 @@ const PropertyInfo qdev_prop_size = { .name = "size", .get = get_size, .set = set_size, - .set_default_value = qdev_propinfo_set_default_value_uint, + .set_default_value = object_propinfo_set_default_value_uint, }; /* --- object link property --- */ From patchwork Thu Oct 29 22:02:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35334C2D0A3 for ; Thu, 29 Oct 2020 22:17:36 +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 561AF206CB for ; Thu, 29 Oct 2020 22:17:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="G0aOmEFn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 561AF206CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYGEg-0005xt-9s for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:17:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG1c-0003tN-12 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:04:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37470) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG1R-0006eY-HT for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:04:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604009032; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WMUrlr5Nzg2z1fF/Bg2uIbL8BR52n2nZGCLd1uOXnGQ=; b=G0aOmEFnPJilttC1BJBvgQveyw2itaN1KtbKq73RG5OmgJcxtOxjDNRlCclVe793BwmJ5b gtYMlL6nJfHDgAbcgFMecRf/ZZlBg4ITbh4sfiJnMCaQnY09SiQ9B7zzqqEW3p6TC8LpzK pd8UvCvyQelgj6QsurqoBk8nrmiIz08= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-461-S5_60EvlMuqRSSbN4f9fug-1; Thu, 29 Oct 2020 18:03:50 -0400 X-MC-Unique: S5_60EvlMuqRSSbN4f9fug-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CF845802B66 for ; Thu, 29 Oct 2020 22:03:49 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4695A60C17; Thu, 29 Oct 2020 22:03:49 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 26/36] qdev: Move softmmu properties to qdev-properties-system.h Date: Thu, 29 Oct 2020 18:02:36 -0400 Message-Id: <20201029220246.472693-27-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Move the property types and property macros implemented in qdev-properties-system.c to a new qdev-properties-system.h header. Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
 
--- audio/audio.h | 1 + include/hw/block/block.h | 1 + include/hw/qdev-properties-system.h | 68 +++++++++++++++++++++++++++++ include/hw/qdev-properties.h | 61 -------------------------- include/net/net.h | 1 + hw/arm/pxa2xx.c | 1 + hw/arm/strongarm.c | 1 + hw/block/fdc.c | 1 + hw/block/m25p80.c | 1 + hw/block/nand.c | 1 + hw/block/onenand.c | 1 + hw/block/pflash_cfi01.c | 1 + hw/block/pflash_cfi02.c | 1 + hw/block/vhost-user-blk.c | 1 + hw/char/avr_usart.c | 1 + hw/char/bcm2835_aux.c | 1 + hw/char/cadence_uart.c | 1 + hw/char/cmsdk-apb-uart.c | 1 + hw/char/debugcon.c | 1 + hw/char/digic-uart.c | 1 + hw/char/escc.c | 1 + hw/char/etraxfs_ser.c | 1 + hw/char/exynos4210_uart.c | 1 + hw/char/grlib_apbuart.c | 1 + hw/char/ibex_uart.c | 1 + hw/char/imx_serial.c | 1 + hw/char/ipoctal232.c | 1 + hw/char/lm32_juart.c | 1 + hw/char/lm32_uart.c | 1 + hw/char/mcf_uart.c | 1 + hw/char/milkymist-uart.c | 1 + hw/char/nrf51_uart.c | 1 + hw/char/parallel.c | 1 + hw/char/pl011.c | 1 + hw/char/renesas_sci.c | 1 + hw/char/sclpconsole-lm.c | 1 + hw/char/sclpconsole.c | 1 + hw/char/serial-pci-multi.c | 1 + hw/char/serial.c | 1 + hw/char/spapr_vty.c | 1 + hw/char/stm32f2xx_usart.c | 1 + hw/char/terminal3270.c | 1 + hw/char/virtio-console.c | 1 + hw/char/xilinx_uartlite.c | 1 + hw/core/qdev-properties-system.c | 1 + hw/i386/kvm/i8254.c | 1 + hw/ide/qdev.c | 1 + hw/ipmi/ipmi_bmc_extern.c | 1 + hw/misc/ivshmem.c | 1 + hw/misc/mac_via.c | 1 + hw/misc/sifive_u_otp.c | 1 + hw/net/rocker/rocker.c | 1 + hw/nvram/eeprom_at24c.c | 1 + hw/nvram/spapr_nvram.c | 1 + hw/pci-bridge/gen_pcie_root_port.c | 1 + hw/pci/pci.c | 1 + hw/ppc/pnv_pnor.c | 1 + hw/rdma/vmw/pvrdma_main.c | 1 + hw/rtc/mc146818rtc.c | 1 + hw/scsi/scsi-disk.c | 1 + hw/scsi/scsi-generic.c | 1 + hw/scsi/vhost-user-scsi.c | 1 + hw/sd/sd.c | 1 + hw/usb/ccid-card-passthru.c | 1 + hw/usb/dev-serial.c | 1 + hw/usb/redirect.c | 1 + hw/vfio/pci.c | 1 + hw/virtio/vhost-user-fs.c | 1 + hw/virtio/vhost-user-vsock.c | 1 + hw/virtio/virtio-iommu-pci.c | 1 + hw/xen/xen_pt.c | 1 + migration/migration.c | 1 + 72 files changed, 138 insertions(+), 61 deletions(-) create mode 100644 include/hw/qdev-properties-system.h diff --git a/audio/audio.h b/audio/audio.h index b883ebfb1f..21fe3226ae 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -28,6 +28,7 @@ #include "qemu/queue.h" #include "qapi/qapi-types-audio.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" typedef void (*audio_callback_fn) (void *opaque, int avail); diff --git a/include/hw/block/block.h b/include/hw/block/block.h index 1e8b6253dd..c172cbe65f 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -13,6 +13,7 @@ #include "exec/hwaddr.h" #include "qapi/qapi-types-block-core.h" +#include "hw/qdev-properties-system.h" /* Configuration */ diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properties-system.h new file mode 100644 index 0000000000..0792d5236e --- /dev/null +++ b/include/hw/qdev-properties-system.h @@ -0,0 +1,68 @@ +#ifndef HW_QDEV_PROPERTIES_SYSTEM_H +#define HW_QDEV_PROPERTIES_SYSTEM_H + +#include "hw/qdev-properties.h" + +extern const PropertyInfo qdev_prop_drive; +extern const PropertyInfo qdev_prop_drive_iothread; +extern const PropertyInfo qdev_prop_chr; +extern const PropertyInfo qdev_prop_macaddr; +extern const PropertyInfo qdev_prop_netdev; +extern const PropertyInfo qdev_prop_audiodev; +extern const PropertyInfo qdev_prop_losttickpolicy; +extern const PropertyInfo qdev_prop_blocksize; +extern const PropertyInfo qdev_prop_blockdev_on_error; +extern const PropertyInfo qdev_prop_bios_chs_trans; +extern const PropertyInfo qdev_prop_fdc_drive_type; +extern const PropertyInfo qdev_prop_multifd_compression; +extern const PropertyInfo qdev_prop_reserved_region; +extern const PropertyInfo qdev_prop_pci_devfn; +extern const PropertyInfo qdev_prop_pci_host_devaddr; +extern const PropertyInfo qdev_prop_off_auto_pcibar; +extern const PropertyInfo qdev_prop_pcie_link_speed; +extern const PropertyInfo qdev_prop_pcie_link_width; + +#define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) +#define DEFINE_PROP_CHR(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharBackend) +#define DEFINE_PROP_NETDEV(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, NICPeers) +#define DEFINE_PROP_DRIVE(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockBackend *) +#define DEFINE_PROP_DRIVE_IOTHREAD(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_drive_iothread, BlockBackend *) +#define DEFINE_PROP_MACADDR(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr) +#define DEFINE_PROP_RESERVED_REGION(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_reserved_region, ReservedRegion) +#define DEFINE_PROP_MULTIFD_COMPRESSION(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_multifd_compression, \ + MultiFDCompression) +#define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ + LostTickPolicy) +#define DEFINE_PROP_BLOCKDEV_ON_ERROR(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_blockdev_on_error, \ + BlockdevOnError) +#define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int) +#define DEFINE_PROP_BLOCKSIZE(_n, _s, _f) \ + DEFINE_PROP_UNSIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint32_t) +#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress) +#define DEFINE_PROP_OFF_AUTO_PCIBAR(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_off_auto_pcibar, \ + OffAutoPCIBAR) +#define DEFINE_PROP_PCIE_LINK_SPEED(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pcie_link_speed, \ + PCIExpLinkSpeed) +#define DEFINE_PROP_PCIE_LINK_WIDTH(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pcie_link_width, \ + PCIExpLinkWidth) +#define DEFINE_PROP_AUDIODEV(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_audiodev, QEMUSoundCard) + + + +#endif diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 4146dac281..3a7b4c8643 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -55,30 +55,12 @@ extern const PropertyInfo qdev_prop_uint64; extern const PropertyInfo qdev_prop_int64; extern const PropertyInfo qdev_prop_size; extern const PropertyInfo qdev_prop_string; -extern const PropertyInfo qdev_prop_chr; extern const PropertyInfo qdev_prop_tpm; -extern const PropertyInfo qdev_prop_macaddr; -extern const PropertyInfo qdev_prop_reserved_region; extern const PropertyInfo qdev_prop_on_off_auto; -extern const PropertyInfo qdev_prop_multifd_compression; -extern const PropertyInfo qdev_prop_losttickpolicy; -extern const PropertyInfo qdev_prop_blockdev_on_error; -extern const PropertyInfo qdev_prop_bios_chs_trans; -extern const PropertyInfo qdev_prop_fdc_drive_type; -extern const PropertyInfo qdev_prop_drive; -extern const PropertyInfo qdev_prop_drive_iothread; -extern const PropertyInfo qdev_prop_netdev; -extern const PropertyInfo qdev_prop_pci_devfn; extern const PropertyInfo qdev_prop_size32; -extern const PropertyInfo qdev_prop_blocksize; -extern const PropertyInfo qdev_prop_pci_host_devaddr; extern const PropertyInfo qdev_prop_uuid; extern const PropertyInfo qdev_prop_arraylen; -extern const PropertyInfo qdev_prop_audiodev; extern const PropertyInfo qdev_prop_link; -extern const PropertyInfo qdev_prop_off_auto_pcibar; -extern const PropertyInfo qdev_prop_pcie_link_speed; -extern const PropertyInfo qdev_prop_pcie_link_width; #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \ .name = (_name), \ @@ -209,52 +191,12 @@ extern const PropertyInfo qdev_prop_pcie_link_width; DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int64, int64_t) #define DEFINE_PROP_SIZE(_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t) -#define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) - -#define DEFINE_PROP_CHR(_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharBackend) #define DEFINE_PROP_STRING(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*) -#define DEFINE_PROP_NETDEV(_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, NICPeers) -#define DEFINE_PROP_DRIVE(_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockBackend *) -#define DEFINE_PROP_DRIVE_IOTHREAD(_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_drive_iothread, BlockBackend *) -#define DEFINE_PROP_MACADDR(_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr) -#define DEFINE_PROP_RESERVED_REGION(_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_reserved_region, ReservedRegion) #define DEFINE_PROP_ON_OFF_AUTO(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_on_off_auto, OnOffAuto) -#define DEFINE_PROP_MULTIFD_COMPRESSION(_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_multifd_compression, \ - MultiFDCompression) -#define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ - LostTickPolicy) -#define DEFINE_PROP_BLOCKDEV_ON_ERROR(_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_blockdev_on_error, \ - BlockdevOnError) -#define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int) #define DEFINE_PROP_SIZE32(_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size32, uint32_t) -#define DEFINE_PROP_BLOCKSIZE(_n, _s, _f) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint32_t) -#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress) -#define DEFINE_PROP_OFF_AUTO_PCIBAR(_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_off_auto_pcibar, \ - OffAutoPCIBAR) -#define DEFINE_PROP_PCIE_LINK_SPEED(_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pcie_link_speed, \ - PCIExpLinkSpeed) -#define DEFINE_PROP_PCIE_LINK_WIDTH(_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pcie_link_width, \ - PCIExpLinkWidth) - #define DEFINE_PROP_UUID(_name, _state, _field) { \ .name = (_name), \ .info = &qdev_prop_uuid, \ @@ -262,9 +204,6 @@ extern const PropertyInfo qdev_prop_pcie_link_width; + type_check(QemuUUID, typeof_field(_state, _field)), \ .set_default = true, \ } -#define DEFINE_PROP_AUDIODEV(_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_audiodev, QEMUSoundCard) - #define DEFINE_PROP_UUID_NODEFAULT(_name, _state, _field) { \ .name = (_name), \ .info = &qdev_prop_uuid, \ diff --git a/include/net/net.h b/include/net/net.h index 897b2d7595..da48bc8254 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -4,6 +4,7 @@ #include "qemu/queue.h" #include "qapi/qapi-types-net.h" #include "net/queue.h" +#include "hw/qdev-properties-system.h" #define MAC_FMT "%02X:%02X:%02X:%02X:%02X:%02X" #define MAC_ARG(x) ((uint8_t *)(x))[0], ((uint8_t *)(x))[1], \ diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c index 591776ba88..9c8030a271 100644 --- a/hw/arm/pxa2xx.c +++ b/hw/arm/pxa2xx.c @@ -21,6 +21,7 @@ #include "hw/i2c/i2c.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/ssi/ssi.h" #include "hw/sd/sd.h" #include "chardev/char-fe.h" diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c index ca7c385f31..c7ca54bcea 100644 --- a/hw/arm/strongarm.c +++ b/hw/arm/strongarm.c @@ -33,6 +33,7 @@ #include "hw/boards.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "strongarm.h" diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 4c2c35e223..3636874432 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -36,6 +36,7 @@ #include "hw/irq.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "hw/block/block.h" diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 483925f57a..0ef7f00cb6 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -25,6 +25,7 @@ #include "qemu/units.h" #include "sysemu/block-backend.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/ssi/ssi.h" #include "migration/vmstate.h" #include "qemu/bitops.h" diff --git a/hw/block/nand.c b/hw/block/nand.c index bcceb64ebb..5558f5d2fa 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -21,6 +21,7 @@ #include "qemu/osdep.h" #include "hw/hw.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/block/flash.h" #include "sysemu/block-backend.h" #include "migration/vmstate.h" diff --git a/hw/block/onenand.c b/hw/block/onenand.c index 5ff7be86bb..579a73d7f7 100644 --- a/hw/block/onenand.c +++ b/hw/block/onenand.c @@ -24,6 +24,7 @@ #include "hw/block/flash.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "exec/memory.h" #include "hw/sysbus.h" diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index f0fcd63f84..90baa72f82 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -40,6 +40,7 @@ #include "hw/block/block.h" #include "hw/block/flash.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "qapi/error.h" #include "qemu/error-report.h" diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c index eb02fccfa5..e2d8a004fe 100644 --- a/hw/block/pflash_cfi02.c +++ b/hw/block/pflash_cfi02.c @@ -36,6 +36,7 @@ #include "hw/block/block.h" #include "hw/block/flash.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/bitmap.h" diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index a076b1e54d..492dc73275 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -22,6 +22,7 @@ #include "qemu/cutils.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user-blk.h" #include "hw/virtio/virtio.h" diff --git a/hw/char/avr_usart.c b/hw/char/avr_usart.c index fbe2a112b7..5bcf9db0b7 100644 --- a/hw/char/avr_usart.c +++ b/hw/char/avr_usart.c @@ -24,6 +24,7 @@ #include "qemu/log.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" static int avr_usart_can_receive(void *opaque) { diff --git a/hw/char/bcm2835_aux.c b/hw/char/bcm2835_aux.c index dade2ab5fd..96410b1ff8 100644 --- a/hw/char/bcm2835_aux.c +++ b/hw/char/bcm2835_aux.c @@ -24,6 +24,7 @@ #include "hw/char/bcm2835_aux.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/module.h" diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index e196906c92..c603e14012 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -32,6 +32,7 @@ #include "hw/char/cadence_uart.h" #include "hw/irq.h" #include "hw/qdev-clock.h" +#include "hw/qdev-properties-system.h" #include "trace.h" #ifdef CADENCE_UART_ERR_DEBUG diff --git a/hw/char/cmsdk-apb-uart.c b/hw/char/cmsdk-apb-uart.c index 626b68f2ec..ba2cbbee3d 100644 --- a/hw/char/cmsdk-apb-uart.c +++ b/hw/char/cmsdk-apb-uart.c @@ -27,6 +27,7 @@ #include "chardev/char-serial.h" #include "hw/char/cmsdk-apb-uart.h" #include "hw/irq.h" +#include "hw/qdev-properties-system.h" REG32(DATA, 0) REG32(STATE, 4) diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c index 2a063ad72c..fdb04fee09 100644 --- a/hw/char/debugcon.c +++ b/hw/char/debugcon.c @@ -30,6 +30,7 @@ #include "chardev/char-fe.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qom/object.h" #define TYPE_ISA_DEBUGCON_DEVICE "isa-debugcon" diff --git a/hw/char/digic-uart.c b/hw/char/digic-uart.c index e130cb4692..00e5df5517 100644 --- a/hw/char/digic-uart.c +++ b/hw/char/digic-uart.c @@ -35,6 +35,7 @@ #include "hw/char/digic-uart.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" enum { ST_RX_RDY = (1 << 0), diff --git a/hw/char/escc.c b/hw/char/escc.c index 7d16ee8688..52e7978287 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "qemu/module.h" diff --git a/hw/char/etraxfs_ser.c b/hw/char/etraxfs_ser.c index d9fba2ae6c..6bee3ee18e 100644 --- a/hw/char/etraxfs_ser.c +++ b/hw/char/etraxfs_ser.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "chardev/char-fe.h" #include "qemu/log.h" diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c index 96afe3580f..6361df2ad3 100644 --- a/hw/char/exynos4210_uart.c +++ b/hw/char/exynos4210_uart.c @@ -32,6 +32,7 @@ #include "hw/arm/exynos4210.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "trace.h" #include "qom/object.h" diff --git a/hw/char/grlib_apbuart.c b/hw/char/grlib_apbuart.c index 3f80f6824e..82ff40a530 100644 --- a/hw/char/grlib_apbuart.c +++ b/hw/char/grlib_apbuart.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sparc/grlib.h" #include "hw/sysbus.h" #include "qemu/module.h" diff --git a/hw/char/ibex_uart.c b/hw/char/ibex_uart.c index cc49a35013..89f1182c9b 100644 --- a/hw/char/ibex_uart.c +++ b/hw/char/ibex_uart.c @@ -30,6 +30,7 @@ #include "hw/irq.h" #include "hw/qdev-clock.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/module.h" diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c index 731b8fc64c..ee1375e26d 100644 --- a/hw/char/imx_serial.c +++ b/hw/char/imx_serial.c @@ -22,6 +22,7 @@ #include "hw/char/imx_serial.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/module.h" diff --git a/hw/char/ipoctal232.c b/hw/char/ipoctal232.c index ad000a39b9..3311e0872c 100644 --- a/hw/char/ipoctal232.c +++ b/hw/char/ipoctal232.c @@ -12,6 +12,7 @@ #include "hw/ipack/ipack.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/bitops.h" #include "qemu/module.h" diff --git a/hw/char/lm32_juart.c b/hw/char/lm32_juart.c index b97aacba91..c5ead05e08 100644 --- a/hw/char/lm32_juart.c +++ b/hw/char/lm32_juart.c @@ -26,6 +26,7 @@ #include "hw/char/lm32_juart.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qom/object.h" enum { diff --git a/hw/char/lm32_uart.c b/hw/char/lm32_uart.c index 0e8b4e46a3..5cb87de548 100644 --- a/hw/char/lm32_uart.c +++ b/hw/char/lm32_uart.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "trace.h" diff --git a/hw/char/mcf_uart.c b/hw/char/mcf_uart.c index e6814faffb..6fa4ac502c 100644 --- a/hw/char/mcf_uart.c +++ b/hw/char/mcf_uart.c @@ -13,6 +13,7 @@ #include "qapi/error.h" #include "hw/m68k/mcf.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "chardev/char-fe.h" #include "qom/object.h" diff --git a/hw/char/milkymist-uart.c b/hw/char/milkymist-uart.c index 1e83dbcafa..09e2f6bd76 100644 --- a/hw/char/milkymist-uart.c +++ b/hw/char/milkymist-uart.c @@ -24,6 +24,7 @@ #include "qemu/osdep.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "trace.h" diff --git a/hw/char/nrf51_uart.c b/hw/char/nrf51_uart.c index d1fef77acd..045ca5fa40 100644 --- a/hw/char/nrf51_uart.c +++ b/hw/char/nrf51_uart.c @@ -18,6 +18,7 @@ #include "hw/char/nrf51_uart.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "trace.h" diff --git a/hw/char/parallel.c b/hw/char/parallel.c index 8b418abf71..b45e67bfbb 100644 --- a/hw/char/parallel.c +++ b/hw/char/parallel.c @@ -32,6 +32,7 @@ #include "hw/irq.h" #include "hw/isa/isa.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "hw/char/parallel.h" #include "sysemu/reset.h" diff --git a/hw/char/pl011.c b/hw/char/pl011.c index ede16c781c..ea4a4e5235 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -23,6 +23,7 @@ #include "hw/irq.h" #include "hw/sysbus.h" #include "hw/qdev-clock.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "chardev/char-fe.h" #include "qemu/log.h" diff --git a/hw/char/renesas_sci.c b/hw/char/renesas_sci.c index 5d7c6e6523..1c63467290 100644 --- a/hw/char/renesas_sci.c +++ b/hw/char/renesas_sci.c @@ -26,6 +26,7 @@ #include "hw/irq.h" #include "hw/registerfields.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/char/renesas_sci.h" #include "migration/vmstate.h" diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c index 81f6d0ed4f..b9e9b2d453 100644 --- a/hw/char/sclpconsole-lm.c +++ b/hw/char/sclpconsole-lm.c @@ -23,6 +23,7 @@ #include "migration/vmstate.h" #include "hw/s390x/event-facility.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/s390x/ebcdic.h" #include "qom/object.h" diff --git a/hw/char/sclpconsole.c b/hw/char/sclpconsole.c index aa72ab40b9..c36b572222 100644 --- a/hw/char/sclpconsole.c +++ b/hw/char/sclpconsole.c @@ -20,6 +20,7 @@ #include "hw/s390x/sclp.h" #include "migration/vmstate.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/s390x/event-facility.h" #include "chardev/char-fe.h" #include "qom/object.h" diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c index 2cf3e44177..3a9f96c2d1 100644 --- a/hw/char/serial-pci-multi.c +++ b/hw/char/serial-pci-multi.c @@ -33,6 +33,7 @@ #include "hw/irq.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #define PCI_SERIAL_MAX_PORTS 4 diff --git a/hw/char/serial.c b/hw/char/serial.c index 97f71879ff..d99daa7695 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -35,6 +35,7 @@ #include "qemu/error-report.h" #include "trace.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #define UART_LCR_DLAB 0x80 /* Divisor latch access bit */ diff --git a/hw/char/spapr_vty.c b/hw/char/spapr_vty.c index e726d4d915..79eaa2fa52 100644 --- a/hw/char/spapr_vty.c +++ b/hw/char/spapr_vty.c @@ -8,6 +8,7 @@ #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qom/object.h" #define VTERM_BUFSIZE 16 diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c index 0d661be6d3..8df0832424 100644 --- a/hw/char/stm32f2xx_usart.c +++ b/hw/char/stm32f2xx_usart.c @@ -26,6 +26,7 @@ #include "hw/char/stm32f2xx_usart.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qemu/log.h" #include "qemu/module.h" diff --git a/hw/char/terminal3270.c b/hw/char/terminal3270.c index d77981bb6d..a9a46c8ed3 100644 --- a/hw/char/terminal3270.c +++ b/hw/char/terminal3270.c @@ -16,6 +16,7 @@ #include "qemu/module.h" #include "chardev/char-fe.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/s390x/3270-ccw.h" #include "qom/object.h" diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c index bc752cf90f..6b132caa29 100644 --- a/hw/char/virtio-console.c +++ b/hw/char/virtio-console.c @@ -16,6 +16,7 @@ #include "qemu/module.h" #include "trace.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/virtio-serial.h" #include "qapi/error.h" #include "qapi/qapi-events-char.h" diff --git a/hw/char/xilinx_uartlite.c b/hw/char/xilinx_uartlite.c index 2e773ec4c4..99b9a6f851 100644 --- a/hw/char/xilinx_uartlite.c +++ b/hw/char/xilinx_uartlite.c @@ -26,6 +26,7 @@ #include "qemu/log.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "qemu/module.h" #include "chardev/char-fe.h" diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 448d77ecab..8cfa9a3d20 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -12,6 +12,7 @@ #include "qemu/osdep.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qapi/error.h" #include "qapi/visitor.h" #include "qapi/qapi-types-block.h" diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c index 40d84734e7..c73254e886 100644 --- a/hw/i386/kvm/i8254.c +++ b/hw/i386/kvm/i8254.c @@ -32,6 +32,7 @@ #include "sysemu/runstate.h" #include "hw/timer/i8254.h" #include "hw/timer/i8254_internal.h" +#include "hw/qdev-properties-system.h" #include "sysemu/kvm.h" #include "qom/object.h" diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 27ff1f7f66..73499a6235 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -26,6 +26,7 @@ #include "qemu/module.h" #include "hw/ide/internal.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "sysemu/blockdev.h" #include "hw/block/block.h" diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c index c3f3306e66..e141a5cd45 100644 --- a/hw/ipmi/ipmi_bmc_extern.c +++ b/hw/ipmi/ipmi_bmc_extern.c @@ -35,6 +35,7 @@ #include "chardev/char-fe.h" #include "hw/ipmi/ipmi.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qom/object.h" diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index e321e5cb69..0505b52c98 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -23,6 +23,7 @@ #include "qemu/cutils.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "sysemu/kvm.h" diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index 6db62dab7d..488d086a17 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -28,6 +28,7 @@ #include "qapi/error.h" #include "qemu/cutils.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "trace.h" #include "qemu/log.h" diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c index 60066375ab..4401787a5c 100644 --- a/hw/misc/sifive_u_otp.c +++ b/hw/misc/sifive_u_otp.c @@ -21,6 +21,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "qemu/log.h" #include "qemu/module.h" diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c index 1af1e6fa2f..0fb8db1dee 100644 --- a/hw/net/rocker/rocker.c +++ b/hw/net/rocker/rocker.c @@ -18,6 +18,7 @@ #include "qemu/osdep.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "hw/pci/msix.h" #include "net/net.h" diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c index 3e93dbbffb..af6f5dbb99 100644 --- a/hw/nvram/eeprom_at24c.c +++ b/hw/nvram/eeprom_at24c.c @@ -13,6 +13,7 @@ #include "qemu/module.h" #include "hw/i2c/i2c.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/block-backend.h" #include "qom/object.h" diff --git a/hw/nvram/spapr_nvram.c b/hw/nvram/spapr_nvram.c index fc53a42572..9e51bc82ae 100644 --- a/hw/nvram/spapr_nvram.c +++ b/hw/nvram/spapr_nvram.c @@ -39,6 +39,7 @@ #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qom/object.h" struct SpaprNvram { diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_root_port.c index 8931afc049..ec9907917e 100644 --- a/hw/pci-bridge/gen_pcie_root_port.c +++ b/hw/pci-bridge/gen_pcie_root_port.c @@ -16,6 +16,7 @@ #include "hw/pci/msix.h" #include "hw/pci/pcie_port.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qom/object.h" diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 100c9381c2..2cd644285c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -30,6 +30,7 @@ #include "hw/pci/pci_bus.h" #include "hw/pci/pci_host.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/qemu-file-types.h" #include "migration/vmstate.h" #include "monitor/monitor.h" diff --git a/hw/ppc/pnv_pnor.c b/hw/ppc/pnv_pnor.c index c365ee58b8..ef8dff03e0 100644 --- a/hw/ppc/pnv_pnor.c +++ b/hw/ppc/pnv_pnor.c @@ -17,6 +17,7 @@ #include "hw/loader.h" #include "hw/ppc/pnv_pnor.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" static uint64_t pnv_pnor_read(void *opaque, hwaddr addr, unsigned size) { diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c index 77b1235a3f..8593570332 100644 --- a/hw/rdma/vmw/pvrdma_main.c +++ b/hw/rdma/vmw/pvrdma_main.c @@ -21,6 +21,7 @@ #include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "cpu.h" #include "trace.h" #include "monitor/monitor.h" diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c index 7a38540cb9..5d0fcacd0c 100644 --- a/hw/rtc/mc146818rtc.c +++ b/hw/rtc/mc146818rtc.c @@ -30,6 +30,7 @@ #include "hw/acpi/aml-build.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qemu/timer.h" #include "sysemu/sysemu.h" #include "sysemu/replay.h" diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index e859534eaf..f9a591cd17 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -34,6 +34,7 @@ #include "sysemu/blockdev.h" #include "hw/block/block.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "sysemu/dma.h" #include "sysemu/sysemu.h" #include "qemu/cutils.h" diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index 2cb23ca891..9740f7e36a 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -19,6 +19,7 @@ #include "hw/scsi/scsi.h" #include "migration/qemu-file-types.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/scsi/emulation.h" #include "sysemu/block-backend.h" #include "trace.h" diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 7c0631656c..4666019442 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -21,6 +21,7 @@ #include "hw/fw-path-provider.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-backend.h" #include "hw/virtio/vhost-user-scsi.h" diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 3091382614..fa07398c8c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -42,6 +42,7 @@ #include "qapi/error.h" #include "qemu/bitmap.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qemu/error-report.h" #include "qemu/timer.h" #include "qemu/log.h" diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c index e8e9d37e88..c27c602697 100644 --- a/hw/usb/ccid-card-passthru.c +++ b/hw/usb/ccid-card-passthru.c @@ -14,6 +14,7 @@ #include #include "chardev/char-fe.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/error-report.h" #include "qemu/module.h" diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index b1622b7c7f..504e1ef423 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -14,6 +14,7 @@ #include "qemu/error-report.h" #include "qemu/module.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/usb.h" #include "migration/vmstate.h" #include "desc.h" diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 3238de6bb8..0b7e0e15f4 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -42,6 +42,7 @@ #include #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/usb.h" #include "migration/qemu-file-types.h" #include "migration/vmstate.h" diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 0d83eb0e47..2e7e4bd6c7 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -27,6 +27,7 @@ #include "hw/pci/msix.h" #include "hw/pci/pci_bridge.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "migration/vmstate.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 1bc5d03a00..ed036ad9c1 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -16,6 +16,7 @@ #include "standard-headers/linux/virtio_fs.h" #include "qapi/error.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 3534a39d62..a6f08c26b9 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -13,6 +13,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/virtio/vhost-user-vsock.h" static const int user_feature_bits[] = { diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c index 378f63b210..770c286be7 100644 --- a/hw/virtio/virtio-iommu-pci.c +++ b/hw/virtio/virtio-iommu-pci.c @@ -14,6 +14,7 @@ #include "virtio-pci.h" #include "hw/virtio/virtio-iommu.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qapi/error.h" #include "hw/boards.h" #include "qom/object.h" diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index 6d359ee486..3cbd08b10e 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -58,6 +58,7 @@ #include "hw/pci/pci.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/xen/xen.h" #include "hw/i386/pc.h" #include "hw/xen/xen-legacy-backend.h" diff --git a/migration/migration.c b/migration/migration.c index 9bb4fee5ac..071e35ed44 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -52,6 +52,7 @@ #include "migration/colo.h" #include "hw/boards.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "monitor/monitor.h" #include "net/announce.h" #include "qemu/queue.h" From patchwork Thu Oct 29 22:02:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 647C6C2D0A3 for ; Thu, 29 Oct 2020 22:24:21 +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 BEBF920782 for ; Thu, 29 Oct 2020 22:24:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Yz3uYooX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BEBF920782 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYGLD-0006fe-Ml for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:24:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG1g-0003vu-Kq for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:04:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50446) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG1Z-0006ez-0P for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:04:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604009036; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Obm/UiHjwrOZvMKR1ByzYIEDJy3ZZONdnzSp2EMhhU8=; b=Yz3uYooXwSBW69vnQzFXe+EoIGMKljIS/b8+F08yICFPMXEeygOSC41bfvbD2tne6gAYWh btgPcQDhmsTqlMJDF/mV+1Eoyk6mWDRGA95FAbr5Qc+eh266xxLlOdMtq0916zC8SsKDO4 ZBkbnKunyxXiNtxgGKVZS77gw7QP/X8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-475-9yYUPXveN8OwXdy0UFyMSQ-1; Thu, 29 Oct 2020 18:03:54 -0400 X-MC-Unique: 9yYUPXveN8OwXdy0UFyMSQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7EDEA84BA67; Thu, 29 Oct 2020 22:03:53 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F0041002C01; Thu, 29 Oct 2020 22:03:53 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 29/36] qdev: Move qdev_prop_tpm declaration to tpm_prop.h Date: Thu, 29 Oct 2020 18:02:39 -0400 Message-Id: <20201029220246.472693-30-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , Stefan Berger , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Move the variable declaration close to the macro that uses it. Signed-off-by: Eduardo Habkost Reviewed-by:  Stefan Berger Reviewed-by: Marc-André Lureau Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
 
--- Cc: Stefan Berger Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- hw/tpm/tpm_prop.h | 2 ++ include/hw/qdev-properties.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/tpm/tpm_prop.h b/hw/tpm/tpm_prop.h index 85e1ae5718..871af584b7 100644 --- a/hw/tpm/tpm_prop.h +++ b/hw/tpm/tpm_prop.h @@ -25,6 +25,8 @@ #include "sysemu/tpm_backend.h" #include "hw/qdev-properties.h" +extern const PropertyInfo qdev_prop_tpm; + #define DEFINE_PROP_TPMBE(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_tpm, TPMBackend *) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index e1ef466790..2b00a1bcf6 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -18,7 +18,6 @@ extern const PropertyInfo qdev_prop_uint64; extern const PropertyInfo qdev_prop_int64; extern const PropertyInfo qdev_prop_size; extern const PropertyInfo qdev_prop_string; -extern const PropertyInfo qdev_prop_tpm; extern const PropertyInfo qdev_prop_on_off_auto; extern const PropertyInfo qdev_prop_size32; extern const PropertyInfo qdev_prop_uuid; From patchwork Thu Oct 29 22:02:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E76C5C2D0A3 for ; Thu, 29 Oct 2020 22:20:47 +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 3273B20FC3 for ; Thu, 29 Oct 2020 22:20:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KAsBBPtH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3273B20FC3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYGHm-0001t6-3i for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:20:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG1i-0003wm-63 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:04:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50242) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG1b-0006fB-Qp for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:04:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604009038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KbWYmlGQf+3OJtXCwCrU9BkTRivKPhSbWwuHbI4KKRc=; b=KAsBBPtHDbAdWo9NwXKC+VevJauWSQeaMTUVgvOvLtRx+//jthuTot8fikah5G1b/8vSXy erGS0WjEvG016u2fQZE4QcNmwxeY6qkmz7WfJ+b7xtBG6cEjtuWj9IMVfCW3+Lw0i/voZE oD4p4bhoQ3QV3nhv3xVkQxJcNF+9YGI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-281-Ks83TpcWPIOK01FytAkbKQ-1; Thu, 29 Oct 2020 18:03:56 -0400 X-MC-Unique: Ks83TpcWPIOK01FytAkbKQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 368CF1842161; Thu, 29 Oct 2020 22:03:55 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F0705C1C4; Thu, 29 Oct 2020 22:03:54 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 30/36] qdev: Rename qdev_prop_* to prop_info_* Date: Thu, 29 Oct 2020 18:02:40 -0400 Message-Id: <20201029220246.472693-31-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action 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: Peter Maydell , Dmitry Fleytman , "Daniel P. Berrange" , Yoshinori Sato , John Snow , Jason Wang , Mark Cave-Ayland , Markus Armbruster , qemu-arm@nongnu.org, Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Artyom Tarasenko Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The basic property types in qdev-properties.c are not going to be qdev-specific anymore. Rename the variables to prop_info_*. Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
 
--- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: Peter Maydell Cc: Yoshinori Sato Cc: Dmitry Fleytman Cc: Jason Wang Cc: Mark Cave-Ayland Cc: Artyom Tarasenko Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org --- include/hw/qdev-properties.h | 68 ++++++++++++++++++------------------ hw/core/qdev-properties.c | 38 ++++++++++---------- hw/intc/arm_gicv3_common.c | 2 +- hw/intc/rx_icu.c | 4 +-- hw/misc/arm_sysctl.c | 4 +-- hw/net/e1000e.c | 6 ++-- target/arm/cpu.c | 2 +- target/sparc/cpu.c | 2 +- 8 files changed, 63 insertions(+), 63 deletions(-) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 2b00a1bcf6..7a08946448 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -6,23 +6,23 @@ /*** qdev-properties.c ***/ -extern const PropertyInfo qdev_prop_bit; -extern const PropertyInfo qdev_prop_bit64; -extern const PropertyInfo qdev_prop_bool; -extern const PropertyInfo qdev_prop_enum; -extern const PropertyInfo qdev_prop_uint8; -extern const PropertyInfo qdev_prop_uint16; -extern const PropertyInfo qdev_prop_uint32; -extern const PropertyInfo qdev_prop_int32; -extern const PropertyInfo qdev_prop_uint64; -extern const PropertyInfo qdev_prop_int64; -extern const PropertyInfo qdev_prop_size; -extern const PropertyInfo qdev_prop_string; -extern const PropertyInfo qdev_prop_on_off_auto; -extern const PropertyInfo qdev_prop_size32; -extern const PropertyInfo qdev_prop_uuid; -extern const PropertyInfo qdev_prop_arraylen; -extern const PropertyInfo qdev_prop_link; +extern const PropertyInfo prop_info_bit; +extern const PropertyInfo prop_info_bit64; +extern const PropertyInfo prop_info_bool; +extern const PropertyInfo prop_info_enum; +extern const PropertyInfo prop_info_uint8; +extern const PropertyInfo prop_info_uint16; +extern const PropertyInfo prop_info_uint32; +extern const PropertyInfo prop_info_int32; +extern const PropertyInfo prop_info_uint64; +extern const PropertyInfo prop_info_int64; +extern const PropertyInfo prop_info_size; +extern const PropertyInfo prop_info_string; +extern const PropertyInfo prop_info_on_off_auto; +extern const PropertyInfo prop_info_size32; +extern const PropertyInfo prop_info_uuid; +extern const PropertyInfo prop_info_arraylen; +extern const PropertyInfo prop_info_link; #define DEFINE_PROP(_name, _state, _field, _prop, _type, ...) { \ .name = (_name), \ @@ -41,7 +41,7 @@ extern const PropertyInfo qdev_prop_link; DEFINE_PROP(_name, _state, _field, _prop, _type) #define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_bit, uint32_t, \ + DEFINE_PROP(_name, _state, _field, prop_info_bit, uint32_t, \ .bitnr = (_bit), \ .set_default = true, \ .defval.u = (bool)_defval) @@ -55,13 +55,13 @@ extern const PropertyInfo qdev_prop_link; DEFINE_PROP(_name, _state, _field, _prop, _type) #define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_bit64, uint64_t, \ + DEFINE_PROP(_name, _state, _field, prop_info_bit64, uint64_t, \ .bitnr = (_bit), \ .set_default = true, \ .defval.u = (bool)_defval) #define DEFINE_PROP_BOOL(_name, _state, _field, _defval) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_bool, bool, \ + DEFINE_PROP(_name, _state, _field, prop_info_bool, bool, \ .set_default = true, \ .defval.u = (bool)_defval) @@ -94,7 +94,7 @@ extern const PropertyInfo qdev_prop_link; #define DEFINE_PROP_ARRAY(_name, _state, _field, \ _arrayfield, _arrayprop, _arraytype) \ DEFINE_PROP((PROP_ARRAY_LEN_PREFIX _name), \ - _state, _field, qdev_prop_arraylen, uint32_t, \ + _state, _field, prop_info_arraylen, uint32_t, \ .set_default = true, \ .defval.u = 0, \ .arrayinfo = &(_arrayprop), \ @@ -102,34 +102,34 @@ extern const PropertyInfo qdev_prop_link; .arrayoffset = offsetof(_state, _arrayfield)) #define DEFINE_PROP_LINK(_name, _state, _field, _type, _ptr_type) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_link, _ptr_type, \ + DEFINE_PROP(_name, _state, _field, prop_info_link, _ptr_type, \ .link_type = _type) #define DEFINE_PROP_UINT8(_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint8, uint8_t) #define DEFINE_PROP_UINT16(_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint16, uint16_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint16, uint16_t) #define DEFINE_PROP_UINT32(_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint32, uint32_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint32, uint32_t) #define DEFINE_PROP_INT32(_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int32, int32_t) + DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_int32, int32_t) #define DEFINE_PROP_UINT64(_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint64, uint64_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint64, uint64_t) #define DEFINE_PROP_INT64(_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int64, int64_t) + DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_int64, int64_t) #define DEFINE_PROP_SIZE(_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_size, uint64_t) #define DEFINE_PROP_STRING(_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*) + DEFINE_PROP(_n, _s, _f, prop_info_string, char*) #define DEFINE_PROP_ON_OFF_AUTO(_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_on_off_auto, OnOffAuto) + DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_on_off_auto, OnOffAuto) #define DEFINE_PROP_SIZE32(_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size32, uint32_t) + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_size32, uint32_t) #define DEFINE_PROP_UUID(_name, _state, _field) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_uuid, QemuUUID, \ + DEFINE_PROP(_name, _state, _field, prop_info_uuid, QemuUUID, \ .set_default = true) #define DEFINE_PROP_UUID_NODEFAULT(_name, _state, _field) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_uuid, QemuUUID) + DEFINE_PROP(_name, _state, _field, prop_info_uuid, QemuUUID) #define DEFINE_PROP_END_OF_LIST() \ {} diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 1b27ba7236..59d65a7362 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -76,7 +76,7 @@ void object_propinfo_set_default_value_enum(ObjectProperty *op, qapi_enum_lookup(prop->info->enum_table, prop->defval.i)); } -const PropertyInfo qdev_prop_enum = { +const PropertyInfo prop_info_enum = { .name = "enum", .get = object_propinfo_get_enum, .set = object_propinfo_set_enum, @@ -87,7 +87,7 @@ const PropertyInfo qdev_prop_enum = { static uint32_t qdev_get_prop_mask(Property *prop) { - assert(prop->info == &qdev_prop_bit); + assert(prop->info == &prop_info_bit); return 0x1 << prop->bitnr; } @@ -129,7 +129,7 @@ static void set_default_value_bool(ObjectProperty *op, const Property *prop) object_property_set_default_bool(op, prop->defval.u); } -const PropertyInfo qdev_prop_bit = { +const PropertyInfo prop_info_bit = { .name = "bool", .description = "on/off", .get = prop_get_bit, @@ -141,7 +141,7 @@ const PropertyInfo qdev_prop_bit = { static uint64_t qdev_get_prop_mask64(Property *prop) { - assert(prop->info == &qdev_prop_bit64); + assert(prop->info == &prop_info_bit64); return 0x1ull << prop->bitnr; } @@ -178,7 +178,7 @@ static void prop_set_bit64(Object *obj, Visitor *v, const char *name, bit64_prop_set(obj, prop, value); } -const PropertyInfo qdev_prop_bit64 = { +const PropertyInfo prop_info_bit64 = { .name = "bool", .description = "on/off", .get = prop_get_bit64, @@ -206,7 +206,7 @@ static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque, visit_type_bool(v, name, ptr, errp); } -const PropertyInfo qdev_prop_bool = { +const PropertyInfo prop_info_bool = { .name = "bool", .get = get_bool, .set = set_bool, @@ -245,7 +245,7 @@ void object_propinfo_set_default_value_uint(ObjectProperty *op, object_property_set_default_uint(op, prop->defval.u); } -const PropertyInfo qdev_prop_uint8 = { +const PropertyInfo prop_info_uint8 = { .name = "uint8", .get = get_uint8, .set = set_uint8, @@ -272,7 +272,7 @@ static void set_uint16(Object *obj, Visitor *v, const char *name, visit_type_uint16(v, name, ptr, errp); } -const PropertyInfo qdev_prop_uint16 = { +const PropertyInfo prop_info_uint16 = { .name = "uint16", .get = get_uint16, .set = set_uint16, @@ -317,14 +317,14 @@ static void set_int32(Object *obj, Visitor *v, const char *name, void *opaque, visit_type_int32(v, name, ptr, errp); } -const PropertyInfo qdev_prop_uint32 = { +const PropertyInfo prop_info_uint32 = { .name = "uint32", .get = get_uint32, .set = set_uint32, .set_default_value = object_propinfo_set_default_value_uint, }; -const PropertyInfo qdev_prop_int32 = { +const PropertyInfo prop_info_int32 = { .name = "int32", .get = object_propinfo_get_int32, .set = set_int32, @@ -369,14 +369,14 @@ static void set_int64(Object *obj, Visitor *v, const char *name, visit_type_int64(v, name, ptr, errp); } -const PropertyInfo qdev_prop_uint64 = { +const PropertyInfo prop_info_uint64 = { .name = "uint64", .get = get_uint64, .set = set_uint64, .set_default_value = object_propinfo_set_default_value_uint, }; -const PropertyInfo qdev_prop_int64 = { +const PropertyInfo prop_info_int64 = { .name = "int64", .get = get_int64, .set = set_int64, @@ -419,7 +419,7 @@ static void set_string(Object *obj, Visitor *v, const char *name, *ptr = str; } -const PropertyInfo qdev_prop_string = { +const PropertyInfo prop_info_string = { .name = "str", .release = release_string, .get = get_string, @@ -428,7 +428,7 @@ const PropertyInfo qdev_prop_string = { /* --- on/off/auto --- */ -const PropertyInfo qdev_prop_on_off_auto = { +const PropertyInfo prop_info_on_off_auto = { .name = "OnOffAuto", .description = "on/off/auto", .enum_table = &OnOffAuto_lookup, @@ -471,7 +471,7 @@ static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque, *ptr = value; } -const PropertyInfo qdev_prop_size32 = { +const PropertyInfo prop_info_size32 = { .name = "size", .get = object_propinfo_get_size32, .set = set_size32, @@ -519,7 +519,7 @@ static void set_default_uuid_auto(ObjectProperty *op, const Property *prop) object_property_set_default_str(op, UUID_VALUE_AUTO); } -const PropertyInfo qdev_prop_uuid = { +const PropertyInfo prop_info_uuid = { .name = "str", .description = "UUID (aka GUID) or \"" UUID_VALUE_AUTO "\" for random value (default)", @@ -640,7 +640,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name, } } -const PropertyInfo qdev_prop_arraylen = { +const PropertyInfo prop_info_arraylen = { .name = "uint32", .get = get_uint32, .set = set_prop_arraylen, @@ -839,7 +839,7 @@ static void set_size(Object *obj, Visitor *v, const char *name, void *opaque, visit_type_size(v, name, ptr, errp); } -const PropertyInfo qdev_prop_size = { +const PropertyInfo prop_info_size = { .name = "size", .get = get_size, .set = set_size, @@ -860,7 +860,7 @@ static ObjectProperty *create_link_property(ObjectClass *oc, Property *prop) OBJ_PROP_LINK_STRONG); } -const PropertyInfo qdev_prop_link = { +const PropertyInfo prop_info_link = { .name = "link", .create = create_link_property, }; diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c index 58ef65f589..6d06b4d4c5 100644 --- a/hw/intc/arm_gicv3_common.c +++ b/hw/intc/arm_gicv3_common.c @@ -496,7 +496,7 @@ static Property arm_gicv3_common_properties[] = { DEFINE_PROP_UINT32("revision", GICv3State, revision, 3), DEFINE_PROP_BOOL("has-security-extensions", GICv3State, security_extn, 0), DEFINE_PROP_ARRAY("redist-region-count", GICv3State, nb_redist_regions, - redist_region_count, qdev_prop_uint32, uint32_t), + redist_region_count, prop_info_uint32, uint32_t), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/intc/rx_icu.c b/hw/intc/rx_icu.c index 94e17a9dea..823160d9a8 100644 --- a/hw/intc/rx_icu.c +++ b/hw/intc/rx_icu.c @@ -365,9 +365,9 @@ static const VMStateDescription vmstate_rxicu = { static Property rxicu_properties[] = { DEFINE_PROP_ARRAY("ipr-map", RXICUState, nr_irqs, map, - qdev_prop_uint8, uint8_t), + prop_info_uint8, uint8_t), DEFINE_PROP_ARRAY("trigger-level", RXICUState, nr_sense, init_sense, - qdev_prop_uint8, uint8_t), + prop_info_uint8, uint8_t), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/misc/arm_sysctl.c b/hw/misc/arm_sysctl.c index 42d4693854..634f3d916f 100644 --- a/hw/misc/arm_sysctl.c +++ b/hw/misc/arm_sysctl.c @@ -628,10 +628,10 @@ static Property arm_sysctl_properties[] = { DEFINE_PROP_UINT32("proc_id", arm_sysctl_state, proc_id, 0), /* Daughterboard power supply voltages (as reported via SYS_CFG) */ DEFINE_PROP_ARRAY("db-voltage", arm_sysctl_state, db_num_vsensors, - db_voltage, qdev_prop_uint32, uint32_t), + db_voltage, prop_info_uint32, uint32_t), /* Daughterboard clock reset values (as reported via SYS_CFG) */ DEFINE_PROP_ARRAY("db-clock", arm_sysctl_state, db_num_clocks, - db_clock_reset, qdev_prop_uint32, uint32_t), + db_clock_reset, prop_info_uint32, uint32_t), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c index b6f1ae3c8f..7928939ae2 100644 --- a/hw/net/e1000e.c +++ b/hw/net/e1000e.c @@ -686,15 +686,15 @@ static void e1000e_class_init(ObjectClass *class, void *data) dc->reset = e1000e_qdev_reset; dc->vmsd = &e1000e_vmstate; - e1000e_prop_disable_vnet = qdev_prop_uint8; + e1000e_prop_disable_vnet = prop_info_uint8; e1000e_prop_disable_vnet.description = "Do not use virtio headers, " "perform SW offloads emulation " "instead"; - e1000e_prop_subsys_ven = qdev_prop_uint16; + e1000e_prop_subsys_ven = prop_info_uint16; e1000e_prop_subsys_ven.description = "PCI device Subsystem Vendor ID"; - e1000e_prop_subsys = qdev_prop_uint16; + e1000e_prop_subsys = prop_info_uint16; e1000e_prop_subsys.description = "PCI device Subsystem ID"; device_class_set_props(dc, e1000e_properties); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 07492e9f9a..cef92879b0 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1108,7 +1108,7 @@ static Property arm_cpu_has_mpu_property = static Property arm_cpu_pmsav7_dregion_property = DEFINE_PROP_UNSIGNED_NODEFAULT("pmsav7-dregion", ARMCPU, pmsav7_dregion, - qdev_prop_uint32, uint32_t); + prop_info_uint32, uint32_t); static bool arm_get_pmu(Object *obj, Error **errp) { diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index cf21efd85f..a03ec9b0e8 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -839,7 +839,7 @@ static Property sparc_cpu_properties[] = { DEFINE_PROP_BIT("cmt", SPARCCPU, env.def.features, 12, false), DEFINE_PROP_BIT("gl", SPARCCPU, env.def.features, 13, false), DEFINE_PROP_UNSIGNED("iu-version", SPARCCPU, env.def.iu_version, 0, - qdev_prop_uint64, target_ulong), + prop_info_uint64, target_ulong), DEFINE_PROP_UINT32("fpu-version", SPARCCPU, env.def.fpu_version, 0), DEFINE_PROP_UINT32("mmu-version", SPARCCPU, env.def.mmu_version, 0), { .name = "nwindows", .info = &qdev_prop_nwindows }, From patchwork Thu Oct 29 22:02:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A129BC2D0A3 for ; Thu, 29 Oct 2020 22:27:46 +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 B1D7520729 for ; Thu, 29 Oct 2020 22:27:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SqPbK8L5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1D7520729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYGOW-00026j-G2 for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:27:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG1l-0003xP-TW for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:04:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG1b-0006fT-Oy for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:04:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604009041; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7IMJp8wu1DOWBwwx/gtg4UHBliHUY0+W5uz2+SzU98U=; b=SqPbK8L5Em35w3vfLvDc3xJZKRsmln31qkMKatcVGOKMJqFwQlrpupw/kgUst9P9T9cKNP CU+xF1Cw7Sh/jV/Hb+TyNoA+SRA7OSCWjrYrfWCTdJWmg5dxzE4R+74jAWXncWVXpTKuLm mI4Yl2ODkn1yyW1BzF7y9D6bX+zQh64= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-22-8F8K1WzAObG_0h-HvQPlTA-1; Thu, 29 Oct 2020 18:03:59 -0400 X-MC-Unique: 8F8K1WzAObG_0h-HvQPlTA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4AA5610E2184 for ; Thu, 29 Oct 2020 22:03:58 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96F4C1975F; Thu, 29 Oct 2020 22:03:57 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 32/36] qdev: Move base property types to qom/property-types.c Date: Thu, 29 Oct 2020 18:02:42 -0400 Message-Id: <20201029220246.472693-33-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 01:47:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Move all property types from qdev-properties.c to qom/property-types.c. Signed-off-by: Eduardo Habkost Reviewed-by: Marc-André Lureau Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

--
Marc-André Lureau
--- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- include/hw/qdev-properties.h | 130 ------- include/qom/static-property.h | 128 +++++++ hw/core/qdev-properties.c | 642 --------------------------------- qom/property-types.c | 649 ++++++++++++++++++++++++++++++++++ qom/meson.build | 1 + 5 files changed, 778 insertions(+), 772 deletions(-) create mode 100644 qom/property-types.c diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 7a08946448..a4ac1e6972 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -4,136 +4,6 @@ #include "hw/qdev-core.h" #include "qom/static-property.h" -/*** qdev-properties.c ***/ - -extern const PropertyInfo prop_info_bit; -extern const PropertyInfo prop_info_bit64; -extern const PropertyInfo prop_info_bool; -extern const PropertyInfo prop_info_enum; -extern const PropertyInfo prop_info_uint8; -extern const PropertyInfo prop_info_uint16; -extern const PropertyInfo prop_info_uint32; -extern const PropertyInfo prop_info_int32; -extern const PropertyInfo prop_info_uint64; -extern const PropertyInfo prop_info_int64; -extern const PropertyInfo prop_info_size; -extern const PropertyInfo prop_info_string; -extern const PropertyInfo prop_info_on_off_auto; -extern const PropertyInfo prop_info_size32; -extern const PropertyInfo prop_info_uuid; -extern const PropertyInfo prop_info_arraylen; -extern const PropertyInfo prop_info_link; - -#define DEFINE_PROP(_name, _state, _field, _prop, _type, ...) { \ - .name = (_name), \ - .info = &(_prop), \ - .offset = offsetof(_state, _field) \ - + type_check(_type, typeof_field(_state, _field)), \ - __VA_ARGS__ \ - } - -#define DEFINE_PROP_SIGNED(_name, _state, _field, _defval, _prop, _type) \ - DEFINE_PROP(_name, _state, _field, _prop, _type, \ - .set_default = true, \ - .defval.i = (_type)_defval) - -#define DEFINE_PROP_SIGNED_NODEFAULT(_name, _state, _field, _prop, _type) \ - DEFINE_PROP(_name, _state, _field, _prop, _type) - -#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) \ - DEFINE_PROP(_name, _state, _field, prop_info_bit, uint32_t, \ - .bitnr = (_bit), \ - .set_default = true, \ - .defval.u = (bool)_defval) - -#define DEFINE_PROP_UNSIGNED(_name, _state, _field, _defval, _prop, _type) \ - DEFINE_PROP(_name, _state, _field, _prop, _type, \ - .set_default = true, \ - .defval.u = (_type)_defval) - -#define DEFINE_PROP_UNSIGNED_NODEFAULT(_name, _state, _field, _prop, _type) \ - DEFINE_PROP(_name, _state, _field, _prop, _type) - -#define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) \ - DEFINE_PROP(_name, _state, _field, prop_info_bit64, uint64_t, \ - .bitnr = (_bit), \ - .set_default = true, \ - .defval.u = (bool)_defval) - -#define DEFINE_PROP_BOOL(_name, _state, _field, _defval) \ - DEFINE_PROP(_name, _state, _field, prop_info_bool, bool, \ - .set_default = true, \ - .defval.u = (bool)_defval) - -#define PROP_ARRAY_LEN_PREFIX "len-" - -/** - * DEFINE_PROP_ARRAY: - * @_name: name of the array - * @_state: name of the device state structure type - * @_field: uint32_t field in @_state to hold the array length - * @_arrayfield: field in @_state (of type '@_arraytype *') which - * will point to the array - * @_arrayprop: PropertyInfo defining what property the array elements have - * @_arraytype: C type of the array elements - * - * Define device properties for a variable-length array _name. A - * static property "len-arrayname" is defined. When the device creator - * sets this property to the desired length of array, further dynamic - * properties "arrayname[0]", "arrayname[1]", ... are defined so the - * device creator can set the array element values. Setting the - * "len-arrayname" property more than once is an error. - * - * When the array length is set, the @_field member of the device - * struct is set to the array length, and @_arrayfield is set to point - * to (zero-initialised) memory allocated for the array. For a zero - * length array, @_field will be set to 0 and @_arrayfield to NULL. - * It is the responsibility of the device deinit code to free the - * @_arrayfield memory. - */ -#define DEFINE_PROP_ARRAY(_name, _state, _field, \ - _arrayfield, _arrayprop, _arraytype) \ - DEFINE_PROP((PROP_ARRAY_LEN_PREFIX _name), \ - _state, _field, prop_info_arraylen, uint32_t, \ - .set_default = true, \ - .defval.u = 0, \ - .arrayinfo = &(_arrayprop), \ - .arrayfieldsize = sizeof(_arraytype), \ - .arrayoffset = offsetof(_state, _arrayfield)) - -#define DEFINE_PROP_LINK(_name, _state, _field, _type, _ptr_type) \ - DEFINE_PROP(_name, _state, _field, prop_info_link, _ptr_type, \ - .link_type = _type) - -#define DEFINE_PROP_UINT8(_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint8, uint8_t) -#define DEFINE_PROP_UINT16(_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint16, uint16_t) -#define DEFINE_PROP_UINT32(_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint32, uint32_t) -#define DEFINE_PROP_INT32(_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_int32, int32_t) -#define DEFINE_PROP_UINT64(_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint64, uint64_t) -#define DEFINE_PROP_INT64(_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_int64, int64_t) -#define DEFINE_PROP_SIZE(_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_size, uint64_t) -#define DEFINE_PROP_STRING(_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, prop_info_string, char*) -#define DEFINE_PROP_ON_OFF_AUTO(_n, _s, _f, _d) \ - DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_on_off_auto, OnOffAuto) -#define DEFINE_PROP_SIZE32(_n, _s, _f, _d) \ - DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_size32, uint32_t) -#define DEFINE_PROP_UUID(_name, _state, _field) \ - DEFINE_PROP(_name, _state, _field, prop_info_uuid, QemuUUID, \ - .set_default = true) -#define DEFINE_PROP_UUID_NODEFAULT(_name, _state, _field) \ - DEFINE_PROP(_name, _state, _field, prop_info_uuid, QemuUUID) - -#define DEFINE_PROP_END_OF_LIST() \ - {} - /* * Set properties between creation and realization. * diff --git a/include/qom/static-property.h b/include/qom/static-property.h index 125ff06327..779918c947 100644 --- a/include/qom/static-property.h +++ b/include/qom/static-property.h @@ -76,4 +76,132 @@ void object_class_add_static_props(ObjectClass *oc, Property *props, void *object_static_prop_ptr(Object *obj, Property *prop); +extern const PropertyInfo prop_info_bit; +extern const PropertyInfo prop_info_bit64; +extern const PropertyInfo prop_info_bool; +extern const PropertyInfo prop_info_enum; +extern const PropertyInfo prop_info_uint8; +extern const PropertyInfo prop_info_uint16; +extern const PropertyInfo prop_info_uint32; +extern const PropertyInfo prop_info_int32; +extern const PropertyInfo prop_info_uint64; +extern const PropertyInfo prop_info_int64; +extern const PropertyInfo prop_info_size; +extern const PropertyInfo prop_info_string; +extern const PropertyInfo prop_info_on_off_auto; +extern const PropertyInfo prop_info_size32; +extern const PropertyInfo prop_info_uuid; +extern const PropertyInfo prop_info_arraylen; +extern const PropertyInfo prop_info_link; + +#define DEFINE_PROP(_name, _state, _field, _prop, _type, ...) { \ + .name = (_name), \ + .info = &(_prop), \ + .offset = offsetof(_state, _field) \ + + type_check(_type, typeof_field(_state, _field)), \ + __VA_ARGS__ \ + } + +#define DEFINE_PROP_SIGNED(_name, _state, _field, _defval, _prop, _type) \ + DEFINE_PROP(_name, _state, _field, _prop, _type, \ + .set_default = true, \ + .defval.i = (_type)_defval) + +#define DEFINE_PROP_SIGNED_NODEFAULT(_name, _state, _field, _prop, _type) \ + DEFINE_PROP(_name, _state, _field, _prop, _type) + +#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) \ + DEFINE_PROP(_name, _state, _field, prop_info_bit, uint32_t, \ + .bitnr = (_bit), \ + .set_default = true, \ + .defval.u = (bool)_defval) + +#define DEFINE_PROP_UNSIGNED(_name, _state, _field, _defval, _prop, _type) \ + DEFINE_PROP(_name, _state, _field, _prop, _type, \ + .set_default = true, \ + .defval.u = (_type)_defval) + +#define DEFINE_PROP_UNSIGNED_NODEFAULT(_name, _state, _field, _prop, _type) \ + DEFINE_PROP(_name, _state, _field, _prop, _type) + +#define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) \ + DEFINE_PROP(_name, _state, _field, prop_info_bit64, uint64_t, \ + .bitnr = (_bit), \ + .set_default = true, \ + .defval.u = (bool)_defval) + +#define DEFINE_PROP_BOOL(_name, _state, _field, _defval) \ + DEFINE_PROP(_name, _state, _field, prop_info_bool, bool, \ + .set_default = true, \ + .defval.u = (bool)_defval) + +#define PROP_ARRAY_LEN_PREFIX "len-" + +/** + * DEFINE_PROP_ARRAY: + * @_name: name of the array + * @_state: name of the device state structure type + * @_field: uint32_t field in @_state to hold the array length + * @_arrayfield: field in @_state (of type '@_arraytype *') which + * will point to the array + * @_arrayprop: PropertyInfo defining what property the array elements have + * @_arraytype: C type of the array elements + * + * Define device properties for a variable-length array _name. A + * static property "len-arrayname" is defined. When the device creator + * sets this property to the desired length of array, further dynamic + * properties "arrayname[0]", "arrayname[1]", ... are defined so the + * device creator can set the array element values. Setting the + * "len-arrayname" property more than once is an error. + * + * When the array length is set, the @_field member of the device + * struct is set to the array length, and @_arrayfield is set to point + * to (zero-initialised) memory allocated for the array. For a zero + * length array, @_field will be set to 0 and @_arrayfield to NULL. + * It is the responsibility of the device deinit code to free the + * @_arrayfield memory. + */ +#define DEFINE_PROP_ARRAY(_name, _state, _field, \ + _arrayfield, _arrayprop, _arraytype) \ + DEFINE_PROP((PROP_ARRAY_LEN_PREFIX _name), \ + _state, _field, prop_info_arraylen, uint32_t, \ + .set_default = true, \ + .defval.u = 0, \ + .arrayinfo = &(_arrayprop), \ + .arrayfieldsize = sizeof(_arraytype), \ + .arrayoffset = offsetof(_state, _arrayfield)) + +#define DEFINE_PROP_LINK(_name, _state, _field, _type, _ptr_type) \ + DEFINE_PROP(_name, _state, _field, prop_info_link, _ptr_type, \ + .link_type = _type) + +#define DEFINE_PROP_UINT8(_n, _s, _f, _d) \ + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint8, uint8_t) +#define DEFINE_PROP_UINT16(_n, _s, _f, _d) \ + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint16, uint16_t) +#define DEFINE_PROP_UINT32(_n, _s, _f, _d) \ + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint32, uint32_t) +#define DEFINE_PROP_INT32(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_int32, int32_t) +#define DEFINE_PROP_UINT64(_n, _s, _f, _d) \ + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint64, uint64_t) +#define DEFINE_PROP_INT64(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_int64, int64_t) +#define DEFINE_PROP_SIZE(_n, _s, _f, _d) \ + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_size, uint64_t) +#define DEFINE_PROP_STRING(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, prop_info_string, char*) +#define DEFINE_PROP_ON_OFF_AUTO(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_on_off_auto, OnOffAuto) +#define DEFINE_PROP_SIZE32(_n, _s, _f, _d) \ + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_size32, uint32_t) +#define DEFINE_PROP_UUID(_name, _state, _field) \ + DEFINE_PROP(_name, _state, _field, prop_info_uuid, QemuUUID, \ + .set_default = true) +#define DEFINE_PROP_UUID_NODEFAULT(_name, _state, _field) \ + DEFINE_PROP(_name, _state, _field, prop_info_uuid, QemuUUID) + +#define DEFINE_PROP_END_OF_LIST() \ + {} + #endif diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 5b9907e8ba..c03842e89a 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -51,602 +51,6 @@ void qdev_prop_allow_set_link_before_realize(const Object *obj, } } -void object_propinfo_get_enum(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - int *ptr = object_static_prop_ptr(obj, prop); - - visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp); -} - -void object_propinfo_set_enum(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - int *ptr = object_static_prop_ptr(obj, prop); - - visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp); -} - -void object_propinfo_set_default_value_enum(ObjectProperty *op, - const Property *prop) -{ - object_property_set_default_str(op, - qapi_enum_lookup(prop->info->enum_table, prop->defval.i)); -} - -const PropertyInfo prop_info_enum = { - .name = "enum", - .get = object_propinfo_get_enum, - .set = object_propinfo_set_enum, - .set_default_value = object_propinfo_set_default_value_enum, -}; - -/* Bit */ - -static uint32_t qdev_get_prop_mask(Property *prop) -{ - assert(prop->info == &prop_info_bit); - return 0x1 << prop->bitnr; -} - -static void bit_prop_set(Object *obj, Property *props, bool val) -{ - uint32_t *p = object_static_prop_ptr(obj, props); - uint32_t mask = qdev_get_prop_mask(props); - if (val) { - *p |= mask; - } else { - *p &= ~mask; - } -} - -static void prop_get_bit(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - uint32_t *p = object_static_prop_ptr(obj, prop); - bool value = (*p & qdev_get_prop_mask(prop)) != 0; - - visit_type_bool(v, name, &value, errp); -} - -static void prop_set_bit(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - bool value; - - if (!visit_type_bool(v, name, &value, errp)) { - return; - } - bit_prop_set(obj, prop, value); -} - -static void set_default_value_bool(ObjectProperty *op, const Property *prop) -{ - object_property_set_default_bool(op, prop->defval.u); -} - -const PropertyInfo prop_info_bit = { - .name = "bool", - .description = "on/off", - .get = prop_get_bit, - .set = prop_set_bit, - .set_default_value = set_default_value_bool, -}; - -/* Bit64 */ - -static uint64_t qdev_get_prop_mask64(Property *prop) -{ - assert(prop->info == &prop_info_bit64); - return 0x1ull << prop->bitnr; -} - -static void bit64_prop_set(Object *obj, Property *props, bool val) -{ - uint64_t *p = object_static_prop_ptr(obj, props); - uint64_t mask = qdev_get_prop_mask64(props); - if (val) { - *p |= mask; - } else { - *p &= ~mask; - } -} - -static void prop_get_bit64(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - uint64_t *p = object_static_prop_ptr(obj, prop); - bool value = (*p & qdev_get_prop_mask64(prop)) != 0; - - visit_type_bool(v, name, &value, errp); -} - -static void prop_set_bit64(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - bool value; - - if (!visit_type_bool(v, name, &value, errp)) { - return; - } - bit64_prop_set(obj, prop, value); -} - -const PropertyInfo prop_info_bit64 = { - .name = "bool", - .description = "on/off", - .get = prop_get_bit64, - .set = prop_set_bit64, - .set_default_value = set_default_value_bool, -}; - -/* --- bool --- */ - -static void get_bool(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) -{ - Property *prop = opaque; - bool *ptr = object_static_prop_ptr(obj, prop); - - visit_type_bool(v, name, ptr, errp); -} - -static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) -{ - Property *prop = opaque; - bool *ptr = object_static_prop_ptr(obj, prop); - - visit_type_bool(v, name, ptr, errp); -} - -const PropertyInfo prop_info_bool = { - .name = "bool", - .get = get_bool, - .set = set_bool, - .set_default_value = set_default_value_bool, -}; - -/* --- 8bit integer --- */ - -static void get_uint8(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) -{ - Property *prop = opaque; - uint8_t *ptr = object_static_prop_ptr(obj, prop); - - visit_type_uint8(v, name, ptr, errp); -} - -static void set_uint8(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) -{ - Property *prop = opaque; - uint8_t *ptr = object_static_prop_ptr(obj, prop); - - visit_type_uint8(v, name, ptr, errp); -} - -void object_propinfo_set_default_value_int(ObjectProperty *op, - const Property *prop) -{ - object_property_set_default_int(op, prop->defval.i); -} - -void object_propinfo_set_default_value_uint(ObjectProperty *op, - const Property *prop) -{ - object_property_set_default_uint(op, prop->defval.u); -} - -const PropertyInfo prop_info_uint8 = { - .name = "uint8", - .get = get_uint8, - .set = set_uint8, - .set_default_value = object_propinfo_set_default_value_uint, -}; - -/* --- 16bit integer --- */ - -static void get_uint16(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - uint16_t *ptr = object_static_prop_ptr(obj, prop); - - visit_type_uint16(v, name, ptr, errp); -} - -static void set_uint16(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - uint16_t *ptr = object_static_prop_ptr(obj, prop); - - visit_type_uint16(v, name, ptr, errp); -} - -const PropertyInfo prop_info_uint16 = { - .name = "uint16", - .get = get_uint16, - .set = set_uint16, - .set_default_value = object_propinfo_set_default_value_uint, -}; - -/* --- 32bit integer --- */ - -static void get_uint32(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - uint32_t *ptr = object_static_prop_ptr(obj, prop); - - visit_type_uint32(v, name, ptr, errp); -} - -static void set_uint32(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - uint32_t *ptr = object_static_prop_ptr(obj, prop); - - visit_type_uint32(v, name, ptr, errp); -} - -void object_propinfo_get_int32(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - int32_t *ptr = object_static_prop_ptr(obj, prop); - - visit_type_int32(v, name, ptr, errp); -} - -static void set_int32(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) -{ - Property *prop = opaque; - int32_t *ptr = object_static_prop_ptr(obj, prop); - - visit_type_int32(v, name, ptr, errp); -} - -const PropertyInfo prop_info_uint32 = { - .name = "uint32", - .get = get_uint32, - .set = set_uint32, - .set_default_value = object_propinfo_set_default_value_uint, -}; - -const PropertyInfo prop_info_int32 = { - .name = "int32", - .get = object_propinfo_get_int32, - .set = set_int32, - .set_default_value = object_propinfo_set_default_value_int, -}; - -/* --- 64bit integer --- */ - -static void get_uint64(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - uint64_t *ptr = object_static_prop_ptr(obj, prop); - - visit_type_uint64(v, name, ptr, errp); -} - -static void set_uint64(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - uint64_t *ptr = object_static_prop_ptr(obj, prop); - - visit_type_uint64(v, name, ptr, errp); -} - -static void get_int64(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - int64_t *ptr = object_static_prop_ptr(obj, prop); - - visit_type_int64(v, name, ptr, errp); -} - -static void set_int64(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - int64_t *ptr = object_static_prop_ptr(obj, prop); - - visit_type_int64(v, name, ptr, errp); -} - -const PropertyInfo prop_info_uint64 = { - .name = "uint64", - .get = get_uint64, - .set = set_uint64, - .set_default_value = object_propinfo_set_default_value_uint, -}; - -const PropertyInfo prop_info_int64 = { - .name = "int64", - .get = get_int64, - .set = set_int64, - .set_default_value = object_propinfo_set_default_value_int, -}; - -/* --- string --- */ - -static void release_string(Object *obj, const char *name, void *opaque) -{ - Property *prop = opaque; - g_free(*(char **)object_static_prop_ptr(obj, prop)); -} - -static void get_string(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - char **ptr = object_static_prop_ptr(obj, prop); - - if (!*ptr) { - char *str = (char *)""; - visit_type_str(v, name, &str, errp); - } else { - visit_type_str(v, name, ptr, errp); - } -} - -static void set_string(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - char **ptr = object_static_prop_ptr(obj, prop); - char *str; - - if (!visit_type_str(v, name, &str, errp)) { - return; - } - g_free(*ptr); - *ptr = str; -} - -const PropertyInfo prop_info_string = { - .name = "str", - .release = release_string, - .get = get_string, - .set = set_string, -}; - -/* --- on/off/auto --- */ - -const PropertyInfo prop_info_on_off_auto = { - .name = "OnOffAuto", - .description = "on/off/auto", - .enum_table = &OnOffAuto_lookup, - .get = object_propinfo_get_enum, - .set = object_propinfo_set_enum, - .set_default_value = object_propinfo_set_default_value_enum, -}; - -/* --- 32bit unsigned int 'size' type --- */ - -void object_propinfo_get_size32(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - Property *prop = opaque; - uint32_t *ptr = object_static_prop_ptr(obj, prop); - uint64_t value = *ptr; - - visit_type_size(v, name, &value, errp); -} - -static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) -{ - Property *prop = opaque; - uint32_t *ptr = object_static_prop_ptr(obj, prop); - uint64_t value; - - if (!visit_type_size(v, name, &value, errp)) { - return; - } - - if (value > UINT32_MAX) { - error_setg(errp, - "Property %s.%s doesn't take value %" PRIu64 - " (maximum: %u)", - object_get_typename(obj), name, value, UINT32_MAX); - return; - } - - *ptr = value; -} - -const PropertyInfo prop_info_size32 = { - .name = "size", - .get = object_propinfo_get_size32, - .set = set_size32, - .set_default_value = object_propinfo_set_default_value_uint, -}; - -/* --- UUID --- */ - -static void get_uuid(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) -{ - Property *prop = opaque; - QemuUUID *uuid = object_static_prop_ptr(obj, prop); - char buffer[UUID_FMT_LEN + 1]; - char *p = buffer; - - qemu_uuid_unparse(uuid, buffer); - - visit_type_str(v, name, &p, errp); -} - -#define UUID_VALUE_AUTO "auto" - -static void set_uuid(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) -{ - Property *prop = opaque; - QemuUUID *uuid = object_static_prop_ptr(obj, prop); - char *str; - - if (!visit_type_str(v, name, &str, errp)) { - return; - } - - if (!strcmp(str, UUID_VALUE_AUTO)) { - qemu_uuid_generate(uuid); - } else if (qemu_uuid_parse(str, uuid) < 0) { - error_setg(errp, "invalid UUID: '%s'", str); - } - g_free(str); -} - -static void set_default_uuid_auto(ObjectProperty *op, const Property *prop) -{ - object_property_set_default_str(op, UUID_VALUE_AUTO); -} - -const PropertyInfo prop_info_uuid = { - .name = "str", - .description = "UUID (aka GUID) or \"" UUID_VALUE_AUTO - "\" for random value (default)", - .get = get_uuid, - .set = set_uuid, - .set_default_value = set_default_uuid_auto, -}; - -/* --- support for array properties --- */ - -/* Used as an opaque for the object properties we add for each - * array element. Note that the struct Property must be first - * in the struct so that a pointer to this works as the opaque - * for the underlying element's property hooks as well as for - * our own release callback. - */ -typedef struct { - struct Property prop; - char *propname; - ObjectPropertyRelease *release; -} ArrayElementProperty; - -/** - * Create ArrayElementProperty based on array length property - * @array_len_prop (which was previously defined using DEFINE_PROP_ARRAY()). - */ -static ArrayElementProperty *array_element_new(Object *obj, - Property *array_len_prop, - const char *arrayname, - int index, - void *eltptr) -{ - char *propname = g_strdup_printf("%s[%d]", arrayname, index); - ArrayElementProperty *arrayprop = g_new0(ArrayElementProperty, 1); - arrayprop->propname = propname; - arrayprop->prop.info = array_len_prop->arrayinfo; - arrayprop->prop.name = propname; - /* This ugly piece of pointer arithmetic sets up the offset so - * that when the underlying get/set hooks call qdev_get_prop_ptr - * they get the right answer despite the array element not actually - * being inside the device struct. - */ - arrayprop->prop.offset = eltptr - (void *)obj; - assert(object_static_prop_ptr(obj, &arrayprop->prop) == eltptr); - return arrayprop; -} - -/* object property release callback for array element properties: - * we call the underlying element's property release hook, and - * then free the memory we allocated when we added the property. - */ -static void array_element_release(Object *obj, const char *name, void *opaque) -{ - ArrayElementProperty *p = opaque; - if (p->release) { - p->release(obj, name, opaque); - } - g_free(p->propname); - g_free(p); -} - -static void object_property_add_array_element(Object *obj, - Property *array_len_prop, - ArrayElementProperty *prop) -{ - ObjectProperty *array_op = object_property_find(obj, array_len_prop->name); - ObjectProperty *op = object_property_add_static(obj, &prop->prop, - array_op->allow_set); - - assert((void *)prop == (void *)&prop->prop); - prop->release = op->release; - /* array_element_release() will call the original release function */ - op->release = array_element_release; -} - -static void set_prop_arraylen(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - /* Setter for the property which defines the length of a - * variable-sized property array. As well as actually setting the - * array-length field in the device struct, we have to create the - * array itself and dynamically add the corresponding properties. - */ - Property *prop = opaque; - uint32_t *alenptr = object_static_prop_ptr(obj, prop); - void **arrayptr = (void *)obj + prop->arrayoffset; - void *eltptr; - const char *arrayname; - int i; - - if (*alenptr) { - error_setg(errp, "array size property %s may not be set more than once", - name); - return; - } - if (!visit_type_uint32(v, name, alenptr, errp)) { - return; - } - if (!*alenptr) { - return; - } - - /* DEFINE_PROP_ARRAY guarantees that name should start with this prefix; - * strip it off so we can get the name of the array itself. - */ - assert(strncmp(name, PROP_ARRAY_LEN_PREFIX, - strlen(PROP_ARRAY_LEN_PREFIX)) == 0); - arrayname = name + strlen(PROP_ARRAY_LEN_PREFIX); - - /* Note that it is the responsibility of the individual device's deinit - * to free the array proper. - */ - *arrayptr = eltptr = g_malloc0(*alenptr * prop->arrayfieldsize); - for (i = 0; i < *alenptr; i++, eltptr += prop->arrayfieldsize) { - ArrayElementProperty *elt_prop = array_element_new(obj, prop, arrayname, - i, eltptr); - object_property_add_array_element(obj, prop, elt_prop); - } -} - -const PropertyInfo prop_info_arraylen = { - .name = "uint32", - .get = get_uint32, - .set = set_prop_arraylen, - .set_default_value = object_propinfo_set_default_value_uint, -}; - /* --- public helpers --- */ static Property *qdev_prop_walk(Property *props, const char *name) @@ -819,52 +223,6 @@ void qdev_prop_set_globals(DeviceState *dev) dev->hotplugged ? NULL : &error_fatal); } -/* --- 64bit unsigned int 'size' type --- */ - -static void get_size(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) -{ - Property *prop = opaque; - uint64_t *ptr = object_static_prop_ptr(obj, prop); - - visit_type_size(v, name, ptr, errp); -} - -static void set_size(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) -{ - Property *prop = opaque; - uint64_t *ptr = object_static_prop_ptr(obj, prop); - - visit_type_size(v, name, ptr, errp); -} - -const PropertyInfo prop_info_size = { - .name = "size", - .get = get_size, - .set = set_size, - .set_default_value = object_propinfo_set_default_value_uint, -}; - -/* --- object link property --- */ - -static ObjectProperty *create_link_property(ObjectClass *oc, Property *prop) -{ - /* - * NOTE: object_property_allow_set_link is unconditional, but - * ObjectProperty.allow_set may be set for the property too. - */ - return object_class_property_add_link(oc, prop->name, prop->link_type, - prop->offset, - object_property_allow_set_link, - OBJ_PROP_LINK_STRONG); -} - -const PropertyInfo prop_info_link = { - .name = "link", - .create = create_link_property, -}; - void qdev_property_add_static(DeviceState *dev, Property *prop) { object_property_add_static(OBJECT(dev), prop, qdev_prop_allow_set); diff --git a/qom/property-types.c b/qom/property-types.c new file mode 100644 index 0000000000..55d8759f06 --- /dev/null +++ b/qom/property-types.c @@ -0,0 +1,649 @@ +#include "qemu/osdep.h" +#include "qom/static-property.h" +#include "qom/static-property-internal.h" +#include "qapi/qapi-types-common.h" +#include "qapi/visitor.h" +#include "qapi/error.h" +#include "qemu/uuid.h" + +void object_propinfo_get_enum(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + int *ptr = object_static_prop_ptr(obj, prop); + + visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp); +} + +void object_propinfo_set_enum(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + int *ptr = object_static_prop_ptr(obj, prop); + + visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp); +} + +void object_propinfo_set_default_value_enum(ObjectProperty *op, + const Property *prop) +{ + object_property_set_default_str(op, + qapi_enum_lookup(prop->info->enum_table, prop->defval.i)); +} + +const PropertyInfo prop_info_enum = { + .name = "enum", + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, +}; + +/* Bit */ + +static uint32_t qdev_get_prop_mask(Property *prop) +{ + assert(prop->info == &prop_info_bit); + return 0x1 << prop->bitnr; +} + +static void bit_prop_set(Object *obj, Property *props, bool val) +{ + uint32_t *p = object_static_prop_ptr(obj, props); + uint32_t mask = qdev_get_prop_mask(props); + if (val) { + *p |= mask; + } else { + *p &= ~mask; + } +} + +static void prop_get_bit(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + uint32_t *p = object_static_prop_ptr(obj, prop); + bool value = (*p & qdev_get_prop_mask(prop)) != 0; + + visit_type_bool(v, name, &value, errp); +} + +static void prop_set_bit(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + bool value; + + if (!visit_type_bool(v, name, &value, errp)) { + return; + } + bit_prop_set(obj, prop, value); +} + +static void set_default_value_bool(ObjectProperty *op, const Property *prop) +{ + object_property_set_default_bool(op, prop->defval.u); +} + +const PropertyInfo prop_info_bit = { + .name = "bool", + .description = "on/off", + .get = prop_get_bit, + .set = prop_set_bit, + .set_default_value = set_default_value_bool, +}; + +/* Bit64 */ + +static uint64_t qdev_get_prop_mask64(Property *prop) +{ + assert(prop->info == &prop_info_bit64); + return 0x1ull << prop->bitnr; +} + +static void bit64_prop_set(Object *obj, Property *props, bool val) +{ + uint64_t *p = object_static_prop_ptr(obj, props); + uint64_t mask = qdev_get_prop_mask64(props); + if (val) { + *p |= mask; + } else { + *p &= ~mask; + } +} + +static void prop_get_bit64(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + uint64_t *p = object_static_prop_ptr(obj, prop); + bool value = (*p & qdev_get_prop_mask64(prop)) != 0; + + visit_type_bool(v, name, &value, errp); +} + +static void prop_set_bit64(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + bool value; + + if (!visit_type_bool(v, name, &value, errp)) { + return; + } + bit64_prop_set(obj, prop, value); +} + +const PropertyInfo prop_info_bit64 = { + .name = "bool", + .description = "on/off", + .get = prop_get_bit64, + .set = prop_set_bit64, + .set_default_value = set_default_value_bool, +}; + +/* --- bool --- */ + +static void get_bool(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + Property *prop = opaque; + bool *ptr = object_static_prop_ptr(obj, prop); + + visit_type_bool(v, name, ptr, errp); +} + +static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + Property *prop = opaque; + bool *ptr = object_static_prop_ptr(obj, prop); + + visit_type_bool(v, name, ptr, errp); +} + +const PropertyInfo prop_info_bool = { + .name = "bool", + .get = get_bool, + .set = set_bool, + .set_default_value = set_default_value_bool, +}; + +/* --- 8bit integer --- */ + +static void get_uint8(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + Property *prop = opaque; + uint8_t *ptr = object_static_prop_ptr(obj, prop); + + visit_type_uint8(v, name, ptr, errp); +} + +static void set_uint8(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + Property *prop = opaque; + uint8_t *ptr = object_static_prop_ptr(obj, prop); + + visit_type_uint8(v, name, ptr, errp); +} + +void object_propinfo_set_default_value_int(ObjectProperty *op, + const Property *prop) +{ + object_property_set_default_int(op, prop->defval.i); +} + +void object_propinfo_set_default_value_uint(ObjectProperty *op, + const Property *prop) +{ + object_property_set_default_uint(op, prop->defval.u); +} + +const PropertyInfo prop_info_uint8 = { + .name = "uint8", + .get = get_uint8, + .set = set_uint8, + .set_default_value = object_propinfo_set_default_value_uint, +}; + +/* --- 16bit integer --- */ + +static void get_uint16(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + uint16_t *ptr = object_static_prop_ptr(obj, prop); + + visit_type_uint16(v, name, ptr, errp); +} + +static void set_uint16(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + uint16_t *ptr = object_static_prop_ptr(obj, prop); + + visit_type_uint16(v, name, ptr, errp); +} + +const PropertyInfo prop_info_uint16 = { + .name = "uint16", + .get = get_uint16, + .set = set_uint16, + .set_default_value = object_propinfo_set_default_value_uint, +}; + +/* --- 32bit integer --- */ + +static void get_uint32(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + uint32_t *ptr = object_static_prop_ptr(obj, prop); + + visit_type_uint32(v, name, ptr, errp); +} + +static void set_uint32(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + uint32_t *ptr = object_static_prop_ptr(obj, prop); + + visit_type_uint32(v, name, ptr, errp); +} + +void object_propinfo_get_int32(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + int32_t *ptr = object_static_prop_ptr(obj, prop); + + visit_type_int32(v, name, ptr, errp); +} + +static void set_int32(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + Property *prop = opaque; + int32_t *ptr = object_static_prop_ptr(obj, prop); + + visit_type_int32(v, name, ptr, errp); +} + +const PropertyInfo prop_info_uint32 = { + .name = "uint32", + .get = get_uint32, + .set = set_uint32, + .set_default_value = object_propinfo_set_default_value_uint, +}; + +const PropertyInfo prop_info_int32 = { + .name = "int32", + .get = object_propinfo_get_int32, + .set = set_int32, + .set_default_value = object_propinfo_set_default_value_int, +}; + +/* --- 64bit integer --- */ + +static void get_uint64(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + uint64_t *ptr = object_static_prop_ptr(obj, prop); + + visit_type_uint64(v, name, ptr, errp); +} + +static void set_uint64(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + uint64_t *ptr = object_static_prop_ptr(obj, prop); + + visit_type_uint64(v, name, ptr, errp); +} + +static void get_int64(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + int64_t *ptr = object_static_prop_ptr(obj, prop); + + visit_type_int64(v, name, ptr, errp); +} + +static void set_int64(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + int64_t *ptr = object_static_prop_ptr(obj, prop); + + visit_type_int64(v, name, ptr, errp); +} + +const PropertyInfo prop_info_uint64 = { + .name = "uint64", + .get = get_uint64, + .set = set_uint64, + .set_default_value = object_propinfo_set_default_value_uint, +}; + +const PropertyInfo prop_info_int64 = { + .name = "int64", + .get = get_int64, + .set = set_int64, + .set_default_value = object_propinfo_set_default_value_int, +}; + +/* --- string --- */ + +static void release_string(Object *obj, const char *name, void *opaque) +{ + Property *prop = opaque; + g_free(*(char **)object_static_prop_ptr(obj, prop)); +} + +static void get_string(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + char **ptr = object_static_prop_ptr(obj, prop); + + if (!*ptr) { + char *str = (char *)""; + visit_type_str(v, name, &str, errp); + } else { + visit_type_str(v, name, ptr, errp); + } +} + +static void set_string(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + char **ptr = object_static_prop_ptr(obj, prop); + char *str; + + if (!visit_type_str(v, name, &str, errp)) { + return; + } + g_free(*ptr); + *ptr = str; +} + +const PropertyInfo prop_info_string = { + .name = "str", + .release = release_string, + .get = get_string, + .set = set_string, +}; + +/* --- on/off/auto --- */ + +const PropertyInfo prop_info_on_off_auto = { + .name = "OnOffAuto", + .description = "on/off/auto", + .enum_table = &OnOffAuto_lookup, + .get = object_propinfo_get_enum, + .set = object_propinfo_set_enum, + .set_default_value = object_propinfo_set_default_value_enum, +}; + +/* --- 32bit unsigned int 'size' type --- */ + +void object_propinfo_get_size32(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Property *prop = opaque; + uint32_t *ptr = object_static_prop_ptr(obj, prop); + uint64_t value = *ptr; + + visit_type_size(v, name, &value, errp); +} + +static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + Property *prop = opaque; + uint32_t *ptr = object_static_prop_ptr(obj, prop); + uint64_t value; + + if (!visit_type_size(v, name, &value, errp)) { + return; + } + + if (value > UINT32_MAX) { + error_setg(errp, + "Property %s.%s doesn't take value %" PRIu64 + " (maximum: %u)", + object_get_typename(obj), name, value, UINT32_MAX); + return; + } + + *ptr = value; +} + +const PropertyInfo prop_info_size32 = { + .name = "size", + .get = object_propinfo_get_size32, + .set = set_size32, + .set_default_value = object_propinfo_set_default_value_uint, +}; + +/* --- UUID --- */ + +static void get_uuid(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + Property *prop = opaque; + QemuUUID *uuid = object_static_prop_ptr(obj, prop); + char buffer[UUID_FMT_LEN + 1]; + char *p = buffer; + + qemu_uuid_unparse(uuid, buffer); + + visit_type_str(v, name, &p, errp); +} + +#define UUID_VALUE_AUTO "auto" + +static void set_uuid(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + Property *prop = opaque; + QemuUUID *uuid = object_static_prop_ptr(obj, prop); + char *str; + + if (!visit_type_str(v, name, &str, errp)) { + return; + } + + if (!strcmp(str, UUID_VALUE_AUTO)) { + qemu_uuid_generate(uuid); + } else if (qemu_uuid_parse(str, uuid) < 0) { + error_setg(errp, "invalid UUID: '%s'", str); + } + g_free(str); +} + +static void set_default_uuid_auto(ObjectProperty *op, const Property *prop) +{ + object_property_set_default_str(op, UUID_VALUE_AUTO); +} + +const PropertyInfo prop_info_uuid = { + .name = "str", + .description = "UUID (aka GUID) or \"" UUID_VALUE_AUTO + "\" for random value (default)", + .get = get_uuid, + .set = set_uuid, + .set_default_value = set_default_uuid_auto, +}; + +/* --- support for array properties --- */ + +/* Used as an opaque for the object properties we add for each + * array element. Note that the struct Property must be first + * in the struct so that a pointer to this works as the opaque + * for the underlying element's property hooks as well as for + * our own release callback. + */ +typedef struct { + struct Property prop; + char *propname; + ObjectPropertyRelease *release; +} ArrayElementProperty; + +/** + * Create ArrayElementProperty based on array length property + * @array_len_prop (which was previously defined using DEFINE_PROP_ARRAY()). + */ +static ArrayElementProperty *array_element_new(Object *obj, + Property *array_len_prop, + const char *arrayname, + int index, + void *eltptr) +{ + char *propname = g_strdup_printf("%s[%d]", arrayname, index); + ArrayElementProperty *arrayprop = g_new0(ArrayElementProperty, 1); + arrayprop->propname = propname; + arrayprop->prop.info = array_len_prop->arrayinfo; + arrayprop->prop.name = propname; + /* This ugly piece of pointer arithmetic sets up the offset so + * that when the underlying get/set hooks call qdev_get_prop_ptr + * they get the right answer despite the array element not actually + * being inside the device struct. + */ + arrayprop->prop.offset = eltptr - (void *)obj; + assert(object_static_prop_ptr(obj, &arrayprop->prop) == eltptr); + return arrayprop; +} + +/* object property release callback for array element properties: + * we call the underlying element's property release hook, and + * then free the memory we allocated when we added the property. + */ +static void array_element_release(Object *obj, const char *name, void *opaque) +{ + ArrayElementProperty *p = opaque; + if (p->release) { + p->release(obj, name, opaque); + } + g_free(p->propname); + g_free(p); +} + +static void object_property_add_array_element(Object *obj, + Property *array_len_prop, + ArrayElementProperty *prop) +{ + ObjectProperty *array_op = object_property_find(obj, array_len_prop->name); + ObjectProperty *op = object_property_add_static(obj, &prop->prop, + array_op->allow_set); + + assert((void *)prop == (void *)&prop->prop); + prop->release = op->release; + /* array_element_release() will call the original release function */ + op->release = array_element_release; +} + +static void set_prop_arraylen(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + /* Setter for the property which defines the length of a + * variable-sized property array. As well as actually setting the + * array-length field in the device struct, we have to create the + * array itself and dynamically add the corresponding properties. + */ + Property *prop = opaque; + uint32_t *alenptr = object_static_prop_ptr(obj, prop); + void **arrayptr = (void *)obj + prop->arrayoffset; + void *eltptr; + const char *arrayname; + int i; + + if (*alenptr) { + error_setg(errp, "array size property %s may not be set more than once", + name); + return; + } + if (!visit_type_uint32(v, name, alenptr, errp)) { + return; + } + if (!*alenptr) { + return; + } + + /* DEFINE_PROP_ARRAY guarantees that name should start with this prefix; + * strip it off so we can get the name of the array itself. + */ + assert(strncmp(name, PROP_ARRAY_LEN_PREFIX, + strlen(PROP_ARRAY_LEN_PREFIX)) == 0); + arrayname = name + strlen(PROP_ARRAY_LEN_PREFIX); + + /* Note that it is the responsibility of the individual device's deinit + * to free the array proper. + */ + *arrayptr = eltptr = g_malloc0(*alenptr * prop->arrayfieldsize); + for (i = 0; i < *alenptr; i++, eltptr += prop->arrayfieldsize) { + ArrayElementProperty *elt_prop = array_element_new(obj, prop, arrayname, + i, eltptr); + object_property_add_array_element(obj, prop, elt_prop); + } +} + +const PropertyInfo prop_info_arraylen = { + .name = "uint32", + .get = get_uint32, + .set = set_prop_arraylen, + .set_default_value = object_propinfo_set_default_value_uint, +}; + +/* --- 64bit unsigned int 'size' type --- */ + +static void get_size(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + Property *prop = opaque; + uint64_t *ptr = object_static_prop_ptr(obj, prop); + + visit_type_size(v, name, ptr, errp); +} + +static void set_size(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + Property *prop = opaque; + uint64_t *ptr = object_static_prop_ptr(obj, prop); + + visit_type_size(v, name, ptr, errp); +} + +const PropertyInfo prop_info_size = { + .name = "size", + .get = get_size, + .set = set_size, + .set_default_value = object_propinfo_set_default_value_uint, +}; + +/* --- object link property --- */ + +static ObjectProperty *create_link_property(ObjectClass *oc, Property *prop) +{ + /* + * NOTE: object_property_allow_set_link is unconditional, but + * ObjectProperty.allow_set may be set for the property too. + */ + return object_class_property_add_link(oc, prop->name, prop->link_type, + prop->offset, + object_property_allow_set_link, + OBJ_PROP_LINK_STRONG); +} + +const PropertyInfo prop_info_link = { + .name = "link", + .create = create_link_property, +}; diff --git a/qom/meson.build b/qom/meson.build index aaebae66b4..8f746e4a0a 100644 --- a/qom/meson.build +++ b/qom/meson.build @@ -5,6 +5,7 @@ qom_ss.add(files( 'object_interfaces.c', 'qom-qobject.c', 'static-property.c', + 'property-types.c', )) qmp_ss.add(files('qom-qmp-cmds.c')) From patchwork Thu Oct 29 22:02:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA116C4741F for ; Thu, 29 Oct 2020 22:23:54 +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 4C36120FC3 for ; Thu, 29 Oct 2020 22:23:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AWrE54+s" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C36120FC3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYGKn-0005lQ-5p for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:23:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG1n-0003xR-FL for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:04:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20733) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG1d-0006g0-VP for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:04:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604009045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WaGICVKFJXVkLncju1zY88FyPaqJBQvQuxC4WR7cjZU=; b=AWrE54+s1PNjAn3i6g1fSQDRBu5JEv/RBsoYliPZLX5wRiCTic8z85qoqP52rXMuDG7M07 OhnDJ789EaaqjE362b6eReUNdE08ojzivgixHIiI4DotgDUTGTsJpcHbs1KfkWVFIBlXFp b1aHVduvY1ViaLu24YEp2uLLnx0CM0o= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-511-iSgGScHrNdaOptsD6ZFhyA-1; Thu, 29 Oct 2020 18:04:03 -0400 X-MC-Unique: iSgGScHrNdaOptsD6ZFhyA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C8D49CC01 for ; Thu, 29 Oct 2020 22:04:02 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF53260C17; Thu, 29 Oct 2020 22:04:01 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 35/36] machine: Use DEFINE_PROP_BOOL for boolean properties Date: Thu, 29 Oct 2020 18:02:45 -0400 Message-Id: <20201029220246.472693-36-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Unfortunately, the "usb" property is not trivial because it actually represents a pair of booleans. It probably should be replaced by a OnOffAuto property instead. Signed-off-by: Eduardo Habkost --- hw/core/machine.c | 77 +++-------------------------------------------- 1 file changed, 5 insertions(+), 72 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 97e102911a..e62097526a 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -236,34 +236,6 @@ static void machine_set_phandle_start(Object *obj, Visitor *v, ms->phandle_start = value; } -static bool machine_get_dump_guest_core(Object *obj, Error **errp) -{ - MachineState *ms = MACHINE(obj); - - return ms->dump_guest_core; -} - -static void machine_set_dump_guest_core(Object *obj, bool value, Error **errp) -{ - MachineState *ms = MACHINE(obj); - - ms->dump_guest_core = value; -} - -static bool machine_get_mem_merge(Object *obj, Error **errp) -{ - MachineState *ms = MACHINE(obj); - - return ms->mem_merge; -} - -static void machine_set_mem_merge(Object *obj, bool value, Error **errp) -{ - MachineState *ms = MACHINE(obj); - - ms->mem_merge = value; -} - static Property machine_props[] = { DEFINE_PROP_STRING("kernel", MachineState, kernel_filename), DEFINE_PROP_STRING("initrd", MachineState, initrd_filename), @@ -273,6 +245,10 @@ static Property machine_props[] = { DEFINE_PROP_STRING("dt-compatible", MachineState, dt_compatible), DEFINE_PROP_STRING("firmware", MachineState, firmware), DEFINE_PROP_STRING("memory-backend", MachineState, ram_memdev_id), + DEFINE_PROP_BOOL("dump-guest-core", MachineState, dump_guest_core, true), + DEFINE_PROP_BOOL("mem-merge", MachineState, mem_merge, true), + DEFINE_PROP_BOOL("graphics", MachineState, enable_graphics, true), + DEFINE_PROP_BOOL("suppress-vmdesc", MachineState, suppress_vmdesc, false), DEFINE_PROP_END_OF_LIST(), }; @@ -291,34 +267,6 @@ static void machine_set_usb(Object *obj, bool value, Error **errp) ms->usb_disabled = !value; } -static bool machine_get_graphics(Object *obj, Error **errp) -{ - MachineState *ms = MACHINE(obj); - - return ms->enable_graphics; -} - -static void machine_set_graphics(Object *obj, bool value, Error **errp) -{ - MachineState *ms = MACHINE(obj); - - ms->enable_graphics = value; -} - -static void machine_set_suppress_vmdesc(Object *obj, bool value, Error **errp) -{ - MachineState *ms = MACHINE(obj); - - ms->suppress_vmdesc = value; -} - -static bool machine_get_suppress_vmdesc(Object *obj, Error **errp) -{ - MachineState *ms = MACHINE(obj); - - return ms->suppress_vmdesc; -} - static char *machine_get_memory_encryption(Object *obj, Error **errp) { MachineState *ms = MACHINE(obj); @@ -339,7 +287,7 @@ static void machine_set_memory_encryption(Object *obj, const char *value, * so there's no point in it trying to merge areas. */ if (value) { - machine_set_mem_merge(obj, false, errp); + ms->mem_merge = false; } } @@ -692,13 +640,8 @@ static void machine_class_init(ObjectClass *oc, void *data) object_class_property_set_description(oc, "dt-compatible", "Overrides the \"compatible\" property of the dt root node"); - object_class_property_add_bool(oc, "dump-guest-core", - machine_get_dump_guest_core, machine_set_dump_guest_core); object_class_property_set_description(oc, "dump-guest-core", "Include guest memory in a core dump"); - - object_class_property_add_bool(oc, "mem-merge", - machine_get_mem_merge, machine_set_mem_merge); object_class_property_set_description(oc, "mem-merge", "Enable/disable memory merge support"); @@ -707,16 +650,10 @@ static void machine_class_init(ObjectClass *oc, void *data) object_class_property_set_description(oc, "usb", "Set on/off to enable/disable usb"); - object_class_property_add_bool(oc, "graphics", - machine_get_graphics, machine_set_graphics); object_class_property_set_description(oc, "graphics", "Set on/off to enable/disable graphics emulation"); - object_class_property_set_description(oc, "firmware", "Firmware image"); - - object_class_property_add_bool(oc, "suppress-vmdesc", - machine_get_suppress_vmdesc, machine_set_suppress_vmdesc); object_class_property_set_description(oc, "suppress-vmdesc", "Set on to disable self-describing migration"); @@ -751,10 +688,6 @@ static void machine_initfn(Object *obj) MachineState *ms = MACHINE(obj); MachineClass *mc = MACHINE_GET_CLASS(obj); - ms->dump_guest_core = true; - ms->mem_merge = true; - ms->enable_graphics = true; - if (mc->nvdimm_supported) { Object *obj = OBJECT(ms); From patchwork Thu Oct 29 22:02:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 316588 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 661BDC2D0A3 for ; Thu, 29 Oct 2020 22:30:25 +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 9FEFB20729 for ; Thu, 29 Oct 2020 22:30:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JEVWJE9+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FEFB20729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYGR3-00048L-Jf for qemu-devel@archiver.kernel.org; Thu, 29 Oct 2020 18:30:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYG1x-0003yQ-61 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:04:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24640) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYG1f-0006gE-6Z for qemu-devel@nongnu.org; Thu, 29 Oct 2020 18:04:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604009046; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oEYbP5Fufv/2Pc0hBcb52f+uJ8RaCQiISEAH9HcQPW4=; b=JEVWJE9+fgRjAdlNZrBruOGap6+vwlOnxLolgvebnAKYj0aHxZiRsXlrrWBN1hQL7UJVoK WF+H9BOGpGwAH1D39434BUxJlH6ZpBFbqASk975uoIbjTcidvIN8m7cVFQJHchp0LX7ah7 4ZymazMvJCYS0s7VED/dNJkxbzovK38= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-171-7n55JuXOMGacp3gh8NUOdQ-1; Thu, 29 Oct 2020 18:04:04 -0400 X-MC-Unique: 7n55JuXOMGacp3gh8NUOdQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 51BF085C706 for ; Thu, 29 Oct 2020 22:04:03 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 123E26EF68; Thu, 29 Oct 2020 22:04:02 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 36/36] qom: Include static property API reference in documentation Date: Thu, 29 Oct 2020 18:02:46 -0400 Message-Id: <20201029220246.472693-37-ehabkost@redhat.com> In-Reply-To: <20201029220246.472693-1-ehabkost@redhat.com> References: <20201029220246.472693-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: "Daniel P. Berrange" , John Snow , Markus Armbruster , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add new doc comments and reformat the existing ones, and include the static-properties.h API reference in docs/devel/qom.rst. Signed-off-by: Eduardo Habkost --- docs/devel/qom.rst | 6 ++ include/qom/static-property.h | 154 ++++++++++++++++++++++++++++++++-- 2 files changed, 151 insertions(+), 9 deletions(-) diff --git a/docs/devel/qom.rst b/docs/devel/qom.rst index 42d0dc4f4d..0989b4e690 100644 --- a/docs/devel/qom.rst +++ b/docs/devel/qom.rst @@ -379,3 +379,9 @@ API Reference ------------- .. kernel-doc:: include/qom/object.h + + +Static Property API Reference +----------------------------- + +.. kernel-doc:: include/qom/static-property.h diff --git a/include/qom/static-property.h b/include/qom/static-property.h index 779918c947..8339700818 100644 --- a/include/qom/static-property.h +++ b/include/qom/static-property.h @@ -8,20 +8,31 @@ #include "qapi/util.h" /** - * Property: - * @set_default: true if the default value should be set from @defval, - * in which case @info->set_default_value must not be NULL - * (if false then no default value is set by the property system - * and the field retains whatever value it was given by instance_init). - * @defval: default value for the property. This is used only if @set_default - * is true. + * struct Property: Definition of a static Property + * + * #Property structs should be always initialized using the + * ``DEFINE_PROP`` family of macros. */ struct Property { + /* private: */ const char *name; const PropertyInfo *info; ptrdiff_t offset; uint8_t bitnr; + /** + * @set_default: true if the default value should be set + * from @defval, in which case + * @info->set_default_value must not be NULL + * (if false then no default value is set by + * the property system and the field retains + * whatever value it was given by + * instance_init). + */ bool set_default; + /** + * @defval: default value for the property. This is used only + * if @set_default is true. + */ union { int64_t i; uint64_t u; @@ -110,6 +121,14 @@ extern const PropertyInfo prop_info_link; #define DEFINE_PROP_SIGNED_NODEFAULT(_name, _state, _field, _prop, _type) \ DEFINE_PROP(_name, _state, _field, _prop, _type) +/** + * DEFINE_PROP_BIT: Define bit property in uint32_t field + * @_name: name of the property + * @_state: name of the object state structure type + * @_field: name of ``uint32_t`` field in @_state + * @_bit: bit offset in @_field + * @_defval: default value for bit + */ #define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) \ DEFINE_PROP(_name, _state, _field, prop_info_bit, uint32_t, \ .bitnr = (_bit), \ @@ -124,12 +143,27 @@ extern const PropertyInfo prop_info_link; #define DEFINE_PROP_UNSIGNED_NODEFAULT(_name, _state, _field, _prop, _type) \ DEFINE_PROP(_name, _state, _field, _prop, _type) +/** + * DEFINE_PROP_BIT64: Define bit property in uint64_t field + * @_name: name of the property + * @_state: name of the object state structure type + * @_field: name of ``uint64_t`` field in @_state + * @_bit: bit offset in @_field + * @_defval: default value for bit + */ #define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) \ DEFINE_PROP(_name, _state, _field, prop_info_bit64, uint64_t, \ .bitnr = (_bit), \ .set_default = true, \ .defval.u = (bool)_defval) +/** + * DEFINE_PROP_BOOL: + * @_name: name of the property + * @_state: name of the object state structure type + * @_field: name of ``bool`` field in @_state + * @_defval: default value of property + */ #define DEFINE_PROP_BOOL(_name, _state, _field, _defval) \ DEFINE_PROP(_name, _state, _field, prop_info_bool, bool, \ .set_default = true, \ @@ -142,9 +176,10 @@ extern const PropertyInfo prop_info_link; * @_name: name of the array * @_state: name of the device state structure type * @_field: uint32_t field in @_state to hold the array length - * @_arrayfield: field in @_state (of type '@_arraytype *') which + * @_arrayfield: field in @_state (of type ``_arraytype *``) which * will point to the array - * @_arrayprop: PropertyInfo defining what property the array elements have + * @_arrayprop: #PropertyInfo variable defining property type of + * array elements * @_arraytype: C type of the array elements * * Define device properties for a variable-length array _name. A @@ -171,36 +206,137 @@ extern const PropertyInfo prop_info_link; .arrayfieldsize = sizeof(_arraytype), \ .arrayoffset = offsetof(_state, _arrayfield)) +/** + * DEFINE_PROP_LINK: Define object link property + * @_name: name of the property + * @_state: name of the object state structure type + * @_field: name of field in @_state holding the property value + * @_type: QOM type name of link target + * @_ptr_type: Type of field @_field in struct @_state + */ #define DEFINE_PROP_LINK(_name, _state, _field, _type, _ptr_type) \ DEFINE_PROP(_name, _state, _field, prop_info_link, _ptr_type, \ .link_type = _type) +/** + * DEFINE_PROP_UINT8: Define uint8 property + * @_n: name of the property + * @_s: name of the object state structure type + * @_f: name of ``uint8_t`` field in @_s + * @_d: default value of property + */ #define DEFINE_PROP_UINT8(_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint8, uint8_t) +/** + * DEFINE_PROP_UINT16: Define uint16 property + * @_n: name of the property + * @_s: name of the object state structure type + * @_f: name of ``uint16_t`` field in @_s + * @_d: default value of property + */ #define DEFINE_PROP_UINT16(_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint16, uint16_t) +/** + * DEFINE_PROP_UINT32: Define uint32 property + * @_n: name of the property + * @_s: name of the object state structure type + * @_f: name of ``uint32_t`` field in @_s + * @_d: default value of property + */ #define DEFINE_PROP_UINT32(_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint32, uint32_t) +/** + * DEFINE_PROP_INT32: Define int32 property + * @_n: name of the property + * @_s: name of the object state structure type + * @_f: name of ``int32_t`` field in @_s + * @_d: default value of property + */ #define DEFINE_PROP_INT32(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_int32, int32_t) +/** + * DEFINE_PROP_UINT64: Define uint64 property + * @_n: name of the property + * @_s: name of the object state structure type + * @_f: name of ``uint64_t`` field in @_s + * @_d: default value of property + */ #define DEFINE_PROP_UINT64(_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_uint64, uint64_t) +/** + * DEFINE_PROP_INT64: Define int64 property + * @_n: name of the property + * @_s: name of the object state structure type + * @_f: name of ``int64_t`` field in @_s + * @_d: default value of property + */ #define DEFINE_PROP_INT64(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_int64, int64_t) +/** + * DEFINE_PROP_SIZE: Define uint64 property + * @_n: name of the property + * @_s: name of the object state structure type + * @_f: name of ``uint64_t`` field in @_s + * @_d: default value of property + */ #define DEFINE_PROP_SIZE(_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_size, uint64_t) +/** + * DEFINE_PROP_STRING: + * @_n: name of the property + * @_s: name of the object state structure type + * @_f: name of ``char *`` field in @_state + */ #define DEFINE_PROP_STRING(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, prop_info_string, char*) +/** + * DEFINE_PROP_ON_OFF_AUTO: Define OnOffAuto property + * @_n: name of the property + * @_s: name of the object state structure type + * @_f: name of ``OnOffAuto`` field in @_s + * @_d: default value of property + */ #define DEFINE_PROP_ON_OFF_AUTO(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, prop_info_on_off_auto, OnOffAuto) +/** + * DEFINE_PROP_SIZE32: Define uint32 property + * @_n: name of the property + * @_s: name of the object state structure type + * @_f: name of ``uint32_t`` field in @_s + * @_d: default value of property + */ #define DEFINE_PROP_SIZE32(_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, prop_info_size32, uint32_t) +/** + * DEFINE_PROP_UUID: Define UUID property + * @_name: name of the property + * @_state: name of the object state structure type + * @_field: name of field in @_state holding the property value + * + * The @_f field in struct @_s must be of type ``QemuUUID``. + * The default value of the property will be "auto". + */ #define DEFINE_PROP_UUID(_name, _state, _field) \ DEFINE_PROP(_name, _state, _field, prop_info_uuid, QemuUUID, \ .set_default = true) +/** + * DEFINE_PROP_UUID_NODEFAULT: Define UUID property with no default + * @_name: name of the property + * @_state: name of the object state structure type + * @_field: name of field in @_state holding the property value + * + * The @_f field in struct @_s must be of type ``QemuUUID``. + * No default value will be set for the property. + */ #define DEFINE_PROP_UUID_NODEFAULT(_name, _state, _field) \ DEFINE_PROP(_name, _state, _field, prop_info_uuid, QemuUUID) +/** + * DEFINE_PROP_END_OF_LIST: Mark end of property array + * + * This must be the last entry in #Property arrays when calling + * object_class_add_static_props(). + */ #define DEFINE_PROP_END_OF_LIST() \ {}