From nobody Sun Feb 8 19:13:14 2026 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=1639586955; cv=none; d=zohomail.com; s=zohoarc; b=gdKE9V/x9E0JsbMHiC10YD4OTLWCYG03bVAE232CJMkw0JRMfoMCWAncMbNwnKkDw06oWl4RB4GdDYuKeFnwucfH/qr+nuenolsN2wLOy8VLpj+44CcPU34vcMbvSWyllRGpObygsXf7S0PwgmFG0TUrFGnHRgvKxOpM5z6qyak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639586955; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=t0HaJa5hL0xbci94VgrhNJFI3KFO8etTJC6TchOuXSE=; b=ak9Q/20jvoAqmA15kafxqw29GuYhitva5UGtsgzEI1m3xBpG9Yu/yx1vM6PE96mZiD9O3Xrt9dNZZ+0XNCdiy28E6t+vgP7DNaMlsopK0GannWKj3NWZZz5c74MYfj3xRW77Y9v9tn4mHuSK1cFLYNYBd3h9GU5GLcrrVGJt/as= 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 1639586955701940.5121697053288; Wed, 15 Dec 2021 08:49:15 -0800 (PST) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-583-7VZ0I3WXMG2623KMip1sHw-1; Wed, 15 Dec 2021 11:49:12 -0500 Received: by mail-wr1-f71.google.com with SMTP id h12-20020adfa4cc000000b001a22dceda69so777678wrb.16 for ; Wed, 15 Dec 2021 08:49:11 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id w17sm2604355wmc.14.2021.12.15.08.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586953; 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=t0HaJa5hL0xbci94VgrhNJFI3KFO8etTJC6TchOuXSE=; b=D6KApL2/N+DpfHszngJAjObY8/+QiSRXh7xt8FJsJU32/i2RoHSDmZ/YYqZZqjlPPYDT8w rY3Kj7zIRi1v9cTLz7Of4MRpq6Mc5VqaslEu+fVS6atXATLJyhDgwj6TaguyR3qhBe6N5Y 1DaFQ21cI8ywmy29aKc2u4x1otrFY60= X-MC-Unique: 7VZ0I3WXMG2623KMip1sHw-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=t0HaJa5hL0xbci94VgrhNJFI3KFO8etTJC6TchOuXSE=; b=jh+Lwrxq21L1DIgs1vrdTN8ut5GnzTsFkT1mYq1+UulGmOFRKIjvyp7vnPK5dYin7m xgllZz6DjgvpZSroz8pEep0Qg2NvHNvQk+HDf5oehXSqjwx6ipbrm30zud/U91uXm/oV /B5NkrvfAiPC8aylZQaWC0fMXTyWBNwp0XhVoncJa/KEZuplV3dNg7RnlnwbY8knWAPY f4UswJ2fmrgt18phtFlmRePq8PvUFtpMcug0xce5F/+VjExYFkvmMcHvaVN1DCKusfjf 01yca/BDGlbjYbnSbR05c0jXW/9JLzNoSd8OIHms/zeqgER4EKym08Ig+3lSMi0v56cO InnQ== X-Gm-Message-State: AOAM532iHaql70zyxFVwmhfzIIOyAu7o450xGX2XZK7R+kJ89lVahBwi gKK5DiJ5cFyDdX8MA4K58Zga4X6VLdK+HyRVY/73zt88FzEiacWwgac5Cn5NGFXcKKMQQI1S6Qv qlfe8GFTA5vykNg== X-Received: by 2002:adf:ce08:: with SMTP id p8mr5261314wrn.154.1639586950580; Wed, 15 Dec 2021 08:49:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4BJQagz8bKCSuYyL0rib/QaODn0P2WzfvKuta6q12qVha+fVsACKfLrpg4NpukFFKeJht0w== X-Received: by 2002:adf:ce08:: with SMTP id p8mr5261299wrn.154.1639586950448; Wed, 15 Dec 2021 08:49:10 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Yanan Wang Subject: [PATCH v5 1/8] tests/unit/test-smp-parse: Pass machine type as argument to tests Date: Wed, 15 Dec 2021 17:48:49 +0100 Message-Id: <20211215164856.381990-2-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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: 1639586995597100001 Use g_test_add_data_func() instead of g_test_add_func() so we can pass the machine type to the tests (we will soon have different machine types). Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-smp-parse.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index b02450e25a3..37c6b4981db 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -487,9 +487,10 @@ static void machine_base_class_init(ObjectClass *oc, v= oid *data) mc->name =3D g_strdup(SMP_MACHINE_NAME); } =20 -static void test_generic(void) +static void test_generic(const void *opaque) { - Object *obj =3D object_new(TYPE_MACHINE); + const char *machine_type =3D opaque; + Object *obj =3D object_new(machine_type); MachineState *ms =3D MACHINE(obj); MachineClass *mc =3D MACHINE_GET_CLASS(obj); SMPTestData *data =3D &(SMPTestData){{ }}; @@ -525,9 +526,10 @@ static void test_generic(void) object_unref(obj); } =20 -static void test_with_dies(void) +static void test_with_dies(const void *opaque) { - Object *obj =3D object_new(TYPE_MACHINE); + const char *machine_type =3D opaque; + Object *obj =3D object_new(machine_type); MachineState *ms =3D MACHINE(obj); MachineClass *mc =3D MACHINE_GET_CLASS(obj); SMPTestData *data =3D &(SMPTestData){{ }}; @@ -599,8 +601,12 @@ int main(int argc, char *argv[]) =20 g_test_init(&argc, &argv, NULL); =20 - g_test_add_func("/test-smp-parse/generic", test_generic); - g_test_add_func("/test-smp-parse/with_dies", test_with_dies); + g_test_add_data_func("/test-smp-parse/generic", + TYPE_MACHINE, + test_generic); + g_test_add_data_func("/test-smp-parse/with_dies", + TYPE_MACHINE, + test_with_dies); =20 g_test_run(); =20 --=20 2.33.1 From nobody Sun Feb 8 19:13:14 2026 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=1639586958; cv=none; d=zohomail.com; s=zohoarc; b=bu4xKzCJTzg0YPkQxPLQx+kNM4fiDVomkVCK/nbpuzZATmN3Cf0o7zASV6zCjvYXjEMQKB+7k4du2TGiZ9kZhx9pmsmlZSqyB+7a6mNgCRTCYA6I7orjnu2+K9NoFPOMkKth2jhHNSGX3ggivp0bkjgdkAPTcFtLGy66XCRm6Zg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639586958; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=GXx7W8UBpOZBRJ+rhAKMv79kybQ7cCiq3Z9AZnQ5faU=; b=F2vISz9gy/dd08U7oxWl5g3OKL3EWWndt9Eutit4ovXVm4w0MMiI6qjtqlt1V4HjNTtexyAXWJgtlpG9LLdOZtQq1LSWLRpj+EpJgR5u6zw4hldbF0JHz+Ji3gdY0ydI0+4H99wd4W7WjQ6N6x+wulPAKX7moGIeTeTrJKrdy0o= 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 1639586958570317.0245984660447; Wed, 15 Dec 2021 08:49:18 -0800 (PST) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-45--1lnvANMNGK-D7FX8rC67g-1; Wed, 15 Dec 2021 11:49:16 -0500 Received: by mail-wm1-f71.google.com with SMTP id i15-20020a05600c354f00b0034566ac865bso1033076wmq.6 for ; Wed, 15 Dec 2021 08:49:16 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id w15sm2428449wrk.77.2021.12.15.08.49.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586957; 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=GXx7W8UBpOZBRJ+rhAKMv79kybQ7cCiq3Z9AZnQ5faU=; b=VMHFT7AB4LY5hijKf6MQXsHezajteBCFui7IpTIzsHEM3G6kx2qu7p9tP6PYMG/KVuELkM 2GkZlayL5xmjNwbx4Unzy4woGL9WUYdSxpWVrvpmRvwgTJU+zYYSIPGDBxB8Vfy24waQKz i9iqu36GOnfQACgZT9oDlXrV8g/9xHY= X-MC-Unique: -1lnvANMNGK-D7FX8rC67g-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=GXx7W8UBpOZBRJ+rhAKMv79kybQ7cCiq3Z9AZnQ5faU=; b=TlzK+/6xd4V9Yh1Z3a2GdvIbELKUp9s/hjzMtGfdL+3CKJ0hcZhvewwy2NY8j8YSVE fSyTPd8ix9nNtS//lzJDPg6RUVKawy7XPIoFjqz2N9MreuQ1UmeRl87cJ4htKcQHuCsu yd1ssQhwrGyhctGML51SKE97Jagr6HIsrXbFy/KqUGaVh8JNcmBPnx3v4zoXH2HNQIVh fXpBs1t/BJGlkYfS4mHZaIAziCONhydg8bUK4CXQkbhMWstlcJVTPS1ju9p0sWCfgOmU GbZB86MlOmvZvQFkOzUF/lop5HoajIhTPSvMMM3IqqXgBddAt1ofHpMxX2iwXDNMvaUZ c4mA== X-Gm-Message-State: AOAM531v/XdTkDjKAYNWdK9N+aLiIwU4MEmwSobs3vX6AFH5k5nTOLbp M01Amw7bA+JF/83didihCOF4wK08MlUgI0fCW7pYYTfRAMr1O7f8oHDMN4yR0gEyoAFxnYWhiKc /LpVUUWvl02OFXg== X-Received: by 2002:a05:6000:cd:: with SMTP id q13mr5327577wrx.488.1639586955180; Wed, 15 Dec 2021 08:49:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJySnjyTdiPcc1h3etCGx8TgmtMe9GuGO1/2cJhrkebD7KlCmVh0OejZtO4Wolw7jo0abvs02g== X-Received: by 2002:a05:6000:cd:: with SMTP id q13mr5327551wrx.488.1639586954864; Wed, 15 Dec 2021 08:49:14 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Yanan Wang Subject: [PATCH v5 2/8] tests/unit/test-smp-parse: Split the 'generic' test in valid / invalid Date: Wed, 15 Dec 2021 17:48:50 +0100 Message-Id: <20211215164856.381990-3-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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: 1639586998546100001 Split the 'generic' test in two tests: 'valid' and 'invalid'. This will allow us to remove the hack which modifies the MachineClass internal state. Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-smp-parse.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 37c6b4981db..425ed6b6b92 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -487,7 +487,7 @@ static void machine_base_class_init(ObjectClass *oc, vo= id *data) mc->name =3D g_strdup(SMP_MACHINE_NAME); } =20 -static void test_generic(const void *opaque) +static void test_generic_valid(const void *opaque) { const char *machine_type =3D opaque; Object *obj =3D object_new(machine_type); @@ -508,6 +508,18 @@ static void test_generic(const void *opaque) smp_parse_test(ms, data, true); } =20 + object_unref(obj); +} + +static void test_generic_invalid(const void *opaque) +{ + const char *machine_type =3D opaque; + Object *obj =3D object_new(machine_type); + MachineState *ms =3D MACHINE(obj); + MachineClass *mc =3D MACHINE_GET_CLASS(obj); + SMPTestData *data =3D &(SMPTestData){}; + int i; + /* Force invalid min CPUs and max CPUs */ mc->min_cpus =3D 2; mc->max_cpus =3D 511; @@ -601,9 +613,12 @@ int main(int argc, char *argv[]) =20 g_test_init(&argc, &argv, NULL); =20 - g_test_add_data_func("/test-smp-parse/generic", + g_test_add_data_func("/test-smp-parse/generic/valid", TYPE_MACHINE, - test_generic); + test_generic_valid); + g_test_add_data_func("/test-smp-parse/generic/invalid", + TYPE_MACHINE, + test_generic_invalid); g_test_add_data_func("/test-smp-parse/with_dies", TYPE_MACHINE, test_with_dies); --=20 2.33.1 From nobody Sun Feb 8 19:13:14 2026 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=1639586962; cv=none; d=zohomail.com; s=zohoarc; b=Y7cigERVUGX+ZKVAT9uzTMH31TOxtFTD7XSehUinFRKUnALJIKM+sYV4gq5+5OLRc/ppvYOEh3AbcJMJ9xIUYTtwgBATtKqu290F/991VyxQqtyVQqw1/2+tV9NkaEy4YEJ8f5LSYkxuQvOEIUa0jTzUKjeoo+vicKWw6Y1loVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639586962; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=1chFsAOK0rTvA7TehLOkyqZafZUrvfp4t7SGxNleGGw=; b=aBIrwFmp4CA8cnbbrXpGlTgV45IZc/eCkuTIQP6TjHK1w97x378KQBg3Bz7e3axg7l/n1qAB/kXsBMWk0yDjCjvRp7zlvODFiaj8MHBO9HLLCWwo816NaP5Mn9B2Lj4SMo511XFEQnw/TuI+eznMhz9TAoDxU4OTp11n9hnk2B0= 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 1639586962866102.4116387382818; Wed, 15 Dec 2021 08:49:22 -0800 (PST) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-350-cBHV7Y9SO2SyPqk2RI4HvQ-1; Wed, 15 Dec 2021 11:49:20 -0500 Received: by mail-wm1-f71.google.com with SMTP id l4-20020a05600c1d0400b00332f47a0fa3so9237625wms.8 for ; Wed, 15 Dec 2021 08:49:20 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id g198sm2770354wme.23.2021.12.15.08.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586961; 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=1chFsAOK0rTvA7TehLOkyqZafZUrvfp4t7SGxNleGGw=; b=CGdHdzBN8pWu93Mub35Bdupg4hi7zTxbKH4B1gN1+VKeRoCOpg/EO0txZGjYvbDQkE+0ly cWQ359xpYcjT7ktu7xviYOTruipSlCs1i0EAjbCCUI3HHfYt5jUiXbXQo2cKUDR6fT27En TTgYYKREOJLSaKPMMr0Mhj4pclTY4Ao= X-MC-Unique: cBHV7Y9SO2SyPqk2RI4HvQ-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=1chFsAOK0rTvA7TehLOkyqZafZUrvfp4t7SGxNleGGw=; b=WACSlSy4ZlPjr2emcEtZbDE7ioSBXQikgZBBDFuH/CkCl6shlAW+fTLZiZABk0QJQ/ nzHbbhYYcIeQ58DbTsAk0je3AWFWFD1pC6dkyRLWAicUWjDXSeVlHmd0ArSYOlkh1qFO P+bi/u3JW7UbzIL+psMkxKgmsHtJ7CzkvMv5VuMltCej8gQnKjRPccJ/FBISFPd1GDcb oMYCGn4oHsD/dP8z9ihNTsB4wy990OM1pd+SaRW2RztBzA8D1T4qLtjD7FQN1hDBK//Z 0KsA2evdVh02uM8JmS9NFvjbzLIr9tmYaXFc20s2NPW+dCG+179zuyDGM8hCHnEttqWH TatQ== X-Gm-Message-State: AOAM532lxx0Jzg1FtKsA3YyCeSEHuOPKCYNFc9Z6K1IqLN7EDDc1781E 4J+dGxrDgsbGJ3D5b4tW1QGEmTEPK/3H59R8FEvmcyz+fR8X/CpZ1BtMCDPuJc8PE70MpH1noIF rxJTxtINDTC33Sg== X-Received: by 2002:adf:f252:: with SMTP id b18mr2219703wrp.341.1639586959504; Wed, 15 Dec 2021 08:49:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvMe099VeiUOsjwqp5vjLQgdbQE2t1ELl+aWSPW++zwyoBgykdmWf3GfuR9CnXjG1nkowesw== X-Received: by 2002:adf:f252:: with SMTP id b18mr2219686wrp.341.1639586959359; Wed, 15 Dec 2021 08:49:19 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Yanan Wang Subject: [PATCH v5 3/8] tests/unit/test-smp-parse: Add 'smp-with-dies' machine type Date: Wed, 15 Dec 2021 17:48:51 +0100 Message-Id: <20211215164856.381990-4-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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: 1639587001658100001 Avoid modifying the MachineClass internals by adding the 'smp-with-dies' machine, which inherits from TYPE_MACHINE. Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-smp-parse.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 425ed6b6b92..f66cf7bb598 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -487,6 +487,16 @@ static void machine_base_class_init(ObjectClass *oc, v= oid *data) mc->name =3D g_strdup(SMP_MACHINE_NAME); } =20 +static void machine_with_dies_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + mc->min_cpus =3D MIN_CPUS; + mc->max_cpus =3D MAX_CPUS; + + mc->smp_props.dies_supported =3D true; +} + static void test_generic_valid(const void *opaque) { const char *machine_type =3D opaque; @@ -548,9 +558,6 @@ static void test_with_dies(const void *opaque) unsigned int num_dies =3D 2; int i; =20 - /* Force the SMP compat properties */ - mc->smp_props.dies_supported =3D true; - for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { *data =3D data_generic_valid[i]; unsupported_params_init(mc, data); @@ -588,9 +595,6 @@ static void test_with_dies(const void *opaque) smp_parse_test(ms, data, false); } =20 - /* Restore the SMP compat properties */ - mc->smp_props.dies_supported =3D false; - object_unref(obj); } =20 @@ -602,6 +606,10 @@ static const TypeInfo smp_machine_types[] =3D { .class_init =3D machine_base_class_init, .class_size =3D sizeof(MachineClass), .instance_size =3D sizeof(MachineState), + }, { + .name =3D MACHINE_TYPE_NAME("smp-with-dies"), + .parent =3D TYPE_MACHINE, + .class_init =3D machine_with_dies_class_init, } }; =20 @@ -620,7 +628,7 @@ int main(int argc, char *argv[]) TYPE_MACHINE, test_generic_invalid); g_test_add_data_func("/test-smp-parse/with_dies", - TYPE_MACHINE, + MACHINE_TYPE_NAME("smp-with-dies"), test_with_dies); =20 g_test_run(); --=20 2.33.1 From nobody Sun Feb 8 19:13:14 2026 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=1639586967; cv=none; d=zohomail.com; s=zohoarc; b=SXy5lgCgWOw3ytAUAZqH/nJLTUQwFn/2kUEfI/8iVXYp2qJbq1olPrBKwE8sT0gzYZQ2FKtHwr0sDvRSIM6Wzm1CSL3sTDgVRSl4kXS9Wmky/s5qSWGurLpV72mkx5yIJaFxcRVMydCLdR1lF26M0FO/tdf+D0ecvXYyVm47y90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639586967; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=gzBQu4QmY83ZJxn/RGUigkeYNejwi9D3HBZlC+kt004=; b=fjVXxMCf+79zWPWtU0m9qGWtpdcdK/CHgnul5X4NRW4+cmq9me0tTF6ZrYSnqmI1QzxyWKo2uWQwuZB71I2NCClOZsS0yZW1PVvt6TcpWWFDk8n/51UrpMTX1jjjp8ZLI8tfCDXfdJ4R/Im6aBOqzktwUSCSalX730R3GX7tO0c= 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 16395869672051009.7260792211604; Wed, 15 Dec 2021 08:49:27 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-351-dEOdfG7dNDmzXhgCsIfSFg-1; Wed, 15 Dec 2021 11:49:25 -0500 Received: by mail-wm1-f72.google.com with SMTP id k25-20020a05600c1c9900b00332f798ba1dso14893143wms.4 for ; Wed, 15 Dec 2021 08:49:24 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id g18sm2470449wrv.42.2021.12.15.08.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586966; 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=gzBQu4QmY83ZJxn/RGUigkeYNejwi9D3HBZlC+kt004=; b=SrsmXejsc7wI3y917n/+Cep/siU5L/b+DcMmAdP6W5fp8yGUYFMwIpR2gkadaczbjWSMGd OW1iGG/T2hwd1IBxvtxzB3hw2AB7H4/RnT9G8Wqb9pttT80NCv6rQ9RaSdfsLODfaMD7a6 585nSnfF5fciLmya+2ioufUZSgJSqZ4= X-MC-Unique: dEOdfG7dNDmzXhgCsIfSFg-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=gzBQu4QmY83ZJxn/RGUigkeYNejwi9D3HBZlC+kt004=; b=uG+U/BTUytVw4pPczWbfC/595vwz3r3s51IvpDpCxo1ubGtqx7yjDXpj93JJwdDbI0 ENZdPHYepXPEmL4oDRAjLh3aartgOZ+fibBgG9P053jMhn3s8VsD4pZIHGtnPDRyhhtH 560C3R1grFWUCZgcJhlbd7jXNC8l665cIUV+1APdTCPTUMolXzUJXGI0XfpV6aXO+pWk EejhEeHHEL4vUrayV2W+uTfaW2PBoiwLkcf8/FV/JFJJcL4k42NTED7DWnKVhaMelS5j +OL6BLnL52yIUtFUpc/opR1+wZ/5pBi4WT5YT6DdNCH+sy3Lzo7PJhGXn8zyjBIEIohx ZMxg== X-Gm-Message-State: AOAM530fWZX0va/f4U8zQqktAxBhzcL239nNSpfqk+8xHgQ0x6pqeK+Z jTKgQdIm0HSMJIeIOFD6iDr4sOIsPmM6bl7TKoQMhX0qpxJr9lrCKO+aAGCu1krXy5T5dDVv7d4 vAao7mAn9/FSi4w== X-Received: by 2002:adf:9cc4:: with SMTP id h4mr5178900wre.644.1639586963834; Wed, 15 Dec 2021 08:49:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXuiAJUWKwJjDdKhC6tiSLXZKZVSJVpPsjSjHdVdioz1ncOuETMqAfL+zESKB3gKAuPP+www== X-Received: by 2002:adf:9cc4:: with SMTP id h4mr5178890wre.644.1639586963692; Wed, 15 Dec 2021 08:49:23 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v5 4/8] tests/unit/test-smp-parse: Add 'smp-generic-invalid' machine type Date: Wed, 15 Dec 2021 17:48:52 +0100 Message-Id: <20211215164856.381990-5-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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: 1639587003814100003 Avoid modifying the MachineClass internals by adding the 'smp-generic-invalid' machine, which inherits from TYPE_MACHINE. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-smp-parse.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index f66cf7bb598..72e7236afd9 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -487,6 +487,17 @@ static void machine_base_class_init(ObjectClass *oc, v= oid *data) mc->name =3D g_strdup(SMP_MACHINE_NAME); } =20 +static void machine_without_dies_invalid_class_init(ObjectClass *oc, void = *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + /* Force invalid min CPUs and max CPUs */ + mc->min_cpus =3D 2; + mc->max_cpus =3D 511; + + mc->smp_props.dies_supported =3D false; +} + static void machine_with_dies_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -530,10 +541,6 @@ static void test_generic_invalid(const void *opaque) SMPTestData *data =3D &(SMPTestData){}; int i; =20 - /* Force invalid min CPUs and max CPUs */ - mc->min_cpus =3D 2; - mc->max_cpus =3D 511; - for (i =3D 0; i < ARRAY_SIZE(data_generic_invalid); i++) { *data =3D data_generic_invalid[i]; unsupported_params_init(mc, data); @@ -541,10 +548,6 @@ static void test_generic_invalid(const void *opaque) 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 @@ -606,6 +609,10 @@ static const TypeInfo smp_machine_types[] =3D { .class_init =3D machine_base_class_init, .class_size =3D sizeof(MachineClass), .instance_size =3D sizeof(MachineState), + }, { + .name =3D MACHINE_TYPE_NAME("smp-generic-invalid"), + .parent =3D TYPE_MACHINE, + .class_init =3D machine_without_dies_invalid_class_init, }, { .name =3D MACHINE_TYPE_NAME("smp-with-dies"), .parent =3D TYPE_MACHINE, @@ -625,7 +632,7 @@ int main(int argc, char *argv[]) TYPE_MACHINE, test_generic_valid); g_test_add_data_func("/test-smp-parse/generic/invalid", - TYPE_MACHINE, + MACHINE_TYPE_NAME("smp-generic-invalid"), test_generic_invalid); g_test_add_data_func("/test-smp-parse/with_dies", MACHINE_TYPE_NAME("smp-with-dies"), --=20 2.33.1 From nobody Sun Feb 8 19:13:14 2026 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=1639587017; cv=none; d=zohomail.com; s=zohoarc; b=NsxXzuz8KbJJokH7OMsxo+l7WHnoIMp8AWkzwR9/q5IeTJU7SMB4yHGrVEY6FEyOBy2hlM9K+ql3gZjfKUTUe6+tRUp/ckcoDjCBGtGX8NryCTC1yGzwCanfFJqzhAODN+MAK2g9taZpa2L+m3nWciHa6lUv6T0FfzzcsV2ydpc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639587017; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=TZ3gZVz3PQYnFV6233ldFCcy6QtI3ljXwdYY5S65e7Q=; b=WQY64B1Mbu+uT9egY+Q4zL/YjS9EopNtxX6C2qafOJ0omtKCL1TQPXY+z+XoYp3JWEHsi6oLVaesdaEJT82dRJOoEoYr4YhcmUoDclUN2WHIIRl8XfAjrC04MDl9WdQs4URe8K2zmZ+dLfy/rYVOwb187WvVyGQsu+8RC6EGvIo= 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 1639587017853551.0828305038672; Wed, 15 Dec 2021 08:50:17 -0800 (PST) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-502-RCMw3HeiP86E3_SQvTf-xg-1; Wed, 15 Dec 2021 11:49:29 -0500 Received: by mail-wm1-f69.google.com with SMTP id l6-20020a05600c4f0600b0033321934a39so9255432wmq.9 for ; Wed, 15 Dec 2021 08:49:29 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id g7sm2096280wrx.104.2021.12.15.08.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639587016; 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=TZ3gZVz3PQYnFV6233ldFCcy6QtI3ljXwdYY5S65e7Q=; b=V1Io5UtfFG2elKTVNHXcNL3ux+R00CEgWVpJwWxJC6sfj4SS1HvxQaYtiTsdxX/rq50lXr Z++FmJvNVAcZhv31VwrYMCCJR7L5NEXNW1yJzjh0J1GOD4J8vsESvGAPXC3zKY56RctimI Vz5qGY0bB8zUPUhtB3utjhslYkIJUYk= X-MC-Unique: RCMw3HeiP86E3_SQvTf-xg-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=TZ3gZVz3PQYnFV6233ldFCcy6QtI3ljXwdYY5S65e7Q=; b=M+0I7noAaAxW6qXYGxNCqyfmjYWCZeOlGnX6tW9VZRuLWlGmUi+8iSQNdMYH1UuxQC 9roIzMvKkzOAlKmY3GORKJ4kKzJTgL01YhAOV0LH9/69yOqsQTTi492qS1B0F0snXlNz WrwKTMBlH9c3gKhfD6L/DHkYaco0Bu0mmhE9NfKqZD0GmM3P7dlKaoT+Fka1pDqBOT0j ir08R3RAPnD3CjAQalfz9RkmfL8/2QvaLgbLWqRAzERhGln9zdzZzHUIG+zuQPPh60QX bEtH/b07qZAsWwFJEMXmy5YNWdHXPv+pEDSi5B8M/FCA4mGNu1qa7BseARlK/IJdjBao f2zg== X-Gm-Message-State: AOAM531pOTPdnxZdGvVRFifyEZjXkMLlPscQsiumBpriQCCrrxdL5UuN j6587KukeFHQwXTaZuR4WGYE2hjUCXJYRDq8BQI1WL8hvaNyzDh88MPAIekgetO5RlyY4NkFoO4 Ljlnz361wSqRfOg== X-Received: by 2002:adf:8b0e:: with SMTP id n14mr5006020wra.281.1639586968208; Wed, 15 Dec 2021 08:49:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyLZRNl/QXAWmtQyPA9iurspmt/Cty8dTXKkBrflwruYnS/bfbzLrk4O0fEL1keu3xvvP4sWQ== X-Received: by 2002:adf:8b0e:: with SMTP id n14mr5006013wra.281.1639586968057; Wed, 15 Dec 2021 08:49:28 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v5 5/8] tests/unit/test-smp-parse: Add 'smp-generic-valid' machine type Date: Wed, 15 Dec 2021 17:48:53 +0100 Message-Id: <20211215164856.381990-6-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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: 1639587029444100003 Keep the common TYPE_MACHINE class initialization in machine_base_class_init(), make it abstract, and move the non-common code to a new class: "smp-generic-valid". Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-smp-parse.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 72e7236afd9..5349ae14824 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -478,13 +478,19 @@ static void machine_base_class_init(ObjectClass *oc, = void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); =20 + mc->smp_props.prefer_sockets =3D true; + + mc->name =3D g_strdup(SMP_MACHINE_NAME); +} + +static void machine_without_dies_valid_class_init(ObjectClass *oc, void *d= ata) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + mc->min_cpus =3D MIN_CPUS; mc->max_cpus =3D MAX_CPUS; =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 machine_without_dies_invalid_class_init(ObjectClass *oc, void = *data) @@ -606,9 +612,14 @@ static const TypeInfo smp_machine_types[] =3D { { .name =3D TYPE_MACHINE, .parent =3D TYPE_OBJECT, + .abstract =3D true, .class_init =3D machine_base_class_init, .class_size =3D sizeof(MachineClass), .instance_size =3D sizeof(MachineState), + }, { + .name =3D MACHINE_TYPE_NAME("smp-generic-valid"), + .parent =3D TYPE_MACHINE, + .class_init =3D machine_without_dies_valid_class_init, }, { .name =3D MACHINE_TYPE_NAME("smp-generic-invalid"), .parent =3D TYPE_MACHINE, @@ -629,7 +640,7 @@ int main(int argc, char *argv[]) g_test_init(&argc, &argv, NULL); =20 g_test_add_data_func("/test-smp-parse/generic/valid", - TYPE_MACHINE, + MACHINE_TYPE_NAME("smp-generic-valid"), test_generic_valid); g_test_add_data_func("/test-smp-parse/generic/invalid", MACHINE_TYPE_NAME("smp-generic-invalid"), --=20 2.33.1 From nobody Sun Feb 8 19:13:14 2026 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=1639586976; cv=none; d=zohomail.com; s=zohoarc; b=H8GttCFckB9JAE2M9EIODpzWq1Z1DQBE09n9jDqjggTz1MPuemMfotC/bZLUmksfRQBP7HJ05ST41mfqEK05L5yI1BbgNc4KUTdiYTnjorTuNncyt9sz3PQHZgcpwFBqXaH2O9m7iesv4jrSfvHXbelYPgaTY3jGH+/8f1zqk5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639586976; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=D0SkCPb2Wszbwa3QNykXiWoYzTzgco57XfQsArolZfs=; b=CrhWLTE1wGEWiOmn61ZzsMkQHyic5VLkIbeeoeUumykzXvsF2bFsQAYSES0K5TaOLk4VSGcKzVJ/bEOjbyW/CZkOdwu1QUr96mkFWr9GtUAaWFJIXTFINZKpTfMr2q3EUL28qAAoMcGWi5qrVcuTXMwH83I6wM88npbJLRhaQc8= 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 1639586976015720.6040186339739; Wed, 15 Dec 2021 08:49:36 -0800 (PST) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-259-JmhyixmEOyyA0kWqAkJ_Qg-1; Wed, 15 Dec 2021 11:49:33 -0500 Received: by mail-wm1-f69.google.com with SMTP id n31-20020a05600c3b9f00b0034440f99123so2290090wms.7 for ; Wed, 15 Dec 2021 08:49:33 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id o64sm2480926wme.28.2021.12.15.08.49.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586975; 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=D0SkCPb2Wszbwa3QNykXiWoYzTzgco57XfQsArolZfs=; b=J91PyIGIwQy7gG1RvFUcLPXMlgQF67+xhYx4zzANuO/X4WzfsfByITqhmz82eDFvux8KF6 l7xt0ZDRoY215TZ6ijHPGeixXsK0r+nnsDEGgB9tUns7zYXSlFOFSWYu73krq1/FlQxOR3 wk9O6IqjyjDQidYJNFJCk0B568xy8Nc= X-MC-Unique: JmhyixmEOyyA0kWqAkJ_Qg-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=D0SkCPb2Wszbwa3QNykXiWoYzTzgco57XfQsArolZfs=; b=FA0xAaxIU6g9FyoyEH3CVYJZjfxUcmb2j+9+NkAAz2wZ8+NT5MIp4IxHR2WiNvo8aE N8AJ1qmPzBo9RI9O0ADfL3m2ZYAO25A6k4Xq0R/ZgtnjHwuybAwuDCuBLdeKNvdBHYPL EW8QRGHAr7I1sie1xxJ8HYX0Actntq47La91BKK46z3wlhj6H4ILFeKM+JPCDMAcamSS 3RGEJsJilGNcHz6Ip/ljnb1LE6WrXt3/2cc9mZUu8B4R470Asfw+tNqsw6ets36LlbcT SC/yXIKuMu1b7lV67qR4X2fRDjVVdWpJkB+zNU5Y2lC9oqWk+8dt80bALB4D26/4Kn3z fTyA== X-Gm-Message-State: AOAM531SsAEPonzNotCi6uONVuwlT7HHxIrkTMq1pq3jdgN7TfpoVdg+ NbO0wmM/SrTv93weZ//yjEoer6zFSXznBCDcFheuncYssIFnY2Xiv52Ha5PGvVe0d4unNYxNDGZ DQ/6Usgval8U0lw== X-Received: by 2002:a7b:c2f7:: with SMTP id e23mr743146wmk.92.1639586972600; Wed, 15 Dec 2021 08:49:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUh5gt6K62qDoWHEvtRipwUyEYToY0j/sL2PlV2cCMr4cBHVx4QqF22sqe8KUvvvqZF0MTjw== X-Received: by 2002:a7b:c2f7:: with SMTP id e23mr743129wmk.92.1639586972422; Wed, 15 Dec 2021 08:49:32 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Jones , Richard Henderson , Yanan Wang Subject: [PATCH v5 6/8] tests/unit/test-smp-parse: Simplify pointer to compound literal use Date: Wed, 15 Dec 2021 17:48:54 +0100 Message-Id: <20211215164856.381990-7-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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: 1639587008888100001 We can simply use a local variable (and pass its pointer) instead of a pointer to a compound literal. Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-smp-parse.c | 66 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 5349ae14824..251c83c60c2 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -520,19 +520,19 @@ static void test_generic_valid(const void *opaque) Object *obj =3D object_new(machine_type); 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 object_unref(obj); @@ -544,14 +544,14 @@ static void test_generic_invalid(const void *opaque) Object *obj =3D object_new(machine_type); 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_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 object_unref(obj); @@ -563,45 +563,45 @@ static void test_with_dies(const void *opaque) Object *obj =3D object_new(machine_type); 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 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.33.1 From nobody Sun Feb 8 19:13:14 2026 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=1639586982; cv=none; d=zohomail.com; s=zohoarc; b=GtQU6ZMW9BLS0dysSfySN7OxXZ6gseed8zA5CTKRi4+BNwylklz9TrJMgZEXK7lvgnhavDG0Xo1k66iVih7s/cTqwVTgTeLNrzg3OZdmVxTM96FEEdJLjzWxhQTP3KUp5x0BIzRgBvWyzkfOKw77xDorPtyfN9nYWDJwLBlve5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639586982; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=qKTQTHa1hb0SLmS1AjA4KYFgifkhSYsgZCXWCGHH/MU=; b=fBRZokuWtOIiBZX9aKuF+S1Il0aQ/zV0KUslbTGI6L0jPSFJGBSslKx9sV0EOg1faggMgHoiTQzak42xoildwjbqtpoZWFXBTxQDn9Mm3qnnjtX7X1J4ARgtafWQFUIOPAJNcUjaaWYu2vBFFZGVUnE4HFwKPMRf4LT3HPM4Xnc= 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 1639586982345628.1124298498869; Wed, 15 Dec 2021 08:49:42 -0800 (PST) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-CIUSj0MYOfSpQbVTqrQHEg-1; Wed, 15 Dec 2021 11:49:38 -0500 Received: by mail-wr1-f71.google.com with SMTP id b1-20020a5d6341000000b001901ddd352eso6113415wrw.7 for ; Wed, 15 Dec 2021 08:49:38 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id z15sm2333023wrr.65.2021.12.15.08.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586981; 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=qKTQTHa1hb0SLmS1AjA4KYFgifkhSYsgZCXWCGHH/MU=; b=FW7CQpZTJ/uxQk6ndI4fFr32hFSJqyowIyR2IlCpapdHhey+9lfRac3PBlzbnmGqCPyMaM amhiDgXr4BBVwEglkGCJaZ6uKzgqGolSVjtKCYgZSQPm/a1PZGSre2uWfHWhnIlzx871Ha TZYdfZcE/2QyQFJEEDvgu1mylpCTAbM= X-MC-Unique: CIUSj0MYOfSpQbVTqrQHEg-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=qKTQTHa1hb0SLmS1AjA4KYFgifkhSYsgZCXWCGHH/MU=; b=y2oat0rjS830GBFfxqRl1LpPOenqJr0xvUTBgc4C7ln+WlYgKaj3k8313vGk5J3mwG 1NPvsggUaEjR1M1fEP+RUfN/SroPKSoRIlqPjsZ4ly76xEsYMqKd2eeOlsQZO/abcQyo 8TkLfaJCbjjY4/NHyjHvn0NllH5CZLO8+WhBzdQ16ZSMLl8EOfT0uZFE53uapwJSLYyk RxWefgwQQRnYYjPWTXRKuScpE+i4JEUWNJ9bekZfgOhdxns0D94dxJIftO6i97Gz5jtL u52IYgDFerwRzr2H043ncqV+Lk0b0kQAkrZSrbI/fmWsDncQ/X/H/aP462f/heGAwbyj GOZg== X-Gm-Message-State: AOAM532g4RBNxC/CqiNhWRULIVFk9pA34L++fiVbIWpGh1FLIMlSPeoJ VfrFjmDf/UrjbXYOOFXuXusiJlEVshlGVDsq+5KiEVNKKa/0niLIg2rpG4SJxbMQyxvdFDV/mxR 6mnKNux1gZUF78w== X-Received: by 2002:a5d:4e92:: with SMTP id e18mr5327174wru.89.1639586977027; Wed, 15 Dec 2021 08:49:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJo3BmYeKI5A5faSWgVV4zxE03y+Be0PSzuG2dBR73uIYvIM1HLURPQluw+jS1AbmQIlFYzQ== X-Received: by 2002:a5d:4e92:: with SMTP id e18mr5327158wru.89.1639586976864; Wed, 15 Dec 2021 08:49:36 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Jones , Richard Henderson , Yanan Wang Subject: [PATCH v5 7/8] tests/unit/test-smp-parse: Constify some pointer/struct Date: Wed, 15 Dec 2021 17:48:55 +0100 Message-Id: <20211215164856.381990-8-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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: 1639587012168100001 Declare structures const when we don't need to modify them at runtime. Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 251c83c60c2..1f26edc5f82 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.33.1 From nobody Sun Feb 8 19:13:14 2026 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=1639586986; cv=none; d=zohomail.com; s=zohoarc; b=jARJupjAYjSkVSUmWCXUbUbArc9QhWs4B5/S19JTKezTU8jnhjtG5rtp6V3lyJfthF2Ar662YHFyvaK7sLKn3XenBjNRyRaHGRm6rGz0wPcdcRwlhZisykR32KUHrL4sd8Suj6WJthcsic5N38OELIDk33ofFZrMOUF7KOS2J1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639586986; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=BmkMZOil0JU/xcw7wrU9Zc8Yh5vuQbVB83QLL1RhrjI=; b=ZUA7A5YADUndLlRezPNKt9U3SHBBebEJOUFu9jSqP392q9R/ZTgX/c2B6e0vC6LHD+W8F3B5g0YDeH8pJxmxF6zQVWD0FFYImBR0nOOkN4v4I4Ts+lTSNVyKph8XDgPCXGRVb087Xp9e1TLksB+SuYX86G1d5XQvRk3ooeKLTaU= 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 1639586986792639.6766368642349; Wed, 15 Dec 2021 08:49:46 -0800 (PST) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-28-8QRApSZwO-6bqDwul-Bysw-1; Wed, 15 Dec 2021 11:49:42 -0500 Received: by mail-wr1-f71.google.com with SMTP id d7-20020a5d6447000000b00186a113463dso6064559wrw.10 for ; Wed, 15 Dec 2021 08:49:42 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id w17sm2605539wmc.14.2021.12.15.08.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586985; 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=BmkMZOil0JU/xcw7wrU9Zc8Yh5vuQbVB83QLL1RhrjI=; b=QOcybVe7VyYPfXL0pKwUcCwJq5MuizpYMc7k/f60clLBkpyg+6NmMSBL6wmTIauFKHqdYa G1BLpnGPeiv36CLMiuKOJCnk743uvjFHllhjt+eeABBGyT65Vu2cip+KEko3R0WrKCjpyl 2yPTpmuqulASMLAr1oy2+kXScZNMBO8= X-MC-Unique: 8QRApSZwO-6bqDwul-Bysw-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=BmkMZOil0JU/xcw7wrU9Zc8Yh5vuQbVB83QLL1RhrjI=; b=DnaJvZY7rQ4TNkavIr3ikgVTFvwwMef7GjRvlP44iq9MJwiecKHSn+8et3AgnXj1oH RV0PFr3o9bcSbXZ8MB1CN5c0ziT664CBTvq0IHbU7ZzlCcCbxgTn2Wjp5qlI8vdHUHZP V/N+cAkr90GkLegSRCasiyy8f72ovMAyLc8ovwv1JdjLFp9RUQ6gWDCUwaIu4eSrO2H4 tqHfAjJF35NNIkZ27sfERhwrObs4AlRVWgAs7gdXPtgeQAw59eneX7CFZrONAORmZ0t5 VObjfbdclJ6NvKW62E6eZg11vyqT8gUg47dqDjaR9N0gVVOUVZfZFnl1/Woz6Ak09SwT vTew== X-Gm-Message-State: AOAM531FXQIaLJQDFuqPwXLe10GKpMVRuHREHrmN9H6rXF0PlMtsYYPa cvHavGSuf+1vA4wYwa9l0OsYxlsIHzLF+nRdWN+LiyFFXiSNXTmH9uvvOE29Mzw3SXh5oX1I5ND 4HLfOp9QjHHWX1A== X-Received: by 2002:a1c:9dd4:: with SMTP id g203mr756579wme.114.1639586981440; Wed, 15 Dec 2021 08:49:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlZgpxaYpwpnsenpIfwM7p0/811ln/m4JkvZxNNTIz/Wk3OCTK6xU55UsUS3mTrunITmJACQ== X-Received: by 2002:a1c:9dd4:: with SMTP id g203mr756569wme.114.1639586981270; Wed, 15 Dec 2021 08:49:41 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Jones , Richard Henderson , Yanan Wang Subject: [PATCH v5 8/8] hw/core: Rename smp_parse() -> machine_parse_smp_config() Date: Wed, 15 Dec 2021 17:48:56 +0100 Message-Id: <20211215164856.381990-9-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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: 1639587014815100001 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. Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 53a99abc560..3993c534b90 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -761,7 +761,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 1f26edc5f82..7f5c4ad222f 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.33.1