On Thu, May 28, 2026 at 14:48:58 +0200, Michal Privoznik via Devel wrote:
> From: Michal Privoznik <[email protected]>
>
> The time_t type can be 32bit or 64bit signed integer. There are
> systems where it's defined as long, or long long (32bit systems
> usually). Therefore, using just 'l' length modifier is not good
> enough. Also, using 'u' conversion specifier is also wrong
> (though, values stored in qemuNbdkitCaps struct reflect mtime of
> some files, so there won't be a negative value).
>
> Anyway, do what we already do for virQEMUCaps - use '%lld' printf
> format and typecast to long long.
>
> Signed-off-by: Michal Privoznik <[email protected]>
> ---
>
> Spotted this on the following pipeline:
>
> https://gitlab.com/MichalPrivoznik/libvirt/-/jobs/14580340190
>
> in which I was testing moving our CI from Debian 12 to 13. Apparently,
> in Debian they decided to -D_TIME_BITS=64 for everything [1] and only
> when compiling on a 32bit arch it's when time_t expands to 'long long'.
>
> 1: https://wiki.debian.org/ReleaseGoals/64bit-time
>
> src/qemu/qemu_nbdkit.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/src/qemu/qemu_nbdkit.c b/src/qemu/qemu_nbdkit.c
> index 542a6b1f44..6918fc6631 100644
> --- a/src/qemu/qemu_nbdkit.c
> +++ b/src/qemu/qemu_nbdkit.c
> @@ -544,18 +544,18 @@ qemuNbdkitCapsFormatCache(qemuNbdkitCaps *nbdkitCaps)
>
> virBufferEscapeString(&buf, "<path>%s</path>\n",
> nbdkitCaps->path);
> - virBufferAsprintf(&buf, "<nbdkitctime>%lu</nbdkitctime>\n",
> - nbdkitCaps->ctime);
> + virBufferAsprintf(&buf, "<nbdkitctime>%lld</nbdkitctime>\n",
> + (long long)nbdkitCaps->ctime);
> virBufferEscapeString(&buf, "<plugindir>%s</plugindir>\n",
> nbdkitCaps->pluginDir);
I looked at how we do this with qemu caps and found this mess:
virBufferAsprintf(&buf, "<selfctime>%llu</selfctime>\n",
(long long)qemuCaps->libvirtCtime);
I'll be away for a bit, feel free to send the patch if you want.
Reviewed-by: Peter Krempa <[email protected]>