From patchwork Mon Mar 16 00:11:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 11439575 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8A32B92A for ; Mon, 16 Mar 2020 01:30: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 15D63206BE for ; Mon, 16 Mar 2020 01:30:49 +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="GY1hy7my" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15D63206BE 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:32934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDead-0005Lr-II for patchwork-qemu-devel@patchwork.kernel.org; Sun, 15 Mar 2020 21:30:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57404) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDdM7-0008KD-EW for qemu-devel@nongnu.org; Sun, 15 Mar 2020 20:11:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDdM3-0004y5-Si for qemu-devel@nongnu.org; Sun, 15 Mar 2020 20:11:43 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:58961 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jDdM3-0004wV-OC for qemu-devel@nongnu.org; Sun, 15 Mar 2020 20:11:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584317499; 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=Ua1jkYmzCnlEiV4PtiMK/WHhXHx6VUTub5ZWx4B5YBY=; b=GY1hy7myzlsCHyQ95o0OI/eGFrh8sYFD440uKdSuqKbVqZnA9yyGdIoFK4sWTfYAOgL039 acch58wEMW3s4/S4n2ZHejPtzffdcWLiwJxpGtl7U1GUamS2XZ9ORRBjFdYnpEUJOtnipg VztSGkzxMCwVEdD54tBsE1YXwiFwxls= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-kfGGnpaxPgaaF73tWyaevA-1; Sun, 15 Mar 2020 20:11:37 -0400 X-MC-Unique: kfGGnpaxPgaaF73tWyaevA-1 Received: by mail-wr1-f69.google.com with SMTP id q18so8131215wrw.5 for ; Sun, 15 Mar 2020 17:11:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s8oVuWi5Pwe/IVfF1LT+AZqvbsSLy1BWdX/KcJ8rJNU=; b=duEwFAB9ZyTwmi1k13lLnaPeS04XjK3Fe2zAUoCaVdB40uaWC6ON4iB7GFFwgUtfjW Vqa02jsRnuhCnOOKkAL25zHilRxOZglRLc74X6s4PjCZ2CWNH8TZJyVKfwvvj23zPaM0 LNKh9XRFkylEVqVYxUPXmmrkcD2WoipyuYKqlSEAlKQLRB/C7GofiDwp0S/DVx7+kHzd R/OH2Z7Ajl5dyKFk2Ssyh4Wm8s1SlFyzYGtDZUiIPsriKQbXXzKeNhISHFOOvvFuI2TS vJNGvTrn1r/QENukO9nL0w6GFKXtJs/0yfILLW7UPWWgz6zx0NZwhzZ3xQE3MZNLBGhT ryaQ== X-Gm-Message-State: ANhLgQ1TAIhBb0+YA2AnhtOAsldvwYleRmgATR+pP6n0YUDWhqlwODx+ q1N2NoskOxmo6IVHaItqJ3YYR9T7zF/7khKABcnthbIQz9zc9RXptJ2oLyV7d2hyN/qAi8t/Rl3 EWFukaLz6Q6bw3qQ= X-Received: by 2002:a1c:c5:: with SMTP id 188mr24067955wma.89.1584317495996; Sun, 15 Mar 2020 17:11:35 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsbDylGOsx0xSgCsw4cxARby8HR/p4/6MAyhl7B/m0vIX81KejWyuePWiACp3gMq/bFnwWQ8w== X-Received: by 2002:a1c:c5:: with SMTP id 188mr24067934wma.89.1584317495765; Sun, 15 Mar 2020 17:11:35 -0700 (PDT) Received: from localhost.localdomain (191.red-83-42-66.dynamicip.rima-tde.net. [83.42.66.191]) by smtp.gmail.com with ESMTPSA id b5sm20354999wrw.86.2020.03.15.17.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2020 17:11:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 4/9] hw/core/qdev-properties: Export enum-related functions Date: Mon, 16 Mar 2020 01:11:06 +0100 Message-Id: <20200316001111.31004-5-philmd@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200316001111.31004-1-philmd@redhat.com> References: <20200316001111.31004-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Richard Henderson , Michael Roth , Markus Armbruster , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We are going to split this file and reuse these static functions. Add the local "qdev-prop-internal.h" header declaring them. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- hw/core/qdev-prop-internal.h | 19 ++++++++++++ hw/core/qdev-properties.c | 58 +++++++++++++++++++----------------- 2 files changed, 49 insertions(+), 28 deletions(-) create mode 100644 hw/core/qdev-prop-internal.h diff --git a/hw/core/qdev-prop-internal.h b/hw/core/qdev-prop-internal.h new file mode 100644 index 0000000000..2a8c9a306a --- /dev/null +++ b/hw/core/qdev-prop-internal.h @@ -0,0 +1,19 @@ +/* + * qdev property parsing + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#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 qdev_propinfo_set_default_value_enum(ObjectProperty *op, + const Property *prop); + +#endif diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 8ef949e3bd..3f3a008938 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -16,6 +16,7 @@ #include "qapi/visitor.h" #include "chardev/char.h" #include "qemu/uuid.h" +#include "qdev-prop-internal.h" void qdev_prop_set_after_realize(DeviceState *dev, const char *name, Error **errp) @@ -51,8 +52,8 @@ void *qdev_get_prop_ptr(DeviceState *dev, Property *prop) return ptr; } -static void get_enum(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +void qdev_propinfo_get_enum(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) { DeviceState *dev = DEVICE(obj); Property *prop = opaque; @@ -61,8 +62,8 @@ static void get_enum(Object *obj, Visitor *v, const char *name, void *opaque, visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp); } -static void set_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) { DeviceState *dev = DEVICE(obj); Property *prop = opaque; @@ -76,7 +77,8 @@ static void set_enum(Object *obj, Visitor *v, const char *name, void *opaque, visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp); } -static void set_default_value_enum(ObjectProperty *op, const Property *prop) +void qdev_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)); @@ -591,9 +593,9 @@ const PropertyInfo qdev_prop_on_off_auto = { .name = "OnOffAuto", .description = "on/off/auto", .enum_table = &OnOffAuto_lookup, - .get = get_enum, - .set = set_enum, - .set_default_value = set_default_value_enum, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, }; /* --- lost tick policy --- */ @@ -603,9 +605,9 @@ QEMU_BUILD_BUG_ON(sizeof(LostTickPolicy) != sizeof(int)); const PropertyInfo qdev_prop_losttickpolicy = { .name = "LostTickPolicy", .enum_table = &LostTickPolicy_lookup, - .get = get_enum, - .set = set_enum, - .set_default_value = set_default_value_enum, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, }; /* --- Block device error handling policy --- */ @@ -617,9 +619,9 @@ const PropertyInfo qdev_prop_blockdev_on_error = { .description = "Error handling policy, " "report/ignore/enospc/stop/auto", .enum_table = &BlockdevOnError_lookup, - .get = get_enum, - .set = set_enum, - .set_default_value = set_default_value_enum, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, }; /* --- BIOS CHS translation */ @@ -631,9 +633,9 @@ const PropertyInfo qdev_prop_bios_chs_trans = { .description = "Logical CHS translation algorithm, " "auto/none/lba/large/rechs", .enum_table = &BiosAtaTranslation_lookup, - .get = get_enum, - .set = set_enum, - .set_default_value = set_default_value_enum, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, }; /* --- FDC default drive types */ @@ -643,9 +645,9 @@ const PropertyInfo qdev_prop_fdc_drive_type = { .description = "FDC drive type, " "144/288/120/none/auto", .enum_table = &FloppyDriveType_lookup, - .get = get_enum, - .set = set_enum, - .set_default_value = set_default_value_enum, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, }; /* --- MultiFDCompression --- */ @@ -655,9 +657,9 @@ const PropertyInfo qdev_prop_multifd_compression = { .description = "multifd_compression values, " "none/zlib/zstd", .enum_table = &MultiFDCompression_lookup, - .get = get_enum, - .set = set_enum, - .set_default_value = set_default_value_enum, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, }; /* --- pci address --- */ @@ -1281,9 +1283,9 @@ const PropertyInfo qdev_prop_off_auto_pcibar = { .name = "OffAutoPCIBAR", .description = "off/auto/bar0/bar1/bar2/bar3/bar4/bar5", .enum_table = &OffAutoPCIBAR_lookup, - .get = get_enum, - .set = set_enum, - .set_default_value = set_default_value_enum, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, }; /* --- PCIELinkSpeed 2_5/5/8/16 -- */ @@ -1362,7 +1364,7 @@ const PropertyInfo qdev_prop_pcie_link_speed = { .enum_table = &PCIELinkSpeed_lookup, .get = get_prop_pcielinkspeed, .set = set_prop_pcielinkspeed, - .set_default_value = set_default_value_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, }; /* --- PCIELinkWidth 1/2/4/8/12/16/32 -- */ @@ -1459,5 +1461,5 @@ const PropertyInfo qdev_prop_pcie_link_width = { .enum_table = &PCIELinkWidth_lookup, .get = get_prop_pcielinkwidth, .set = set_prop_pcielinkwidth, - .set_default_value = set_default_value_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, };