From patchwork Thu Nov 11 10:03:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12614555 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34C8AC433EF for ; Thu, 11 Nov 2021 10:07:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F0D1161107 for ; Thu, 11 Nov 2021 10:06:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F0D1161107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:42746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ml6yx-0004N7-3s for qemu-devel@archiver.kernel.org; Thu, 11 Nov 2021 05:06:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml6w9-0006kf-2N for qemu-devel@nongnu.org; Thu, 11 Nov 2021 05:04:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45492) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml6w7-00010G-09 for qemu-devel@nongnu.org; Thu, 11 Nov 2021 05:04:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636625040; 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=XXNqvsHtQ9xNOvoPKZ0ZfKhs6w2BWEA412aZVl3hArOjwZTQSDpZHtmHHTN0n9f0VpowU/ CKt6Zrx54NS26Fx2tAKbAl0XBJLiIZyeMwCQSJrmKVTlmbvskO/VUWz67ExxmeS4sRQ0KK ZxyZ9r5V7MWPeVbE2RYrYxIpvCbkOHE= 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-325-8aFlnMAEP1aqk6MAa2vkAg-1; Thu, 11 Nov 2021 05:03:59 -0500 X-MC-Unique: 8aFlnMAEP1aqk6MAa2vkAg-1 Received: by mail-wm1-f72.google.com with SMTP id k25-20020a05600c1c9900b00332f798ba1dso4549250wms.4 for ; Thu, 11 Nov 2021 02:03:58 -0800 (PST) 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=kzd19IxbXeug0kH93uuWfZa0eapdcgvZvwOr0HoPlOaFLFylgvaLdMmgMYw5TuDksi vjcseCsXTkx7YcGmqYhqvEC4QmwVzDdp7VjnKULDvdRJgmrgobMtSqQbglnW0hDOFEHX PW4ExrLNQLgW1hLR1VmuIWEr+ymqvTXa24p1SOgFway4C8Bte3KgcDpdbwp11mnGA3ey W+7+/yyNJY3IuEx+eDBXQqrJ4Y1qrN9k0H/ZoFOGCjqlUsoEGUja2kJQ1xqvcMbzgmoD 1wiMIFtQ8nbaC6XaCUzN/lCNU1kHVIdUHGII7zzdRIziaVCRpTvI6XCMSUzRG183Qtxz y9kg== X-Gm-Message-State: AOAM533xDQRjeSfL1AW6jiVnY5wtI9QdkQHTP4322M+BNFKP4P6PQ2GC rNQTOXGfFOBLfFSGxzBPT6M59aoI9NmnlW+MzVp8I3ITMWs6gQ7fQHEOtoom4aV+Zi4fibXo+WI zb4vLG5P7NWZr48h8bM9j9MsfjXcps+I7oDC2zK+Cc5hXtYAaqSruLhjDdmPDEnqF X-Received: by 2002:a1c:287:: with SMTP id 129mr9508556wmc.49.1636625037502; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Andrew Jones , Eduardo Habkost , Markus Armbruster , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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); } - /* Reset the supported min CPUs and max CPUs */ + /* Force invalid min CPUs and max CPUs */ mc->min_cpus = 2; mc->max_cpus = 511; @@ -523,6 +523,10 @@ static void test_generic(void) smp_parse_test(ms, data, false); } + /* Reset the supported min CPUs and max CPUs */ + mc->min_cpus = MIN_CPUS; + mc->max_cpus = MAX_CPUS; + object_unref(obj); } From patchwork Thu Nov 11 10:03:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12614553 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C1FFC433EF for ; Thu, 11 Nov 2021 10:06:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E63B161107 for ; Thu, 11 Nov 2021 10:06:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E63B161107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:40782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ml6yc-00035N-4D for qemu-devel@archiver.kernel.org; Thu, 11 Nov 2021 05:06:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml6wC-0006r8-49 for qemu-devel@nongnu.org; Thu, 11 Nov 2021 05:04:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31824) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml6w9-00010b-9K for qemu-devel@nongnu.org; Thu, 11 Nov 2021 05:04:07 -0500 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= 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-395-e6hYlTIfPJ6kkEzTnFfSAw-1; Thu, 11 Nov 2021 05:04:03 -0500 X-MC-Unique: e6hYlTIfPJ6kkEzTnFfSAw-1 Received: by mail-wm1-f72.google.com with SMTP id 144-20020a1c0496000000b003305ac0e03aso4530974wme.8 for ; Thu, 11 Nov 2021 02:04:03 -0800 (PST) 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=WQN2jlrtnHetncE+h3UvvqraU445ACdg3Q7+3Qio0/s4826vNzLAt4+WOd/BSel8Nh Hg/2S0DCZ3x+y+tatGapgofOeVE+FJmb2O9BFZQdopopfrz7G4s9Kps8OLak7NEyd9+j 7CESBcRJbcePwwRip6vvOsSkzLm6ANjx/f4OiEzKBf6LmFav/+98+qYcLQjLOBC/bPOf WG90a4MlGo7B1Qx1+m5OgL4hvuCwdzBaE7L1dLHz1AllGSG1OR0oeU0DCf2mSE5vxVBS Cz+qXWBxBlUXOE5g4GEnSOTscNQzxtUWsRyUfQ0qssXNVHvezShIRYRspWqm9risiOVZ ZiSQ== X-Gm-Message-State: AOAM530iT8a8MyJRvcdBq4v7AVBIeYhYrOwd44lXhuCpvwqiBu6N1IDk rz2jmC0HSryTTEbjCAPqVED3uziEo5xR+aXPgjXXTmrDVeELXDg6nd7Ri48zgrfuJsp9x3l7mPd ZIXFtYn6xE+80ybQWrJAywn9x307DekSrQWSTJQ8x0sYjqhqUIQxUW3eiHgIDfwct X-Received: by 2002:adf:e682:: with SMTP id r2mr7490328wrm.281.1636625041999; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Andrew Jones , Eduardo Habkost , Markus Armbruster , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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; -/* Type info of the tested machine */ -static const TypeInfo smp_machine_info = { - .name = TYPE_MACHINE, - .parent = TYPE_OBJECT, - .class_size = sizeof(MachineClass), - .instance_size = 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) } } -/* 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 = MACHINE_CLASS(oc); + mc->min_cpus = MIN_CPUS; mc->max_cpus = MAX_CPUS; @@ -498,8 +491,6 @@ static void test_generic(void) SMPTestData *data = &(SMPTestData){{ }}; int i; - smp_machine_class_init(mc); - for (i = 0; i < ARRAY_SIZE(data_generic_valid); i++) { *data = data_generic_valid[i]; unsupported_params_init(mc, data); @@ -539,7 +530,6 @@ static void test_with_dies(void) unsigned int num_dies = 2; int i; - smp_machine_class_init(mc); mc->smp_props.dies_supported = true; for (i = 0; i < ARRAY_SIZE(data_generic_valid); i++) { @@ -582,6 +572,15 @@ static void test_with_dies(void) object_unref(obj); } +/* Type info of the tested machine */ +static const TypeInfo smp_machine_info = { + .name = TYPE_MACHINE, + .parent = TYPE_OBJECT, + .class_init = machine_class_init, + .class_size = sizeof(MachineClass), + .instance_size = sizeof(MachineState), +}; + int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); From patchwork Thu Nov 11 10:03:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12614563 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8B9EC433F5 for ; Thu, 11 Nov 2021 10:08:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B00761107 for ; Thu, 11 Nov 2021 10:08:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9B00761107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:49826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ml70m-0000en-PT for qemu-devel@archiver.kernel.org; Thu, 11 Nov 2021 05:08:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml6wI-0006z8-Ko for qemu-devel@nongnu.org; Thu, 11 Nov 2021 05:04:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27434) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml6wF-00011G-Cr for qemu-devel@nongnu.org; Thu, 11 Nov 2021 05:04:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636625050; 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=h/oRLNmgegtPKhJ9ItokFy8DFtXxyNkiAtb0MHuHrRDRfF2AvRI7wdnWBfnj12OzC3/P7R feZZVk2fGTMSs7xJegL5gLFlyBKs5+qOEnEK6sdYhFuXh0h8c7/o7H3jpp+PGXe/k2tVtU yBn+bL3Wkpwzr9ICEN2OIwhZvR12/cw= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-DiruEl8AMZCtHMHOY96D3w-1; Thu, 11 Nov 2021 05:04:07 -0500 X-MC-Unique: DiruEl8AMZCtHMHOY96D3w-1 Received: by mail-wr1-f72.google.com with SMTP id w14-20020adfbace000000b001884bf6e902so929635wrg.3 for ; Thu, 11 Nov 2021 02:04:07 -0800 (PST) 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=6qxty2ELkFInwXa6ld2p2yPy4nZGA1j/o1DhBx5V7MpjXhVdjM8kZK5b+VahYrkFD2 QvxMp5qUx2YZOqi5Gym4Za8LRKVuCQEWCv6UoEOVeirCdpOZmW9hUsAni+I54rwG3gAx 6jA4j229NmDWnEj9JRDnHCoWgsdD1ZL1lN9/j35cOh4Wa6UNNa/HEw0r591MQ+rkHU85 nFYtgirlXc/Q2QqmcX7LPrQPObJ9S3P8G6qh7Xtfd0XKYxk4MpviairmB6n3cV/xsEz6 k19fmUp1FJQ4KxKiH62msKesSfzvHaOCmxYLLcKSDlC7wLDeQpcKSbobHOZIdyuBHTJ+ xMqQ== X-Gm-Message-State: AOAM533SZANygc+NPsv/o/X9UOH93qx3fQq2NK/dxQvkea2FkSve4H/w bHmcVPucbhFUMUxuHH64ix9FmNphpng2ks8HR3EZtWPe89TeBwICUETCyxo5Rh3W0iV5fUHaIvq uxMBAJmXnQneDFAnBwo6DY2URo1ACbGBZcwxUj9d9jo+YgbnXmJQtLKsAd7oS3s+k X-Received: by 2002:adf:fb09:: with SMTP id c9mr6997175wrr.223.1636625046282; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Andrew Jones , Eduardo Habkost , Markus Armbruster , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é Reported-by: Philippe Mathieu-Daudé Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-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 */ +#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[] = { * should tweak the supported min CPUs to 2 for testing */ .config = SMP_CONFIG_GENERIC(T, 1, F, 0, F, 0, F, 0, F, 0), .expect_error = "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 = SMP_CONFIG_GENERIC(T, 512, F, 0, F, 0, F, 0, F, 0), .expect_error = "Invalid SMP CPUs 512. The max CPUs supported " - "by machine '(null)' is 511", + "by machine '" SMP_MACHINE_NAME "' is 511", }, }; @@ -481,6 +483,8 @@ static void machine_class_init(ObjectClass *oc, void *data) mc->smp_props.prefer_sockets = true; mc->smp_props.dies_supported = false; + + mc->name = g_strdup(SMP_MACHINE_NAME); } static void test_generic(void) From patchwork Thu Nov 11 10:03:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12614559 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9603C4332F for ; Thu, 11 Nov 2021 10:08:01 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45C9E6124D for ; Thu, 11 Nov 2021 10:08:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 45C9E6124D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:47064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ml6zw-0007Fr-BV for qemu-devel@archiver.kernel.org; Thu, 11 Nov 2021 05:08:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml6wK-000754-9d for qemu-devel@nongnu.org; Thu, 11 Nov 2021 05:04:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29848) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml6wI-00011W-6L for qemu-devel@nongnu.org; Thu, 11 Nov 2021 05:04:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636625053; 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=BGtaNgEyek+9oscbnckHz8eAuOo+TqkAolRGvj/EUpLA5COOSTyql978p2T66gjDBmAdR2 igTvvM1AMJi2u5qALya2/AQD9xnr+sJrUNxhkBuiJtTjsP+KoFJJ3zx5HO6rDwZWKMyI5u Sk0zIARaW7+iyimP5CpHG4KDSUgtquM= 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-548-3f8Jsl0pP0uXnVvpsGZbCQ-1; Thu, 11 Nov 2021 05:04:12 -0500 X-MC-Unique: 3f8Jsl0pP0uXnVvpsGZbCQ-1 Received: by mail-wm1-f69.google.com with SMTP id m18-20020a05600c3b1200b0033283ea5facso1615532wms.1 for ; Thu, 11 Nov 2021 02:04:12 -0800 (PST) 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=VFWHPJn2T2w4O5mRkWGDmwYt2kQ8PKrk986Jwf0JgA8De02yo3Cv3ZB48QP1A6e2Im APjFb7yq1NGBfTVl9I2uXk8SSl9Spw8dB6Q0xLiRZEf0djUbSwtFoepxmS7EYlOaZEAl L8mMH4wkIubgXAQT2pyECZ+aQchlVdsDRZGe0A3MLZNt5+v6UKYE0npAxHSuP9QE1LX2 msIk+y/8W9kQEP6ywiFbyahRxmB5reCCHUqlPKEh7gnNgHuO4vx58QcmY09MiokdqLO7 a6m89p6OhkGjPNkvKp6q2qEXOlfLnDC1h3uszQPpIE+LViBi7k1Cak4b7IZJJp6rQraC 0T0Q== X-Gm-Message-State: AOAM533bo1c/eqXPoEC4Tw7jT7w1nTewZZED42zOJFAywkovdo7tFUIi aim/UNSsHSZZ2OfIXV/dS6GoOSo7bG2QfAAyHFyWAL1/nxtwyAkLiNYLZg8jfiwE6u6dBTPMxwk oXSZIKwwMeFiTqmOs5mWSn/FfxJTDvpdciS7tnFZbpA56quka0UIMEJrEYiRglla+ X-Received: by 2002:a05:600c:4108:: with SMTP id j8mr6836688wmi.139.1636625050588; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Andrew Jones , Eduardo Habkost , Markus Armbruster , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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 = object_new(TYPE_MACHINE); MachineState *ms = MACHINE(obj); MachineClass *mc = MACHINE_GET_CLASS(obj); - SMPTestData *data = &(SMPTestData){{ }}; + SMPTestData data = {}; int i; for (i = 0; i < ARRAY_SIZE(data_generic_valid); i++) { - *data = data_generic_valid[i]; - unsupported_params_init(mc, data); + data = data_generic_valid[i]; + unsupported_params_init(mc, &data); - smp_parse_test(ms, data, true); + smp_parse_test(ms, &data, true); /* Unsupported parameters can be provided with their values as 1 */ - data->config.has_dies = true; - data->config.dies = 1; - smp_parse_test(ms, data, true); + data.config.has_dies = true; + data.config.dies = 1; + smp_parse_test(ms, &data, true); } /* Force invalid min CPUs and max CPUs */ @@ -512,10 +512,10 @@ static void test_generic(void) mc->max_cpus = 511; for (i = 0; i < ARRAY_SIZE(data_generic_invalid); i++) { - *data = data_generic_invalid[i]; - unsupported_params_init(mc, data); + data = data_generic_invalid[i]; + unsupported_params_init(mc, &data); - smp_parse_test(ms, data, false); + smp_parse_test(ms, &data, false); } /* Reset the supported min CPUs and max CPUs */ @@ -530,47 +530,47 @@ static void test_with_dies(void) Object *obj = object_new(TYPE_MACHINE); MachineState *ms = MACHINE(obj); MachineClass *mc = MACHINE_GET_CLASS(obj); - SMPTestData *data = &(SMPTestData){{ }}; + SMPTestData data = {}; unsigned int num_dies = 2; int i; mc->smp_props.dies_supported = true; for (i = 0; i < ARRAY_SIZE(data_generic_valid); i++) { - *data = data_generic_valid[i]; - unsupported_params_init(mc, data); + data = data_generic_valid[i]; + unsupported_params_init(mc, &data); /* when dies parameter is omitted, it will be set as 1 */ - data->expect_prefer_sockets.dies = 1; - data->expect_prefer_cores.dies = 1; + data.expect_prefer_sockets.dies = 1; + data.expect_prefer_cores.dies = 1; - smp_parse_test(ms, data, true); + smp_parse_test(ms, &data, true); /* when dies parameter is specified */ - data->config.has_dies = true; - data->config.dies = num_dies; - if (data->config.has_cpus) { - data->config.cpus *= num_dies; + data.config.has_dies = true; + data.config.dies = num_dies; + if (data.config.has_cpus) { + data.config.cpus *= num_dies; } - if (data->config.has_maxcpus) { - data->config.maxcpus *= num_dies; + if (data.config.has_maxcpus) { + data.config.maxcpus *= num_dies; } - data->expect_prefer_sockets.dies = num_dies; - data->expect_prefer_sockets.cpus *= num_dies; - data->expect_prefer_sockets.max_cpus *= num_dies; - data->expect_prefer_cores.dies = num_dies; - data->expect_prefer_cores.cpus *= num_dies; - data->expect_prefer_cores.max_cpus *= num_dies; + data.expect_prefer_sockets.dies = num_dies; + data.expect_prefer_sockets.cpus *= num_dies; + data.expect_prefer_sockets.max_cpus *= num_dies; + data.expect_prefer_cores.dies = num_dies; + data.expect_prefer_cores.cpus *= num_dies; + data.expect_prefer_cores.max_cpus *= num_dies; - smp_parse_test(ms, data, true); + smp_parse_test(ms, &data, true); } for (i = 0; i < ARRAY_SIZE(data_with_dies_invalid); i++) { - *data = data_with_dies_invalid[i]; - unsupported_params_init(mc, data); + data = data_with_dies_invalid[i]; + unsupported_params_init(mc, &data); - smp_parse_test(ms, data, false); + smp_parse_test(ms, &data, false); } object_unref(obj); From patchwork Thu Nov 11 10:03:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12614577 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6B91C433F5 for ; Thu, 11 Nov 2021 10:14:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5DE4F61241 for ; Thu, 11 Nov 2021 10:14:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5DE4F61241 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:58386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ml763-0006jN-H2 for qemu-devel@archiver.kernel.org; Thu, 11 Nov 2021 05:14:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml6wc-0007aJ-29 for qemu-devel@nongnu.org; Thu, 11 Nov 2021 05:04:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml6wN-000123-W9 for qemu-devel@nongnu.org; Thu, 11 Nov 2021 05:04:33 -0500 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= 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-397-J0Cg7-DYNI-AxpaFyChpVg-1; Thu, 11 Nov 2021 05:04:16 -0500 X-MC-Unique: J0Cg7-DYNI-AxpaFyChpVg-1 Received: by mail-wm1-f72.google.com with SMTP id k25-20020a05600c1c9900b00332f798ba1dso4549620wms.4 for ; Thu, 11 Nov 2021 02:04:16 -0800 (PST) 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=vqCXAHbaJQhTOL8aanzPGN5BsSqsufIXExkIYRk5Kbu1rxLekERrSaQbR5xCXhn9yr vHHqqYhBbW/h3Za8Jar1cEoO2MIScbK7Z73ksg4IQawKxxXmGrksXsNEvCmdqNTK8HKA kELMJGXscLh/pFNUrcJCifz2CWK8X9D+/s+aby6szdnGwJktLJ47hwCD+ViSNQZreKBu B24+KVygE7gSBPVBgeqZTOVItQnB40StdwKFlBrbwRPy+7nI7M0ExtmeUnKjjOmf4SwN mTCW54CeaLuhjZRh+VR2ok0LCxtrUPo2EA9qoUNfBelCg5LK/5mKezpm1bF1mLVddfdq cMFQ== X-Gm-Message-State: AOAM530CEk61aoWzlYUcDrWU4EUrRIKOTl7Nc6rYlwr2wjES/zNimk8G /2Jo/ito8Kmo/G7F51XMKcJfg37JtDyNZvYOdkR7+KJJU/l4YqEdQXoLY8WjCVcASvHYNiAMoRm bQCdZXbVYZGq4LletlbmWGSlMJG8VFhSMYoTYmpyTnraeSiygw5EDY1NwcFGKrOjF X-Received: by 2002:a05:600c:1989:: with SMTP id t9mr6811450wmq.24.1636625055146; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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: , Cc: Thomas Huth , Andrew Jones , Eduardo Habkost , Markus Armbruster , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Declare structures const when we don't need to modify them at runtime. Signed-off-by: Philippe Mathieu-Daudé 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[] = { +static const struct SMPTestData data_generic_valid[] = { { /* config: no configuration provided * expect: cpus=1,sockets=1,cores=1,threads=1,maxcpus=1 */ @@ -285,7 +285,7 @@ static struct SMPTestData data_generic_valid[] = { }, }; -static struct SMPTestData data_generic_invalid[] = { +static const struct SMPTestData data_generic_invalid[] = { { /* config: -smp 2,dies=2 */ .config = 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[] = { }, }; -static struct SMPTestData data_with_dies_invalid[] = { +static const struct SMPTestData data_with_dies_invalid[] = { { /* config: -smp 16,sockets=2,dies=2,cores=4,threads=2,maxcpus=16 */ .config = 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 *config) config->has_maxcpus ? "true" : "false", config->maxcpus); } -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) } 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 = smp_config_to_string(config); @@ -466,7 +466,7 @@ static void smp_parse_test(MachineState *ms, SMPTestData *data, bool is_valid) } /* 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 *data) { if (!mc->smp_props.dies_supported) { data->expect_prefer_sockets.dies = 1; From patchwork Thu Nov 11 10:03:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12614567 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F8CEC433F5 for ; Thu, 11 Nov 2021 10:13:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E6FA961108 for ; Thu, 11 Nov 2021 10:13:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E6FA961108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:56286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ml74u-0005GP-Ve for qemu-devel@archiver.kernel.org; Thu, 11 Nov 2021 05:13:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml6wW-0007PH-30 for qemu-devel@nongnu.org; Thu, 11 Nov 2021 05:04:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53340) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml6wQ-00012L-Ra for qemu-devel@nongnu.org; Thu, 11 Nov 2021 05:04:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636625062; 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=F9WnHv8hcnxkLzf3SaxS2iGgfPB29oyJniWaO6aO6jEzXrzpLH6B3faainV1b723LK0zIY 7nDl+HOhQYoVUH59UtQLJaAa7CN+DqAbyPQYTDbWo6XkDfhBo94BfG24A+29mKQ/wP6lut rV2i+6S7pgHyxqcVBZ+OY7xYqgZBC4Y= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-595-jtOGQFFiMymdqmZN19T_Vw-1; Thu, 11 Nov 2021 05:04:20 -0500 X-MC-Unique: jtOGQFFiMymdqmZN19T_Vw-1 Received: by mail-wr1-f72.google.com with SMTP id r12-20020adfdc8c000000b0017d703c07c0so938036wrj.0 for ; Thu, 11 Nov 2021 02:04:20 -0800 (PST) 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=sISoAugcLWcT2iwGUgrJAeVclX7X210wHhTrcL8nywMivM7lobASFGuMGcFwHCzbZx UMXYT/HiK3L4SnLZQElhj0qK0H1k0k+U1DGHzPbWsX3FlErH9xAKTLHV4fcNRhZNhtBP 0d5ACFVAjhsEhF5tLZ1+b7hzNJ6TvN7KoNFtw4kEUgkjI0jGTdGIJnhiIkyVuYR7Q8Pz lzBqWQ0xiFWtDK7i+pxOfp49LogztmQD2+e0ksIrxDezIUDaf96Fw+Pn/3BoHuUK+kWC Rb8jnVrjNWBBT8S5Z3XKwn2ttu4HL2qVbt3+LpqA407QQ1QIdsXr3esVal7EwDj2kv4y DaRw== X-Gm-Message-State: AOAM531re3bJA95aB7hl2sfpptcNNaINdkAcMzcAl51E+AcENDrINc+g XYsu97NegUFIJSpiidS0cZDYATzK55kvGsC59hIcDOupCAViIbQFajilPUmAhx/8ql9KqFroDNJ oN8j38x8wMHqgXNkAf3WSS3Zh9OkDlVcWt4PjlzZ+FWpUt/YHiSqFTI6dzQeGwIg0 X-Received: by 2002:a5d:4cd1:: with SMTP id c17mr7402559wrt.31.1636625059454; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Andrew Jones , Eduardo Habkost , Markus Armbruster , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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(MachineState *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); /** * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devices 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) } /* - * 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 should * 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 = MACHINE_GET_CLASS(ms); unsigned cpus = 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, const char *name, return; } - smp_parse(ms, config, errp); + machine_parse_smp_config(ms, config, errp); } 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[] = { }, }; -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); } -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, SMPConfiguration *config, g_autofree char *output_topo_str = NULL; Error *err = NULL; - /* call the generic parser smp_parse() */ - smp_parse(ms, config, &err); + /* call the generic parser */ + machine_parse_smp_config(ms, config, &err); output_topo_str = cpu_topology_to_string(&ms->smp);