[libnbd] Some IRC questions
01:58 < eblake_> it would be nice if libnbd had a way to query if nbd support were compiled in 01:58 < eblake_> whether a constant we set in the .h file, or a runtime function 01:58 < eblake_> it would also be nice if libnbd.h declared a macro LIBNBD_VERSION 01:59 < eblake_> although my OCaml skills are too weak to figure out how to reflect something from configure.ac into the generator output A constant defined by the generator is possible like this (but not necessarily a good idea, see below). (1) Create a file called something like generator/config.ml.in which contains: let package = "@PACKAGE_NAME@" let version = "@PACKAGE_VERSION@" let has_libxml2 = "@HAS_LIBXML2@" = "1" For an example see: https://github.com/libguestfs/supermin/blob/master/src/config.ml.in (2) Generate config.ml using configure. (3) Use AC_SUBST etc as appropriate. (4) In generator/generator, add near the top: #mod_use "config.ml" (5) The variables can be used from the OCaml code as Config.version, etc. However I don't think this isn't a good idea. One problem is that you end up with the version of the library that your program compiled against, not the version it is linked against (and similarly for other features like URI support). So as you say above a runtime function is better, which can be added as an ordinary API. This is what we did in libguestfs: http://libguestfs.org/guestfs.3.html#guestfs_version http://libguestfs.org/guestfs.3.html#guestfs_feature_available 02:00 < eblake_> ^ make that if libxml2 support for uri parsing were compiled in 02:01 < eblake_> and the spec file needs an update: libnbd-0.1.2-1.fc29.x86_64 gives: 02:01 < eblake_> nbdkit: error: failure while creating nbd handle: nbd_connect_uri: libnbd was compiled without libxml2 support, so we do not support NBD URI: Operation not supported This is fixed now in the Fedora libnbd-0.1.2-2 packages. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
On Sun, Jun 02, 2019 at 11:14:58AM +0100, Richard W.M. Jones wrote:
However I don't think this isn't a good idea. One problem is that you
I don't think this *is* a good idea. Too early on a Sunday ... Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
participants (1)
-
Richard W.M. Jones