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(a)redhat.com>
---
meson.build | 6 ++++++
meson_options.txt | 1 +
src/qemu/qemu_nbdkit.c | 40 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 47 insertions(+)
diff --git a/meson.build b/meson.build
index 93de355430..e4581e74dd 100644
--- a/meson.build
+++ b/meson.build
@@ -1731,6 +1731,12 @@ if not get_option('driver_qemu').disabled()
qemu_dbus_daemon_path = '/usr/bin/dbus-daemon'
endif
conf.set_quoted('QEMU_DBUS_DAEMON', qemu_dbus_daemon_path)
+
+ nbdkit_moddir = get_option('nbdkit_moddir')
+ if nbdkit_moddir == ''
+ nbdkit_moddir = libdir / 'nbdkit'
+ endif
+ conf.set_quoted('NBDKIT_MODDIR', nbdkit_moddir)
endif
endif
diff --git a/meson_options.txt b/meson_options.txt
index 861c5577d2..d5ea4376e0 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -71,6 +71,7 @@ option('driver_vbox', type: 'feature', value:
'auto', description: 'VirtualBox X
option('vbox_xpcomc_dir', type: 'string', value: '', description:
'Location of directory containing VirtualBox XPCOMC library')
option('driver_vmware', type: 'feature', value: 'auto',
description: 'VMware driver')
option('driver_vz', type: 'feature', value: 'auto', description:
'Virtuozzo driver')
+option('nbdkit_moddir', type: 'string', value: '', description:
'set the directory where nbdkit modules are located')
option('secdriver_apparmor', type: 'feature', value: 'auto',
description: 'use AppArmor security driver')
option('apparmor_profiles', type: 'feature', value: 'auto',
description: 'install apparmor profiles')
diff --git a/src/qemu/qemu_nbdkit.c b/src/qemu/qemu_nbdkit.c
index 7a7248c1ef..5de1021d89 100644
--- a/src/qemu/qemu_nbdkit.c
+++ b/src/qemu/qemu_nbdkit.c
@@ -41,6 +41,9 @@
VIR_LOG_INIT("qemu.nbdkit");
+#define NBDKIT_PLUGINDIR NBDKIT_MODDIR "/plugins"
+#define NBDKIT_FILTERDIR NBDKIT_MODDIR "/filters"
+
VIR_ENUM_IMPL(qemuNbdkitCaps,
QEMU_NBDKIT_CAPS_LAST,
/* 0 */
@@ -54,6 +57,11 @@ struct _qemuNbdkitCaps {
char *path;
char *version;
+ time_t ctime;
+ time_t libvirtCtime;
+ time_t pluginDirMtime;
+ time_t filterDirMtime;
+ unsigned int libvirtVersion;
virBitmap *flags;
};
@@ -178,9 +186,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.37.3