The C standard defines the L length modifier only for floating-point conversions. glibc's printf() treats %Lu as %llu, but musl's fails at it, and the message ends where the number should be. With musl, the line that lkvm prints when it starts a guest stops after "-m": Info: # lkvm run -k /guest/Image -m and the error for a firmware image that is too big stops after "(". The values are unsigned long long, so print them with %llu, as the rest of kvmtool does. Assisted-by: Claude:claude-fable-5-2 Signed-off-by: Mika Tammi --- Tested with nixpkgs' kvmtool package at kvmtool master (4b4aceb1dae7) on x86_64. With glibc, the messages are the same with and without this patch. With musl, dynamic and static, they were cut off as above and are now the same as with glibc. The musl builds also have "Set the VCPU affinity with sched_setaffinity() (for musl compatibility)" [1], which master needs to build with musl; the two patches apply independently. A static musl lkvm on QEMU rv32 and rv64 KVM hosts prints the whole line too. Cross builds for arm64, riscv32 and riscv64 build. [1] https://lore.kernel.org/kvm/20261128061232.64870-1-mikatammi@gmail.com/ builtin-run.c | 4 ++-- x86/boot.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin-run.c b/builtin-run.c index f06231e..1dc962a 100644 --- a/builtin-run.c +++ b/builtin-run.c @@ -839,12 +839,12 @@ static struct kvm *kvm_cmd_run_init(int argc, const char **argv) kvm_run_set_real_cmdline(kvm); if (kvm->cfg.kernel_filename) { - pr_info("# %s run -k %s -m %Lu -c %d --name %s", KVM_BINARY_NAME, + pr_info("# %s run -k %s -m %llu -c %d --name %s", KVM_BINARY_NAME, kvm->cfg.kernel_filename, (unsigned long long)kvm->cfg.ram_size >> MB_SHIFT, kvm->cfg.nrcpus, kvm->cfg.guest_name); } else if (kvm->cfg.firmware_filename) { - pr_info("# %s run --firmware %s -m %Lu -c %d --name %s", KVM_BINARY_NAME, + pr_info("# %s run --firmware %s -m %llu -c %d --name %s", KVM_BINARY_NAME, kvm->cfg.firmware_filename, (unsigned long long)kvm->cfg.ram_size >> MB_SHIFT, kvm->cfg.nrcpus, kvm->cfg.guest_name); diff --git a/x86/boot.c b/x86/boot.c index 61535eb..ed856a1 100644 --- a/x86/boot.c +++ b/x86/boot.c @@ -26,7 +26,7 @@ bool kvm__load_firmware(struct kvm *kvm, const char *firmware_filename) return false; if (st.st_size > MB_FIRMWARE_BIOS_SIZE) - die("firmware image %s is too big to fit in memory (%Lu KB).\n", firmware_filename, (u64)(st.st_size / 1024)); + die("firmware image %s is too big to fit in memory (%llu KB).\n", firmware_filename, (u64)(st.st_size / 1024)); p = guest_flat_to_host(kvm, MB_FIRMWARE_BIOS_BEGIN); -- 2.54.0 (Apple Git-157)