Skip to content

Commit

Permalink
vddk: Work with VDDK libraries back to 5.1.1.
Browse files Browse the repository at this point in the history
Enhance the configure test so it recognizes the optional fields
nfcHostPort and vimApiVer in VixDiskLibConnectParams.

Modify the code to make these fields optional.

To check if the optional fields are present, use --dump-plugin.  You
will see these lines if the corresponding fields (and command line
keys) are present, otherwise they will be missing:

vddk_has_nfchostport=1
vddk_has_vimapiver=1
  • Loading branch information
rwmjones committed Dec 6, 2017
1 parent b94b1a6 commit 1535d18
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 1 deletion.
45 changes: 44 additions & 1 deletion configure.ac
Expand Up @@ -424,7 +424,7 @@ AS_IF([test "$with_vddk" = "yes"],[
VDDK_LIBS="-lvixDiskLib"
# XXX Warning: stupid VMware API.
VDDK_LIBDIR="$libdir/vmware-vix-disklib"
AC_MSG_NOTICE([VDDK plugin enabled])
AC_MSG_NOTICE([VDDK plugin enabled from $VDDK_LIBDIR])
],[
AS_IF([test "$with_vddk" != "no"], [
VDDK_CFLAGS="-I$with_vddk/include"
Expand All @@ -435,6 +435,49 @@ AS_IF([test "$with_vddk" = "yes"],[
[AC_MSG_NOTICE([VDDK plugin disabled])
])
])

dnl If the VDDK plugin was enabled, compile and link a test program to make
dnl sure the library really works.
AS_IF([test "x$VDDK_LIBS" != "x"],[
# Save CFLAGS etc while we do this test.
acx_nbdkit_save_CFLAGS="${CFLAGS}"
acx_nbdkit_save_LIBS="${LIBS}"
CFLAGS="$CFLAGS $VDDK_CFLAGS"
LIBS="$VDDK_LIBS $LIBS"
AC_MSG_CHECKING([if we can link to VDDK])
AC_LINK_IFELSE([
AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdint.h>
#include <vixDiskLib.h>
int
main ()
{
VixDiskLib_Exit ();
}
]])
],[
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
AC_MSG_ERROR([could not link to VDDK, see ‘config.log’ for more information])
])
dnl Check for optional fields in VixDiskLibConnectParams struct.
AC_CHECK_MEMBERS([VixDiskLibConnectParams.nfcHostPort, VixDiskLibConnectParams.vimApiVer],
[], [], [[
#include <stdio.h>
#include <stdint.h>
#include <vixDiskLib.h>
]])
dnl Restore CFLAGS, etc.
CFLAGS="${acx_nbdkit_save_CFLAGS}"
LIBS="${acx_nbdkit_save_LIBS}"
])

AC_SUBST([VDDK_CFLAGS])
AC_SUBST([VDDK_LIBS])
AC_DEFINE_UNQUOTED([VDDK_LIBDIR],["$VDDK_LIBDIR"],[VDDK 'libDir'.])
Expand Down
36 changes: 36 additions & 0 deletions plugins/vddk/nbdkit-vddk-plugin.pod
Expand Up @@ -12,6 +12,7 @@ nbdkit-vddk-plugin - VMware VDDK plugin for nbdkit
[cookie=COOKIE] [thumbprint=THUMBPRINT]
[vimapiver=APIVER] [port=PORT] [nfchostport=PORT]
[snapshot=MOREF] [transports=MODE:MODE:...]
nbdkit vddk --dump-plugin

=head1 DESCRIPTION

Expand Down Expand Up @@ -77,6 +78,8 @@ compile time is used.
Optional. Port used to establish an NFC connection to ESXi. Defaults
to 902.

(Only supported in VDDK ≥ 5.5.5 and ≥ 6.0.1)

=item B<password=PASSWORD>

Optional (required for remote connections). Set the password to use
Expand Down Expand Up @@ -177,6 +180,8 @@ L<https://blogs.vmware.com/vsphere/2012/02/uniquely-identifying-virtual-machines
Optional. Specify the VIM API version. If not given it defaults to
the current version.

(Only supported in VDDK ≥ 6.5.0)

=back

=head1 EXAMPLES
Expand Down Expand Up @@ -242,6 +247,37 @@ C<file> is the actual file you want to open, usually in the form
C<"[datastore] vmname/vmname.vmdk">. You can find this from the
L<virsh(1)> as described in L</PARAMETERS> above.

=head1 DUMP-PLUGIN OUTPUT

To query more information about the plugin (and whether it is
working), use:

nbdkit vddk --dump-plugin

If the plugin is not present, not working or the library path is wrong
you will get an error.

If it works the output will include:

=over 4

=item C<vddk_default_libdir=...>

The compiled-in library path. Use C<libdir=PATHNAME> to override this
at runtime.

=item C<vddk_has_nfchostport=1>

If this is printed then the C<nfchostport=PORT> parameter is supported
by this build.

=item C<vddk_has_vimapiver=1>

If this is printed then the C<vimapiver=APIVER> parameter is supported
by this build.

=back

=head1 DEBUGGING VDDK

Debugging messages can be very helpful if you have problems connecting
Expand Down
23 changes: 23 additions & 0 deletions plugins/vddk/vddk.c
Expand Up @@ -171,10 +171,15 @@ vddk_config (const char *key, const char *value)
libdir = value;
}
else if (strcmp (key, "nfchostport") == 0) {
#if HAVE_VIXDISKLIBCONNECTPARAMS_NFCHOSTPORT
if (sscanf (value, "%d", &nfc_host_port) != 1) {
nbdkit_error ("cannot parse nfchostport: %s", value);
return -1;
}
#else
nbdkit_error ("this version of VDDK is too old to support nfchostpost");
return -1;
#endif
}
else if (strcmp (key, "password") == 0) {
free (password);
Expand Down Expand Up @@ -203,7 +208,12 @@ vddk_config (const char *key, const char *value)
username = value;
}
else if (strcmp (key, "vimapiver") == 0) {
#if HAVE_VIXDISKLIBCONNECTPARAMS_VIMAPIVER
vim_api_ver = value;
#else
nbdkit_error ("this version of VDDK is too old to support vimapiver");
return -1;
#endif
}
else if (strcmp (key, "vm") == 0) {
vmx_spec = value;
Expand Down Expand Up @@ -266,6 +276,15 @@ static void
vddk_dump_plugin (void)
{
printf ("vddk_default_libdir=%s\n", VDDK_LIBDIR);

#if HAVE_VIXDISKLIBCONNECTPARAMS_NFCHOSTPORT
printf ("vddk_has_nfchostport=1\n");
#endif

#if HAVE_VIXDISKLIBCONNECTPARAMS_VIMAPIVER
printf ("vddk_has_vimapiver=1\n");
#endif

/* XXX We really need to print the version of the dynamically
* linked library here, but VDDK does not provide it.
*/
Expand Down Expand Up @@ -315,8 +334,12 @@ vddk_open (int readonly)
}
params.thumbPrint = (char *) thumb_print;
params.port = port;
#if HAVE_VIXDISKLIBCONNECTPARAMS_NFCHOSTPORT
params.nfcHostPort = nfc_host_port;
#endif
#if HAVE_VIXDISKLIBCONNECTPARAMS_VIMAPIVER
params.vimApiVer = (char *) vim_api_ver;
#endif
}

/* XXX Some documentation suggests we should call
Expand Down

0 comments on commit 1535d18

Please sign in to comment.