From nobody Wed Nov 27 18:33:57 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1542141724607528.3797459412085; Tue, 13 Nov 2018 12:42:04 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F1D2F308339B; Tue, 13 Nov 2018 20:42:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7CED36013F; Tue, 13 Nov 2018 20:42: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 2374F4BB79; Tue, 13 Nov 2018 20:42:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wADKLA9D012692 for ; Tue, 13 Nov 2018 15:21:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 13C285C88D; Tue, 13 Nov 2018 20:21:10 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-124-253.rdu2.redhat.com [10.10.124.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id B87FF5C1A1 for ; Tue, 13 Nov 2018 20:21:09 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 13 Nov 2018 15:21:06 -0500 Message-Id: <20181113202106.10130-4-jferlan@redhat.com> In-Reply-To: <20181113202106.10130-1-jferlan@redhat.com> References: <20181113202106.10130-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 3/3] qemu: Add ability to invalidate the capabilities cache 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: , MIME-Version: 1.0 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 13 Nov 2018 20:42:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Provide a mechanism via the QEMU driver reload functionality to invalidate all the capabilities cache and force a reread of the capabilities rather than requiring an admin to "know" they need to remove all the capability cache files and restart libvirtd. This still requires usage of the reload functionality, but it provides the "internal mechanism" in order to cause a reread rather than the "external need" to remove and restart. Signed-off-by: John Ferlan --- src/qemu/qemu_capabilities.c | 35 +++++++++++++++++++++++++++++++++++ src/qemu/qemu_capabilities.h | 2 ++ src/qemu/qemu_driver.c | 4 +++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index ebe0c0c7df..6b66ee006c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -553,6 +553,7 @@ struct _virQEMUCaps { =20 bool usedQMP; bool isNested; + bool invalid; =20 char *binary; time_t ctime; @@ -3870,6 +3871,11 @@ virQEMUCapsIsValid(void *data, if (!qemuCaps->binary) return true; =20 + if (qemuCaps->invalid) { + VIR_DEBUG("capabilities for '%s' invalidated", qemuCaps->binary); + return false; + } + if (qemuCaps->libvirtCtime !=3D virGetSelfLastChanged() || qemuCaps->libvirtVersion !=3D LIBVIR_VERSION_NUMBER) { VIR_DEBUG("Outdated capabilities for '%s': libvirt changed " @@ -4958,6 +4964,35 @@ virQEMUCapsCacheLookupDefault(virFileCachePtr cache, return ret; } =20 + +/** virQEMUCapsInvalidateCapabilities: + * + * Using the @driver and existing qemuCapsCache, force all the data + * in the cache to be invalidated so that a subsequent isValid call + * force a refetch of the capabilities data. + */ + +static int +virQEMUCapsInvalidateData(void *payload, + const void *name ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + virQEMUCaps *qemuCaps =3D payload; + + qemuCaps->invalid =3D true; + + return 0; +} + + +void +virQEMUCapsInvalidateCapabilities(virFileCachePtr cache) +{ + virFileCacheForEach(cache, virQEMUCapsInvalidateData, NULL); + return; +} + + bool virQEMUCapsSupportsVmport(virQEMUCapsPtr qemuCaps, const virDomainDef *def) diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 6bb9a2c8f0..0600ecd424 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -598,6 +598,8 @@ virCapsPtr virQEMUCapsInit(virFileCachePtr cache); int virQEMUCapsGetDefaultVersion(virCapsPtr caps, virFileCachePtr capsCache, unsigned int *version); +void +virQEMUCapsInvalidateCapabilities(virFileCachePtr cache); =20 VIR_ENUM_DECL(virQEMUCaps); =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 09e04b8544..3b6b399e5b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -968,7 +968,9 @@ qemuStateReload(void) if (!qemu_driver) return 0; =20 - if (!(caps =3D virQEMUDriverGetCapabilities(qemu_driver, false))) + virQEMUCapsInvalidateCapabilities(qemu_driver->qemuCapsCache); + + if (!(caps =3D virQEMUDriverGetCapabilities(qemu_driver, true))) goto cleanup; =20 cfg =3D virQEMUDriverGetConfig(qemu_driver); --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list