[libvirt] [PATCH v2 1/3] qemu: add explicit flag to skip qemu caps invalidation

Daniel P. Berrangé posted 3 patches 6 years, 1 month ago
[libvirt] [PATCH v2 1/3] qemu: add explicit flag to skip qemu caps invalidation
Posted by Daniel P. Berrangé 6 years, 1 month ago
Currently if the binary path is NULL in the qemu capabilities object,
cache invalidation is skipped. A future patch will ensure that the
binary path is always non-NULL, so a way to explicitly skip invalidation
is required.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/qemu/qemu_capabilities.c | 14 ++++++++++++++
 src/qemu/qemu_capabilities.h |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 2223589058..cc6d9bbd44 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -612,6 +612,7 @@ struct _virQEMUCaps {
     char *binary;
     time_t ctime;
     time_t libvirtCtime;
+    bool invalidation;
 
     virBitmapPtr flags;
 
@@ -1633,6 +1634,7 @@ virQEMUCapsNew(void)
     if (!(qemuCaps = virObjectNew(virQEMUCapsClass)))
         return NULL;
 
+    qemuCaps->invalidation = true;
     if (!(qemuCaps->flags = virBitmapNew(QEMU_CAPS_LAST)))
         goto error;
 
@@ -1647,6 +1649,14 @@ virQEMUCapsNew(void)
 }
 
 
+void
+virQEMUCapsSetInvalidation(virQEMUCapsPtr qemuCaps,
+                           bool enabled)
+{
+    qemuCaps->invalidation = enabled;
+}
+
+
 static int
 virQEMUCapsHostCPUDataCopy(virQEMUCapsHostCPUDataPtr dst,
                            virQEMUCapsHostCPUDataPtr src)
@@ -1746,6 +1756,7 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps)
     if (!ret)
         return NULL;
 
+    ret->invalidation = qemuCaps->invalidation;
     ret->usedQMP = qemuCaps->usedQMP;
     ret->kvmSupportsNesting = qemuCaps->kvmSupportsNesting;
 
@@ -4423,6 +4434,9 @@ virQEMUCapsIsValid(void *data,
     struct stat sb;
     bool kvmSupportsNesting;
 
+    if (!qemuCaps->invalidation)
+        return true;
+
     if (!qemuCaps->binary)
         return true;
 
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 1b2522126c..7488b9ddb8 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -545,6 +545,9 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virQEMUCaps, virObjectUnref);
 
 virQEMUCapsPtr virQEMUCapsNew(void);
 
+void virQEMUCapsSetInvalidation(virQEMUCapsPtr qemuCaps,
+                                bool enabled);
+
 void virQEMUCapsSet(virQEMUCapsPtr qemuCaps,
                     virQEMUCapsFlags flag) ATTRIBUTE_NONNULL(1);
 
-- 
2.23.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 1/3] qemu: add explicit flag to skip qemu caps invalidation
Posted by Michal Prívozník 6 years, 1 month ago
On 12/20/19 2:47 PM, Daniel P. Berrangé wrote:
> Currently if the binary path is NULL in the qemu capabilities object,
> cache invalidation is skipped. A future patch will ensure that the
> binary path is always non-NULL, so a way to explicitly skip invalidation
> is required.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  src/qemu/qemu_capabilities.c | 14 ++++++++++++++
>  src/qemu/qemu_capabilities.h |  3 +++
>  2 files changed, 17 insertions(+)
> 

> diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
> index 1b2522126c..7488b9ddb8 100644
> --- a/src/qemu/qemu_capabilities.h
> +++ b/src/qemu/qemu_capabilities.h
> @@ -545,6 +545,9 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virQEMUCaps, virObjectUnref);
>  
>  virQEMUCapsPtr virQEMUCapsNew(void);
>  
> +void virQEMUCapsSetInvalidation(virQEMUCapsPtr qemuCaps,
> +                                bool enabled);
> +

Since this function is intended to be used from tests only, I guess it
can be moved to src/qemu/qemu_capspriv.h so we are not tempted to use it
from real code.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list