v2v: nbdkit: Add a generic function to probe if filters are available.

This uses the technique described in the nbdkit-probing(1) man page.
It should work with a wide range of versions of nbdkit, and is the one
which the nbdkit developers currently recommend.
This commit is contained in:
Richard W.M. Jones
2019-09-24 14:28:13 +01:00
parent 56727f8431
commit 0796092e05

View File

@@ -133,6 +133,17 @@ let common_create plugin_name plugin_args plugin_env =
if have_selinux then ( (* label the socket so qemu can open it *)
add_arg "--selinux-label"; add_arg "system_u:object_r:svirt_socket_t:s0"
);
(* Probe to see if a filter is installed. See nbdkit-probing(1)
* for recommended method.
*)
let probe_filter filter_name =
let cmd =
sprintf "%s nbdkit --dump-plugin --filter=%s null >/dev/null"
env_as_string filter_name in
Sys.command cmd <> 0
in
let args = get_args () @ [ plugin_name ] @ plugin_args in
{ plugin_name; args; env; dump_config; dump_plugin }