[PATCH v2 2/3] Change QEMU capabilities cache to check ctime instead of mtime

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Debian's package manager will preserve mtime timesatmp on binaries
from the time they are built, rather than installed. So if a
user downgrades their QEMU dpkg, the libvirt capabilities
cache will not refresh. The fix is to use ctime instead of mtime
since it cannot be faked.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index cae25e0..df5581f 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -259,7 +259,7 @@ struct _virQEMUCaps {
     bool usedQMP;
 
     char *binary;
-    time_t mtime;
+    time_t ctime;
 
     virBitmapPtr flags;
 
@@ -2796,7 +2796,7 @@ virQEMUCapsPtr virQEMUCapsNewForBinary(const char *binary,
                              binary);
         goto error;
     }
-    qemuCaps->mtime = sb.st_mtime;
+    qemuCaps->ctime = sb.st_ctime;
 
     /* Make sure the binary we are about to try exec'ing exists.
      * Technically we could catch the exec() failure, but that's
@@ -2838,7 +2838,7 @@ bool virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps)
     if (stat(qemuCaps->binary, &sb) < 0)
         return false;
 
-    return sb.st_mtime == qemuCaps->mtime;
+    return sb.st_ctime == qemuCaps->ctime;
 }
 
 
-- 
1.8.5.3

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]