On Tue, Jul 07, 2026 at 09:48:20AM +0200, Denis V. Lunev via Devel wrote:
> virScaleInteger() already turns a number plus a unit suffix into
> bytes, but every caller has to split a whole string like "10GiB" by
> hand via virStrToLong_ullp() first, the way virFileReadValueScaledInt()
> does for sysfs files. Add virStrToBytes(), which does that split once,
> and virConfGetValueBytes() on top of it, so a qemu.conf-style setting
> can accept a scaled size in one call. Named "Bytes" rather than "Size"
> to avoid reading as a variant of virConfGetValueSizeT()/SSizeT(),
> whose "T" is the C type they fill, not a unit.
> 
> Add unit tests for virStrToBytes() in virstringtest.c.
> 
> Signed-off-by: Denis V. Lunev <[email protected]>
> ---
>  src/libvirt_private.syms |  2 ++
>  src/util/virconf.c       | 47 +++++++++++++++++++++++++
>  src/util/virconf.h       |  3 ++
>  src/util/virutil.c       | 23 ++++++++++++
>  src/util/virutil.h       |  5 +++
>  tests/virstringtest.c    | 76 ++++++++++++++++++++++++++++++++++++++++
>  6 files changed, 156 insertions(+)

Reviewed-by: Daniel P. Berrangé <[email protected]>
 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|

Reply via email to