From nobody Mon Feb 9 07:55:47 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=1637016496; cv=none; d=zohomail.com; s=zohoarc; b=SlRyLLD/2QNHsO3A6YUQQbdERX44Rem/tKzj4oA/4Her0cZ3LwJBALUWoHwJeLyK019qWNg7W/mptWUPvgnXNA00c0XYoTcA/R8vTpaj0YTp570y0CLwq4I4QU+41I/loPrrOPrnXP1uxVGQXuUS5rdbiw0FMl81CSDLTQjJE/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637016496; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=nEd/ygkIQTZNVKYYqfDQ3gUYWshnM+QoFjlZKizg/LY=; b=gjb/e9iOfVR0y9tk6ve1W6G0qiElF7OUhC8iyzos5cb4IRw1rb43BjeLuE0Ty1KsGndOPgr9VBLpT89PnBD5qpzpEIasAl5ox4KMGvBj6iz/LjFYsvFhGAAfqd17hQJb+V4teNXYsYA3X95a1sQY2ljExkmZZvgh7RXR9IBbljw= 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 1637016496703929.9486166504557; Mon, 15 Nov 2021 14:48:16 -0800 (PST) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-105-ZNJnjY7JPvOo2wCvx6NfcA-1; Mon, 15 Nov 2021 17:48:14 -0500 Received: by mail-wm1-f69.google.com with SMTP id r129-20020a1c4487000000b00333629ed22dso245500wma.6 for ; Mon, 15 Nov 2021 14:48:14 -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 n32sm569230wms.42.2021.11.15.14.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 14:48:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637016495; 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=nEd/ygkIQTZNVKYYqfDQ3gUYWshnM+QoFjlZKizg/LY=; b=F8cMMQhOe9e5wqsqBNvS50fZ2V5rUUD59PS2pyZ1pbz3pEIOaSA1uHYLSSlHTcHxo2zcB2 d22c23hYV0riRU8nlb12xzCwlWDrenrIVphHjkI3UAwaviF7J3ly511hIYVRdcJxLYziZG vEtO+FBvUY563yyyckVNUdgOh16Exp0= X-MC-Unique: ZNJnjY7JPvOo2wCvx6NfcA-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=nEd/ygkIQTZNVKYYqfDQ3gUYWshnM+QoFjlZKizg/LY=; b=oNy1eo/wcijs7q6zTmfYuabBMLf7PblckHZIE/sntAyQWu9BRdc4IGNXgpoNwEgXM2 1bp1X05aAUWY3wovp0cF0y+0MeLHQX9GSEAecJRgcSsVOcEl5cSN2a6GpqUpqbmw/KZt ha3MPzHMTsFwYddjNhfDwS9ibXo1WTct/2G0mnOF366DyPg5fyv62DWvTcSYZ0IL/G6D aar4U9d943dOw1GTe4tidfgbApIikc9pLmEOtzilkvuaUHEKaCeVIIfieFJXRBJdCkWK uM9t7R3cJoqp0iarBOEXPiOhOK5pqjn5wcOVPqNtwgQWDovNShUk/ZUkOMPg8dRceMCK OS6A== X-Gm-Message-State: AOAM533SPY1fLVqQB8yxJdsrXoFRKik1vUNQJqmbUrcRYCtYoBMRBf9A iLhpBFboRie+DfzIKncni/9yRZLl13Gg2GUba4eGxCai4ZoZheqJlQ+hiTEDQKceYsSasa7wkoA ijAzNWSoq4NdL7Q== X-Received: by 2002:a05:6000:1813:: with SMTP id m19mr3265210wrh.51.1637016493105; Mon, 15 Nov 2021 14:48:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlw6Spi22UL5K2B0CXJ+L1BIp50mO4OVEhJnoBZMR8wfvCTeavkZcHpNbKuDxei2CobzlXqw== X-Received: by 2002:a05:6000:1813:: with SMTP id m19mr3265194wrh.51.1637016492993; Mon, 15 Nov 2021 14:48:12 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Andrew Jones , Richard Henderson , Yanan Wang Subject: [PULL 2/3] tests/unit/test-smp-parse: QOM'ify smp_machine_class_init() Date: Mon, 15 Nov 2021 23:48:01 +0100 Message-Id: <20211115224802.2602894-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115224802.2602894-1-philmd@redhat.com> References: <20211115224802.2602894-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: 1637016498327100001 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 Message-Id: <20211115145900.2531865-3-philmd@redhat.com> --- 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