[libvirt PATCH v8 03/37] qemu: expand nbdkit capabilities

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

 



In order to add caching of the nbdkit capabilities, we will need to
compare against file modification times, etc. So look up this
information when creating the nbdkit caps.

Add a nbdkit_moddir build option to allow the builder to specify the
location to look for nbdkit plugins and filters.

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_nbdkit.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/src/qemu/qemu_nbdkit.c b/src/qemu/qemu_nbdkit.c
index e4e8fd568e..58828dd89a 100644
--- a/src/qemu/qemu_nbdkit.c
+++ b/src/qemu/qemu_nbdkit.c
@@ -20,6 +20,7 @@
 #include <config.h>
 #include <glib.h>
 
+#include "configmake.h"
 #include "vircommand.h"
 #include "virerror.h"
 #include "virlog.h"
@@ -38,6 +39,10 @@
 
 VIR_LOG_INIT("qemu.nbdkit");
 
+#define NBDKIT_MODDIR LIBDIR "/nbdkit"
+#define NBDKIT_PLUGINDIR NBDKIT_MODDIR "/plugins"
+#define NBDKIT_FILTERDIR NBDKIT_MODDIR "/filters"
+
 VIR_ENUM_IMPL(qemuNbdkitCaps,
     QEMU_NBDKIT_CAPS_LAST,
     /* 0 */
@@ -51,6 +56,11 @@ struct _qemuNbdkitCaps {
 
     char *path;
     char *version;
+    time_t ctime;
+    time_t libvirtCtime;
+    time_t pluginDirMtime;
+    time_t filterDirMtime;
+    unsigned int libvirtVersion;
 
     virBitmap *flags;
 };
@@ -175,9 +185,41 @@ qemuNbdkitCapsNew(const char *path)
 }
 
 
+static time_t
+qemuNbdkitGetDirMtime(const char *moddir)
+{
+    struct stat st;
+
+    if (stat(moddir, &st) < 0) {
+        VIR_DEBUG("Failed to stat nbdkit module directory '%s': %s",
+                  moddir,
+                  g_strerror(errno));
+        return 0;
+    }
+
+    return st.st_mtime;
+}
+
+
 G_GNUC_UNUSED static void
 qemuNbdkitCapsQuery(qemuNbdkitCaps *caps)
 {
+    struct stat st;
+
+    if (stat(caps->path, &st) < 0) {
+        VIR_DEBUG("Failed to stat nbdkit binary '%s': %s",
+                  caps->path,
+                  g_strerror(errno));
+        caps->ctime  = 0;
+        return;
+    }
+
+    caps->ctime = st.st_ctime;
+    caps->filterDirMtime = qemuNbdkitGetDirMtime(NBDKIT_FILTERDIR);
+    caps->pluginDirMtime = qemuNbdkitGetDirMtime(NBDKIT_PLUGINDIR);
+    caps->libvirtCtime = virGetSelfLastChanged();
+    caps->libvirtVersion = LIBVIR_VERSION_NUMBER;
+
     qemuNbdkitCapsQueryPlugins(caps);
     qemuNbdkitCapsQueryFilters(caps);
     qemuNbdkitCapsQueryVersion(caps);
-- 
2.41.0




[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]

  Powered by Linux