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 <jferlan@redhat.com>
---
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 {
bool usedQMP;
bool isNested;
+ bool invalid;
char *binary;
time_t ctime;
@@ -3870,6 +3871,11 @@ virQEMUCapsIsValid(void *data,
if (!qemuCaps->binary)
return true;
+ if (qemuCaps->invalid) {
+ VIR_DEBUG("capabilities for '%s' invalidated", qemuCaps->binary);
+ return false;
+ }
+
if (qemuCaps->libvirtCtime != virGetSelfLastChanged() ||
qemuCaps->libvirtVersion != LIBVIR_VERSION_NUMBER) {
VIR_DEBUG("Outdated capabilities for '%s': libvirt changed "
@@ -4958,6 +4964,35 @@ virQEMUCapsCacheLookupDefault(virFileCachePtr cache,
return ret;
}
+
+/** 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 = payload;
+
+ qemuCaps->invalid = 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);
VIR_ENUM_DECL(virQEMUCaps);
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;
- if (!(caps = virQEMUDriverGetCapabilities(qemu_driver, false)))
+ virQEMUCapsInvalidateCapabilities(qemu_driver->qemuCapsCache);
+
+ if (!(caps = virQEMUDriverGetCapabilities(qemu_driver, true)))
goto cleanup;
cfg = virQEMUDriverGetConfig(qemu_driver);
--
2.17.2
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2024 Red Hat, Inc.