From nobody Sun Feb 8 10:16:58 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=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: 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 1653079651376985.7033147274559; Fri, 20 May 2022 13:47:31 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-94-BG2sOAFPOZei6NF57kg4vA-1; Fri, 20 May 2022 16:47:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 68979100DDF4; Fri, 20 May 2022 20:47:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53A521415101; Fri, 20 May 2022 20:47:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1CB621947052; Fri, 20 May 2022 20:47:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AC892193F6D6 for ; Fri, 20 May 2022 20:47:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 969C640D2821; Fri, 20 May 2022 20:47:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 922D640D2820 for ; Fri, 20 May 2022 20:47:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 78F3E802A5B for ; Fri, 20 May 2022 20:47:19 +0000 (UTC) Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-219-pSo_qiztMLez22zYMJy34g-2; Fri, 20 May 2022 16:47:17 -0400 Received: by mail-oi1-f182.google.com with SMTP id t144so8030156oie.7 for ; Fri, 20 May 2022 13:47:17 -0700 (PDT) Received: from balboa.ibmuc.com ([191.193.151.26]) by smtp.gmail.com with ESMTPSA id o192-20020a4a2cc9000000b0035eb4e5a6cfsm1464343ooo.37.2022.05.20.13.47.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 13:47:17 -0700 (PDT) X-MC-Unique: BG2sOAFPOZei6NF57kg4vA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: pSo_qiztMLez22zYMJy34g-2 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=ugVj9QZR+vdAv/lvuYgBgbYjJ5H8/GIHR2R6f8q6bP0=; b=U4ZSQlI3M3h3psjbyQPzUnviGhgakjHMg6ySm5Fyy1xdksknGBGIeA18QB+dakoyHU H078mKXi/W7PkgGn3Les6Egfho9SrM+CULrh65tpPF5+DejleeeOMdP0Kt0Z72EdYZ9i XHoNUDKQYJyiPe0vMRNR+4eZ0o5LMRn15GSoCdYWCmuet5dZ0bonvODYFGPW1d0y1Yqw Hxm9XXZ8/Qwh69wyjJtMkW1SPJjlOgptaK9zZ/1auvf+YjaZvwSY62XtlR6jAkofHIUV 8414n7TkBm1OAAxF0tsuzxG6zaoab27df8YgtQEtCp1mwg4QsuvVkQcCTA0Ar/38RPhN /+sQ== X-Gm-Message-State: AOAM532zDtZ6SrV21pKSwphTCmVNa5zihSrclnUykv01fhjxjz8Lsthn 5F0U+dTnGK+8sYoHT2CgyQhrru6elt8= X-Google-Smtp-Source: ABdhPJyVGc5WTmQkxjV93tfNdWeR9E3oY3mysHCDcUpUOi7dtQXR45Ji23E8XzCfOjT2R837YVJjvg== X-Received: by 2002:a05:6808:14c2:b0:326:c129:d308 with SMTP id f2-20020a05680814c200b00326c129d308mr6209007oiw.193.1653079637242; Fri, 20 May 2022 13:47:17 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 2/3] testutilsqemu: introduce ARG_CAPS_HOST_CPU_MODEL Date: Fri, 20 May 2022 17:47:03 -0300 Message-Id: <20220520204704.1290007-3-danielhb413@gmail.com> In-Reply-To: <20220520204704.1290007-1-danielhb413@gmail.com> References: <20220520204704.1290007-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: danielhb413@gmail.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1653079652592100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When loading a latest caps for an arch for the first time the following occurs in testQemuInfoInitArgs(): - the caps file is located. It's not in the cache since it's the first time it's being read; - the cachecaps are retrieved using qemuTestParseCapabilitiesArch() and stored in the capscache; - FLAG_REAL_CAPS is set and regular flow continues. Loading the same latest caps for the second time the caps are loaded from t= he cache, skipping qemuTestParseCapabilitiesArch(). By skipping this function = it means that it also skips virQEMUCapsLoadCache() and, more relevant to our case, virQEMUCapsInitHostCPUModel(). This function will use the current arch and cpuModel settings to write the qemuCaps that are being stored in the cache. And we're also setting FLAG_REAL_CAPS, meaning that we won't be updating the qemucaps host model via testUpdateQEMUCaps() as well. This has side-effects such as: - the first time the latest caps for an arch is loaded determines the cpuModel it'll use during the current qemuxml2argvtest run. For example, when running all tests, the first time the latest ppc64 caps are read is on "disk-floppy-pseries" test. Since the current host arch at this point is x86_64, the cpuModel that will be set for this capability is "core2duo"; - every other latest arch test will use the same hostCPU as the first one set since we read it from the cache after the first run. qemuTestSetHostCPU() makes no difference because we won't update the host model due to FLAG_REAL_CAPS being set. Using the previous example, every other latest ppc64 test that will be run will be using the "core2duo" cpuModel. Using fake capabilities (e.g. using DO_TEST()) prevent FLAG_REAL_CAPS to be set, meaning that the cpuModel will be updated using the current settings the test is being ran due to testUpdateQEMUCaps(). Note that not all latest caps arch tests care about the cpuModel being set to an unexpected default cpuModel. But some tests will care, e.g. "pseries-cpu-compat-power9", and changing it from DO_TEST() to DO_TEST_CAPS_ARCH_LATEST() will make it fail every time the "disk-floppy-pseries" is being ran first. One way of fixing it is to rethink all the existing logic, for example not setting FLAG_REAL_CAPS for latest arch tests. Another way is presented here. ARGS_CAPS_HOST_CPU_MODEL is a new testQemuInfo arg that allow us to set any specific host CPU model we want when running latest arch caps tests. This new arg can then be used when converting existing DO_TEST() testcases to DO_TEST_CAPS_ARCH_LATEST() that requires a specific host CPU setting to be successful, which we're going to do in the next patch with "pseries-cpu-compat-power9". Signed-off-by: Daniel Henrique Barboza Reviewed-by: Martin Kletzander --- tests/qemuxml2argvtest.c | 18 ++++++++++++++---- tests/testutilsqemu.c | 4 ++++ tests/testutilsqemu.h | 18 +++++++++--------- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index aadfaddc17..96bc7aadeb 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -336,6 +336,12 @@ testAddCPUModels(virQEMUCaps *caps, bool skipLegacy) return 0; } =20 +static void +testUpdateQEMUCapsHostCPUModel(virQEMUCaps *qemuCaps, virArch hostArch) +{ + virQEMUCapsUpdateHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM); + virQEMUCapsUpdateHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU= ); +} =20 static int testUpdateQEMUCaps(const struct testQemuInfo *info, @@ -353,10 +359,7 @@ testUpdateQEMUCaps(const struct testQemuInfo *info, !!(info->flags & FLAG_SKIP_LEGACY_CPUS)) < 0) return -1; =20 - virQEMUCapsUpdateHostCPUModel(info->qemuCaps, caps->host.arch, - VIR_DOMAIN_VIRT_KVM); - virQEMUCapsUpdateHostCPUModel(info->qemuCaps, caps->host.arch, - VIR_DOMAIN_VIRT_QEMU); + testUpdateQEMUCapsHostCPUModel(info->qemuCaps, caps->host.arch); =20 return 0; } @@ -650,6 +653,13 @@ testCompareXMLToArgv(const void *data) if (info->arch !=3D VIR_ARCH_NONE && info->arch !=3D VIR_ARCH_X86_64) qemuTestSetHostArch(&driver, info->arch); =20 + if (info->args.capsHostCPUModel) { + virCPUDef *hostCPUModel =3D qemuTestGetCPUDef(info->args.capsHostC= PUModel); + + qemuTestSetHostCPU(&driver, driver.hostarch, hostCPUModel); + testUpdateQEMUCapsHostCPUModel(info->qemuCaps, driver.hostarch); + } + if (!(conn =3D virGetConnect())) goto cleanup; =20 diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 004c7cf1d6..7e4e5d28b7 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -886,6 +886,10 @@ testQemuInfoSetArgs(struct testQemuInfo *info, info->args.capsver =3D va_arg(argptr, char *); break; =20 + case ARG_CAPS_HOST_CPU_MODEL: + info->args.capsHostCPUModel =3D va_arg(argptr, int); + break; + case ARG_HOST_OS: info->args.hostOS =3D va_arg(argptr, int); break; diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 99897e6b79..5419b813ea 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -47,6 +47,7 @@ typedef enum { ARG_PARSEFLAGS, ARG_CAPS_ARCH, ARG_CAPS_VER, + ARG_CAPS_HOST_CPU_MODEL, ARG_HOST_OS, ARG_END, } testQemuInfoArgName; @@ -66,12 +67,20 @@ struct testQemuConf { GHashTable *qapiSchemaCache; }; =20 +typedef enum { + QEMU_CPU_DEF_DEFAULT, + QEMU_CPU_DEF_HASWELL, + QEMU_CPU_DEF_POWER8, + QEMU_CPU_DEF_POWER9, +} qemuTestCPUDef; + struct testQemuArgs { bool newargs; virQEMUCaps *fakeCaps; bool fakeCapsUsed; char *capsver; char *capsarch; + qemuTestCPUDef capsHostCPUModel; int gic; testQemuHostOS hostOS; bool invalidarg; @@ -101,15 +110,6 @@ virDomainXMLOption *testQemuXMLConfInit(void); =20 virQEMUCaps *qemuTestParseCapabilitiesArch(virArch arch, const char *capsFile); - - -typedef enum { - QEMU_CPU_DEF_DEFAULT, - QEMU_CPU_DEF_HASWELL, - QEMU_CPU_DEF_POWER8, - QEMU_CPU_DEF_POWER9, -} qemuTestCPUDef; - virCPUDef *qemuTestGetCPUDef(qemuTestCPUDef d); =20 void qemuTestSetHostArch(virQEMUDriver *driver, --=20 2.32.0