From nobody Tue Apr 23 19:52:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555324625; cv=none; d=zoho.com; s=zohoarc; b=e+ycPOL5JP1r0kPW0JdQtHJXGNOZOcgROvILmLTjm+L8jKAf0BqGAiujgpDlvFILjioTqN25xKNblmlzHTnIAhZ3M2av+XNIW7kIIogTvjOwQ+m+Aul6cHC8C624ICw7bTFTDT+zRUfkdVXEJlkPxsu5G3iZ2WlFVJ7tl24ijrQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555324625; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=SYGYZy9P8m5uLtS0qsbevuCXIouozHomxyeYR/gL4uI=; b=Q99Z2Zn3dzLKqscOGH5aHvTfxpKAA4U000pWES/2sUh6ZfQ20PpVM2UcCGw67NT2IvJc51K6FM+mgKZuJHCCkDoDgBQcd4AyatAOkNjVzUZn/g+I3wOB44QwDadSW8tddvsx7wxSXa4zj/5CLP0gJMFcAIJM4mxM/bidqmvkOkQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1555324625205596.5301352609904; Mon, 15 Apr 2019 03:37:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 081AA308FBB1; Mon, 15 Apr 2019 10:37:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8360A5D70E; Mon, 15 Apr 2019 10:37:01 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E2223181AC45; Mon, 15 Apr 2019 10:37:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3FAaxIX002540 for ; Mon, 15 Apr 2019 06:36:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id C620C19C56; Mon, 15 Apr 2019 10:36:59 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74EBC19C4F for ; Mon, 15 Apr 2019 10:36:57 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 185561038FA; Mon, 15 Apr 2019 12:36:56 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 15 Apr 2019 12:36:52 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Don't cache microcode version X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 15 Apr 2019 10:37:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" My earlier commit be46f61326 was incomplete. It removed caching of microcode version in the CPU driver, which means the capabilities XML will see the correct microcode version. But it is also cached in the QEMU capabilities cache where it is used to detect whether we need to reprobe QEMU. By missing the second place, the original commit be46f61326 made the situation even worse since libvirt would report correct microcode version while still using the old host CPU model (visible in domain capabilities XML). Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_capabilities.c | 12 ++++++++---- src/qemu/qemu_capabilities.h | 3 +-- src/qemu/qemu_driver.c | 9 +-------- tests/testutilsqemu.c | 2 +- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index da90cd666e..a74dc84056 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4542,7 +4542,7 @@ virQEMUCapsNewData(const char *binary, priv->libDir, priv->runUid, priv->runGid, - priv->microcodeVersion, + virHostCPUGetMicrocodeVersion(), priv->kernelVersion); } =20 @@ -4625,8 +4625,7 @@ virFileCachePtr virQEMUCapsCacheNew(const char *libDir, const char *cacheDir, uid_t runUid, - gid_t runGid, - unsigned int microcodeVersion) + gid_t runGid) { char *capsCacheDir =3D NULL; virFileCachePtr cache =3D NULL; @@ -4650,7 +4649,6 @@ virQEMUCapsCacheNew(const char *libDir, =20 priv->runUid =3D runUid; priv->runGid =3D runGid; - priv->microcodeVersion =3D microcodeVersion; priv->kvmUsable =3D VIR_TRISTATE_BOOL_ABSENT; =20 if (uname(&uts) =3D=3D 0 && @@ -4672,8 +4670,11 @@ virQEMUCapsPtr virQEMUCapsCacheLookup(virFileCachePtr cache, const char *binary) { + virQEMUCapsCachePrivPtr priv =3D virFileCacheGetPriv(cache); virQEMUCapsPtr ret =3D NULL; =20 + priv->microcodeVersion =3D virHostCPUGetMicrocodeVersion(); + ret =3D virFileCacheLookup(cache, binary); =20 VIR_DEBUG("Returning caps %p for %s", ret, binary); @@ -4727,6 +4728,7 @@ virQEMUCapsPtr virQEMUCapsCacheLookupByArch(virFileCachePtr cache, virArch arch) { + virQEMUCapsCachePrivPtr priv =3D virFileCacheGetPriv(cache); virQEMUCapsPtr ret =3D NULL; const char *binaryFilters[] =3D { "qemu-system-", @@ -4739,6 +4741,8 @@ virQEMUCapsCacheLookupByArch(virFileCachePtr cache, size_t i; size_t j; =20 + priv->microcodeVersion =3D virHostCPUGetMicrocodeVersion(); + for (i =3D 0; i < ARRAY_CARDINALITY(binaryFilters); i++) { for (j =3D 0; j < ARRAY_CARDINALITY(archs); j++) { struct virQEMUCapsSearchData data =3D { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index fd7bec7589..8f5656a89b 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -590,8 +590,7 @@ void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemu= Caps, virFileCachePtr virQEMUCapsCacheNew(const char *libDir, const char *cacheDir, uid_t uid, - gid_t gid, - unsigned int microcodeVersion); + gid_t gid); virQEMUCapsPtr virQEMUCapsCacheLookup(virFileCachePtr cache, const char *binary); virQEMUCapsPtr virQEMUCapsCacheLookupCopy(virFileCachePtr cache, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7e334d0d8d..4510b0ce60 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -584,8 +584,6 @@ qemuStateInitialize(bool privileged, char *hugepagePath =3D NULL; char *memoryBackingPath =3D NULL; size_t i; - virCPUDefPtr hostCPU =3D NULL; - unsigned int microcodeVersion =3D 0; =20 if (VIR_ALLOC(qemu_driver) < 0) return -1; @@ -808,15 +806,10 @@ qemuStateInitialize(bool privileged, run_gid =3D cfg->group; } =20 - if ((hostCPU =3D virCPUProbeHost(virArchFromHost()))) - microcodeVersion =3D hostCPU->microcodeVersion; - virCPUDefFree(hostCPU); - qemu_driver->qemuCapsCache =3D virQEMUCapsCacheNew(cfg->libDir, cfg->cacheDir, run_uid, - run_gid, - microcodeVersion); + run_gid); if (!qemu_driver->qemuCapsCache) goto error; =20 diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 3ee8a0c6c6..763f511bcf 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -740,7 +740,7 @@ int qemuTestDriverInit(virQEMUDriver *driver) =20 /* Using /dev/null for libDir and cacheDir automatically produces erro= rs * upon attempt to use any of them */ - driver->qemuCapsCache =3D virQEMUCapsCacheNew("/dev/null", "/dev/null"= , 0, 0, 0); + driver->qemuCapsCache =3D virQEMUCapsCacheNew("/dev/null", "/dev/null"= , 0, 0); if (!driver->qemuCapsCache) goto error; =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list