From nobody Sun May 19 15:44:08 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1713509113; cv=none; d=zohomail.com; s=zohoarc; b=dHhpcQ9oa/A3EMo7GTJTzBUtRrEU5fm5T75/WTB0NKOpjZPsO9TKFI045ysWe4eGHJzdpUeyXBax2UjxNPlEpjQI4uOB1JXIREZlabgOiP3xJ2xvdyTZrwj3K82VEeSx7WizQebPnvWxLCo5vhOBLrS5VG7tM5iQxQhlJYVy08Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713509113; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yg+zI05VxzDbOMX0j9+r8gK10CZrEnQ2+SXlSi4Lgyk=; b=VeHw9SeAmAUG2IirJKOnzibaqRc6h1RH+29+frh5rqd64/I8HBB8wxkIKtdqtMvMo0q509cfYUdbZIBBg4rQkh6cOLMU7luhelRcI+KFAJliwKVaSIMcX1+8egH1KsFwOrrc1aD+Z7IXY3pJCRcySyiSzMF+FalKr4uAn3YKjYk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713509113004814.3335347254359; Thu, 18 Apr 2024 23:45:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxhy3-0007nh-0E; Fri, 19 Apr 2024 02:43:27 -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 1rxhxv-0007mZ-DX; Fri, 19 Apr 2024 02:43:19 -0400 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxhxt-0001Bv-Ce; Fri, 19 Apr 2024 02:43:19 -0400 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 23:43:14 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 18 Apr 2024 23:43:11 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713508997; x=1745044997; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iWKKaHfg5cqYfoIHDCIm+pcw/eQF/WdGOSbon8iw0RM=; b=el2QQQEYpRFW1ZCJYflrLob1JdWP3qpoTgpfGY8DplZzeOKhuogauvO6 awM9WN4VmqLJh0vKx/lYznk/xrY7KYkNxp5Lx6vkuSDOr7/5o+NGQDniF Zaeyk6xsSRaAl1NzuWiwjgd40JvkD1SIuGyP91Os3ljKRulZemoJbAz+t 6JbeEDi1qmDCN9GDf61VIDQCRUfr55AiWcIU/5hdUpJekUqzHu51HW24o lUtZy1rXCEoY2X22rqJ4zECpFAQOnj5Ry8bM2jWxJojGRNCHmacMnL0ec nVEH/CLOsFGd+o+RCz3VQjC7FpqJbPAHqvwhEJ25dxDcTGdo94HRII4s1 Q==; X-CSE-ConnectionGUID: DuSyXQ1/RaCzf2q0dlWeXw== X-CSE-MsgGUID: 2itpKq9jRgqYJOYlZnw0Zg== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="19659918" X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="19659918" X-CSE-ConnectionGUID: joRA+eebTfWnqvk/AuGOPw== X-CSE-MsgGUID: s9AhufdzQTGPrt2bpVtnxA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="28071842" From: Zhao Liu To: Thomas Huth , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Zhao Liu Subject: [PATCH 1/6] target/s390x/cpu_model: Make check_compatibility() return boolean Date: Fri, 19 Apr 2024 14:57:07 +0800 Message-Id: <20240419065712.1225038-2-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240419065712.1225038-1-zhao1.liu@linux.intel.com> References: <20240419065712.1225038-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.067, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1713509114180100003 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As error.h suggested, the best practice for callee is to return something to indicate success / failure. With returned boolean, there's no need to check @err. Suggested-by: Thomas Huth Signed-off-by: Zhao Liu Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth --- target/s390x/cpu_models.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 8ed3bb6a27b3..8cb47d905fb4 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -510,7 +510,7 @@ static void check_compat_model_failed(Error **errp, return; } =20 -static void check_compatibility(const S390CPUModel *max_model, +static bool check_compatibility(const S390CPUModel *max_model, const S390CPUModel *model, Error **errp) { ERRP_GUARD(); @@ -518,11 +518,11 @@ static void check_compatibility(const S390CPUModel *m= ax_model, =20 if (model->def->gen > max_model->def->gen) { check_compat_model_failed(errp, max_model, "Selected CPU generatio= n is too new"); - return; + return false; } else if (model->def->gen =3D=3D max_model->def->gen && model->def->ec_ga > max_model->def->ec_ga) { check_compat_model_failed(errp, max_model, "Selected CPU GA level = is too new"); - return; + return false; } =20 #ifndef CONFIG_USER_ONLY @@ -530,14 +530,14 @@ static void check_compatibility(const S390CPUModel *m= ax_model, error_setg(errp, "The unpack facility is not compatible with " "the --only-migratable option. You must remove either " "the 'unpack' facility or the --only-migratable option"= ); - return; + return false; } #endif =20 /* detect the missing features to properly report them */ bitmap_andnot(missing, model->features, max_model->features, S390_FEAT= _MAX); if (bitmap_empty(missing, S390_FEAT_MAX)) { - return; + return true; } =20 error_setg(errp, " "); @@ -546,6 +546,7 @@ static void check_compatibility(const S390CPUModel *max= _model, "available in the current configuration: "); error_append_hint(errp, "Consider a different accelerator, QEMU, or kernel v= ersion\n"); + return false; } =20 S390CPUModel *get_max_cpu_model(Error **errp) @@ -605,8 +606,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) cpu->model->cpu_ver =3D max_model->cpu_ver; =20 check_consistency(cpu->model); - check_compatibility(max_model, cpu->model, &err); - if (err) { + if (!check_compatibility(max_model, cpu->model, &err)) { error_propagate(errp, err); return; } --=20 2.34.1 From nobody Sun May 19 15:44:08 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1713509089; cv=none; d=zohomail.com; s=zohoarc; b=F//t0FtUTZ3J6lXtGjoRH20f83xGH7Yb43spIyfnlzTQg2QWTnh70Yu4TTC7Etxdvra/hdvDuRe5WN4aVDD/G9FO/9MdH6jT72WzvMBgz4ALg/Bgf4ev6zpNoxX84PucQa+L2kie8Lcflkdj6SRbpv1xx9dRRxb6TuudlFlNBL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713509089; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TPuDBHYQ7H6YaU9gJGGFPAafHFg5MY6zkIi+9BhMC7s=; b=laxPr/3E0vxdlU5MASRGN3/NlAi0l3Yq15QCAOufL81+e+0rzVWRfGfPlh7JnqXCnWIDdWl1/m7FpjUWt8X+4EfP77jp5gKlM7TMm+mvIt7x1BiNuQ3Y+6yLGSAL3G+RK/JtZ/E5DMR+YWUrkatF48RyQ9CQKK+F4MJOo5eyPTc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713509089018410.21854488533836; Thu, 18 Apr 2024 23:44:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxhy7-0007oZ-GU; Fri, 19 Apr 2024 02:43:31 -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 1rxhxv-0007mv-VV; Fri, 19 Apr 2024 02:43:22 -0400 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxhxu-0001C1-9C; Fri, 19 Apr 2024 02:43:19 -0400 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 23:43:16 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 18 Apr 2024 23:43:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713508998; x=1745044998; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UkzcgPrX7JhPfDWYAR9t1jT+HmH8Ih9TbuBc2w9snTU=; b=Thh8p90paUwISuCL9RBg9/ZBu5OL620AzLhMXyksVvKVHbPEXzGSEFhz hk2psyg34Ix8Itu5Qu2mPd1slj/lMe5xltDHZYsINH1nnyyDrmoPDjuwj N4igtfBv9F4cbpQtjgndNl5AtY8HYqG5eLWUnHi55mgZMz/Tam1i2eDrU pwAPpDTuNOt3tsR6IWSFruGsg0PVJQlgsxYVwWv60AWlE8xMXllsCNN0q D4v0a3ecCL5tD4+pQwwdxZuD4SKSNsIvPiLMD+BIqY+7cn7BO6SxjKXAw eq8fufI/fZ2hQJ7Rwf5cIOKonVXv2Cx+U4RcZXID/zU5cpELQrsezKcVX w==; X-CSE-ConnectionGUID: mywXvmwSQWaKgpeEB6s+Pw== X-CSE-MsgGUID: hENosOE/RVu789S1fHoyWA== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="19659924" X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="19659924" X-CSE-ConnectionGUID: GDKasGoYTKaAuq9XzRk/6Q== X-CSE-MsgGUID: 7yRWAzbTQEukKOq5RH76+A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="28071850" From: Zhao Liu To: Thomas Huth , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Zhao Liu Subject: [PATCH 2/6] target/s390x/cpu_model: Drop local @err in s390_realize_cpu_model() Date: Fri, 19 Apr 2024 14:57:08 +0800 Message-Id: <20240419065712.1225038-3-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240419065712.1225038-1-zhao1.liu@linux.intel.com> References: <20240419065712.1225038-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.067, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1713509090099100003 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Use @errp to fetech error information directly and drop the local virable @err. Suggested-by: Thomas Huth Signed-off-by: Zhao Liu Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth --- target/s390x/cpu_models.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 8cb47d905fb4..052540a866ac 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -577,7 +577,6 @@ S390CPUModel *get_max_cpu_model(Error **errp) void s390_realize_cpu_model(CPUState *cs, Error **errp) { ERRP_GUARD(); - Error *err =3D NULL; S390CPUClass *xcc =3D S390_CPU_GET_CLASS(cs); S390CPU *cpu =3D S390_CPU(cs); const S390CPUModel *max_model; @@ -606,8 +605,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) cpu->model->cpu_ver =3D max_model->cpu_ver; =20 check_consistency(cpu->model); - if (!check_compatibility(max_model, cpu->model, &err)) { - error_propagate(errp, err); + if (!check_compatibility(max_model, cpu->model, errp)) { return; } =20 --=20 2.34.1 From nobody Sun May 19 15:44:08 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1713509066; cv=none; d=zohomail.com; s=zohoarc; b=fIuFm5vGUUJbVFnOGZS3x5ZWlE87og/TCVpxyecw5SQ6WZ8mIMqRiUunPZRHTgAfyStWpqGx/Ni9iip+gYWgQthiG5fw8wKlv6VEWjg22JgWORpOzaGqLuqXgS0WFMGhrZy3GjopxrN3t0gpqseSRvBSjyYbj7q7foW8yOJVhFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713509066; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Dnw/H71I0Jh8FFZFHW6/zC+gDFl7i9ybCD6oWImzPeM=; b=mrWbuwd1GJDNsWGL89oJYEmledTqIJ6L0FcrWNWH1buSt+DPdBMMoB1mQ1YwqCQaZB8cU8q4b+1Q1q9JGSpZjFiLoGflWIMnJAiDuyI3ymPvp7jzABlQXW1am6Wez3uc75AiVy7YzmcYD89FhXVowztaN5emO3Q+3QkgUiK4Apk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171350906607292.33470357573151; Thu, 18 Apr 2024 23:44:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxhy9-0007pa-DA; Fri, 19 Apr 2024 02:43:34 -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 1rxhxy-0007nA-HC; Fri, 19 Apr 2024 02:43:23 -0400 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxhxw-0001C1-Ju; Fri, 19 Apr 2024 02:43:22 -0400 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 23:43:19 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 18 Apr 2024 23:43:16 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713509000; x=1745045000; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LwFLeqkK2C7815gQQwiOlEqSvA1CBsyQ8KubM+wnykI=; b=ZGv44uPu4cfSRTB+AQ4tTQabXwqpguKH4WOXCLGpqPwEAIOF6gC2hS0I 7G+hmGCgP47VoWIP3C/ObSEx3/v3kmXjtzXpW/0IqreDlZ1IVuUcDTHLl VyT18aG+M8fJIMvHCjPkj+oZAw762LoTJtRW8GJwHb8WkUp/3cmoeYYwZ Pf4w2wp3RwPRZOJV+wR/yyPbkbwUkLKrzUroTEP8+Q5a7ClA6kkIzVt4q wiNHUQIV/8/TpTdUyjZp7jEPbHwfs1rkczgIYhgMhqX8kD9vQAqRm8nRG s6V/u6BQUKD0KGiXtKU8SSIKuVCQ9bOa5nSiK+wFbKJjz8VD6yQXnDjd6 Q==; X-CSE-ConnectionGUID: cIh4/bI5RqylTy+/0yNmyw== X-CSE-MsgGUID: bKoxjEcvTGO57vwlGiFlxg== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="19659930" X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="19659930" X-CSE-ConnectionGUID: OQCZVyfFT9mVPkcdyuOKRQ== X-CSE-MsgGUID: RGPOX07FTkijby1WNR6q+A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="28071880" From: Zhao Liu To: Thomas Huth , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Zhao Liu Subject: [PATCH 3/6] target/s390x/cpu_models: Make kvm_s390_get_host_cpu_model() return boolean Date: Fri, 19 Apr 2024 14:57:09 +0800 Message-Id: <20240419065712.1225038-4-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240419065712.1225038-1-zhao1.liu@linux.intel.com> References: <20240419065712.1225038-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.067, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1713509068051100010 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As error.h suggested, the best practice for callee is to return something to indicate success / failure. So make kvm_s390_get_host_cpu_model() return boolean and check the returned boolean in get_max_cpu_model() instead of accessing @err. Additionally, since now get_max_cpu_model() returns directly if kvm_s390_get_host_cpu_model() fills @err, so make kvm_s390_get_host_cpu_model() return true by default for the non-KVM case in target/s390x/cpu_models.h. Signed-off-by: Zhao Liu Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/s390x/cpu_models.c | 9 ++++----- target/s390x/cpu_models.h | 5 +++-- target/s390x/kvm/kvm.c | 13 +++++++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 052540a866ac..a0e4acb707d7 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -560,16 +560,15 @@ S390CPUModel *get_max_cpu_model(Error **errp) } =20 if (kvm_enabled()) { - kvm_s390_get_host_cpu_model(&max_model, &err); + if (!kvm_s390_get_host_cpu_model(&max_model, &err)) { + error_propagate(errp, err); + return NULL; + } } else { max_model.def =3D s390_find_cpu_def(QEMU_MAX_CPU_TYPE, QEMU_MAX_CP= U_GEN, QEMU_MAX_CPU_EC_GA, NULL); bitmap_copy(max_model.features, qemu_max_cpu_feat, S390_FEAT_MAX); } - if (err) { - error_propagate(errp, err); - return NULL; - } cached =3D true; return &max_model; } diff --git a/target/s390x/cpu_models.h b/target/s390x/cpu_models.h index d7b89129891a..5041c1e10fed 100644 --- a/target/s390x/cpu_models.h +++ b/target/s390x/cpu_models.h @@ -116,12 +116,13 @@ S390CPUDef const *s390_find_cpu_def(uint16_t type, ui= nt8_t gen, uint8_t ec_ga, =20 #ifdef CONFIG_KVM bool kvm_s390_cpu_models_supported(void); -void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp); +bool kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp); void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp); #else -static inline void kvm_s390_get_host_cpu_model(S390CPUModel *model, +static inline bool kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) { + return true; } static inline void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp) diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 4ce809c5d46b..57937b4ddbef 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -2375,7 +2375,7 @@ bool kvm_s390_cpu_models_supported(void) KVM_S390_VM_CPU_MACHINE_SUBFUNC); } =20 -void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) +bool kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) { struct kvm_s390_vm_cpu_machine prop =3D {}; struct kvm_device_attr attr =3D { @@ -2390,14 +2390,14 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *mode= l, Error **errp) =20 if (!kvm_s390_cpu_models_supported()) { error_setg(errp, "KVM doesn't support CPU models"); - return; + return false; } =20 /* query the basic cpu model properties */ rc =3D kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attr); if (rc) { error_setg(errp, "KVM: Error querying host CPU model: %d", rc); - return; + return false; } =20 cpu_type =3D cpuid_type(prop.cpuid); @@ -2420,13 +2420,13 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *mode= l, Error **errp) rc =3D query_cpu_feat(model->features); if (rc) { error_setg(errp, "KVM: Error querying CPU features: %d", rc); - return; + return false; } /* get supported cpu subfunctions indicated via query / test bit */ rc =3D query_cpu_subfunc(model->features); if (rc) { error_setg(errp, "KVM: Error querying CPU subfunctions: %d", rc); - return; + return false; } =20 /* PTFF subfunctions might be indicated although kernel support missin= g */ @@ -2482,7 +2482,7 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model,= Error **errp) } if (!model->def) { error_setg(errp, "KVM: host CPU model could not be identified"); - return; + return false; } /* for now, we can only provide the AP feature with HW support */ if (ap_available()) { @@ -2506,6 +2506,7 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model,= Error **errp) /* strip of features that are not part of the maximum model */ bitmap_and(model->features, model->features, model->def->full_feat, S390_FEAT_MAX); + return true; } =20 static int configure_uv_feat_guest(const S390FeatBitmap features) --=20 2.34.1 From nobody Sun May 19 15:44:08 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1713509066; cv=none; d=zohomail.com; s=zohoarc; b=nXpBdgzrn++wsqh/BO9smrjQiQoElxZOo3sCk19c0kZjyDJLMP5YgKkBiMShBLc7BYsEqacyKnp0j5Huu/K2ahYAPwKGnxiLxN+CtTnrVHObcWIajQMC6SztfrUf6NtS/xPjPs/lbntJlP7/C1BQ4maB31SYYypIAgsinDkG/vE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713509066; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LTjUhS/oDWmX8UacjP4rcW5xYCVuj/fi+R1a6BYcYmM=; b=azjLG86hqVDy9EYJ/xNeb3o+upWXffne12VxTxHxhzEh5/bgqfGKmznJSv6tRkOUNa2tlIG1K402HN2/cJBEwMG+892uyXs9AXxREPSPTJaaypXGIhj/BFl1KCKzFdS5e8iG2Iv11xgZTe5fZC0AQKcdqa0RMG8FG6wRK93K0I4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713509066087168.53267993826853; Thu, 18 Apr 2024 23:44:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxhy9-0007pZ-8m; Fri, 19 Apr 2024 02:43:33 -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 1rxhy2-0007nq-8n; Fri, 19 Apr 2024 02:43:26 -0400 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxhxz-0001CX-7k; Fri, 19 Apr 2024 02:43:24 -0400 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 23:43:22 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 18 Apr 2024 23:43:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713509003; x=1745045003; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ucB5FkqzcnuIstw2NbeLrpaazDPnjkDurJu46dvoWLc=; b=iIGplWm/41TzeTHeg13CMFTihtUfLT6G4WQGHq0Smm/A27IvSJrvcUnS yS5ljx0gmcEXb5+ixERroL9ESooc8i4mTBO4Hha2aK6WuEprfg5xUbxij LeuJUkJiXn4QfFog60Il8VEJ91e+bwuX3rb6HhYX6pJ3rv1Ag96PNcEs2 9pMEoktRNwlwCkbFIXpqeJYLX/87AYGVk49/O4i5roud4kPWr+OPTqFug INojeNPSNJAJ1pkQMv2THMOWhKK0BVcgWxzTYWuU5DwSR/Sh/FetviBMb WcWxPj9+VhRNMiFq/atv8zEhhedNDpCzxgl/dqB6/Wk0tfyYzDND1KHvA A==; X-CSE-ConnectionGUID: ofnMlBcvSLu2lBESLc2KSg== X-CSE-MsgGUID: dMBOO1DlREO68GwFRJilhg== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="19659945" X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="19659945" X-CSE-ConnectionGUID: Q2gs5EYESRebsok4FwG5WA== X-CSE-MsgGUID: zj2ExFi7TamFhVFEifQZhw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="28071900" From: Zhao Liu To: Thomas Huth , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Zhao Liu Subject: [PATCH 4/6] target/s390x/cpu_models: Drop local @err in get_max_cpu_model() Date: Fri, 19 Apr 2024 14:57:10 +0800 Message-Id: <20240419065712.1225038-5-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240419065712.1225038-1-zhao1.liu@linux.intel.com> References: <20240419065712.1225038-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.067, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1713509068048100009 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Use @errp to fetech error information directly and drop the local virable @err. Signed-off-by: Zhao Liu Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth --- target/s390x/cpu_models.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index a0e4acb707d7..aae452cfd3fc 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -551,7 +551,6 @@ static bool check_compatibility(const S390CPUModel *max= _model, =20 S390CPUModel *get_max_cpu_model(Error **errp) { - Error *err =3D NULL; static S390CPUModel max_model; static bool cached; =20 @@ -560,8 +559,7 @@ S390CPUModel *get_max_cpu_model(Error **errp) } =20 if (kvm_enabled()) { - if (!kvm_s390_get_host_cpu_model(&max_model, &err)) { - error_propagate(errp, err); + if (!kvm_s390_get_host_cpu_model(&max_model, errp)) { return NULL; } } else { --=20 2.34.1 From nobody Sun May 19 15:44:08 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1713509066; cv=none; d=zohomail.com; s=zohoarc; b=Q2KQ7KW+iLB7Tvfzv0o29bKEkvp7M45QvZR/VsQtU9TKuyvhtRmmIPwY3MIIs7WCqh7kARp2e8OYQqqfWiD79dI4irA02jgUxF64v9eqrMng7u24KJxCoB9e3s/4y2LNMF7bwGdDh6JL+JgD+8g6dxFFCDkXu8+wv8R+Q9fVPyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713509066; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Q7jyzuNtkLLvS/SPu0ad4rdsHyCGMgbTTOVmf4AMzfg=; b=IWZcw19FLUegF2FtK9Hp//b6tvcs7DJX0RQIcHLafDjHi/wUQoRSNKpHl1q/sdSA8bnLt2eIb6rKUfTbHYJ1/WbCqi2q5kXxjvZMHKzOKtDDad/kBlbI6fl2Jl/e9Y6upRUzfrTUfhiC2+LGb8nQQ7CLL7UmiqSi/4u2EZa0bR4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171350906604469.42609815158391; Thu, 18 Apr 2024 23:44:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxhyF-0007sC-FC; Fri, 19 Apr 2024 02:43:39 -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 1rxhy5-0007oc-IN; Fri, 19 Apr 2024 02:43:29 -0400 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxhy2-0001C1-IA; Fri, 19 Apr 2024 02:43:29 -0400 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 23:43:24 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 18 Apr 2024 23:43:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713509006; x=1745045006; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IZecTxaU+frQtocDHWoMZbTxqF4pkIWlVnz4Y1UGpIM=; b=DmJr01r/aX+QCm2bHHzuwve3NOADZbPleqfkLedzsVKgq0n+ccPuBaYO O9DtBFQtO6GuIbw4zipKkWD1jHULpmavlPndEwkVAfN98TJJvqAkIdNVn saxabOUBE1ZNxHs4nNR2RM1Ev4xHtfUH/662LjenusV4YAFksvR993TOS VdcJahFujJxAxBWdmilS2NUlGlSzNO5LdXqsVedJexDrlGodIHQjg+0J+ auZnZa3PK8lkSUnvEx1RKBriz2zdDJHxShZP8RjRSx9IxrgqSf9AnOycg 5lxHpwvqZOSibaa/83Al2rLPqrcRphb+jSP4XTyLcRuQn3dwsooc/DFrk w==; X-CSE-ConnectionGUID: I5jaqsLnSAqRjm7dog+veg== X-CSE-MsgGUID: QYaAYf6mTn+TIXtyxREEUQ== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="19659953" X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="19659953" X-CSE-ConnectionGUID: l2dhBQ8GRZ2UN4QvOcGYJg== X-CSE-MsgGUID: Jv+QNeDzQ2mcIPgqa1ZLMw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="28071914" From: Zhao Liu To: Thomas Huth , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Zhao Liu Subject: [PATCH 5/6] target/s390x/cpu_models: Make kvm_s390_apply_cpu_model() return boolean Date: Fri, 19 Apr 2024 14:57:11 +0800 Message-Id: <20240419065712.1225038-6-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240419065712.1225038-1-zhao1.liu@linux.intel.com> References: <20240419065712.1225038-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.067, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1713509068087100012 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As error.h suggested, the best practice for callee is to return something to indicate success / failure. So make kvm_s390_apply_cpu_model() return boolean and check the returned boolean in apply_cpu_model() instead of accessing @err. Signed-off-by: Zhao Liu Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth --- target/s390x/cpu_models.h | 5 +++-- target/s390x/cpu_models_sysemu.c | 3 +-- target/s390x/kvm/kvm.c | 15 ++++++++------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/target/s390x/cpu_models.h b/target/s390x/cpu_models.h index 5041c1e10fed..1be94294319d 100644 --- a/target/s390x/cpu_models.h +++ b/target/s390x/cpu_models.h @@ -117,16 +117,17 @@ S390CPUDef const *s390_find_cpu_def(uint16_t type, ui= nt8_t gen, uint8_t ec_ga, #ifdef CONFIG_KVM bool kvm_s390_cpu_models_supported(void); bool kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp); -void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp); +bool kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp); #else static inline bool kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) { return true; } -static inline void kvm_s390_apply_cpu_model(const S390CPUModel *model, +static inline bool kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp) { + return true; } static inline bool kvm_s390_cpu_models_supported(void) { diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sys= emu.c index 2d99218069cb..bf855c659d5e 100644 --- a/target/s390x/cpu_models_sysemu.c +++ b/target/s390x/cpu_models_sysemu.c @@ -405,8 +405,7 @@ void apply_cpu_model(const S390CPUModel *model, Error *= *errp) } =20 if (kvm_enabled()) { - kvm_s390_apply_cpu_model(model, &err); - if (err) { + if (!kvm_s390_apply_cpu_model(model, &err)) { error_propagate(errp, err); return; } diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 57937b4ddbef..6334fb84141b 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -2543,7 +2543,7 @@ static void kvm_s390_configure_apie(bool interpret) } } =20 -void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp) +bool kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp) { struct kvm_s390_vm_cpu_processor prop =3D { .fac_list =3D { 0 }, @@ -2560,11 +2560,11 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *m= odel, Error **errp) if (kvm_s390_cmma_available()) { kvm_s390_enable_cmma(); } - return; + return true; } if (!kvm_s390_cpu_models_supported()) { error_setg(errp, "KVM doesn't support CPU models"); - return; + return false; } prop.cpuid =3D s390_cpuid_from_cpu_model(model); prop.ibc =3D s390_ibc_from_cpu_model(model); @@ -2574,19 +2574,19 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *m= odel, Error **errp) rc =3D kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); if (rc) { error_setg(errp, "KVM: Error configuring the CPU model: %d", rc); - return; + return false; } /* configure cpu features indicated e.g. via SCLP */ rc =3D configure_cpu_feat(model->features); if (rc) { error_setg(errp, "KVM: Error configuring CPU features: %d", rc); - return; + return false; } /* configure cpu subfunctions indicated via query / test bit */ rc =3D configure_cpu_subfunc(model->features); if (rc) { error_setg(errp, "KVM: Error configuring CPU subfunctions: %d", rc= ); - return; + return false; } /* enable CMM via CMMA */ if (test_bit(S390_FEAT_CMM, model->features)) { @@ -2601,8 +2601,9 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *mod= el, Error **errp) rc =3D configure_uv_feat_guest(model->features); if (rc) { error_setg(errp, "KVM: Error configuring CPU UV features %d", rc); - return; + return false; } + return true; } =20 void kvm_s390_restart_interrupt(S390CPU *cpu) --=20 2.34.1 From nobody Sun May 19 15:44:08 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1713509081; cv=none; d=zohomail.com; s=zohoarc; b=M8Qv2pMjVTCGN0U52CCB73/zrlqDqT0eTsb57UTgdNEugjQ/Q/Lu1xvzr2ioSmAZj8zVCP6MM3VB9kDC+HYsvfg4lpZXPApNANKwyzlh8cdYKkOwW8q1sPmxMigZuVeNxPz4kCqfhOIdrv4jflm7F2CkT0pvYX1brinHyrWopQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713509081; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TLBBvgaTjt6r+0L+rNkp20ZJYKtZpbn7YJDPLWDVCQ4=; b=BgU4yWfdC+TYQiwbrIMlOEPkSStRVXUFU43WW164C6dgVNHv0cvJIAdKAloiFMWVAsvzIJSGRTWJjHmKQ2CeqT8A34BUbulB3MRJP94DG40zEYNALTPXGZjKBog/EQqFF41b8nf9Zm3sX6fgH1aRQ8T80jy1l4pFQk7PH/N9XpM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713509081044233.40939404093695; Thu, 18 Apr 2024 23:44:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxhyH-0007tS-TR; Fri, 19 Apr 2024 02:43:41 -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 1rxhy6-0007ov-7v; Fri, 19 Apr 2024 02:43:31 -0400 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxhy4-0001CX-L9; Fri, 19 Apr 2024 02:43:29 -0400 Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 23:43:27 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa004.jf.intel.com with ESMTP; 18 Apr 2024 23:43:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713509008; x=1745045008; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QW0U6rqEdHhhrUN6J4GUhhbNLR4rcAUCgpYyl5CCOUg=; b=gYHtscWrXwtPsmRzhGd4kG+Y8Ha2X4SstYd/iU06D8CmlW+Ya57KK2TD eg27vY++KSAO55p7bSwfA4ldu97mXkUh/REA60QsPPXe2IOfLzuIi/lML jMV4vsjp4Afa13eJNyUCyCkKGVE1bgi1rkZvumkJdm3HJIiimrr75IjYC V7jVvy38eS1SxRJLZe+C4pivaZFwFKndkD07UJqJDaS9tnFRyBmdIAkaX lddsdqabr1e/LlE46W2buIvlSqVJonzfzRFsCKrnXIMAJ8XI2uiv6HNhl ttIsWzdK8zaqF85F2eSztV58GprpLlnxSMl/9NX/EV1JCywCod4XafoOZ g==; X-CSE-ConnectionGUID: jq94hL5bT920tJDdBRd1hg== X-CSE-MsgGUID: noKV8yJbTCGXUlO0TY2Htw== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="19659959" X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="19659959" X-CSE-ConnectionGUID: DWmkPqKvR1eDdtP7gcRgIg== X-CSE-MsgGUID: cokQpEhZSsWGHwmJ33GhqQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="28071927" From: Zhao Liu To: Thomas Huth , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Zhao Liu Subject: [PATCH 6/6] target/s390x/cpu_models_sysemu: Drop local @err in apply_cpu_model() Date: Fri, 19 Apr 2024 14:57:12 +0800 Message-Id: <20240419065712.1225038-7-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240419065712.1225038-1-zhao1.liu@linux.intel.com> References: <20240419065712.1225038-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=198.175.65.11; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.067, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1713509082108100003 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Use @errp to fetech error information directly and drop the local virable @err. Signed-off-by: Zhao Liu Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth --- target/s390x/cpu_models_sysemu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sys= emu.c index bf855c659d5e..15be729c3d48 100644 --- a/target/s390x/cpu_models_sysemu.c +++ b/target/s390x/cpu_models_sysemu.c @@ -389,7 +389,6 @@ CpuModelBaselineInfo *qmp_query_cpu_model_baseline(CpuM= odelInfo *infoa, =20 void apply_cpu_model(const S390CPUModel *model, Error **errp) { - Error *err =3D NULL; static S390CPUModel applied_model; static bool applied; =20 @@ -405,8 +404,7 @@ void apply_cpu_model(const S390CPUModel *model, Error *= *errp) } =20 if (kvm_enabled()) { - if (!kvm_s390_apply_cpu_model(model, &err)) { - error_propagate(errp, err); + if (!kvm_s390_apply_cpu_model(model, errp)) { return; } } --=20 2.34.1