From patchwork Sat Jul 6 09:29:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13725798 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4C88CC2BD09 for ; Sat, 6 Jul 2024 09:30:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQ1ji-0008PX-BC; Sat, 06 Jul 2024 05:29:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sQ1jc-0008M7-Vm for qemu-devel@nongnu.org; Sat, 06 Jul 2024 05:29:37 -0400 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQ1ja-0006np-SZ for qemu-devel@nongnu.org; Sat, 06 Jul 2024 05:29:36 -0400 Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-7035d9edcd9so481663a34.1 for ; Sat, 06 Jul 2024 02:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1720258174; x=1720862974; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=iUYzEcnP1I3fIISMCAmJ4EzGqqLnO8BreYmG+l4tYic=; b=gwOUAHnlKHkw4cHbctvM4q/Z1B0EaabKsr7CSarAwBb3uqZ9BcZ43GWq7TG3QsWTrm Skp/sKn5DGx8jaYmS4QRJ2/+92tFtFEIRtmEcR9g57aPqtWeibZV0hS/JGjoBGsGNERO ibsgRGJV502VrqvoDVEDzwckcaRL6P2hmHgzgXOIt/D0Cr4bWxpIaPgRJHAd1JuPOiiN BGtszifIpXODJQoFm20/mDPreoF7fHiqZLUFU+IIfRIyAvcRmyS052WXHq9SY/ObVEZa timArAWU73nGpP/9RjIsXCcKOH5vfKAfX0QDeQ1gtq7O65CeMzOLiqwDxuqd3h9/0zKx qVxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720258174; x=1720862974; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iUYzEcnP1I3fIISMCAmJ4EzGqqLnO8BreYmG+l4tYic=; b=WbpNnyIkQgWMyP1ugCuve82gSa8RxRuI3rnjmFDC9bKGWzqkabgbC/rDgq9BZ/baeG 21A6sLYS1S3idlxNKZVnTVLF/GTJwSJVeuH1YGYLSQGgF+8Idx/XSZ15fC7eQQz2YrHH M+Xxmf65gDb33ssE4Fq43GrF4iZwjK1LgKsyntJSZmhFtNwqBO4Zk1mRsxniArJzqePO FWrHuJpelcmlNx0R/ykXG0UZbW1IW3dlAF1yI1uvdM1HYFHBPBjTMkbaG/l+DhhnAuB5 YSdyIrgWnlmNvf0R/4cgeE/eE2AnvK/12CHqewZzMbDCWuM+QZjSQJCus+rfqagmKgBP H9fA== X-Gm-Message-State: AOJu0YwxfCOmJ6Dnl2npUlbm9+ei1TSRsWS2qJ4shX9wK70xYH5cm9NS 5sibuxwzKnYCyDkrl6vX+EaowUEfJYcTOHUGtC6EgT27r8EfAtYw+k8i/wf7WRQ= X-Google-Smtp-Source: AGHT+IGRFhDI7DgI8u4V+68tfNpsMDMcU0d8pZwZXNFbFUgri6xy5rXgRyYOXhU0KyoowW5ZxfcZvw== X-Received: by 2002:a9d:6b07:0:b0:703:5c04:940f with SMTP id 46e09a7af769-7035c0497e8mr3044158a34.36.1720258173584; Sat, 06 Jul 2024 02:29:33 -0700 (PDT) Received: from localhost ([157.82.204.135]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-72c69b53ba0sm12341915a12.7.2024.07.06.02.29.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Jul 2024 02:29:33 -0700 (PDT) From: Akihiko Odaki Date: Sat, 06 Jul 2024 18:29:21 +0900 Subject: [PATCH 1/4] qapi: Add visit_type_str_preserving() MIME-Version: 1.0 Message-Id: <20240706-rombar-v1-1-802daef2aec1@daynix.com> References: <20240706-rombar-v1-0-802daef2aec1@daynix.com> In-Reply-To: <20240706-rombar-v1-0-802daef2aec1@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goa?= =?utf-8?q?ter?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::32e; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x32e.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org visit_type_str_preserving() is mostly indentical with visit_type_str() but leaves the value intact. This is useful when the caller may interpret the value with a different type. Signed-off-by: Akihiko Odaki --- include/qapi/visitor-impl.h | 3 ++- include/qapi/visitor.h | 20 ++++++++++++++++++++ qapi/opts-visitor.c | 7 +++++-- qapi/qapi-clone-visitor.c | 2 +- qapi/qapi-dealloc-visitor.c | 4 ++-- qapi/qapi-forward-visitor.c | 4 +++- qapi/qapi-visit-core.c | 17 +++++++++++++++-- qapi/qobject-input-visitor.c | 23 ++++++++++++----------- qapi/qobject-output-visitor.c | 2 +- qapi/string-input-visitor.c | 2 +- qapi/string-output-visitor.c | 2 +- 11 files changed, 63 insertions(+), 23 deletions(-) diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h index 2badec5ba460..7b61f55995b5 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -95,7 +95,8 @@ struct Visitor bool (*type_bool)(Visitor *v, const char *name, bool *obj, Error **errp); /* Must be set */ - bool (*type_str)(Visitor *v, const char *name, char **obj, Error **errp); + bool (*type_str)(Visitor *v, const char *name, char **obj, bool consume, + Error **errp); /* Must be set to visit numbers */ bool (*type_number)(Visitor *v, const char *name, double *obj, diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 27b85d4700f2..b3ae3188edfb 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -654,6 +654,26 @@ bool visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp); */ bool visit_type_str(Visitor *v, const char *name, char **obj, Error **errp); +/* + * Visit a string value but do not consume it. + * + * @name expresses the relationship of this string to its parent + * container; see the general description of @name above. + * + * @obj must be non-NULL. Input and clone visitors set *@obj to the + * value (always using "" rather than NULL for an empty string). + * Other visitors leave *@obj unchanged, and commonly treat NULL like + * "". + * + * This function must be called only with an input visitor. + * + * This is mostly identical with visit_type_str() but leaves the value intact. + * This is useful when the caller may interpret the value with a different + * type. + */ +bool visit_type_str_preserving(Visitor *v, const char *name, char **obj, + Error **errp); + /* * Visit a number (i.e. double) value. * diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c index 3d1a28b41918..e9fad756e189 100644 --- a/qapi/opts-visitor.c +++ b/qapi/opts-visitor.c @@ -347,7 +347,8 @@ processed(OptsVisitor *ov, const char *name) static bool -opts_type_str(Visitor *v, const char *name, char **obj, Error **errp) +opts_type_str(Visitor *v, const char *name, char **obj, bool consume, + Error **errp) { OptsVisitor *ov = to_ov(v); const QemuOpt *opt; @@ -363,7 +364,9 @@ opts_type_str(Visitor *v, const char *name, char **obj, Error **errp) * valid enum value; this is harmless because tracking what gets * consumed only matters to visit_end_struct() as the final error * check if there were no other failures during the visit. */ - processed(ov, name); + if (consume) { + processed(ov, name); + } return true; } diff --git a/qapi/qapi-clone-visitor.c b/qapi/qapi-clone-visitor.c index bbf953698f38..90e6641835a7 100644 --- a/qapi/qapi-clone-visitor.c +++ b/qapi/qapi-clone-visitor.c @@ -108,7 +108,7 @@ static bool qapi_clone_type_bool(Visitor *v, const char *name, bool *obj, } static bool qapi_clone_type_str(Visitor *v, const char *name, char **obj, - Error **errp) + bool consume, Error **errp) { QapiCloneVisitor *qcv = to_qcv(v); diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c index ef283f296601..6b0f957047d5 100644 --- a/qapi/qapi-dealloc-visitor.c +++ b/qapi/qapi-dealloc-visitor.c @@ -62,9 +62,9 @@ static void qapi_dealloc_end_list(Visitor *v, void **obj) } static bool qapi_dealloc_type_str(Visitor *v, const char *name, char **obj, - Error **errp) + bool consume, Error **errp) { - if (obj) { + if (obj && consume) { g_free(*obj); } return true; diff --git a/qapi/qapi-forward-visitor.c b/qapi/qapi-forward-visitor.c index e36d9bc9ba7e..891282e0c3b3 100644 --- a/qapi/qapi-forward-visitor.c +++ b/qapi/qapi-forward-visitor.c @@ -180,6 +180,7 @@ static bool forward_field_type_bool(Visitor *v, const char *name, bool *obj, } static bool forward_field_type_str(Visitor *v, const char *name, char **obj, + bool consume, Error **errp) { ForwardFieldVisitor *ffv = to_ffv(v); @@ -187,7 +188,8 @@ static bool forward_field_type_str(Visitor *v, const char *name, char **obj, if (!forward_field_translate_name(ffv, &name, errp)) { return false; } - return visit_type_str(ffv->target, name, obj, errp); + return (consume ? visit_type_str : visit_type_str_preserving)( + ffv->target, name, obj, errp); } static bool forward_field_type_size(Visitor *v, const char *name, uint64_t *obj, diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 6c13510a2bc7..89b52fc99202 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -336,7 +336,8 @@ bool visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp) return v->type_bool(v, name, obj, errp); } -bool visit_type_str(Visitor *v, const char *name, char **obj, Error **errp) +static bool visit_type_str_common(Visitor *v, const char *name, char **obj, + bool consume, Error **errp) { bool ok; @@ -346,13 +347,25 @@ bool visit_type_str(Visitor *v, const char *name, char **obj, Error **errp) assert(!(v->type & VISITOR_OUTPUT) || *obj); */ trace_visit_type_str(v, name, obj); - ok = v->type_str(v, name, obj, errp); + ok = v->type_str(v, name, obj, consume, errp); if (v->type & VISITOR_INPUT) { assert(ok != !*obj); } return ok; } +bool visit_type_str(Visitor *v, const char *name, char **obj, Error **errp) +{ + return visit_type_str_common(v, name, obj, true, errp); +} + +bool visit_type_str_preserving(Visitor *v, const char *name, char **obj, + Error **errp) +{ + assert(v->type & VISITOR_INPUT); + return visit_type_str_common(v, name, obj, false, errp); +} + bool visit_type_number(Visitor *v, const char *name, double *obj, Error **errp) { diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index f110a804b2ae..facbbf01bd27 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -174,13 +174,13 @@ static QObject *qobject_input_get_object(QObjectInputVisitor *qiv, } static const char *qobject_input_get_keyval(QObjectInputVisitor *qiv, - const char *name, + const char *name, bool consume, Error **errp) { QObject *qobj; QString *qstr; - qobj = qobject_input_get_object(qiv, name, true, errp); + qobj = qobject_input_get_object(qiv, name, consume, errp); if (!qobj) { return NULL; } @@ -416,7 +416,7 @@ static bool qobject_input_type_int64_keyval(Visitor *v, const char *name, int64_t *obj, Error **errp) { QObjectInputVisitor *qiv = to_qiv(v); - const char *str = qobject_input_get_keyval(qiv, name, errp); + const char *str = qobject_input_get_keyval(qiv, name, true, errp); if (!str) { return false; @@ -467,7 +467,7 @@ static bool qobject_input_type_uint64_keyval(Visitor *v, const char *name, uint64_t *obj, Error **errp) { QObjectInputVisitor *qiv = to_qiv(v); - const char *str = qobject_input_get_keyval(qiv, name, errp); + const char *str = qobject_input_get_keyval(qiv, name, true, errp); if (!str) { return false; @@ -507,7 +507,7 @@ static bool qobject_input_type_bool_keyval(Visitor *v, const char *name, bool *obj, Error **errp) { QObjectInputVisitor *qiv = to_qiv(v); - const char *str = qobject_input_get_keyval(qiv, name, errp); + const char *str = qobject_input_get_keyval(qiv, name, true, errp); if (!str) { return false; @@ -522,10 +522,10 @@ static bool qobject_input_type_bool_keyval(Visitor *v, const char *name, } static bool qobject_input_type_str(Visitor *v, const char *name, char **obj, - Error **errp) + bool consume, Error **errp) { QObjectInputVisitor *qiv = to_qiv(v); - QObject *qobj = qobject_input_get_object(qiv, name, true, errp); + QObject *qobj = qobject_input_get_object(qiv, name, consume, errp); QString *qstr; *obj = NULL; @@ -544,10 +544,11 @@ static bool qobject_input_type_str(Visitor *v, const char *name, char **obj, } static bool qobject_input_type_str_keyval(Visitor *v, const char *name, - char **obj, Error **errp) + char **obj, bool consume, + Error **errp) { QObjectInputVisitor *qiv = to_qiv(v); - const char *str = qobject_input_get_keyval(qiv, name, errp); + const char *str = qobject_input_get_keyval(qiv, name, consume, errp); *obj = g_strdup(str); return !!str; @@ -578,7 +579,7 @@ static bool qobject_input_type_number_keyval(Visitor *v, const char *name, double *obj, Error **errp) { QObjectInputVisitor *qiv = to_qiv(v); - const char *str = qobject_input_get_keyval(qiv, name, errp); + const char *str = qobject_input_get_keyval(qiv, name, true, errp); double val; if (!str) { @@ -635,7 +636,7 @@ static bool qobject_input_type_size_keyval(Visitor *v, const char *name, uint64_t *obj, Error **errp) { QObjectInputVisitor *qiv = to_qiv(v); - const char *str = qobject_input_get_keyval(qiv, name, errp); + const char *str = qobject_input_get_keyval(qiv, name, true, errp); if (!str) { return false; diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c index 74770edd73c6..36a9fc245b79 100644 --- a/qapi/qobject-output-visitor.c +++ b/qapi/qobject-output-visitor.c @@ -173,7 +173,7 @@ static bool qobject_output_type_bool(Visitor *v, const char *name, bool *obj, } static bool qobject_output_type_str(Visitor *v, const char *name, char **obj, - Error **errp) + bool consume, Error **errp) { QObjectOutputVisitor *qov = to_qov(v); if (*obj) { diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c index 3f1b9e9b4137..6562bbe3cfd4 100644 --- a/qapi/string-input-visitor.c +++ b/qapi/string-input-visitor.c @@ -336,7 +336,7 @@ static bool parse_type_bool(Visitor *v, const char *name, bool *obj, } static bool parse_type_str(Visitor *v, const char *name, char **obj, - Error **errp) + bool consume, Error **errp) { StringInputVisitor *siv = to_siv(v); diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c index 5115536b1539..9a8cca0d5c68 100644 --- a/qapi/string-output-visitor.c +++ b/qapi/string-output-visitor.c @@ -269,7 +269,7 @@ static bool print_type_bool(Visitor *v, const char *name, bool *obj, } static bool print_type_str(Visitor *v, const char *name, char **obj, - Error **errp) + bool consume, Error **errp) { StringOutputVisitor *sov = to_sov(v); char *out; From patchwork Sat Jul 6 09:29:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13725796 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CE06DC38150 for ; Sat, 6 Jul 2024 09:30:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQ1jk-0008Rv-0d; Sat, 06 Jul 2024 05:29:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sQ1jg-0008Pj-Un for qemu-devel@nongnu.org; Sat, 06 Jul 2024 05:29:42 -0400 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQ1jf-0006oz-CN for qemu-devel@nongnu.org; Sat, 06 Jul 2024 05:29:40 -0400 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3d928b2843dso32378b6e.2 for ; Sat, 06 Jul 2024 02:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1720258178; x=1720862978; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=jiaYdGJdtPWsnfbPGe8XqhPOhb333O5wAJMSGqRo6p4=; b=FvcRwOdH+8skz6pW0F2TFm6R/EDBg7WI2160t05D5u4H4+rOlepjqp1eYvjAJ3ewL5 mO7HBZnugCeNohwAceIAhL61vDG27PwgVBn5Ipqmrerlzx5t18rp8pKspfzoV602BCJc x9gJ+ab8V8shk8JzwtEEi8ZvAK6OnBomY8+oxiDKRDZdH5lu9qOw7e3DlEYv4wD8Yvha DaVbw++vP3obHtu+tkpgOJcoV1RzeFmMlupbPh1aBYDC93IveJ+sH3z6qrhqK6h45jrc EUvQ8jLfdd1TxXKJl02Ya5C/Is7KN9cJf0sk5pUiXWywVD7gloTeH2WlRoqr8wA6ku+E INmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720258178; x=1720862978; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jiaYdGJdtPWsnfbPGe8XqhPOhb333O5wAJMSGqRo6p4=; b=auTfE55RkmMS84sonXWirlC63sr/UE+OlTiLgQNAeOJM0/yJF2jXjh9TKYb7Y9DLYH qG8h4JjP9mlraxM3DIybRl8IoUDmoHpzGqm0cpcBNgOmLRyoA72HbNIIkdBMejAEdKG1 AqmkoqVlHdfPrYf/RjQkSCuMBZ3q65Ta/uA0c53NQy63pu1EzrMs5eVZVyOfXPPZqKTf BjBftustfol4CQl2yt3vVuE+uiK4OLXRGaIUPyoTpYXLlHpl92IN6QoROmyWSCK3f3lb 4yvipr20ppxN+TYIXQjvMQF0qf9iwepEwtfI/JPpsdGFuZs6F+VGEAGGTKW4KCXrKdbB lGpg== X-Gm-Message-State: AOJu0YyzAAgZl3K07G+a83rzGsdPdDQxBjf1De9Hy45jbrz9Fx1JSYx+ TtdGoOKXhko+qmYfjzvCq4/rUsPlT72t1TH71FSwGMqRUeXMhFux1JsvtcWulNK6GuGAqYuHHAl vZ24= X-Google-Smtp-Source: AGHT+IF9neLvPkPJVUwqJamV3WTms4iS9iN6pwgUA2PkCasSKHD3PtXsqcmsJEyRDzQtLpwRbid1zg== X-Received: by 2002:a05:6808:19a7:b0:3d6:2fb8:2905 with SMTP id 5614622812f47-3d914cb4c7amr7416107b6e.42.1720258178266; Sat, 06 Jul 2024 02:29:38 -0700 (PDT) Received: from localhost ([157.82.204.135]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-70b01193a96sm4346393b3a.31.2024.07.06.02.29.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Jul 2024 02:29:37 -0700 (PDT) From: Akihiko Odaki Date: Sat, 06 Jul 2024 18:29:22 +0900 Subject: [PATCH 2/4] qapi: Do not consume a value when visit_type_enum() fails MIME-Version: 1.0 Message-Id: <20240706-rombar-v1-2-802daef2aec1@daynix.com> References: <20240706-rombar-v1-0-802daef2aec1@daynix.com> In-Reply-To: <20240706-rombar-v1-0-802daef2aec1@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goa?= =?utf-8?q?ter?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::229; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x229.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Consuming a value when visit_type_enum() fails makes it impossible to reinterpret the value with a different type. Signed-off-by: Akihiko Odaki --- include/qapi/visitor.h | 5 ----- qapi/opts-visitor.c | 5 ----- qapi/qapi-visit-core.c | 4 +++- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index b3ae3188edfb..8e841b26428b 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -513,11 +513,6 @@ void visit_set_policy(Visitor *v, CompatPolicy *policy); * is an input visitor. * * Return true on success, false on failure. - * - * May call visit_type_str() under the hood, and the enum visit may - * fail even if the corresponding string visit succeeded; this implies - * that an input visitor's visit_type_str() must have no unwelcome - * side effects. */ bool visit_type_enum(Visitor *v, const char *name, int *obj, const QEnumLookup *lookup, Error **errp); diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c index e9fad756e189..d83434b95a56 100644 --- a/qapi/opts-visitor.c +++ b/qapi/opts-visitor.c @@ -359,11 +359,6 @@ opts_type_str(Visitor *v, const char *name, char **obj, bool consume, return false; } *obj = g_strdup(opt->str ? opt->str : ""); - /* Note that we consume a string even if this is called as part of - * an enum visit that later fails because the string is not a - * valid enum value; this is harmless because tracking what gets - * consumed only matters to visit_end_struct() as the final error - * check if there were no other failures during the visit. */ if (consume) { processed(ov, name); } diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 89b52fc99202..1137d472290b 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -411,7 +411,7 @@ static bool input_type_enum(Visitor *v, const char *name, int *obj, int64_t value; g_autofree char *enum_str = NULL; - if (!visit_type_str(v, name, &enum_str, errp)) { + if (!visit_type_str_preserving(v, name, &enum_str, errp)) { return false; } @@ -430,6 +430,8 @@ static bool input_type_enum(Visitor *v, const char *name, int *obj, return false; } + enum_str = NULL; + visit_type_str(v, name, &enum_str, &error_abort); *obj = value; return true; } From patchwork Sat Jul 6 09:29:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13725799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E669BC38150 for ; Sat, 6 Jul 2024 09:30:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQ1js-00004x-Jg; Sat, 06 Jul 2024 05:29:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sQ1jo-0008UU-LU for qemu-devel@nongnu.org; Sat, 06 Jul 2024 05:29:48 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQ1jk-0006pO-F2 for qemu-devel@nongnu.org; Sat, 06 Jul 2024 05:29:48 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1fb53bfb6easo7530875ad.2 for ; Sat, 06 Jul 2024 02:29:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1720258183; x=1720862983; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=cNH7pzH7pWMk7GwZKAjOZkKaKNTxy8Q2306a5wKd+pg=; b=G80Atig8nQvnT/uXJWF5ojZX1GkZMzWLUKpMXW/WJcepGgAj0bsbE1t/vZOC82YK05 nuu2HFKh/jc4WGYkAPjdUA1Ei+oGp+43qw+ZLBYbdQiirW/l49dTOs+olzjOC8RzMMOH UGfMRulpXbh4wejr+HFalZP3/OlgciZAM5+Hl6e+IPl1N2ci++z/cur0+p3jkta0hxn8 tvF0pc4vnpaTJ6OnjUYuKQE5eiXpmMIb5t9LTQgD3Pn+ID5cX9aRnxm0VZH6m0CLNssW mqz1IgkJESq0v9GFOk6BSqYIC6ZMUQMjs38RCbuspv0Y6vOGP98uZ8rfzB5MaM4C90SU XPng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720258183; x=1720862983; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cNH7pzH7pWMk7GwZKAjOZkKaKNTxy8Q2306a5wKd+pg=; b=sDbgtfLwMSuRLU5+/RJp7p4jbVP69a7/FE2shY8XeWAPsF9eCbOWfXeoxBil4VuK8W KtumDlgS/Qea4wiqwCXzZEr+LKfHYOWtAEtRMlsb7UBRrM5FonMsvHOhoCwQSVoDdZzd y1A60NJ261ROwP7uQynO6T238jdzBeh6InwlO9GEaYDN1/Q99SJgOwwdGj5jRst03X2+ UiZiTut2q17MzyFaSkewebM6KjlRwDP73DuWHTob1GJ34tDbKtmYLTcy9eDAhNjKf1Ui aBbPfXVpW4+VPCiOLYzWfu1M1FsYBZkr/Wux8H6prYWGlYF45/QG105WKHkwIgO/hWfi 3TNQ== X-Gm-Message-State: AOJu0Yx87xpVek6KmpFfJkqAMl8mdWh+8pn42fYwCC4hx4RDs9hOEz1u HRANcywsCg6RHIFo3oKUuxnlKPWW+WMsj3Gmce2qJNrMnhkZzQ7s+y4rNEqxhcCCEQsvl53dBgF EXAE= X-Google-Smtp-Source: AGHT+IHItZjQKnoAlyczYw0QW75LmzzI1WxhhW2f5TD8YzaQmwbMeZgHUdws+9LZQ1eVG36Nrj9AyQ== X-Received: by 2002:a17:902:d48d:b0:1fb:284b:b3ad with SMTP id d9443c01a7336-1fb33e5b27dmr59727295ad.28.1720258182965; Sat, 06 Jul 2024 02:29:42 -0700 (PDT) Received: from localhost ([157.82.204.135]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fb13059efasm65202525ad.41.2024.07.06.02.29.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Jul 2024 02:29:42 -0700 (PDT) From: Akihiko Odaki Date: Sat, 06 Jul 2024 18:29:23 +0900 Subject: [PATCH 3/4] hw/pci: Convert rom_bar into OnOffAuto MIME-Version: 1.0 Message-Id: <20240706-rombar-v1-3-802daef2aec1@daynix.com> References: <20240706-rombar-v1-0-802daef2aec1@daynix.com> In-Reply-To: <20240706-rombar-v1-0-802daef2aec1@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goa?= =?utf-8?q?ter?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::630; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x630.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org rom_bar is tristate but was defined as uint32_t so convert it into OnOffAuto to clarify that. For compatibility, a uint32 value set via QOM will be converted into OnOffAuto. Signed-off-by: Akihiko Odaki --- docs/igd-assign.txt | 2 +- include/hw/pci/pci_device.h | 2 +- hw/pci/pci.c | 57 +++++++++++++++++++++++++++++++++++++-- hw/vfio/pci-quirks.c | 2 +- hw/vfio/pci.c | 11 ++++---- hw/xen/xen_pt_load_rom.c | 4 +-- tests/qtest/virtio-net-failover.c | 32 +++++++++++----------- 7 files changed, 81 insertions(+), 29 deletions(-) diff --git a/docs/igd-assign.txt b/docs/igd-assign.txt index e17bb50789ad..35c6c8e28493 100644 --- a/docs/igd-assign.txt +++ b/docs/igd-assign.txt @@ -35,7 +35,7 @@ IGD has two different modes for assignment using vfio-pci: ISA/LPC bridge device (vfio-pci-igd-lpc-bridge) on the root bus at PCI address 1f.0. * The IGD device must have a VGA ROM, either provided via the romfile - option or loaded automatically through vfio (standard). rombar=0 + option or loaded automatically through vfio (standard). rombar=off will disable legacy mode support. * Hotplug of the IGD device is not supported. * The IGD device must be a SandyBridge or newer model device. diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index ca151325085d..49b341ce2e27 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -147,7 +147,7 @@ struct PCIDevice { uint32_t romsize; bool has_rom; MemoryRegion rom; - uint32_t rom_bar; + OnOffAuto rom_bar; /* INTx routing notifier */ PCIINTxRoutingNotifier intx_routing_notifier; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 4c7be5295110..ca8fb5383765 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -67,11 +67,64 @@ static char *pcibus_get_fw_dev_path(DeviceState *dev); static void pcibus_reset_hold(Object *obj, ResetType type); static bool pcie_has_upstream_port(PCIDevice *dev); +static void rom_bar_get(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + Property *prop = opaque; + int *ptr = object_field_prop_ptr(obj, prop); + + visit_type_enum(v, name, ptr, prop->info->enum_table, errp); +} + +static void rom_bar_set(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + Property *prop = opaque; + Error *local_err = NULL; + int *ptr = object_field_prop_ptr(obj, prop); + uint32_t value; + + visit_type_enum(v, name, ptr, prop->info->enum_table, &local_err); + if (!local_err) { + return; + } + + if (visit_type_uint32(v, name, &value, NULL)) { + if (value) { + *ptr = ON_OFF_AUTO_ON; + warn_report("Specifying a number for rombar is deprecated; replace a non-zero value with 'on'"); + } else { + *ptr = ON_OFF_AUTO_OFF; + warn_report("Specifying a number for rombar is deprecated; replace 0 with 'off'"); + } + + return; + } + + error_propagate(errp, local_err); +} + +static void rom_bar_set_default_value(ObjectProperty *op, const Property *prop) +{ + object_property_set_default_str(op, + qapi_enum_lookup(prop->info->enum_table, prop->defval.i)); +} + +static const PropertyInfo qdev_prop_rom_bar = { + .name = "OnOffAuto", + .description = "on/off/auto", + .enum_table = &OnOffAuto_lookup, + .get = rom_bar_get, + .set = rom_bar_set, + .set_default_value = rom_bar_set_default_value, +}; + static Property pci_props[] = { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), DEFINE_PROP_STRING("romfile", PCIDevice, romfile), DEFINE_PROP_UINT32("romsize", PCIDevice, romsize, UINT32_MAX), - DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1), + DEFINE_PROP_SIGNED("rombar", PCIDevice, rom_bar, ON_OFF_AUTO_AUTO, + qdev_prop_rom_bar, OnOffAuto), DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present, QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false), DEFINE_PROP_BIT("x-pcie-lnksta-dllla", PCIDevice, cap_present, @@ -2334,7 +2387,7 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom, return; } - if (!pdev->rom_bar) { + if (pdev->rom_bar == ON_OFF_AUTO_OFF) { /* * Load rom via fw_cfg instead of creating a rom bar, * for 0.11 compatibility. diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index 39dae72497e0..0e920ed0691a 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -33,7 +33,7 @@ * execution as noticed with the BCM 57810 card for lack of a * more better way to handle such issues. * The user can still override by specifying a romfile or - * rombar=1. + * rombar=on. * Please see https://bugs.launchpad.net/qemu/+bug/1284874 * for an analysis of the 57810 card hang. When adding * a new vendor id/device id combination below, please also add diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index e03d9f3ba546..502ee2ed0489 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -902,7 +902,7 @@ static void vfio_pci_load_rom(VFIOPCIDevice *vdev) error_report("vfio-pci: Cannot read device rom at " "%s", vdev->vbasedev.name); error_printf("Device option ROM contents are probably invalid " - "(check dmesg).\nSkip option ROM probe with rombar=0, " + "(check dmesg).\nSkip option ROM probe with rombar=off, " "or load from file with romfile=\n"); return; } @@ -1012,11 +1012,10 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) { uint32_t orig, size = cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK); off_t offset = vdev->config_offset + PCI_ROM_ADDRESS; - DeviceState *dev = DEVICE(vdev); char *name; int fd = vdev->vbasedev.fd; - if (vdev->pdev.romfile || !vdev->pdev.rom_bar) { + if (vdev->pdev.romfile || vdev->pdev.rom_bar == ON_OFF_AUTO_OFF) { /* Since pci handles romfile, just print a message and return */ if (vfio_opt_rom_in_denylist(vdev) && vdev->pdev.romfile) { warn_report("Device at %s is known to cause system instability" @@ -1046,17 +1045,17 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) } if (vfio_opt_rom_in_denylist(vdev)) { - if (dev->opts && qdict_haskey(dev->opts, "rombar")) { + if (vdev->pdev.rom_bar == ON_OFF_AUTO_ON) { warn_report("Device at %s is known to cause system instability" " issues during option rom execution", vdev->vbasedev.name); error_printf("Proceeding anyway since user specified" - " non zero value for rombar\n"); + " on for rombar\n"); } else { warn_report("Rom loading for device at %s has been disabled" " due to system instability issues", vdev->vbasedev.name); - error_printf("Specify rombar=1 or romfile to force\n"); + error_printf("Specify rombar=on or romfile to force\n"); return; } } diff --git a/hw/xen/xen_pt_load_rom.c b/hw/xen/xen_pt_load_rom.c index 6bc64acd3352..025a6b25a916 100644 --- a/hw/xen/xen_pt_load_rom.c +++ b/hw/xen/xen_pt_load_rom.c @@ -26,7 +26,7 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, Object *owner = OBJECT(dev); /* If loading ROM from file, pci handles it */ - if (dev->romfile || !dev->rom_bar) { + if (dev->romfile || dev->rom_bar == ON_OFF_AUTO_OFF) { return NULL; } @@ -71,7 +71,7 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, if (!fread(ptr, 1, st.st_size, fp)) { error_report("pci-assign: Cannot read from host %s", rom_file); error_printf("Device option ROM contents are probably invalid " - "(check dmesg).\nSkip option ROM probe with rombar=0, " + "(check dmesg).\nSkip option ROM probe with rombar=off, " "or load from file with romfile=\n"); goto close_rom; } diff --git a/tests/qtest/virtio-net-failover.c b/tests/qtest/virtio-net-failover.c index 73dfabc2728b..f65b97683fb6 100644 --- a/tests/qtest/virtio-net-failover.c +++ b/tests/qtest/virtio-net-failover.c @@ -568,7 +568,7 @@ static void test_hotplug_2_reverse(void) "{'bus': 'root0'," "'failover': true," "'netdev': 'hs0'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_STANDBY0"'}"); @@ -655,7 +655,7 @@ static void test_migrate_out(gconstpointer opaque) "{'bus': 'root1'," "'failover_pair_id': 'standby0'," "'netdev': 'hs1'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY0"'}"); @@ -765,7 +765,7 @@ static void test_migrate_in(gconstpointer opaque) "{'bus': 'root1'," "'failover_pair_id': 'standby0'," "'netdev': 'hs1'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY0"'}"); @@ -819,7 +819,7 @@ static void test_off_migrate_out(gconstpointer opaque) "{'bus': 'root1'," "'failover_pair_id': 'standby0'," "'netdev': 'hs1'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY0"'}"); @@ -887,7 +887,7 @@ static void test_off_migrate_in(gconstpointer opaque) "{'bus': 'root1'," "'failover_pair_id': 'standby0'," "'netdev': 'hs1'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY0"'}"); @@ -938,7 +938,7 @@ static void test_guest_off_migrate_out(gconstpointer opaque) "{'bus': 'root1'," "'failover_pair_id': 'standby0'," "'netdev': 'hs1'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY0"'}"); @@ -1014,7 +1014,7 @@ static void test_guest_off_migrate_in(gconstpointer opaque) "{'bus': 'root1'," "'failover_pair_id': 'standby0'," "'netdev': 'hs1'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY0"'}"); @@ -1065,7 +1065,7 @@ static void test_migrate_guest_off_abort(gconstpointer opaque) "{'bus': 'root1'," "'failover_pair_id': 'standby0'," "'netdev': 'hs1'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY0"'}"); @@ -1170,7 +1170,7 @@ static void test_migrate_abort_wait_unplug(gconstpointer opaque) "{'bus': 'root1'," "'failover_pair_id': 'standby0'," "'netdev': 'hs1'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY0"'}"); @@ -1259,7 +1259,7 @@ static void test_migrate_abort_active(gconstpointer opaque) "{'bus': 'root1'," "'failover_pair_id': 'standby0'," "'netdev': 'hs1'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY0"'}"); @@ -1358,7 +1358,7 @@ static void test_migrate_off_abort(gconstpointer opaque) "{'bus': 'root1'," "'failover_pair_id': 'standby0'," "'netdev': 'hs1'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY0"'}"); @@ -1450,7 +1450,7 @@ static void test_migrate_abort_timeout(gconstpointer opaque) "{'bus': 'root1'," "'failover_pair_id': 'standby0'," "'netdev': 'hs1'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY0"'}"); @@ -1543,7 +1543,7 @@ static void test_multi_out(gconstpointer opaque) "{'bus': 'root1'," "'failover_pair_id': 'standby0'," "'netdev': 'hs1'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY0"'}"); @@ -1574,7 +1574,7 @@ static void test_multi_out(gconstpointer opaque) "{'bus': 'root3'," "'failover_pair_id': 'standby1'," "'netdev': 'hs3'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY1"'}"); @@ -1713,7 +1713,7 @@ static void test_multi_in(gconstpointer opaque) "{'bus': 'root1'," "'failover_pair_id': 'standby0'," "'netdev': 'hs1'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY0"'}"); @@ -1737,7 +1737,7 @@ static void test_multi_in(gconstpointer opaque) "{'bus': 'root3'," "'failover_pair_id': 'standby1'," "'netdev': 'hs3'," - "'rombar': 0," + "'rombar': 'off'," "'romfile': ''," "'mac': '"MAC_PRIMARY1"'}"); From patchwork Sat Jul 6 09:29:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13725800 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D36C5C38150 for ; Sat, 6 Jul 2024 09:31:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQ1ju-0000A6-F9; Sat, 06 Jul 2024 05:29:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sQ1js-00005g-68 for qemu-devel@nongnu.org; Sat, 06 Jul 2024 05:29:52 -0400 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQ1jq-0006qL-PF for qemu-devel@nongnu.org; Sat, 06 Jul 2024 05:29:51 -0400 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3d84546a05bso1255018b6e.1 for ; Sat, 06 Jul 2024 02:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1720258188; x=1720862988; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0VSYKVQCF4c9EWbUkbZPOSynuO1Ww6rZL2afZDm8mb0=; b=rYOZpOlY1s1RJ3rM5v/l5RQuhu6qwSesIPp+QA9dGkGXX0BVcM5+7bCrbsc+QqZ+Gu pGCRp0hnw9ZdHv6MNoAvzWcFOWQYGf2iQxqsYkTvN/guB8TtyP98aF37E5aHOan8liZ/ iAtQHfZD6EQyyRGoG0UEZq2F3AD3rfRLZPOIE0okpUTfhfBpzD4Iyl3d1werkb5EouEr TWWV71o2PNuHzRWIVyudIC5BpWIRDvWCrVOq3DJUuYl1gBCsuEwagdI9ls7N4qBE39lg GwemISAXPE8sliO41gS9CcU7uZDuraf/M7UbgXpmtNP7C24vzvTZWgTxaVJOestD9GC9 ddUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720258188; x=1720862988; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0VSYKVQCF4c9EWbUkbZPOSynuO1Ww6rZL2afZDm8mb0=; b=v5TphcjcXpasWOdUS/oJefZUQP7+9bZTrHY0OeRaIS2cO1NgjVkXdPIm9TcdK8i1N8 U0OhpR7BxIZMlCXKMEPh6NS1V+eOqqesnM09nBkOCbztT5Vl4C95k2J3Tg0lvrijNBDl 8QRqCTmRy8sZXA7YHrhO+npN4lhhsgD0FBBf0i8UldLGU2PDYFr1/ha4rlZAMevJS7Ud E1gEg35Z9/hil1aJzW8TmZZ9d74z+ChAlJPu0IM4gq8kpgUto0LgXj6appndbfZaTp9l xJdlB52MdADyCHJhuWauuGevLgIajWPqG/Uqa162eBRXKxAZfymiVo85QhKQw+W3I5KL aw1g== X-Gm-Message-State: AOJu0YwTsy5TVS/0O6YHHVlf0uFAJG0TwWE06DKzG0mY8MWrDPbuOAgh XSVBBgwg9IuCXXjJ/CP/42gZqaJfPKg9WmCca6j6GaMUVO0SlXKenwhkEy8f+LY= X-Google-Smtp-Source: AGHT+IGB+EQlGz0ilMTKvabnps6LeG4zVWHm59SVK/fv5Eab3qpVTNNrIDwe+aHjtVkCrYk1VyjumQ== X-Received: by 2002:a05:6808:144b:b0:3d5:5e73:1645 with SMTP id 5614622812f47-3d914b7899bmr9378745b6e.0.1720258188183; Sat, 06 Jul 2024 02:29:48 -0700 (PDT) Received: from localhost ([157.82.204.135]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-70803ecf9d0sm15394737b3a.115.2024.07.06.02.29.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Jul 2024 02:29:47 -0700 (PDT) From: Akihiko Odaki Date: Sat, 06 Jul 2024 18:29:24 +0900 Subject: [PATCH 4/4] hw/qdev: Remove opts member MIME-Version: 1.0 Message-Id: <20240706-rombar-v1-4-802daef2aec1@daynix.com> References: <20240706-rombar-v1-0-802daef2aec1@daynix.com> In-Reply-To: <20240706-rombar-v1-0-802daef2aec1@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goa?= =?utf-8?q?ter?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::22b; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x22b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org It is no longer used. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster --- include/hw/qdev-core.h | 4 ---- hw/core/qdev.c | 1 - system/qdev-monitor.c | 12 +++++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 5336728a23f6..40f2d185f17c 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -237,10 +237,6 @@ struct DeviceState { * @pending_deleted_expires_ms: optional timeout for deletion events */ int64_t pending_deleted_expires_ms; - /** - * @opts: QDict of options for the device - */ - QDict *opts; /** * @hotplugged: was device added after PHASE_MACHINE_READY? */ diff --git a/hw/core/qdev.c b/hw/core/qdev.c index f3a996f57dee..2fc84699d432 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -706,7 +706,6 @@ static void device_finalize(Object *obj) dev->canonical_path = NULL; } - qobject_unref(dev->opts); g_free(dev->id); } diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 6af6ef7d667f..3551989d5153 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -624,6 +624,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts, char *id; DeviceState *dev = NULL; BusState *bus = NULL; + QDict *properties; driver = qdict_get_try_str(opts, "driver"); if (!driver) { @@ -705,13 +706,14 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts, } /* set properties */ - dev->opts = qdict_clone_shallow(opts); - qdict_del(dev->opts, "driver"); - qdict_del(dev->opts, "bus"); - qdict_del(dev->opts, "id"); + properties = qdict_clone_shallow(opts); + qdict_del(properties, "driver"); + qdict_del(properties, "bus"); + qdict_del(properties, "id"); - object_set_properties_from_keyval(&dev->parent_obj, dev->opts, from_json, + object_set_properties_from_keyval(&dev->parent_obj, properties, from_json, errp); + qobject_unref(properties); if (*errp) { goto err_del_dev; }