From nobody Fri Dec 19 07:16:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636625045; cv=none; d=zohomail.com; s=zohoarc; b=duuJVtRvfISeAvpn7o2/Dc8wFWemGN9P2k+RqriTRSWgLscvd5LEei5h9279IemABb+6mkGZYfIGll3+Azzhp/7RZsCYCTlx5UzOIVFAKZtEmNTAF8WgoRebeo+4HRsga98KGNmRSmtbqDws5rrPhp3u4oJHbG+2dCiOsa9O6tA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636625045; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=aQ1GdzcB7LjSoWeOeDhq1zxy9yHw2IVmuuwVgLYpvfQ=; b=OREm9nNd7fzUFDEpNgKdYJHAq2IdKPDI5zjQmzrku/Vf4yNIGYwcc2KKlNGvPf1cFnTCH5LeVS5sSbttNjbGq1BZsQb/e+hvb3j6S1F3hV/cKtcNU7xSdKlItitl2bAum2BCYGRM1OJ0RyYWCDupUtK4VAU1Z+03cn18fOGmroo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1636625045416737.6862335143228; Thu, 11 Nov 2021 02:04:05 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-355-lJerQ6tkMCKxeXTYYe_xsQ-1; Thu, 11 Nov 2021 05:04:03 -0500 Received: by mail-wm1-f72.google.com with SMTP id 144-20020a1c0496000000b003305ac0e03aso4530966wme.8 for ; Thu, 11 Nov 2021 02:04:02 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id l124sm8381601wml.8.2021.11.11.02.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 02:04:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636625044; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aQ1GdzcB7LjSoWeOeDhq1zxy9yHw2IVmuuwVgLYpvfQ=; b=XAIq3EHgDzhmQRjEhJHA2cYi+G0nt6hL8woFxRyMTEoaZI1miog8dClu96wKGJ5qlsxv2P 5nG4WjYszFyAG1XmjsUzsP8G1M7hZlZfoOo0pIhlUdFXUE9STEXR5GUHIQocFl0pXHGKPw LW+KeyNElj8BDTTSa1TQOpHLBORMVvo= X-MC-Unique: lJerQ6tkMCKxeXTYYe_xsQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aQ1GdzcB7LjSoWeOeDhq1zxy9yHw2IVmuuwVgLYpvfQ=; b=ZawMzmIYm9LPYpnaMCmqPYMPGku9Y7GpDAu6j3qtTei5SGxvsJRPfOKynYfhLMlGfB fO2XiYCitVfyHcDQ/TOmBViZf1koEdBAelHijfzTN96nHhs6UaT6BXv6Vo1sPWu8n3fP 6upEHvivhZozm5NihFPLPsYKUSM3zoZx1dSzFSFP2vzT/5iv6C++gzBeNux1Wkqdpt75 SP8ICwVzs3y+bD/BnIIVpMta3asZ5nndni0Yj8ObcGGgR7wM9Xj0tHFRBORuzN37ik35 9nx5kdTt9Dv11JFtPbTT1jmTprFXEA45mOiT86/dD2cruoT1OTvwxfWOGoDY0jBXh08S 90dQ== X-Gm-Message-State: AOAM5339qgjNPQwCtD+60cvnnya3Fq4yZhyW2T1MT4dQRRDhNt3OZ6C0 nOZLAD5IPw/FMvAS9LURJAiSUW6Ifjhwl3CAgO3rr+oqREqz6nBMlDrsxunT3A2yvp+2GUw8I36 L3wWRQleZSUxDlA== X-Received: by 2002:adf:e682:: with SMTP id r2mr7490321wrm.281.1636625041959; Thu, 11 Nov 2021 02:04:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4ZoFof0DtjTfl/siX1LXfxngQIqc6TrdBbvk7BJRctnx+i3Z5gvgEzJxFsOEux18Qx+gfsA== X-Received: by 2002:adf:e682:: with SMTP id r2mr7490292wrm.281.1636625041819; Thu, 11 Nov 2021 02:04:01 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Yanan Wang , Marcel Apfelbaum , Eduardo Habkost , Andrew Jones Subject: [PATCH-for-6.2 v3 2/6] tests/unit/test-smp-parse: QOM'ify smp_machine_class_init() Date: Thu, 11 Nov 2021 11:03:47 +0100 Message-Id: <20211111100351.2153662-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211111100351.2153662-1-philmd@redhat.com> References: <20211111100351.2153662-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636625047370100005 smp_machine_class_init() is the actual TypeInfo::class_init(). Declare it as such in smp_machine_info, and avoid to call it manually in each test. Move smp_machine_info definition just before we register the type to avoid a forward declaration. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang --- tests/unit/test-smp-parse.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index bd11fbe91de..51670297bf9 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -75,14 +75,6 @@ typedef struct SMPTestData { const char *expect_error; } SMPTestData; =20 -/* Type info of the tested machine */ -static const TypeInfo smp_machine_info =3D { - .name =3D TYPE_MACHINE, - .parent =3D TYPE_OBJECT, - .class_size =3D sizeof(MachineClass), - .instance_size =3D sizeof(MachineState), -}; - /* * List all the possible valid sub-collections of the generic 5 * topology parameters (i.e. cpus/maxcpus/sockets/cores/threads), @@ -480,9 +472,10 @@ static void unsupported_params_init(MachineClass *mc, = SMPTestData *data) } } =20 -/* Reset the related machine properties before each sub-test */ -static void smp_machine_class_init(MachineClass *mc) +static void machine_class_init(ObjectClass *oc, void *data) { + MachineClass *mc =3D MACHINE_CLASS(oc); + mc->min_cpus =3D MIN_CPUS; mc->max_cpus =3D MAX_CPUS; =20 @@ -498,8 +491,6 @@ static void test_generic(void) SMPTestData *data =3D &(SMPTestData){{ }}; int i; =20 - smp_machine_class_init(mc); - for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { *data =3D data_generic_valid[i]; unsupported_params_init(mc, data); @@ -539,7 +530,6 @@ static void test_with_dies(void) unsigned int num_dies =3D 2; int i; =20 - smp_machine_class_init(mc); mc->smp_props.dies_supported =3D true; =20 for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { @@ -582,6 +572,15 @@ static void test_with_dies(void) object_unref(obj); } =20 +/* Type info of the tested machine */ +static const TypeInfo smp_machine_info =3D { + .name =3D TYPE_MACHINE, + .parent =3D TYPE_OBJECT, + .class_init =3D machine_class_init, + .class_size =3D sizeof(MachineClass), + .instance_size =3D sizeof(MachineState), +}; + int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); --=20 2.31.1