From nobody Sun May 19 00:47:39 2024 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=1639660833; cv=none; d=zohomail.com; s=zohoarc; b=QhKy1Bs6WYFz2VLYSCOkzs26qc+boGTYbFRF6Y8VFKz2OYd1JAda2GgH97cNzkKzu38NwKpRHILSy7qBDD9B+s2lApVOzDRtkVonTD3vPI9zbv6ZWAbU5qdABov61eN1Nq2yeXQgsNVP6kW5vvH7XY58bILEAO91EcoD2VcaXPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639660833; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=t0HaJa5hL0xbci94VgrhNJFI3KFO8etTJC6TchOuXSE=; b=B8NVW8RzFIvlCgYYatO7h0pq6ZyAoX/TkoQJgZPE4KL9pPTnnub4dZKXh3kY1sjcaYJZ5yfAdKS03eNaOPP1YgpS6k3SSBmu4RhmU95ZVvda4ri/Gx0f6+9+vrbeNG+gCwiUjyi8BBvr3r872kpGwj8DuL8Af8GrXjAohhjEZ/w= 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 1639660833009155.71424255777526; Thu, 16 Dec 2021 05:20:33 -0800 (PST) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-457-pcidkIRUPMegwfo0KzVP9Q-1; Thu, 16 Dec 2021 08:20:31 -0500 Received: by mail-wr1-f70.google.com with SMTP id a11-20020adffb8b000000b001a0b0f4afe9so4121378wrr.13 for ; Thu, 16 Dec 2021 05:20:30 -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 d13sm622953wru.41.2021.12.16.05.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660831; 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=bQcH1X6TNt2odHXy4h39CyrvoBfwqc0KPN1+AqPIZ0xJX41NhdEiHC9pi5lKZHHGaRkUCa xPZRfGLkvLM6XJTOite0AD4XdUFm5nNqiCh72lpVI6kpY3YljLta0264bjY69n3y0jUn46 QgjdlYx7Xvt+GcXn+5OSt7l5z3r1j2E= X-MC-Unique: pcidkIRUPMegwfo0KzVP9Q-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=nNlA0cMPQKrbxoW3Q+yfpq1sb4gkMAR+V1N62mMoZZ3/SnQZZ4DY2SL+fYMVbVUwfm DcIg1hoap9+oPjh28jSYqP6nKZTrRWplzY8ed5OPSg6293ApST+MmVOzDh2Haj6nxDj5 LpgOIR9iWFSV737ttxFcuHwRrg+t6dUw1LFwVgf6dGsrFIiyJvq7UD3vWoPJVINXfuuP GD6eqXE+h/VN2eh1pJ6YDCpvqufJihrkVmzzinulCb7b8NLNFAOhAAdxqeLLw5NpKL23 nh0dNNeSqG7azdSlH+7O9lChSzfQSv7LSGAbmctrex41x7uY6PZbXZktwDcpBElVukKB toqg== X-Gm-Message-State: AOAM532C2k5NbdRMPdbjIF07HkLAxBpNeWvnwzeJYNpRA7z5Y6ja+Hb4 tGDkiZIwZPSveqDNWNUHOXIheLCQ6bH5e3bngYGSmunCHxt2bRt3BsuyVdvjJt+FwTEIQXV0RWe bPXnim/2vlEczow== X-Received: by 2002:a5d:4486:: with SMTP id j6mr1263865wrq.160.1639660829883; Thu, 16 Dec 2021 05:20:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQ8DG5F2/GyHtKr4ceY/cv2HsvzJMgdXn0wjTMzUVOvZl4mD4Z+fq+HLBWqw1JPcGEtabUNg== X-Received: by 2002:a5d:4486:: with SMTP id j6mr1263857wrq.160.1639660829743; Thu, 16 Dec 2021 05:20:29 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson , Yanan Wang Subject: [PATCH v6 1/8] tests/unit/test-smp-parse: Pass machine type as argument to tests Date: Thu, 16 Dec 2021 14:20:08 +0100 Message-Id: <20211216132015.815493-2-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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: 1639660833715100001 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 May 19 00:47:39 2024 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=1639660839; cv=none; d=zohomail.com; s=zohoarc; b=k6bbIDP/vORamOXDaWNeApni/DTxo83Mv1u09kLscacQtQ4xD0eoF53KZReIohvZSOorKp3isZ13oot2PCNmuKbkhuL6XpMALQxtECqo1YejGQPin70MsqlsGxnqHhVuSd5gyHrpbFFyLXO4ymTVczdf0TpBo6uPV+wU2Si8VxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639660839; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=GXx7W8UBpOZBRJ+rhAKMv79kybQ7cCiq3Z9AZnQ5faU=; b=jyn01Uy26aUglNr2OnZ5Sw5GVpnHuQPqfAABsetyadZb8ShRJMORLsBXoE6W/VfEkZOYDP0hp/Viah8Tsycusj2bRqqF6HpUApkUnfuQOXSieTH7fPswJj2hpXP1H6ohoC5+6XmLNxi6VHYAUjjEyLCyOwEd8lj50+U8qPJNVBs= 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 1639660839319428.7236810158631; Thu, 16 Dec 2021 05:20:39 -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-323-yXvEuC4sOsShM1OaGKMwyQ-1; Thu, 16 Dec 2021 08:20:35 -0500 Received: by mail-wr1-f71.google.com with SMTP id p17-20020adff211000000b0017b902a7701so6912537wro.19 for ; Thu, 16 Dec 2021 05:20:35 -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 b13sm4913829wrh.32.2021.12.16.05.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660838; 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=bGCup/HQtFRlLR/nVnFO0NvMNrxK1FWH8IJHkZfmowNJhLIJQkR+hmrlBjujiQb1LWBsog BbinYhPGBRLo9hOyOtTg6dzolaf2higxQItcz94nIy8hvaj9An2py8WqohLn/I14nm0K9u 0Od3GLdmngOdpHD2p8uC1vd47JtCjuM= X-MC-Unique: yXvEuC4sOsShM1OaGKMwyQ-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=LdkHGOFVM0XYl1k2Dc3pQLmF7abuniiEOVJHKb8vGJWzNG+Z9xdBuESW5A+sjj6vHc chnDjsgGw+mD3aZ0cm/dcNKPj+7EvRUVplGiVjp2VNwidPnOsMu6kLDFmughh3tUCiRd cjbqv6vHSuAj+lKWGva0s35ObJkdYe0tWyDypS60VEwEsgwWJr1kG/rOPMuT3pFxqpFX ijQkrSdWWb44BS2K8F8DIvpdYPBkctsHI4kTNnV3BgHgQrR/lHwzUP/Xq5ZnUTKVJ1VX Dw7klkVQ0K8dwK5HZiy3CipqHhZC2Mahs5ZHd+3aRhUL49wFhSpPlr1mfuQuXklWof7q Snxg== X-Gm-Message-State: AOAM530Y6PgY41ekgPJLIJ/9qFlbefmrjkc1NUUdkZORKMnTIDU18PfI ff3PE3z4vfdA1QupHj2UywOlH5Qag6TsGiF6BbvnikA4n5wsUKcAPCaWzt1Qw9WmfRbZlP1wjPF aquU24pkVO68IYA== X-Received: by 2002:adf:f40b:: with SMTP id g11mr2246640wro.645.1639660834160; Thu, 16 Dec 2021 05:20:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0ivJJuE7YYVPPtmTmDxTvvNMxH4jY1xs7qs0KFisPeXoVwTJUJVCYOIyMABEJ5KhM1mUpvg== X-Received: by 2002:adf:f40b:: with SMTP id g11mr2246626wro.645.1639660834009; Thu, 16 Dec 2021 05:20:34 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson , Yanan Wang Subject: [PATCH v6 2/8] tests/unit/test-smp-parse: Split the 'generic' test in valid / invalid Date: Thu, 16 Dec 2021 14:20:09 +0100 Message-Id: <20211216132015.815493-3-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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: 1639660841120100001 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 May 19 00:47:39 2024 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=1639660841; cv=none; d=zohomail.com; s=zohoarc; b=VQG7UQHbqYEi0yIBunNCbcNcRUdMBWqBJTgYM8lyXJAnD2Q3XN6LQ+EkPz1qPz7buthVU8PRopQYMa+PWVflnZeGi+tf9D5TzlR2Gs/P0OPnuHq0H/1ru+arTiR/1032hWgsil9wCDTC/qCFY+y/yQP1x8vCOjmhUkY8MiuDwmU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639660841; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=1chFsAOK0rTvA7TehLOkyqZafZUrvfp4t7SGxNleGGw=; b=bG/dKPp1ILv0XC9I1abEWoLZsv6LFVdXUpaq363eEH7+6ndz5Chutz2efKhIEokHzDxRCKXCDsxRkcE0ch5qmCFWiceB/+ufh12DbEiLnHGXc6UFqBSPCEk2935GJtv6QuCZF/81L0uaX0mGxWSZurOuVST7k45Qwinc+Cneqp4= 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 1639660841636255.55655389236097; Thu, 16 Dec 2021 05:20:41 -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-214-e_CLlFcpMlm6fqb0fq114g-1; Thu, 16 Dec 2021 08:20:39 -0500 Received: by mail-wr1-f71.google.com with SMTP id p15-20020adfaa0f000000b001a240b45c1fso610711wrd.4 for ; Thu, 16 Dec 2021 05:20:39 -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 t11sm4597752wrz.97.2021.12.16.05.20.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660840; 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=UKeLArtn1mF4w2MoUm378xRwmxnSMd/SuSSe66zY/2yCyDizXpks/xeLCZvFQQC8YLAnm7 /Rw3I8iFGoESb/qncik8hxgtxTi9Y1ENAzja0CFd814To3GP0bpv9hEbQD3pRH2GuKalmd 0YJORsljHTNI7tNRkU3nkq20FkOZMQY= X-MC-Unique: e_CLlFcpMlm6fqb0fq114g-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=2u661LAh5/pRU39T/wb/pT8MbjfniQptigX1E8VI0lP7OCAdjHyO2Ruxg36syM3x4n lMu2Hw6p2qs500i5dYj7IpTZDngHnhVYvTuZArfkcKm2fwHABQrgMzufatNmPUZTrwaY V5o0Yd0hlOPY57H9fPa4v2tc5/3M7zRpUyImty8EqU1HssTtRBOhfRKsDy3XSKyk228V HHsNa0TMJ8CEZtIlOI7Aje9egtcKxEzzIXbnJIrCcuCOy2iFtunnT6wIxvEGcbS/65wC DUrIzzyl3a1GQy4mCvm1NIXsriLHSPH1ekiSlkP5vRDUIFpdP+c767jSrnmMPV0bfpaG 2wjg== X-Gm-Message-State: AOAM531zCIIzrXvX0CbL8OvJ6tggNqsiiU6ecg26kwyZo/U/jF/A5JBZ RmAOu7KkWLnxhNeeBZdGkcBm6USaWF1GYwZJJqFYeD5kXCPkVd8F8sDlTKZaCyoNILRxMPIomyL iapbIzlRJa3bs+Q== X-Received: by 2002:a05:6000:104c:: with SMTP id c12mr8638539wrx.588.1639660838492; Thu, 16 Dec 2021 05:20:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9FyDLN2KLSJxbfwjviG1yY8ZaRuGTvyxYv7cYvz73wWlktpKvitGPeP6AifT0+LQF5uwrZQ== X-Received: by 2002:a05:6000:104c:: with SMTP id c12mr8638525wrx.588.1639660838335; Thu, 16 Dec 2021 05:20:38 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson , Yanan Wang Subject: [PATCH v6 3/8] tests/unit/test-smp-parse: Add 'smp-with-dies' machine type Date: Thu, 16 Dec 2021 14:20:10 +0100 Message-Id: <20211216132015.815493-4-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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: 1639660843887100001 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 May 19 00:47:39 2024 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=1639660846; cv=none; d=zohomail.com; s=zohoarc; b=bv8//JBAj2EgusfahH0YGke63QvIAhw+ntibCXVra0jKMx8bDfp9yxEC24mnWh3rLI4qCl0McHrQKzXpXJ61LMG+P5x/tQZNIV9oh5FMxmBnlsOPbBQClNDytvf1Qozox4KZdJ3ORTekaGgkZivI566syDYNZi4a0bg884u7vJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639660846; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Jq9mjYYb0qGdPqgYaDEj1wSgWHxTePfmSvB1yYAydck=; b=ElunEXwo126GEAj0RhMCcUYv892SOy9e5F6uUPe4AEZI1I2tWcRRFyiiX0cjvq2tvCuTTYY4VdT/MCCwd9W/2Pd3FAbvQqBYbLDguV9bmQImYKlETd1Y4twtg9PMS4OfGkHzFDcsU8V2KBszdp9WkJKoMO2AxXSP9EmX4ZuH+I0= 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 1639660846312616.8998698435267; Thu, 16 Dec 2021 05:20:46 -0800 (PST) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-544-p5i3vljYO1mhR3jFhcktWQ-1; Thu, 16 Dec 2021 08:20:44 -0500 Received: by mail-wr1-f70.google.com with SMTP id h7-20020adfaa87000000b001885269a937so6956582wrc.17 for ; Thu, 16 Dec 2021 05:20:44 -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 j18sm10293444wmq.44.2021.12.16.05.20.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660845; 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=Jq9mjYYb0qGdPqgYaDEj1wSgWHxTePfmSvB1yYAydck=; b=SL2EdyvhbwMcdBWrmK1gtkypcMOKOX9pJqV6BTryHD+HhKX9dscs7QcITW4w1suHbS5B4W 9Bbogv0Hbp6FKCumwLM0qv2owiN+e9QNV0aM5jb0pouHPAPBElJChO+ZaCinH4NQuSUKGf WN5EfygwrigmIZFVNJnBMlh3gKEfbOU= X-MC-Unique: p5i3vljYO1mhR3jFhcktWQ-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=Jq9mjYYb0qGdPqgYaDEj1wSgWHxTePfmSvB1yYAydck=; b=YY+/8tjelIwIVJJoscLAB1gnj9j3UiwXg9MmogblTuLh6be5WFqoEE0fr36ZZGNr5S JQceXVtSqS8oElaX+cB5aPrCh0uiNP0Vqi/ZhHNZTzQjUbc+NFkryjpo+kTff0WzJj71 LD2fvbVGSDxgENxpSr/nJN3dInDF7vyBURMRCQPoE8a/uBDQwDlV9Gf/Tg/kjmx99xFH FV8E/cE00ma9b+OZwGm7+3T9rbMTQK/HdqtUQEfLC5PhKvvy7nK1LgG4gLTaGXaB53fR GGel6XWtKQRxe8Kki8JOUNr9z+pYezwhGMSjeR0TWsUPVzM4PmUciumdArlK2DJaPqpl sGqA== X-Gm-Message-State: AOAM531czw8tSyrNZlJgcdzrGGpESM1Dw/5dvJfQvPabvLbxD/8PUoma hYmVtfUFdf4sz8PKUQMaSo5bbdtohWyWxFZobypxaehtHK1ew/MuUtGk2uKXJx59SenN/ztLIfT irSlf7e/T29k1+Q== X-Received: by 2002:a5d:50c7:: with SMTP id f7mr8721523wrt.327.1639660842816; Thu, 16 Dec 2021 05:20:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxC9x+fuE0iUTpPPeFN3hAmrvHgs+mtnao9AhdPvImgRKlxsxQmddMWnfRev9Gzspys9TuanA== X-Received: by 2002:a5d:50c7:: with SMTP id f7mr8721510wrt.327.1639660842620; Thu, 16 Dec 2021 05:20:42 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v6 4/8] tests/unit/test-smp-parse: Add 'smp-generic-invalid' machine type Date: Thu, 16 Dec 2021 14:20:11 +0100 Message-Id: <20211216132015.815493-5-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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: 1639660846919100001 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 Reviewed-by: Yanan Wang --- 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..47e11089e22 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_generic_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_generic_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 May 19 00:47:39 2024 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=1639660850; cv=none; d=zohomail.com; s=zohoarc; b=ZGtYYWx51jwk7MIkvhaEi/mjB4vpUs+IKDqF3IWmo0a2t7hSXFRG1TZRzdj/k1RMUHHFpGHTXhnSYGsbl4aK7qLCHeG40qfPePkkQo08vCaQ8otBUQLpwCgunOdBvnctSsg+KIXvGCDswH2WRIujZoSS+OuQLQ/xTdR4q1jrbIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639660850; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=HqXPiCt79z3PGUD6iKjmKupwIGk6gXPKMLdUw9UGyco=; b=RIo/CeahyzZaNM8qhj8QEybj4CvehVyCcEVxil/LLeV/YfKBB0UEud5AFAsZPu2DxaIxHWaMeY37elplCRjnax38KxEZOLyRia9Nu3INrOP6ap5ce2gzc53qWYGWHuFO3Zj9sTL+OJBEGru7cDn77j7WpiGOsSiQAVBplZZ1a70= 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 1639660850444516.219430276036; Thu, 16 Dec 2021 05:20:50 -0800 (PST) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-628-9iPv4rpRPEWznthgfZdE0A-1; Thu, 16 Dec 2021 08:20:48 -0500 Received: by mail-wr1-f69.google.com with SMTP id v17-20020adfedd1000000b0017c5e737b02so6894278wro.18 for ; Thu, 16 Dec 2021 05:20:48 -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 f18sm4663357wre.7.2021.12.16.05.20.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660849; 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=HqXPiCt79z3PGUD6iKjmKupwIGk6gXPKMLdUw9UGyco=; b=OV8BX+MG6muGqbBNUaGIrtii6URCrsNFVfdHRbY8T4IOn4GBfK3ZVs1ROMtNbjXHJtjPnW stvqnpIcCIKYhvxLhFDYffBBktw0uZ9xVwWFi8vvO4H+FLm4hCpIC0akKuoBrgeAlgZA3e e3QSU5QfQwKHBTKBRXIQ/sHL/ZEssr8= X-MC-Unique: 9iPv4rpRPEWznthgfZdE0A-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=HqXPiCt79z3PGUD6iKjmKupwIGk6gXPKMLdUw9UGyco=; b=Nf9aGAbZYOnlUDjlTiRvMJiEuZz39z+oAy2N6FklF6r4GjIEvXCvRCiC0SCoNQXGnK iBgf1UzB0KPcm70/V0jscF/KOnYswjO6EsKdiNkZLBwTZQCvMOgchqGYW6DvuAc94KTO MbEmSWi4ir5UV/6B9dPtluJcN/eH4+A6GJMx91NW/tqWfwVxoeAcb7zLIC0t9T3Oy+P+ uOC6UPl84ZPg99T4b9Zjo3RF9g6GnPcKDk7dBdZjHQgltDOxmzxZaONmzL51bZhI+7a+ vwe93fXOWkjeflTixsq9yrj3swsk0K6Z7LSatxtkZHcUgib8Bgr2oxOAhwUlMVcl6VwM 7Hyg== X-Gm-Message-State: AOAM532NqnvZDdlS8foK0DLLM/M6Kxx52dzqC50JmWn4irjW+zHr84O7 MDC64vlUScIPoAbvwx9aNDDxAyYFUYiaWo3HAiPHrh8zbQJ6T5wbcw7sW350VT7WqPzeb1ki6bL 91GI63QsoiD1Rvg== X-Received: by 2002:a1c:e915:: with SMTP id q21mr5156149wmc.94.1639660847147; Thu, 16 Dec 2021 05:20:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTfBEZYFWlOjEVkuNxIRychZ9SzNiZ9yOpxrRedeLrrvVnM2qwi8cxU9rFC8MNaw+Ay9QUcg== X-Received: by 2002:a1c:e915:: with SMTP id q21mr5156131wmc.94.1639660846988; Thu, 16 Dec 2021 05:20:46 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Richard Henderson Subject: [PATCH v6 5/8] tests/unit/test-smp-parse: Add 'smp-generic-valid' machine type Date: Thu, 16 Dec 2021 14:20:12 +0100 Message-Id: <20211216132015.815493-6-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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: 1639660851544100001 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 Reviewed-by: Yanan Wang --- 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 47e11089e22..b20bf2c2359 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_generic_valid_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 - 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_generic_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_generic_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 May 19 00:47:39 2024 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=1639660860; cv=none; d=zohomail.com; s=zohoarc; b=FTS/3MvlZt2/IWWmMFypcxz+QYqvMtuH6o5qNfQ48R1AlTqGIMzNMTf+If9fYnMDJzfsE/YsFXMa4IAFooJdCfRdR+0SOfCbXezG4JyeUjP4+c75i9ViNgv+RaDzEpwYWbQJwlhXBDIKHzXQMCDsyA6wkOzG/YKUXt6VWFvFowk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639660860; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Gas95xydnkNBfxR9mpd2N4KEjaivWAJSZ81O3dj9XTI=; b=R6So99StCv8PYwqZCbhO7OTuNWml0DPJninZR1doymeg+KHOhJkSvmRxUc1uLiEnfJs1rJQfyyckq5lrbAdvhYwRBynrkkNEeUPYmiZNCgX3FvIfkJAQW6du6LRATwGrOqWUtXw2V1ORdlXjlV/lW/dAq/F8e0+X/tCOcgiJ9fM= 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 1639660860521615.5694394580554; Thu, 16 Dec 2021 05:21:00 -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-56-MVr5_ACPMSuRWb7YLcWX8g-1; Thu, 16 Dec 2021 08:20:53 -0500 Received: by mail-wm1-f69.google.com with SMTP id v62-20020a1cac41000000b0033719a1a714so13802641wme.6 for ; Thu, 16 Dec 2021 05:20:53 -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 e11sm6018238wrq.28.2021.12.16.05.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660854; 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=Gas95xydnkNBfxR9mpd2N4KEjaivWAJSZ81O3dj9XTI=; b=HJF0bG3pd2cGMC8/pL2P20K0oeYVtAfaoK4ZGxO2txC1srlc9cG+Bte1E8QPTU4hSprWpd eBEzwvuFI5+b435PYbGp26oKJ9uxb95PoEup1/6Rj7DG/IiXCof9g+aEWRe4jItkjjQVDJ V71zS8iI7DnlS+uN4aUihLcM8sFVZgw= X-MC-Unique: MVr5_ACPMSuRWb7YLcWX8g-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=Gas95xydnkNBfxR9mpd2N4KEjaivWAJSZ81O3dj9XTI=; b=YgOBoD/w3niHnCPws+j9agkIGDNGsTXrdZfIVg0Fp8DT8wk2w4XzpaL34ktmWbTAth F8zRvCXVKP2WMRCmswW/dhL1f3tqXH6+1Pk8DJEpy22de52cDLJW7P1VjeXz0weX06hE uyGxpYFi7h6Zx/Q7BdG10Igi1dsCXDHFuIxkBfT7ZbN/QCSb0Nnr98IUZMw44oWYGpJD viSCpJx2pPxBTipqNFfsaHJvuQ6XP9NL4L/D6jFwc5ze+entVNy4wcTSBYAtBfbw3AXj M4LKoNz7qm7WbAwkbiZGRK37V4pY4r3t5f3Xp0Pw5uFLil26GtT8e/bKswYZo1UJICWa zeig== X-Gm-Message-State: AOAM532Tx7UoXowm4QnOQm55r5px43Fq2MtYcwIkE1w99eCxyHgh6k0v iaH6HpFU4GSRoON4l+P6xM+Bd4Qp+S1sMPHMZm2ouk6POm/zqfbPEJm9FIOxqLKETncqXWudXJB P2UgEUnZkaDdyGw== X-Received: by 2002:a05:600c:4ec7:: with SMTP id g7mr4971847wmq.138.1639660851524; Thu, 16 Dec 2021 05:20:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdHxlLrzvqG2sxs1BgKH2jaCOPoHWBWJTUcJhPLqj6Cy/ONngWBm8MpXjceFkdkLk5iLgH9Q== X-Received: by 2002:a05:600c:4ec7:: with SMTP id g7mr4971833wmq.138.1639660851318; Thu, 16 Dec 2021 05:20:51 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Andrew Jones , Richard Henderson , Yanan Wang Subject: [PATCH v6 6/8] tests/unit/test-smp-parse: Simplify pointer to compound literal use Date: Thu, 16 Dec 2021 14:20:13 +0100 Message-Id: <20211216132015.815493-7-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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: 1639660861782100001 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 b20bf2c2359..395929b66cf 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 May 19 00:47:39 2024 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=1639660861; cv=none; d=zohomail.com; s=zohoarc; b=fQw0kgo/msLJy2Yp7ptKoxiFHmjGDMAsQ89hRmQiBRxsMQx8HYLh20aMnUwk70+7sdWHJU7dWmcDedH3RJDxJuVS+lWV773XY9Iy/1gk3kp06/iXrQG0z2s/DHTg301MlFq4ZymKbtIgJAPn12VY/U8OSbMqarDmlnEovwYBYiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639660861; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=XIR/7k3+LEqXkFaBCSIJ9jj6FHOlOGORQLMrHC9gYqo=; b=m1uq2yt8zUGvKZfIZlquykKmGv2xg4RkTcVPUOpGF+J/be5oo7EFl6O5yumRJo2hBs/OF1m7Hb1kJ/JLQw5CoYCwnX/AS8py0Xhc36QZVHdOPbqqsz2Eht0/7FXtIvweU0xEn9Dv3HAF0zm9v23n8DSU2CZChAenO+Ss1T/mHNA= 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 1639660861391881.0034525040392; Thu, 16 Dec 2021 05:21:01 -0800 (PST) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-222-LXMDFOEwMIWiYKW4hWMGrA-1; Thu, 16 Dec 2021 08:20:57 -0500 Received: by mail-wr1-f72.google.com with SMTP id v18-20020a5d5912000000b001815910d2c0so6927952wrd.1 for ; Thu, 16 Dec 2021 05:20:57 -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 w25sm5045259wmk.20.2021.12.16.05.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660860; 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=XIR/7k3+LEqXkFaBCSIJ9jj6FHOlOGORQLMrHC9gYqo=; b=Sp+X6npqfITdqxgNbqkH77bd7sxFwiUrZyH2gNmY8EC0AfqrNzTuKuukMurn9ppe/hrMZd uN9HJXmiycR4Vn+E3G+tQOQZWio6mRFMB3f+lpxUCf4HSZjodVOvXsX0eRzrYy3r1M6bO6 pvDNCWSvWlS4sUKHiKvXJPXOJaP53fI= X-MC-Unique: LXMDFOEwMIWiYKW4hWMGrA-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=XIR/7k3+LEqXkFaBCSIJ9jj6FHOlOGORQLMrHC9gYqo=; b=FiufovYDS1REbZKN2VEjBC8oSyuyB0MRONgDw6sdp95l5tOlFQ+0dZjVD1GIBFt8CF 2Y+Vn7VBk7xwlzKVDkepiGMksvXZwQ7NIuBpzplRHTXRVkQadw5SgqGW96w7i83c7jfs zhf8rar2GiuOAEhgZmJ0ZAXBeylo+g2fciSa4/uee0fP9sWVVL77iuqJE6VO3VjLG54K JHGeVN2VJTKlH0864TfchXwfUZrRp42acvXFMeDkmSHlqaIeVqPGkeDeXJo5MBrhx9SZ 3qVQMD0Xk12TNyJQ6QtgddXCQ0v/Bu5nCGxzVV4c4LspVeBnBimaAxrrbOsHj5RrSDO5 pSSQ== X-Gm-Message-State: AOAM5308h5YqM7X+yDdv3UeykqTfQpY59zBHVLHgPVFcJRPtWZbMnC3V 6ijQIKjLZOM7W7RIaa2SSyGfyOfHQCO5wMe/yb67nKie2JLu/EMjUrHP0vL4WkDqrv6SUPGOg4N Ecb6Zi5/h/SoizA== X-Received: by 2002:a05:600c:b43:: with SMTP id k3mr4914760wmr.159.1639660855820; Thu, 16 Dec 2021 05:20:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7U9ulwEmx8HA2/W7bSkCYEuamU6pe/+WHQWJiprLrnjx/99BgT0v2MoxfsRIEgrzN+DUZGA== X-Received: by 2002:a05:600c:b43:: with SMTP id k3mr4914741wmr.159.1639660855649; Thu, 16 Dec 2021 05:20:55 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Andrew Jones , Richard Henderson , Yanan Wang Subject: [PATCH v6 7/8] tests/unit/test-smp-parse: Constify some pointer/struct Date: Thu, 16 Dec 2021 14:20:14 +0100 Message-Id: <20211216132015.815493-8-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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: 1639660861970100003 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 395929b66cf..0f98c9509ee 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 May 19 00:47:39 2024 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=1639660863; cv=none; d=zohomail.com; s=zohoarc; b=VU2jtHQDYSF4D9ENw8H+5s9N4Lg/frlEf65Bi1IxxHVDPWiuHzLis+gRt09biex770Ns2SfHJZesGSBkTmES3cdPH1n9wNAip83uH4KQU6WhXgiWOi4rxzDweKSfnQh92LAd3ir95x0KWqwx9y6Ophsas6M5HM7jzq091w80vDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639660863; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=qjhf+bvQNgSb5Piftj9ZwUSggj/6sIcVgFV+K5PRUr0=; b=NxZwlgKraUws9ESwxVKYcplp+b0EEtcvijV9exzbRVjRpKbEVB658W1Mt1C6u1g1t+m/OThTSZ6UbL7twxhWnsHdA2P0aqVuWiQeLiKV8bgttKSa++JMd1flSZRuNvlkx/23OveMxH2jCPU77w1WP1RvP/xGQUWLSZ3yhRkbrJI= 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 163966086349683.16736461243477; Thu, 16 Dec 2021 05:21:03 -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-26-_JYzQa3rPOqspvVfptHIoA-1; Thu, 16 Dec 2021 08:21:01 -0500 Received: by mail-wm1-f71.google.com with SMTP id p13-20020a05600c1d8d00b0034565e7e5c6so2390382wms.9 for ; Thu, 16 Dec 2021 05:21:01 -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 g18sm4785470wrv.42.2021.12.16.05.20.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660862; 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=qjhf+bvQNgSb5Piftj9ZwUSggj/6sIcVgFV+K5PRUr0=; b=GZT7q4MSqCtokuJTVS4lrCvAeG66Yif1rTX7bRKQyqZZMjHr6Wa4bVmEfTvV88vDo5AVzQ 3zlLJbuLDpCcpVuy4bOM0eUji1kr2OXeu14o8jcJm8Hsz8w2LKzZXM6P6G7NXJI++K/RIX MayYYASXGCDY+scNkbv2anfOtlkdiq4= X-MC-Unique: _JYzQa3rPOqspvVfptHIoA-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=qjhf+bvQNgSb5Piftj9ZwUSggj/6sIcVgFV+K5PRUr0=; b=atEWqhtBvxaSvGkL9NRLh2z0ViZ9B6GDMfvjDodjco3opOyIcsYgLL9lnw9bDsXmcj xhVn8go7BfFUizMhh+IiQQRbEtPvcAz8VFkvlfnI6FaOfW4n26/QQoBiX0+gb0vBYpcF pTtEd4dGZsG0RWiUdczx0l6rcY/zxuRa1YgJhbHgK1L+S+lUHX7E84mcaFRIWdLCOEQg pW8GHmXPe7anNMq7eZuITkliLUQ/nuEQJUpSdhY/e9AXs21mJeP19R/9uc2z1Qt6mD0v DCj8UDfPJJDuqcOXs7HomOhf6DubWIY7/xwpSWcBE2f5xsaz8PW56wfjEiz9iQOLt+A5 FCXQ== X-Gm-Message-State: AOAM531+NKxzDDnpTp7BXMAcmKXNKHrdkLZAraXL5FSB6yJvA5eUjrft IABHrSpevLtLfeoh1mcVKDvDsle5xWlPf4xgR/nkecCKkUigc7dDD05C1lOHPZyWvlGsL7yWw+z joh7UHaPQ2XG2oQ== X-Received: by 2002:a05:6000:1541:: with SMTP id 1mr8843897wry.347.1639660860164; Thu, 16 Dec 2021 05:21:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxF6mqbnnOOH3WtFObppwPWGxmCzxXXciFV6QUOHqi4+4GvdHf1nWm8z4QCZxFjkTYfPtVJ3g== X-Received: by 2002:a05:6000:1541:: with SMTP id 1mr8843884wry.347.1639660860004; Thu, 16 Dec 2021 05:21:00 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Andrew Jones , Richard Henderson , Yanan Wang Subject: [PATCH v6 8/8] hw/core: Rename smp_parse() -> machine_parse_smp_config() Date: Thu, 16 Dec 2021 14:20:15 +0100 Message-Id: <20211216132015.815493-9-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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: 1639660864486100001 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 0f98c9509ee..b6df8137fcc 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