[Libguestfs] [PATCH] virt-sysprep:add logging feature

Wanlong Gao gaowanlong at cn.fujitsu.com
Wed Apr 11 00:40:36 UTC 2012


On 04/06/2012 04:56 PM, Richard W.M. Jones wrote:

> On Fri, Apr 06, 2012 at 01:37:33PM +0800, Wanlong Gao wrote:
>> Hi Rich,
>>
>> I tried to implement the logging feature, but I can't though
>> compiling with this patch now, could you please give me
>> some comments?
>>
>> The error message is below,
>> ---
>> ocamlfind ocamlopt -g -warn-error CDEFLMPSUVYZX -package unix -I ../src/.libs -I ../ocaml -c sysprep_operation.ml -o sysprep_operation.cmx
>> File "sysprep_operation.ml", line 1, characters 0-1:
>> Error: The implementation sysprep_operation.ml
>>        does not match the interface sysprep_operation.cmi:
>>        Type declarations do not match:
>>          type operation = {
>>            name : string;
>>            pod_description : string;
>>            extra_args : ((Arg.key * Arg.spec * Arg.doc) * string) list;
>>            perform : Guestfs.guestfs -> string -> bool -> flag list;
>>          }
>>        is not included in
>>          type operation = {
>>            name : string;
>>            pod_description : string;
>>            extra_args : ((Arg.key * Arg.spec * Arg.doc) * string) list;
>>            perform : Guestfs.guestfs -> string -> flag list;
>>          }
>>        The types for field perform are not equal.
> 
> Indeed they are not!  The implementation (*.ml) has changed:
> 
>> -  perform : Guestfs.guestfs -> string -> flag list;
>> +  perform : Guestfs.guestfs -> string -> bool -> flag list;
> 
> but you must make an equivalent change to the interface (in
> sysprep_operation.mli) -- adding the extra debug flag.
> 
> May I suggest another way to do this which is a bit more natural.  Use
> a function.  Declare it as:
> 
>   type debug_fn = ('a, unit, string, unit) format4 -> 'a


Could you please point out the error I met here?

File "sysprep_operation.mli", line 23, characters 17-19:
Error: Unbound type parameter 'a
make: *** [sysprep_operation.cmi] Error 2
make: Leaving directory `/work/git/libguestfs/sysprep'

Thanks,
Wanlong Gao

>   type operation = { ...
>     perform : Guestfs.guestfs -> debug:debug_fn -> string -> flag list
>   }
> 
> Implementations would just do this:
> 
>   let foo_perform g ~debug root =
>     debug "I'm calling foo %s" root;
>     ...
> 
> The main function does this:
> 
>   let debug fs =
>     ksprintf (fun str -> if show_log then prerr_endline str) fs
> 
>   ...
> 
>   Sysprep_operations.perform_operations ?operations ~debug g root
> 
> Note that the debug function prints conditionally, based on whether
> show_log is set or not.
> 
> Rich.
> 





More information about the Libguestfs mailing list