mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
qemu: expand nbdkit capabilities
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@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
6b7e6b73a9
commit
03afd10cd3
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user