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 | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+)
diff --git a/meson.build b/meson.build
index 0b3187ad88..2b0425f1f6 100644
--- a/meson.build
+++ b/meson.build
@@ -1744,6 +1744,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 5b43cdbd6b..382174bc03 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 f55f68299f..0ea1b754cd 100644
--- a/src/qemu/qemu_nbdkit.c
+++ b/src/qemu/qemu_nbdkit.c
@@ -42,6 +42,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 */
@@ -55,6 +58,11 @@ struct _qemuNbdkitCaps {
char *path;
char *version;
+ time_t ctime;
+ time_t libvirtCtime;
+ time_t pluginDirMtime;
+ time_t filterDirMtime;
+ unsigned int libvirtVersion;
virBitmap *flags;
};
@@ -177,9 +185,40 @@ qemuNbdkitCapsNew(const char *path)
}
+static time_t
+getDirMtime(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;
+}
+
+
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;
+ } else {
+ caps->ctime = st.st_ctime;
+ }
+ caps->filterDirMtime = getDirMtime(NBDKIT_FILTERDIR);
+ caps->pluginDirMtime = getDirMtime(NBDKIT_PLUGINDIR);
+ caps->libvirtCtime = virGetSelfLastChanged();
+ caps->libvirtVersion = LIBVIR_VERSION_NUMBER;
+
qemuNbdkitCapsQueryPlugins(caps);
qemuNbdkitCapsQueryFilters(caps);
qemuNbdkitCapsQueryVersion(caps);
--
2.37.1