[Libguestfs] [v2v PATCH 2/2] lib/utils: get_disk_allocated: adopt the int64 element type for "entries"

Richard W.M. Jones rjones at redhat.com
Fri Jan 14 14:07:35 UTC 2022


On Fri, Jan 14, 2022 at 02:50:48PM +0100, Laszlo Ersek wrote:
> Adapt our "Utils.get_disk_allocated" function to the changed signature of
> "NBD.block_status", coming from libnbd patch
> 
>   ocaml: map C's uint32_t to OCaml's int64
> 
> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2027598
> Signed-off-by: Laszlo Ersek <lersek at redhat.com>
> ---
>  lib/utils.ml | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/utils.ml b/lib/utils.ml
> index f599b0e32450..4c8998c28a3c 100644
> --- a/lib/utils.ml
> +++ b/lib/utils.ml
> @@ -195,10 +195,10 @@ let get_disk_allocated ~dir ~disknr =
>                 (fun ctx offset entries err ->
>                    assert (ctx = alloc_ctx);
>                    for i = 0 to Array.length entries / 2 - 1 do
> -                    let len = Int64.of_int32 entries.(i * 2)
> +                    let len = entries.(i * 2)
>                      and typ = entries.(i * 2 + 1) in
>                      assert (len > 0_L);
> -                    if Int32.logand typ 1_l = 0_l then
> +                    if typ &^ 1_L = 0_L then
>                        allocated := !allocated +^ len;
>                      fetch_offset := !fetch_offset +^ len
>                    done;

ACK - even makes the code better :-)

Getting this into RHEL is going to be a pain, I will deal with the
chain of builds once you've pushed this upstream.

Thanks,

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list