virQEMUCapsLoadCache loads QEMU capabilities from a file, but strangely
enough it returns the loaded QEMU binary ctime in qemuctime parameter
instead of storing it in qemuCaps.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 10 +++++-----
src/qemu/qemu_capspriv.h | 1 -
tests/testutilsqemu.c | 3 +--
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b9e94dc..91e8b30 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3023,7 +3023,6 @@ int
virQEMUCapsLoadCache(virCapsPtr caps,
virQEMUCapsPtr qemuCaps,
const char *filename,
- time_t *qemuctime,
time_t *selfctime,
unsigned long *selfvers)
{
@@ -3060,7 +3059,7 @@ virQEMUCapsLoadCache(virCapsPtr caps,
_("missing qemuctime in QEMU capabilities XML"));
goto cleanup;
}
- *qemuctime = (time_t)l;
+ qemuCaps->ctime = (time_t)l;
if (virXPathLongLong("string(./selfctime)", ctxt, &l) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -3477,7 +3476,7 @@ virQEMUCapsInitCached(virCapsPtr caps,
int ret = -1;
char *binaryhash = NULL;
struct stat sb;
- time_t qemuctime;
+ time_t qemuctime = qemuCaps->ctime;
time_t selfctime;
unsigned long selfvers;
@@ -3513,7 +3512,7 @@ virQEMUCapsInitCached(virCapsPtr caps,
}
if (virQEMUCapsLoadCache(caps, qemuCaps, capsfile,
- &qemuctime, &selfctime, &selfvers) < 0) {
+ &selfctime, &selfvers) < 0) {
VIR_WARN("Failed to load cached caps from '%s' for '%s':
%s",
capsfile, qemuCaps->binary, virGetLastErrorMessage());
virResetLastError();
@@ -3529,7 +3528,7 @@ virQEMUCapsInitCached(virCapsPtr caps,
VIR_DEBUG("Outdated cached capabilities '%s' for '%s'
"
"(%lld vs %lld, %lld vs %lld, %lu vs %lu)",
capsfile, qemuCaps->binary,
- (long long)qemuctime, (long long)qemuCaps->ctime,
+ (long long)qemuCaps->ctime, (long long)qemuctime,
(long long)selfctime, (long long)virGetSelfLastChanged(),
selfvers, (unsigned long)LIBVIR_VERSION_NUMBER);
ignore_value(unlink(capsfile));
@@ -3544,6 +3543,7 @@ virQEMUCapsInitCached(virCapsPtr caps,
ret = 1;
cleanup:
+ qemuCaps->ctime = qemuctime;
VIR_FREE(binaryhash);
VIR_FREE(capsfile);
VIR_FREE(capsdir);
diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
index 68b2d82..e6489b4 100644
--- a/src/qemu/qemu_capspriv.h
+++ b/src/qemu/qemu_capspriv.h
@@ -57,7 +57,6 @@ virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
int virQEMUCapsLoadCache(virCapsPtr caps,
virQEMUCapsPtr qemuCaps,
const char *filename,
- time_t *qemuctime,
time_t *selfctime,
unsigned long *selfvers);
char *virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps,
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index e66903a..56a89c9 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -495,13 +495,12 @@ qemuTestParseCapabilities(virCapsPtr caps,
const char *capsFile)
{
virQEMUCapsPtr qemuCaps = NULL;
- time_t qemuctime;
time_t selfctime;
unsigned long version;
if (!(qemuCaps = virQEMUCapsNew()) ||
virQEMUCapsLoadCache(caps, qemuCaps, capsFile,
- &qemuctime, &selfctime, &version) < 0)
+ &selfctime, &version) < 0)
goto error;
return qemuCaps;
--
2.10.2