This adds an nbdinfo sub-option --map --totals to display the total of
each type of mapping:

  $ nbdkit -r file fedora-33.img --run 'nbdinfo --map --totals $uri'
  1226113024  19.0   0 data
  5216337920  81.0   3 hole,zero

I need this kind of functionality for virt-v2v in order to estimate
how much space is required on the target, although for virt-v2v I will
probably use the API directly.  Nevertheless it seems like a useful
feature and the implementation does not complicate nbdinfo.

It can also be used for other map types, eg. for showing how much of
the dirty-bitmap is dirty.

The implementation could be done in a single pass although for the
vast majority of use cases I doubt that would be any faster since the
table easily fits in L1 cache, and it would require a complex data
structure.  But it's worth noting that a malicious server could try to
make nbdinfo use O(n^2) time (with a very small constant).

Rich.


_______________________________________________
Libguestfs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to