]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add helper APIs to track if libvirtd or loadable modules have changed
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 5 Mar 2014 17:20:50 +0000 (17:20 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 11 Mar 2014 10:51:49 +0000 (10:51 +0000)
The future QEMU capabilities cache needs to be able to invalidate
itself if the libvirtd binary or any loadable modules are changed
on disk. Record the 'ctime' value for these binaries and provide
helper APIs to query it. This approach assumes that if libvirt.so
is changed, then libvirtd will also change, which should usually
be the case with libtool's wrapper scripts that cause libvirtd to
get re-linked

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
daemon/libvirtd.c
src/driver.c
src/libvirt_private.syms
src/util/virutil.c
src/util/virutil.h

index 72f0e81e67e2cbde9b81b957b89ec82efb097d92..36adaf09c755157d5e9784b79b8a84e488c294a3 100644 (file)
@@ -1152,6 +1152,8 @@ int main(int argc, char **argv) {
         exit(EXIT_FAILURE);
     }
 
+    virUpdateSelfLastChanged(argv[0]);
+
     if (strstr(argv[0], "lt-libvirtd") ||
         strstr(argv[0], "/daemon/.libs/libvirtd")) {
         char *tmp = strrchr(argv[0], '/');
index ab2a2538a0a69c4cc714b8f1e0e0af2ce73b9c09..721cbeb9f529bce02b2d279b2c90ff41e24652c8 100644 (file)
@@ -74,6 +74,8 @@ virDriverLoadModule(const char *name)
         goto cleanup;
     }
 
+    virUpdateSelfLastChanged(modfile);
+
     handle = dlopen(modfile, RTLD_NOW | RTLD_GLOBAL);
     if (!handle) {
         VIR_ERROR(_("failed to load module %s %s"), modfile, dlerror());
index 00e3d9cd2332bdf6ab884e3df9f8687c7c4397c3..f1607cd6acdae253750a1395cb066e950d6d4759 100644 (file)
@@ -1954,6 +1954,7 @@ virGetGroupID;
 virGetGroupList;
 virGetGroupName;
 virGetHostname;
+virGetSelfLastChanged;
 virGetUnprivSGIOSysfsPath;
 virGetUserCacheDirectory;
 virGetUserConfigDirectory;
@@ -1983,6 +1984,7 @@ virSetNonBlock;
 virSetUIDGID;
 virSetUIDGIDWithCaps;
 virStrIsPrint;
+virUpdateSelfLastChanged;
 virValidateWWN;
 
 
index 7a2fbb0561484463ca26ecdaa11fbf0869cb5bc4..b6106fce2a0d69c6ec61bc9fce12de413effc901 100644 (file)
@@ -2173,3 +2173,26 @@ bool virIsSUID(void)
 {
     return getuid() != geteuid();
 }
+
+
+static time_t selfLastChanged;
+
+time_t virGetSelfLastChanged(void)
+{
+    return selfLastChanged;
+}
+
+
+void virUpdateSelfLastChanged(const char *path)
+{
+    struct stat sb;
+
+    if (stat(path, &sb) < 0)
+        return;
+
+    if (sb.st_ctime > selfLastChanged) {
+        VIR_DEBUG("Setting self last changed to %lld for '%s'",
+                  (long long)sb.st_ctime, path);
+        selfLastChanged = sb.st_ctime;
+    }
+}
index 029265c2c0ca91fbc17438b298a19a1d60ace222..cffe1ede48d04f9574e008006324c150d740f239 100644 (file)
@@ -194,4 +194,8 @@ const char *virGetEnvBlockSUID(const char *name);
 const char *virGetEnvAllowSUID(const char *name);
 bool virIsSUID(void);
 
+
+time_t virGetSelfLastChanged(void);
+void virUpdateSelfLastChanged(const char *path);
+
 #endif /* __VIR_UTIL_H__ */