[Libguestfs] [PATCH v2 1/2] mltools, options: support --allow-discards when decrypting LUKS devices

Pino Toscano ptoscano at redhat.com
Tue Jan 28 15:49:06 UTC 2020


On Monday, 27 January 2020 13:12:35 CET Jan Synacek wrote:
> ---
>  mltools/tools_utils-c.c | 8 ++++----
>  mltools/tools_utils.ml  | 6 +++---
>  mltools/tools_utils.mli | 8 ++++++--
>  options/decrypt.c       | 5 +++--
>  options/inspect.c       | 2 +-
>  options/options.h       | 2 +-
>  6 files changed, 18 insertions(+), 13 deletions(-)
> 
> diff --git a/mltools/tools_utils-c.c b/mltools/tools_utils-c.c
> index 6c43b8d..1dcebc4 100644
> --- a/mltools/tools_utils-c.c
> +++ b/mltools/tools_utils-c.c
> @@ -36,7 +36,7 @@
>  
>  #include "options.h"
>  
> -extern value guestfs_int_mllib_inspect_decrypt (value gv, value gpv, value keysv);
> +extern value guestfs_int_mllib_inspect_decrypt (value gv, value gpv, value keysv, value allowdiscards);

We usually name arguments of type value in C implementations of OCaml
functions with a "v" suffix (see the other parameters, for example).

> -  inspect_do_decrypt (g, ks);
> +  inspect_do_decrypt (g, ks, Int_val (allowdiscards));

The parameter is 'bool', so this must be Bool_val() -- in practice it
is the same, however better use the right _val() function to avoid
unexpected surprises in newer OCaml versions.

>          guestfs_push_error_handler (g, NULL, NULL);
> -        r = guestfs_luks_open (g, partitions[i], keys[j], mapname);
> +        r = guestfs_luks_open_opts (g, partitions[i], keys[j], mapname,
> +                                    GUESTFS_LUKS_OPEN_OPTS_ALLOWDISCARDS, allowdiscards, -1);

This is in the common submodule, while the new API parameter is in the
main libguestfs repository -- considering the common submodule is used
also by virt-v2v, we do not want to push the virt-v2v requirements to
the git version of libguestfs.

One way to get around that for now is to make the new API conditional;
see for example few lines above what was done for the luks_uuid.
guestfs.h provides #define's also for optional parameters of functions.

Thanks,
-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20200128/f00d7228/attachment.sig>


More information about the Libguestfs mailing list