On Wed, Nov 02, 2016 at 10:22:35AM +0100, Jiri Denemark wrote: > Let's keep all run time validation of cached QEMU capabilities in > virQEMUCapsIsValid and call it whenever we access the cache. > virQEMUCapsInitCached should keep only the checks which do not make > sense once the cache is loaded in memory. > > Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> > --- > src/qemu/qemu_capabilities.c | 59 ++++++++++++++++++++++++++++++-------------- > src/qemu/qemu_capabilities.h | 3 ++- > 2 files changed, 42 insertions(+), 20 deletions(-) > > diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c > index 91e8b30..d1c31ad 100644 > --- a/src/qemu/qemu_capabilities.c > +++ b/src/qemu/qemu_capabilities.c > @@ -3516,25 +3516,21 @@ virQEMUCapsInitCached(virCapsPtr caps, > VIR_WARN("Failed to load cached caps from '%s' for '%s': %s", > capsfile, qemuCaps->binary, virGetLastErrorMessage()); > virResetLastError(); > - ret = 0; > - virQEMUCapsReset(qemuCaps); > - goto cleanup; > + goto discard; > } > > + if (!virQEMUCapsIsValid(qemuCaps, qemuctime)) > + goto discard; > + > /* Discard cache if QEMU binary or libvirtd changed */ > - if (qemuctime != qemuCaps->ctime || > - selfctime != virGetSelfLastChanged() || > + if (selfctime != virGetSelfLastChanged() || > selfvers != LIBVIR_VERSION_NUMBER) { > - VIR_DEBUG("Outdated cached capabilities '%s' for '%s' " > - "(%lld vs %lld, %lld vs %lld, %lu vs %lu)", > + VIR_DEBUG("Dropping cached capabilities '%s' for '%s': " > + "libvirt changed (%lld vs %lld, %lu vs %lu)", > capsfile, qemuCaps->binary, > - (long long)qemuCaps->ctime, (long long)qemuctime, > (long long)selfctime, (long long)virGetSelfLastChanged(), > selfvers, (unsigned long)LIBVIR_VERSION_NUMBER); > - ignore_value(unlink(capsfile)); > - virQEMUCapsReset(qemuCaps); > - ret = 0; > - goto cleanup; > + goto discard; > } > > VIR_DEBUG("Loaded '%s' for '%s' ctime %lld usedQMP=%d", > @@ -3548,6 +3544,12 @@ virQEMUCapsInitCached(virCapsPtr caps, > VIR_FREE(capsfile); > VIR_FREE(capsdir); > return ret; > + > + discard: > + ignore_value(unlink(capsfile)); > + virQEMUCapsReset(qemuCaps); > + ret = 0; > + goto cleanup; > } > > > @@ -4111,17 +4113,36 @@ virQEMUCapsNewForBinary(virCapsPtr caps, > } > > > -bool virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps) > +bool > +virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps, > + time_t ctime) This broke the build on RHEL-6 c1: warnings being treated as errors ../../src/qemu/qemu_capabilities.c: In function 'virQEMUCapsIsValid': ../../src/qemu/qemu_capabilities.c:4085: error: declaration of 'ctime' shadows a global declaration [-Wshadow] /usr/include/time.h:258: error: shadowed declaration is here [-Wshadow] We should just call this qemuctime, as done elsewhere to avoid the clash. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list