On Fri, May 29, 2026 at 16:46:58 +0200, Radoslaw Smigielski wrote: [...]
Another issue is that if you'll have:
<filesystem type='file' accessmode='passthrough'> <driver type='loop' format='raw'/> <source file='/root/someveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerylongpath/a.raw'/> <target dir='/'/> </filesystem> <filesystem type='file' accessmode='passthrough'> <driver type='loop' format='raw'/> <source file='/root/someveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerylongpath/b.raw'/> <target dir='/'/> </filesystem>
They'll be truncated to the same string.
So I tried to follow the same logic like losetup from util-linux uses to handle long paths: - takes the first 63 bytes of the absolute path - no intelligent path shortening (like keeping the filename and truncating middle) - adds an asterisk at position 62 to indicate the name was truncated
lo->lo_file_name[LO_NAME_SIZE - 2] = '*'; // Position 62 gets '*' lo->lo_file_name[LO_NAME_SIZE - 1] = '\0'; // Position 63 is null terminator
Above indeed can result in non-unique or unhelpful loop device names in the kernel's loop_info64 structure.
So ... the most important question is how the value is used (which I don't remember any more). If it's visible or used from withint the LXC instance, then we must not change it. The users are out of luck unfortunately. If it's just informative and we can change it (and based on the fact that it's being truncated so it doesn't reflect anything real) we could also replace it by a controlled string which is unable to exceed 63 chars without truncation. It could be something like: 'libvirt-$UUID-$DEVALIAS'
Question if we should mimic the same logic or imlement someting smarter.
It really depends on what the semantics are; see above. If it can be changed though I'd go for something more stable for the future.
Addint "*" before '\0' to indicate truncation would make it compatibile with losetup behavior.
I'm not sure if that's too valuable of a behaviour. It prevents you from identifying the resource. Having an indentifier allowing you to look up the path would make more sense. ... Well, now you see why this issue lingered so long. There are plenty corner cases that need to be checked and behaviour analyzed :)