From nobody Fri Dec 19 07:16:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636625043; cv=none; d=zohomail.com; s=zohoarc; b=OWFxMs6GTOpG4Vy6ykFYwMvC3U9treb6m8IC3w+awquk0bukGjvUsjpHitagaUbhFqLNtp484iX76d0N1v8bHXZiqp5FlmARAyXoiAaNKvYcTpqqzHmdgnFmgwdqy2iLdSMaWCrkxIrHoACneOTRrWOvNi4cLLPT0D01eLw7AqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636625043; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=UAQJZocas4bPTljBjE8/4eZncm0k7SsFi5AABg6C/Aw=; b=cQQixm4/gwlCOxcUyDRNy2+ge9G1GgLjrPwxly1GbbTsjeHutgdZMvAxKCx1FpZska77wUpQGLIQLEEG7wziIiVVcs4mNoyzMXxNr8CVtc59YjuOrOtgEmzgI0xeDEJ9KE9Y3aR8nUj0AJHJvolYqPk+PFh1zDxhQIrjf0QPFn8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1636625043007367.3413466834613; Thu, 11 Nov 2021 02:04:03 -0800 (PST) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-63-G_OtEINeNVO7t8JbouwyLA-1; Thu, 11 Nov 2021 05:03:58 -0500 Received: by mail-wm1-f69.google.com with SMTP id z138-20020a1c7e90000000b003319c5f9164so4540415wmc.7 for ; Thu, 11 Nov 2021 02:03:58 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id q18sm8600902wmc.7.2021.11.11.02.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 02:03:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636625041; 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=UAQJZocas4bPTljBjE8/4eZncm0k7SsFi5AABg6C/Aw=; b=TzDl/iZcow1VA85+S5GBLSgfpkJwfZI0IesDZJgnib1a98ppM2xmclmpM//O5EEjIC/XOB pJIGIgyvIEt+SCiFVsf+fnazDYM5ZRGnZlNIQ2fcMMCBmpPVZhMMl1CHdgspYLn+Swg/oW 1xjsbWoEY6splz9bN0f3SAAU7oSIiC0= X-MC-Unique: G_OtEINeNVO7t8JbouwyLA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UAQJZocas4bPTljBjE8/4eZncm0k7SsFi5AABg6C/Aw=; b=wxe7bazp0iIJ88sXzWD5/IJgfxVUfGSKjXDDp7IgSIIDGeZNLG76JzUsFViA9tw99N Z/lqGUrtajjXtsLCezmpSDRb9PPL/Hqpii5XlqhsuT2p2u589OuRKqFrRzUOEzksUTkg iNkEybxSB+roNyItYtA6PmyVnBjJwwOTsUXsSWXbcrzZ+NmexoXodHQWv4koK9PAVB+X 5y2IXqp1E52kcEfxtaHSGriULSsicRL13ohOVEF9N8gMueA/5DLJCt8m0fjafhjyxQqW o8LxhtnpPKMtbIDih0p0Y3+6q4ywj25yLp0tQ12ve9kgFYqmJy5x36nOYjUgQi4b+9/B 5kSg== X-Gm-Message-State: AOAM531g3kH1n+29TVRPexyPQ9lxYnPBUD0S28RT+Jifl6pwpemiRD12 kQTFCLwe89xwoWGVSIxCVgeIWYGuLGiTPhMi4wmyG0cSlML3Bc/McI9smsxIt6QS1iYLLYSMBW7 eDnpnHRM6FLJpUQ== X-Received: by 2002:a1c:287:: with SMTP id 129mr9508544wmc.49.1636625037400; Thu, 11 Nov 2021 02:03:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJz57akgQK3IVeD5RUy1LWIKehQr3tvgNoTNXgmxUZBN1/3RmGFwrtdZ/cQ2MGMJyEUsbCPa2g== X-Received: by 2002:a1c:287:: with SMTP id 129mr9508521wmc.49.1636625037246; Thu, 11 Nov 2021 02:03:57 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Yanan Wang , Marcel Apfelbaum , Eduardo Habkost , Andrew Jones Subject: [PATCH-for-6.2 v3 1/6] tests/unit/test-smp-parse: Restore MachineClass fields after modifying Date: Thu, 11 Nov 2021 11:03:46 +0100 Message-Id: <20211111100351.2153662-2-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211111100351.2153662-1-philmd@redhat.com> References: <20211111100351.2153662-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636625045256100003 There is a single MachineClass object, registered with type_register_static(&smp_machine_info). Since the same object is used multiple times (an MachineState object is instantiated in both test_generic and test_with_dies), we should restore its internal state after modifying for the test purpose. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang --- tests/unit/test-smp-parse.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index cbe0c990494..bd11fbe91de 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -512,7 +512,7 @@ static void test_generic(void) smp_parse_test(ms, data, true); } =20 - /* Reset the supported min CPUs and max CPUs */ + /* Force invalid min CPUs and max CPUs */ mc->min_cpus =3D 2; mc->max_cpus =3D 511; =20 @@ -523,6 +523,10 @@ static void test_generic(void) smp_parse_test(ms, data, false); } =20 + /* Reset the supported min CPUs and max CPUs */ + mc->min_cpus =3D MIN_CPUS; + mc->max_cpus =3D MAX_CPUS; + object_unref(obj); } =20 --=20 2.31.1 From nobody Fri Dec 19 07:16:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636625045; cv=none; d=zohomail.com; s=zohoarc; b=duuJVtRvfISeAvpn7o2/Dc8wFWemGN9P2k+RqriTRSWgLscvd5LEei5h9279IemABb+6mkGZYfIGll3+Azzhp/7RZsCYCTlx5UzOIVFAKZtEmNTAF8WgoRebeo+4HRsga98KGNmRSmtbqDws5rrPhp3u4oJHbG+2dCiOsa9O6tA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636625045; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=aQ1GdzcB7LjSoWeOeDhq1zxy9yHw2IVmuuwVgLYpvfQ=; b=OREm9nNd7fzUFDEpNgKdYJHAq2IdKPDI5zjQmzrku/Vf4yNIGYwcc2KKlNGvPf1cFnTCH5LeVS5sSbttNjbGq1BZsQb/e+hvb3j6S1F3hV/cKtcNU7xSdKlItitl2bAum2BCYGRM1OJ0RyYWCDupUtK4VAU1Z+03cn18fOGmroo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1636625045416737.6862335143228; Thu, 11 Nov 2021 02:04:05 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-355-lJerQ6tkMCKxeXTYYe_xsQ-1; Thu, 11 Nov 2021 05:04:03 -0500 Received: by mail-wm1-f72.google.com with SMTP id 144-20020a1c0496000000b003305ac0e03aso4530966wme.8 for ; Thu, 11 Nov 2021 02:04:02 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id l124sm8381601wml.8.2021.11.11.02.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 02:04:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636625044; 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=aQ1GdzcB7LjSoWeOeDhq1zxy9yHw2IVmuuwVgLYpvfQ=; b=XAIq3EHgDzhmQRjEhJHA2cYi+G0nt6hL8woFxRyMTEoaZI1miog8dClu96wKGJ5qlsxv2P 5nG4WjYszFyAG1XmjsUzsP8G1M7hZlZfoOo0pIhlUdFXUE9STEXR5GUHIQocFl0pXHGKPw LW+KeyNElj8BDTTSa1TQOpHLBORMVvo= X-MC-Unique: lJerQ6tkMCKxeXTYYe_xsQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aQ1GdzcB7LjSoWeOeDhq1zxy9yHw2IVmuuwVgLYpvfQ=; b=ZawMzmIYm9LPYpnaMCmqPYMPGku9Y7GpDAu6j3qtTei5SGxvsJRPfOKynYfhLMlGfB fO2XiYCitVfyHcDQ/TOmBViZf1koEdBAelHijfzTN96nHhs6UaT6BXv6Vo1sPWu8n3fP 6upEHvivhZozm5NihFPLPsYKUSM3zoZx1dSzFSFP2vzT/5iv6C++gzBeNux1Wkqdpt75 SP8ICwVzs3y+bD/BnIIVpMta3asZ5nndni0Yj8ObcGGgR7wM9Xj0tHFRBORuzN37ik35 9nx5kdTt9Dv11JFtPbTT1jmTprFXEA45mOiT86/dD2cruoT1OTvwxfWOGoDY0jBXh08S 90dQ== X-Gm-Message-State: AOAM5339qgjNPQwCtD+60cvnnya3Fq4yZhyW2T1MT4dQRRDhNt3OZ6C0 nOZLAD5IPw/FMvAS9LURJAiSUW6Ifjhwl3CAgO3rr+oqREqz6nBMlDrsxunT3A2yvp+2GUw8I36 L3wWRQleZSUxDlA== X-Received: by 2002:adf:e682:: with SMTP id r2mr7490321wrm.281.1636625041959; Thu, 11 Nov 2021 02:04:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4ZoFof0DtjTfl/siX1LXfxngQIqc6TrdBbvk7BJRctnx+i3Z5gvgEzJxFsOEux18Qx+gfsA== X-Received: by 2002:adf:e682:: with SMTP id r2mr7490292wrm.281.1636625041819; Thu, 11 Nov 2021 02:04:01 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Yanan Wang , Marcel Apfelbaum , Eduardo Habkost , Andrew Jones Subject: [PATCH-for-6.2 v3 2/6] tests/unit/test-smp-parse: QOM'ify smp_machine_class_init() Date: Thu, 11 Nov 2021 11:03:47 +0100 Message-Id: <20211111100351.2153662-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211111100351.2153662-1-philmd@redhat.com> References: <20211111100351.2153662-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636625047370100005 smp_machine_class_init() is the actual TypeInfo::class_init(). Declare it as such in smp_machine_info, and avoid to call it manually in each test. Move smp_machine_info definition just before we register the type to avoid a forward declaration. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang --- tests/unit/test-smp-parse.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index bd11fbe91de..51670297bf9 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -75,14 +75,6 @@ typedef struct SMPTestData { const char *expect_error; } SMPTestData; =20 -/* Type info of the tested machine */ -static const TypeInfo smp_machine_info =3D { - .name =3D TYPE_MACHINE, - .parent =3D TYPE_OBJECT, - .class_size =3D sizeof(MachineClass), - .instance_size =3D sizeof(MachineState), -}; - /* * List all the possible valid sub-collections of the generic 5 * topology parameters (i.e. cpus/maxcpus/sockets/cores/threads), @@ -480,9 +472,10 @@ static void unsupported_params_init(MachineClass *mc, = SMPTestData *data) } } =20 -/* Reset the related machine properties before each sub-test */ -static void smp_machine_class_init(MachineClass *mc) +static void machine_class_init(ObjectClass *oc, void *data) { + MachineClass *mc =3D MACHINE_CLASS(oc); + mc->min_cpus =3D MIN_CPUS; mc->max_cpus =3D MAX_CPUS; =20 @@ -498,8 +491,6 @@ static void test_generic(void) SMPTestData *data =3D &(SMPTestData){{ }}; int i; =20 - smp_machine_class_init(mc); - for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { *data =3D data_generic_valid[i]; unsupported_params_init(mc, data); @@ -539,7 +530,6 @@ static void test_with_dies(void) unsigned int num_dies =3D 2; int i; =20 - smp_machine_class_init(mc); mc->smp_props.dies_supported =3D true; =20 for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { @@ -582,6 +572,15 @@ static void test_with_dies(void) object_unref(obj); } =20 +/* Type info of the tested machine */ +static const TypeInfo smp_machine_info =3D { + .name =3D TYPE_MACHINE, + .parent =3D TYPE_OBJECT, + .class_init =3D machine_class_init, + .class_size =3D sizeof(MachineClass), + .instance_size =3D sizeof(MachineState), +}; + int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); --=20 2.31.1 From nobody Fri Dec 19 07:16:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636625049; cv=none; d=zohomail.com; s=zohoarc; b=E3jYsVbjv7qhQSi2DNOqroiJYHZ2w+vwWytjwg6iRrPJoyQB70ppCxIpzr5X9hbWnY/EtULktyRTzUw0mB6pFvhyr5ot+m63gKxaBAipdkwVhjA0v8U3whJj22+JhdiS9osKzvatY4tdrOmiBp9sYXOqL7CNiwCEs1E9crZAQ2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636625049; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=6CWt9qvUfdPUYJvJPJwk4S85pT07giVjWWIGVSTBQMQ=; b=NmQH5IqhS4mG+SlZijBLrtQBmrrkCE0Z6yUPsQw3s6Hdlq/9/vff32GNzWkzFJYKhKnIN78KnCXDwce260upO0xuU0kmGoFqZSvF831V4te6iZ3qxeOxzPPoOOWR4bRu3zWQ7goypphiEfKJ/XMv7O78o0o9tR5a1+W+rqneyI4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1636625049542775.5104010509889; Thu, 11 Nov 2021 02:04:09 -0800 (PST) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-409-Tf_K6xh7O9eaSLE6QHG-8g-1; Thu, 11 Nov 2021 05:04:07 -0500 Received: by mail-wr1-f71.google.com with SMTP id a2-20020a5d4d42000000b0017b3bcf41b9so916631wru.23 for ; Thu, 11 Nov 2021 02:04:07 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id f7sm2727883wri.74.2021.11.11.02.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 02:04:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636625048; 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=6CWt9qvUfdPUYJvJPJwk4S85pT07giVjWWIGVSTBQMQ=; b=FKcvg7Csk4eYF57wzpxFXI2tD+aAvi1gmdvTvbcGebIfbfiNfRx9AYri84xJHkx9KuDU+3 qBYBE4a/+sEbe9VCXP2zDyMZkza3gTr171qcZSrUb5WF2yjOh1zLu94YTQwnati1pVxuxB +CQbuB8R4Ky+TFNNz0DQKvyTBTdI/ck= X-MC-Unique: Tf_K6xh7O9eaSLE6QHG-8g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6CWt9qvUfdPUYJvJPJwk4S85pT07giVjWWIGVSTBQMQ=; b=yow8YoMR/oEoLnhXfWueZdiQHHzYjde14sJVFgoIRfgNW96r1d9nE93uSqiBFOYVcc H2UA6nUZKT2VETdn3P5o2vwIvubW9lZN2yEhDFOkkqjv7zFA6ot+CHT4b0Hrkyn9wQLU RGFFNajnsw369e5Wnlsva28z5qjvNG3TXgAbm3bH1zEP6mRjxtagmU+jz5RT0NUWGXAw hWBy0rDfWNBqRfuBioSUKB4ROtHOh5d4ztg/28NvUW0TcGcGFoJOkG4SBRUMAkG91Koy vBoVww6PkTlIHghz89nHojENpf9U9fE51JHkR/6cwsLUhGKfCda2uor3yP9KCBWOdamO JVnA== X-Gm-Message-State: AOAM530d5Up2X6eAaEc5BhBmWZPlWenlqS+dCc0jxPBqB/sVc3QYXmkh tLT1rsbewQeGjzcKRR3BIB1suuWOR3mRJfWuMTTdNXpIylIdxq2vr73j1nVgsBCmdWruBAawndv HqLceUz/+JHZNYQ== X-Received: by 2002:adf:fb09:: with SMTP id c9mr6997171wrr.223.1636625046251; Thu, 11 Nov 2021 02:04:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjkKP3jlm7WgcixPtOzz5Nu78jHIxpkFcloO0+roEU6MxpDlS9/SXchhwk0sqcXEOXQ2yMJw== X-Received: by 2002:adf:fb09:: with SMTP id c9mr6997147wrr.223.1636625046094; Thu, 11 Nov 2021 02:04:06 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Yanan Wang , Marcel Apfelbaum , Eduardo Habkost , Andrew Jones Subject: [PATCH-for-6.2 v3 3/6] tests/unit/test-smp-parse: Explicit MachineClass name Date: Thu, 11 Nov 2021 11:03:48 +0100 Message-Id: <20211111100351.2153662-4-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211111100351.2153662-1-philmd@redhat.com> References: <20211111100351.2153662-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636625050362100001 If the MachineClass::name pointer is not explicitly set, it is NULL. Per the C standard, passing a NULL pointer to printf "%s" format is undefined. Some implementations display it as 'NULL', other as 'null'. Since we are comparing the formatted output, we need a stable value. The easiest is to explicit a machine name string. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reported-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Suggested-by: Yanan Wang Tested-by: Yanan Wang --- tests/unit/test-smp-parse.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 51670297bf9..de6d226b455 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -23,6 +23,8 @@ #define MIN_CPUS 1 /* set the min CPUs supported by the machine as 1 */ #define MAX_CPUS 512 /* set the max CPUs supported by the machine as 512 */ =20 +#define SMP_MACHINE_NAME "TEST-SMP" + /* * Used to define the generic 3-level CPU topology hierarchy * -sockets/cores/threads @@ -307,13 +309,13 @@ static struct SMPTestData data_generic_invalid[] =3D { * should tweak the supported min CPUs to 2 for testing */ .config =3D SMP_CONFIG_GENERIC(T, 1, F, 0, F, 0, F, 0, F, 0), .expect_error =3D "Invalid SMP CPUs 1. The min CPUs supported " - "by machine '(null)' is 2", + "by machine '" SMP_MACHINE_NAME "' is 2", }, { /* config: -smp 512 * should tweak the supported max CPUs to 511 for testing */ .config =3D SMP_CONFIG_GENERIC(T, 512, F, 0, F, 0, F, 0, F, 0), .expect_error =3D "Invalid SMP CPUs 512. The max CPUs supported " - "by machine '(null)' is 511", + "by machine '" SMP_MACHINE_NAME "' is 511", }, }; =20 @@ -481,6 +483,8 @@ static void machine_class_init(ObjectClass *oc, void *d= ata) =20 mc->smp_props.prefer_sockets =3D true; mc->smp_props.dies_supported =3D false; + + mc->name =3D g_strdup(SMP_MACHINE_NAME); } =20 static void test_generic(void) --=20 2.31.1 From nobody Fri Dec 19 07:16:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636625053; cv=none; d=zohomail.com; s=zohoarc; b=WNHAFLMoXYvDSJqxmL1cPoXZBQ1qGewWRiB+PsJ230fCjtJ3MHpEtB1+gdsIRBoXiZVwbzDy/8BKJ1afGzpfO77cma/vCbTh4d3b3e3c1u31saekXTUMoH1bMa1p6/pCuj9+lfWtyahIsr+E2UB9/8gOE9kzYN1nX2MI6zOPiG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636625053; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Zv98ESowpSBPXuA/RP8hwOuMiWSKWHaIHsyJuURTSP0=; b=CBDxjvVmj32cmtBc86qUkwZDZN9pU7kQfGlTXqDQaELwPOfOkil96mziWYBYsc99ZB8DBwcxiEIc2pS6vSvL1/kPTmN89YceB5tP0QJpE9uNbspCXAKldvB2aWnFtWgP8OShhzfy1TCNsrSWPf9DMRubrKlV4QWiHs6KL/P4MG8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636625053809606.2896746141893; Thu, 11 Nov 2021 02:04:13 -0800 (PST) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-520-vXtIlxsBN8yim_nQpx81Gw-1; Thu, 11 Nov 2021 05:04:11 -0500 Received: by mail-wm1-f71.google.com with SMTP id m18-20020a05600c3b1200b0033283ea5facso1615527wms.1 for ; Thu, 11 Nov 2021 02:04:11 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id u2sm2366924wrr.35.2021.11.11.02.04.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 02:04:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636625052; 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=Zv98ESowpSBPXuA/RP8hwOuMiWSKWHaIHsyJuURTSP0=; b=H66P1VZOKEGNi/U/ifpTNE1rQ/QYyBZovaqEJf9WE+DZKhRga4XCzQMHOYf9gDwslzJHU6 qicGnzNjedix745wknkJFKnWeb9tZ73fHZLj/SnyDz6D43nCxkHdK+TSbSbGvMIKjZlWPJ 6st8ksMfgAyZ76I55D/rcNHB2XP3pgg= X-MC-Unique: vXtIlxsBN8yim_nQpx81Gw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zv98ESowpSBPXuA/RP8hwOuMiWSKWHaIHsyJuURTSP0=; b=JNftCLE7xJXy6vVxHiHOp1+pc1RHtvGKrFhUtHQoKXWibgkvFi57MegEpfPDu99GjW /EE871cxSHMwnHdTSZIoWjm6OVlTmyF1UTqKNe0axObWMuZycBAmacg+JZ2vZZWPrNH7 +l2tF1rrFyeBngCLtBw1NP+8/9XE17cTAnuc9T+mjfLyvDtOf3tHgjH30jFdMKLXvBSP 8sxIeZ41stIjxL/scxBDDz03pDSASVgUBJkkqy+9JQEeIgoX8ExDuj+b0+JFVXIrZncR WMOsXL0K/fEGI1586lF+E2EPV8SXN0NB9VlNdUaVdtpw/Q0svdeqd6/1aa6QtGFoya7J Xo2w== X-Gm-Message-State: AOAM533MWnaZeTdt/GG+1/t7Bes7OaESUotlHqLZF6wuSksunjc2P1fJ fa837C4fHnB9nyOqr11Sr7sx2w0mCQ2DmpP0OslFLs/xn/HTMPEFDiLnkUEVkPFyz5/RuKRDOUd H6He8G2OOQgKb6g== X-Received: by 2002:a05:600c:4108:: with SMTP id j8mr6836673wmi.139.1636625050540; Thu, 11 Nov 2021 02:04:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0luYu3xf1hS+4KtALHWN3LTqhBwtMRD6PQCwNB/UpN3JWI0w43AjLo9Ioe0zm7upiSoatXw== X-Received: by 2002:a05:600c:4108:: with SMTP id j8mr6836653wmi.139.1636625050400; Thu, 11 Nov 2021 02:04:10 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Yanan Wang , Marcel Apfelbaum , Eduardo Habkost , Andrew Jones Subject: [PATCH-for-6.2 v3 4/6] tests/unit/test-smp-parse: Simplify pointer to compound literal use Date: Thu, 11 Nov 2021 11:03:49 +0100 Message-Id: <20211111100351.2153662-5-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211111100351.2153662-1-philmd@redhat.com> References: <20211111100351.2153662-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636625054396100001 We can simply use a local variable (and pass its pointer) instead of a pointer to a compound literal. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang --- tests/unit/test-smp-parse.c | 64 ++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index de6d226b455..83a5b8ffdcf 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -492,19 +492,19 @@ static void test_generic(void) Object *obj =3D object_new(TYPE_MACHINE); MachineState *ms =3D MACHINE(obj); MachineClass *mc =3D MACHINE_GET_CLASS(obj); - SMPTestData *data =3D &(SMPTestData){{ }}; + SMPTestData data =3D {}; int i; =20 for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { - *data =3D data_generic_valid[i]; - unsupported_params_init(mc, data); + data =3D data_generic_valid[i]; + unsupported_params_init(mc, &data); =20 - smp_parse_test(ms, data, true); + smp_parse_test(ms, &data, true); =20 /* Unsupported parameters can be provided with their values as 1 */ - data->config.has_dies =3D true; - data->config.dies =3D 1; - smp_parse_test(ms, data, true); + data.config.has_dies =3D true; + data.config.dies =3D 1; + smp_parse_test(ms, &data, true); } =20 /* Force invalid min CPUs and max CPUs */ @@ -512,10 +512,10 @@ static void test_generic(void) mc->max_cpus =3D 511; =20 for (i =3D 0; i < ARRAY_SIZE(data_generic_invalid); i++) { - *data =3D data_generic_invalid[i]; - unsupported_params_init(mc, data); + data =3D data_generic_invalid[i]; + unsupported_params_init(mc, &data); =20 - smp_parse_test(ms, data, false); + smp_parse_test(ms, &data, false); } =20 /* Reset the supported min CPUs and max CPUs */ @@ -530,47 +530,47 @@ static void test_with_dies(void) Object *obj =3D object_new(TYPE_MACHINE); MachineState *ms =3D MACHINE(obj); MachineClass *mc =3D MACHINE_GET_CLASS(obj); - SMPTestData *data =3D &(SMPTestData){{ }}; + SMPTestData data =3D {}; unsigned int num_dies =3D 2; int i; =20 mc->smp_props.dies_supported =3D true; =20 for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { - *data =3D data_generic_valid[i]; - unsupported_params_init(mc, data); + data =3D data_generic_valid[i]; + unsupported_params_init(mc, &data); =20 /* when dies parameter is omitted, it will be set as 1 */ - data->expect_prefer_sockets.dies =3D 1; - data->expect_prefer_cores.dies =3D 1; + data.expect_prefer_sockets.dies =3D 1; + data.expect_prefer_cores.dies =3D 1; =20 - smp_parse_test(ms, data, true); + smp_parse_test(ms, &data, true); =20 /* when dies parameter is specified */ - data->config.has_dies =3D true; - data->config.dies =3D num_dies; - if (data->config.has_cpus) { - data->config.cpus *=3D num_dies; + data.config.has_dies =3D true; + data.config.dies =3D num_dies; + if (data.config.has_cpus) { + data.config.cpus *=3D num_dies; } - if (data->config.has_maxcpus) { - data->config.maxcpus *=3D num_dies; + if (data.config.has_maxcpus) { + data.config.maxcpus *=3D num_dies; } =20 - data->expect_prefer_sockets.dies =3D num_dies; - data->expect_prefer_sockets.cpus *=3D num_dies; - data->expect_prefer_sockets.max_cpus *=3D num_dies; - data->expect_prefer_cores.dies =3D num_dies; - data->expect_prefer_cores.cpus *=3D num_dies; - data->expect_prefer_cores.max_cpus *=3D num_dies; + data.expect_prefer_sockets.dies =3D num_dies; + data.expect_prefer_sockets.cpus *=3D num_dies; + data.expect_prefer_sockets.max_cpus *=3D num_dies; + data.expect_prefer_cores.dies =3D num_dies; + data.expect_prefer_cores.cpus *=3D num_dies; + data.expect_prefer_cores.max_cpus *=3D num_dies; =20 - smp_parse_test(ms, data, true); + smp_parse_test(ms, &data, true); } =20 for (i =3D 0; i < ARRAY_SIZE(data_with_dies_invalid); i++) { - *data =3D data_with_dies_invalid[i]; - unsupported_params_init(mc, data); + data =3D data_with_dies_invalid[i]; + unsupported_params_init(mc, &data); =20 - smp_parse_test(ms, data, false); + smp_parse_test(ms, &data, false); } =20 object_unref(obj); --=20 2.31.1 From nobody Fri Dec 19 07:16:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636625058; cv=none; d=zohomail.com; s=zohoarc; b=ISwEPqPDLiQdu3q5fWW4I/ipNFsTzARbeXkXU9XaThuD/39PoY/hmtIngul1hlMHeOTofNFoAmZbQ0hH8XtHrmzGVt0wA0Go9R5V67gt+lDL5RGUegaSzI8K4zdh5tsRkjTV29364LeGQa/3JuiHhsiDdHT7ZdIrDJAtT8Lg8PM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636625058; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=uPiGfJGGXXvWAef0vocDFa36Z1A0Gwvp66AOmpazW+Y=; b=Q2Gw/Y3/N+Ys5LZ4D253hkfzs3op5LHbjfRv5W3+PMW/OHxtlkDukBRFg3zgTVJ0ZzXXxX4w3FbamM+PszCONh792ABf5TRlJ7l/ZPmQgjRWCZnVnQBABcwrqQ+qvs96rZk6P02NtykoJff7ylzFlwNoTNhWhebtZwIB1aJpxr0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1636625058227666.0301453015447; Thu, 11 Nov 2021 02:04:18 -0800 (PST) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-553-HIJ7v-ztOQq_9rmD4YWAWA-1; Thu, 11 Nov 2021 05:04:16 -0500 Received: by mail-wm1-f69.google.com with SMTP id 144-20020a1c0496000000b003305ac0e03aso4531224wme.8 for ; Thu, 11 Nov 2021 02:04:16 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id w7sm2443499wru.51.2021.11.11.02.04.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 02:04:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636625057; 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=uPiGfJGGXXvWAef0vocDFa36Z1A0Gwvp66AOmpazW+Y=; b=OTSugkrRsRW1haE/JLx25Vjv8vv4i5Kvt3T9xSVMYaH0yOTN1JdZMybAtX/ElPYiD8fKtz USG5NKU9btIoWRVB2K/gb3XUziSWUEUL2Vlgss+Ebnzgrqmpu5ygzejfQFnWMFA3MjPwHo +nMxkzcKJX4Elo6qSKeIFWdMjoV+msY= X-MC-Unique: HIJ7v-ztOQq_9rmD4YWAWA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uPiGfJGGXXvWAef0vocDFa36Z1A0Gwvp66AOmpazW+Y=; b=G5ioX8dchLoshW1/gkac79t+o7Eoh1/ZaxicMebdNOBiRceHnIM9xgFY4JosLtLoND /pAbps54V/49YNI+m6iLB4iGPEuO35mLz2QKsOFTzhWEXKA3hBn+4kqjSvrU3YFDDeZc Bfco+zxRli35dBm9Luw136/8LgL4HOsbreu1dqxj/KnJj/U3g2aZ8Evid+FQRKRQMYrw rFjYw+O8EETtUBzL9IFmWlo65sdgpuaqX28zomZ7dEPnfwJC5MQJX+y+Eiyko9GgSBXU GPIUiJg4zvEWnB4YBlI4xiMCdJcaNW6LwDAqjHjWasE8pF8Oq88EYDL/czeITKr6L9xK OBkA== X-Gm-Message-State: AOAM533j87OEkj3qdJvha9AvSAljlJNdyzTxpZOvl0jQXvhyrLGNGAn/ ICsGZC3fB2jdMX7DIPXXVpLGxdzJUjd7su9qHr6G3dDFQR9uI0F1stA4Bj1MR0MG9+wTOi0XLVE 9GFKklt/07ALxNQ== X-Received: by 2002:a05:600c:1989:: with SMTP id t9mr6811429wmq.24.1636625055047; Thu, 11 Nov 2021 02:04:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyADShtS3puNw/QayYYDzOefeQ0Y0ewm1eIhnV+IQ9y87D9vlUQiyb9kcY57J9wVeGgw74TgQ== X-Received: by 2002:a05:600c:1989:: with SMTP id t9mr6811405wmq.24.1636625054889; Thu, 11 Nov 2021 02:04:14 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Yanan Wang , Marcel Apfelbaum , Eduardo Habkost , Andrew Jones Subject: [PATCH-for-6.2 v3 5/6] tests/unit/test-smp-parse: Constify some pointer/struct Date: Thu, 11 Nov 2021 11:03:50 +0100 Message-Id: <20211111100351.2153662-6-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211111100351.2153662-1-philmd@redhat.com> References: <20211111100351.2153662-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636625059329100001 Declare structures const when we don't need to modify them at runtime. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang --- tests/unit/test-smp-parse.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 83a5b8ffdcf..11109752799 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -83,7 +83,7 @@ typedef struct SMPTestData { * then test the automatic calculation algorithm of the missing * values in the parser. */ -static struct SMPTestData data_generic_valid[] =3D { +static const struct SMPTestData data_generic_valid[] =3D { { /* config: no configuration provided * expect: cpus=3D1,sockets=3D1,cores=3D1,threads=3D1,maxcpus=3D1 = */ @@ -285,7 +285,7 @@ static struct SMPTestData data_generic_valid[] =3D { }, }; =20 -static struct SMPTestData data_generic_invalid[] =3D { +static const struct SMPTestData data_generic_invalid[] =3D { { /* config: -smp 2,dies=3D2 */ .config =3D SMP_CONFIG_WITH_DIES(T, 2, F, 0, T, 2, F, 0, F, 0, F, = 0), @@ -319,7 +319,7 @@ static struct SMPTestData data_generic_invalid[] =3D { }, }; =20 -static struct SMPTestData data_with_dies_invalid[] =3D { +static const struct SMPTestData data_with_dies_invalid[] =3D { { /* config: -smp 16,sockets=3D2,dies=3D2,cores=3D4,threads=3D2,maxc= pus=3D16 */ .config =3D SMP_CONFIG_WITH_DIES(T, 16, T, 2, T, 2, T, 4, T, 2, T,= 16), @@ -356,7 +356,7 @@ static char *smp_config_to_string(SMPConfiguration *con= fig) config->has_maxcpus ? "true" : "false", config->maxcpus); } =20 -static char *cpu_topology_to_string(CpuTopology *topo) +static char *cpu_topology_to_string(const CpuTopology *topo) { return g_strdup_printf( "(CpuTopology) {\n" @@ -372,7 +372,7 @@ static char *cpu_topology_to_string(CpuTopology *topo) } =20 static void check_parse(MachineState *ms, SMPConfiguration *config, - CpuTopology *expect_topo, const char *expect_err, + const CpuTopology *expect_topo, const char *expect= _err, bool is_valid) { g_autofree char *config_str =3D smp_config_to_string(config); @@ -466,7 +466,7 @@ static void smp_parse_test(MachineState *ms, SMPTestDat= a *data, bool is_valid) } =20 /* The parsed results of the unsupported parameters should be 1 */ -static void unsupported_params_init(MachineClass *mc, SMPTestData *data) +static void unsupported_params_init(const MachineClass *mc, SMPTestData *d= ata) { if (!mc->smp_props.dies_supported) { data->expect_prefer_sockets.dies =3D 1; --=20 2.31.1 From nobody Fri Dec 19 07:16:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636625062; cv=none; d=zohomail.com; s=zohoarc; b=UPt0P4i2xh6XD8zXL9l8dfo2wxH3h2l3qoosSk2Ep/hNkllNI6B2yXo1Bk9W/f6nm2zROv29sPJ7e4sYKHULX+kLO1kcFVw5SpqHhIfCW9eUZJKVghdhavW5ogY+ASzyR2JE8r8DobxTvieTZBQX3ZEpH/p8wMQoTFjIiBPiqjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636625062; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=K6REFy2Z9s6d+bG385Dx3esh0VGm1oiX7Asv3HUk+NQ=; b=VBIJ3kZb38vgDt3Yo4dRKHlzzrpiXwLhfKzq4BqVW8pUUn+UPxczXW9ClAygiux93hBh7CeerL40p+Qy0oX5H21pOnZgNPjcXc0KKII4koz7a1LHxmM24DQGs5gLwbrIMXej73w3yPxVDVoija5P33pfei6k2/J94IdZxiQdg54= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1636625062590569.7903088919338; Thu, 11 Nov 2021 02:04:22 -0800 (PST) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-595-F1vVyFZPMJuSGIsUIBuY4A-1; Thu, 11 Nov 2021 05:04:20 -0500 Received: by mail-wr1-f71.google.com with SMTP id f3-20020a5d50c3000000b00183ce1379feso922181wrt.5 for ; Thu, 11 Nov 2021 02:04:20 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id c1sm2499021wrt.14.2021.11.11.02.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 02:04:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636625061; 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=K6REFy2Z9s6d+bG385Dx3esh0VGm1oiX7Asv3HUk+NQ=; b=NdRSpMtJmIQbxSNiSkygNV8XFYZgPnSuLh5VjQmjJqM9JI4519jXJr8OBO/DT/DJQ4MWVA OIsfI6NdHORsNecumDVjGT2lTHfMvLM94Cv9XhNRkZ5hnOFRW95ToEo8anmkwSNHn8Yokv sIl/zicNpmZUBeAvE58sv5K4qRzFPm0= X-MC-Unique: F1vVyFZPMJuSGIsUIBuY4A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=K6REFy2Z9s6d+bG385Dx3esh0VGm1oiX7Asv3HUk+NQ=; b=2d1vAlghv2og7uYIpvsE7ZNnoAuMmytH7NxP9Q4yHB6wtmuxlZxt9xIkBRXqYgvmIT wTI3JoK4A4+1BRvzSRJBf+xnM8F2bQrhDm3oZ6d+jmWWI2um6F5ThBTDLTx3L8Anz7TC dODS0DZWJ2Xmv0Y8HQyAThT7pybmL5P1kExCwMLv9tzk6fR12JjzcDv3yM5VDuH4RLzp yjmgNk+c97nCABBDdNBAFw+utuezfqNjj0mzgsqcEGEzGIx6W+RprX9VuVrl752Txamq t2YmarZ5VMv6bkRaagxNwpkNjAlNpCd20f1cfIko0ub0oQ8mKPET6Nb1r7aKHZYPU48+ w54A== X-Gm-Message-State: AOAM532pOoUnFlSGMx0UmjjSZmDDJ5+cEDkI2YA4HhINi4WZy3Qmdfbp PBxedgHTgL+pTkoLTO4lPQwlp3ztieUq5ttskucEjHEggit8r5mDkSDifZ3nY++6ygS6y0ZaVsv ZIIzGE/uU0GNC2g== X-Received: by 2002:a5d:4cd1:: with SMTP id c17mr7402543wrt.31.1636625059368; Thu, 11 Nov 2021 02:04:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYPottiScYoGYWMuBHI1kt1CFDM3B+TKHa93TDks3lkapvWVBg4p8N7CqCNRRw0CvNn/bbEQ== X-Received: by 2002:a5d:4cd1:: with SMTP id c17mr7402513wrt.31.1636625059207; Thu, 11 Nov 2021 02:04:19 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Yanan Wang , Marcel Apfelbaum , Eduardo Habkost , Andrew Jones Subject: [PATCH-for-6.2 v3 6/6] hw/core: Rename smp_parse() -> machine_parse_smp_config() Date: Thu, 11 Nov 2021 11:03:51 +0100 Message-Id: <20211111100351.2153662-7-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211111100351.2153662-1-philmd@redhat.com> References: <20211111100351.2153662-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636625063160100001 All methods related to MachineState are prefixed with "machine_". smp_parse() does not need to be an exception. Rename it and const'ify the SMPConfiguration argument, since it doesn't need to be modified. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang --- include/hw/boards.h | 3 ++- hw/core/machine-smp.c | 6 ++++-- hw/core/machine.c | 2 +- tests/unit/test-smp-parse.c | 8 ++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 9c1c1901046..7597cec4400 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -34,7 +34,8 @@ HotpluggableCPUList *machine_query_hotpluggable_cpus(Mach= ineState *machine); void machine_set_cpu_numa_node(MachineState *machine, const CpuInstanceProperties *props, Error **errp); -void smp_parse(MachineState *ms, SMPConfiguration *config, Error **errp); +void machine_parse_smp_config(MachineState *ms, + const SMPConfiguration *config, Error **errp= ); =20 /** * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devic= es diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c index 116a0cbbfab..2cbfd574293 100644 --- a/hw/core/machine-smp.c +++ b/hw/core/machine-smp.c @@ -44,7 +44,8 @@ static char *cpu_hierarchy_to_string(MachineState *ms) } =20 /* - * smp_parse - Generic function used to parse the given SMP configuration + * machine_parse_smp_config: Generic function used to parse the given + * SMP configuration * * Any missing parameter in "cpus/maxcpus/sockets/cores/threads" will be * automatically computed based on the provided ones. @@ -63,7 +64,8 @@ static char *cpu_hierarchy_to_string(MachineState *ms) * introduced topology members which are likely to be target specific shou= ld * be directly set as 1 if they are omitted (e.g. dies for PC since 4.1). */ -void smp_parse(MachineState *ms, SMPConfiguration *config, Error **errp) +void machine_parse_smp_config(MachineState *ms, + const SMPConfiguration *config, Error **errp) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); unsigned cpus =3D config->has_cpus ? config->cpus : 0; diff --git a/hw/core/machine.c b/hw/core/machine.c index 26ec54e7261..a2d3c9969d9 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -760,7 +760,7 @@ static void machine_set_smp(Object *obj, Visitor *v, co= nst char *name, return; } =20 - smp_parse(ms, config, errp); + machine_parse_smp_config(ms, config, errp); } =20 static void machine_class_init(ObjectClass *oc, void *data) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 11109752799..b158ebb16b1 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -337,7 +337,7 @@ static const struct SMPTestData data_with_dies_invalid[= ] =3D { }, }; =20 -static char *smp_config_to_string(SMPConfiguration *config) +static char *smp_config_to_string(const SMPConfiguration *config) { return g_strdup_printf( "(SMPConfiguration) {\n" @@ -371,7 +371,7 @@ static char *cpu_topology_to_string(const CpuTopology *= topo) topo->cores, topo->threads, topo->max_cpus); } =20 -static void check_parse(MachineState *ms, SMPConfiguration *config, +static void check_parse(MachineState *ms, const SMPConfiguration *config, const CpuTopology *expect_topo, const char *expect= _err, bool is_valid) { @@ -380,8 +380,8 @@ static void check_parse(MachineState *ms, SMPConfigurat= ion *config, g_autofree char *output_topo_str =3D NULL; Error *err =3D NULL; =20 - /* call the generic parser smp_parse() */ - smp_parse(ms, config, &err); + /* call the generic parser */ + machine_parse_smp_config(ms, config, &err); =20 output_topo_str =3D cpu_topology_to_string(&ms->smp); =20 --=20 2.31.1