From nobody Tue Feb 10 04:15:59 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=1636988353; cv=none; d=zohomail.com; s=zohoarc; b=DfzYwuoNk6Yl8J2Au1Y5wk7LQGIqm4Vi8Wd0ANKTwaatAAYSGzblPjknw2j0wTwTRjkqzYy7EMr9PbD1LNO1XbIn3DwwPatw0z1wU3oaKM56t0B7nAQl3lABi36U1Qj8mjNEYUQ2BoeS+LHRTCGZHjLRIQDynGresY11vksdIuU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636988353; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=5aBWgeT8dX8n5hQ5ktoKDC7N22O1xIWSsGNqfC8T6cI=; b=khsRQgvHGd5UxO822aNzxXtN8qs1GUgpIKSvAt5tH5ixqF5uthC1ICSC4JxVp7b1qS81N07AOtZYwuG6L+h/beaSWMl1hCRoPJfAs2GA55WgeV3OWmNpXp6z+OTVVVm8nU5Fyi3NN07m6qcHKwsi4VGSjrk8Dt0ieIQZnarLQBE= 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 1636988353959844.1281943452993; Mon, 15 Nov 2021 06:59:13 -0800 (PST) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-274-oBqBc3iYMISZEwoPYUocVw-1; Mon, 15 Nov 2021 09:59:11 -0500 Received: by mail-wm1-f71.google.com with SMTP id r6-20020a1c4406000000b0033119c22fdbso6319623wma.4 for ; Mon, 15 Nov 2021 06:59:11 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id l5sm13007464wml.20.2021.11.15.06.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 06:59:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636988353; 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=5aBWgeT8dX8n5hQ5ktoKDC7N22O1xIWSsGNqfC8T6cI=; b=FgZeXsQzy0dboNcELF4SMmz8l6U7qe7hgBzu36c5A1cKuhBDwysdJ94XYVXWegN9s5zvcd jnRvzRZIXB0W3ERNUzt6wwspUkdIypb8pPpO6kI2tUWIhOqSOhRiWXXzp0I/9uLQt7YgML uXrfWapT10kiW7bRAkdIqkR2phtAzPw= X-MC-Unique: oBqBc3iYMISZEwoPYUocVw-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=5aBWgeT8dX8n5hQ5ktoKDC7N22O1xIWSsGNqfC8T6cI=; b=xb21sV2guwxKj9aJx8VYrN5wMeIccC8KoKKskBFrbsyOG/B8FkrsxS6zHq0ykxV06i PQHDBBkdjiRt4ABAeltsIW0GnPV9NpQ/g59uG83oiGh4/EaMzadt1ddVy0/KQOEcLRKG HTpiqTQtWglPn4mqGbVHnrgPB2H+S0IPxspMBOEUtOcEmLPEY2oP3C2Sx9Dj6V4Ou4dg ISbJwzympv1qru83jyrQjN3vne498N61V9QrZ8vq2CHCgRmhilKd72PsTb59soOxIWDP KOzaeUTysCd6DxiTx0bWQx4Wl65oecPcn7UwLlNoP5IP+34JSCrxblbwqC8Wa6wsmt+S pSmQ== X-Gm-Message-State: AOAM531W6e84tO7fHoz+wK3+zIEUwkV4TofjeTIcYBvDtCBiiABZlJ2z fVQgeOszW+9jS0vT+zGj7isHPNvpcuwEfbCgBWS6vEVIWLaoNL3rM/q6iKggCsP//NaAEH1sOqE MFWw8HOclNvU8aQ== X-Received: by 2002:a5d:4704:: with SMTP id y4mr46850737wrq.85.1636988350575; Mon, 15 Nov 2021 06:59:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5Sfp5AM6+xO0tVEMe/4po5R+MIwLeW8l/RmHHIhz5RGCmDJZPaa/VBr0hQVulmXgq8Vrr/A== X-Received: by 2002:a5d:4704:: with SMTP id y4mr46850721wrq.85.1636988350453; Mon, 15 Nov 2021 06:59:10 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Andrew Jones , Eduardo Habkost , Thomas Huth , Marcel Apfelbaum , Richard Henderson Subject: [PATCH-for-6.2 v4 02/11] tests/unit/test-smp-parse: QOM'ify smp_machine_class_init() Date: Mon, 15 Nov 2021 15:58:51 +0100 Message-Id: <20211115145900.2531865-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115145900.2531865-1-philmd@redhat.com> References: <20211115145900.2531865-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: 1636988355477100001 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. 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 | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 47774c1ee2a..3fff2af4e27 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_base_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); /* Force the SMP compat properties */ mc->smp_props.dies_supported =3D true; =20 @@ -586,12 +576,24 @@ static void test_with_dies(void) object_unref(obj); } =20 +/* Type info of the tested machine */ +static const TypeInfo smp_machine_types[] =3D { + { + .name =3D TYPE_MACHINE, + .parent =3D TYPE_OBJECT, + .class_init =3D machine_base_class_init, + .class_size =3D sizeof(MachineClass), + .instance_size =3D sizeof(MachineState), + } +}; + +DEFINE_TYPES(smp_machine_types) + int main(int argc, char *argv[]) { - g_test_init(&argc, &argv, NULL); - module_call_init(MODULE_INIT_QOM); - type_register_static(&smp_machine_info); + + 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); --=20 2.31.1