Bug 1817401

Summary: virtiofs log name may be too long to start the guest
Product: Red Hat Enterprise Linux 9 Reporter: yafu <yafu>
Component: libvirtAssignee: Ján Tomko <jtomko>
libvirt sub component: Storage QA Contact: Lili Zhu <lizhu>
Status: CLOSED WONTFIX Docs Contact:
Severity: low    
Priority: low CC: bugproxy, chhu, jsuchane, jtomko, kwolf, lmen, mkletzan, mprivozn, virt-maint, xuzhang, yanqzhan
Version: 9.0Keywords: Reopened, Triaged
Target Milestone: betaFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-07-11 13:07:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1694166    
Bug Blocks: 1897025, 1916117, 1924294    

Description yafu 2020-03-26 09:54:55 UTC
Description of problem:
The virtiofs_debug log is named as 'domain-alias name-viriofsd.log'. If the alias name is 'ua+uuid', such as: 'ua-1035e984-8238-46e1-bf56-b546246e1a39', the log name is about 50 chars longer than the vm name and it may cause the name of virtiofs debug log too long to create. Then the guest will fail to start.

Version-Release number of selected component (if applicable):
libvirt-6.0.0-15.el8.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Define a guest with long guest name:
#virsh list --all
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

2.Start the guest
#virsh start 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
error: Failed to start domain 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
error: Unable to open file: /var/log/libvirt/qemu/11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111-ua-1035e984-8238-46e1-bf56-b546246e1a39-virtiofsd.log: File name too long


3.

Actual results:


Expected results:


Additional info:

Comment 1 Luiz Capitulino 2020-03-26 12:51:15 UTC
Jano,

How serious do you think this is?

Is the debug log enabled by default for all guests, or
is it something the user has to enable?

If the user has to enable, then I'd say it's less serious.

Comment 2 Ján Tomko 2020-03-27 14:03:38 UTC
The log is created for all guests with a virtiofs filesystem.

The filename length is problematic for the combination of:
* using uuids as user-defined device aliases
* using very long guest names

By default the device alias for the first device is just "fs0", so it
does not limit the domain name as much.

Also, the current naming scheme is not foolproof - it can clash with
another domain's log file if someone puts the log filename as the
domain name:
https://www.redhat.com/archives/libvir-list/2020-March/msg00818.html

Comment 4 Martin Kletzander 2020-12-02 16:01:53 UTC
Each domain should just have its own directory in the common log directory, just like we had to migrate to this in the case with other files.  Ideally most of the files should move to that structure.

Comment 6 RHEL Program Management 2021-09-26 07:26:49 UTC
After evaluating this issue, there are no plans to address it further or fix it in an upcoming release.  Therefore, it is being closed.  If plans change such that this issue will be fixed in an upcoming release, then the bug can be reopened.

Comment 7 Luiz Capitulino 2021-09-27 17:18:55 UTC
Jan,

This looks like an important issue we'd like to get fix, so I'm reopening it.

Comment 12 RHEL Program Management 2022-03-27 07:27:17 UTC
After evaluating this issue, there are no plans to address it further or fix it in an upcoming release.  Therefore, it is being closed.  If plans change such that this issue will be fixed in an upcoming release, then the bug can be reopened.

Comment 13 Lili Zhu 2022-03-27 09:18:10 UTC
Hi, Jarda

I reopened this bug. please help to confirm whether this bug should be fixed. Thanks

Comment 16 Jaroslav Suchanek 2022-04-07 12:06:02 UTC
Patch proposed upstream by MartinK:
https://listman.redhat.com/archives/libvir-list/2022-April/229916.html

Comment 17 Michal Privoznik 2022-04-07 13:19:04 UTC
How serious is this issue? I mean, we can try to shorten the log path but then the next problem is collision in log filename. And even if we'd figure a workaround for this, the path limit is going to be hit for something else (e.g. domain monitor socket/log file/...). My suggestion is: don't use long names for domains. Use <description/> or <title/> for that. At very best we can document that there is a limit wrt virtiofsd.

Comment 18 IBM Bug Proxy 2022-04-07 14:30:58 UTC
------- Comment From danielhb.com 2022-04-07 10:24 EDT-------
(In reply to comment #13)
> How serious is this issue? I mean, we can try to shorten the log path but
> then the next problem is collision in log filename. And even if we'd figure
> a workaround for this, the path limit is going to be hit for something else
> (e.g. domain monitor socket/log file/...). My suggestion is: don't use long
> names for domains. Use <description/> or <title/> for that. At very best we
> can document that there is a limit wrt virtiofsd.

Not only document, but also limit the VM instance name size. For what it's worth VMWare caps the instance name in 128 chars:

https://docs.vmware.com/en/VMware-Cloud-Director/9.7/com.vmware.vcloud.admin.doc/GUID-023D4FBC-3016-4757-B52B-4A97984ABD7F.html

I don't see a reason not to have a VM name size limit in libvirt as well. There might be a number where we can mitigate/avoid these file name size issues. 40 chars seems like a good size for a VM name since we have other fields such as "Description" where a long explanation can be provided. Of course that such limit would be imposed just for new VMs - VMs already in the wild can't be impacted by this rule.

Without any form of name size sanitization this bug will keep appearing over and over again, impacting different parts of the VM lifecycle, because we thought that a documentation hint alone would do the trick.

Comment 22 Martin Kletzander 2022-04-07 16:11:51 UTC
(In reply to IBM Bug Proxy from comment #18)
> ------- Comment From danielhb.com 2022-04-07 10:24 EDT-------
> (In reply to comment #13)
> > How serious is this issue? I mean, we can try to shorten the log path but
> > then the next problem is collision in log filename. And even if we'd figure
> > a workaround for this, the path limit is going to be hit for something else
> > (e.g. domain monitor socket/log file/...). My suggestion is: don't use long
> > names for domains. Use <description/> or <title/> for that. At very best we
> > can document that there is a limit wrt virtiofsd.
> 
> Not only document, but also limit the VM instance name size. For what it's
> worth VMWare caps the instance name in 128 chars:
> 
> https://docs.vmware.com/en/VMware-Cloud-Director/9.7/com.vmware.vcloud.admin.
> doc/GUID-023D4FBC-3016-4757-B52B-4A97984ABD7F.html
> 
> I don't see a reason not to have a VM name size limit in libvirt as well.
> There might be a number where we can mitigate/avoid these file name size
> issues. 40 chars seems like a good size for a VM name since we have other
> fields such as "Description" where a long explanation can be provided. Of
> course that such limit would be imposed just for new VMs - VMs already in
> the wild can't be impacted by this rule.
> 
> Without any form of name size sanitization this bug will keep appearing over
> and over again, impacting different parts of the VM lifecycle, because we
> thought that a documentation hint alone would do the trick.

And if we enforce the length of the domain name we will hit the same issue with other user supplied strings.  We'll always hit those.  And enforcing the limit is not as easy as it seems because of backward compatibility.  I am not against limiting the name length to something reasonable (well, who uses names longer than 30 characters anyway, right?), but doing it properly seems like too much of a trouble when the user actually gets a reasonable error (see the description) from which it is very clear why that is.  The same will happen if you use a very long alias because the socket name does not fit in sockaddr_t.

I personally think we should expect the users to be able to figure this out for themselves without us hand-holding them and checking for every single possible failure to provide a slightly nicer error message.

Comment 23 Martin Kletzander 2022-04-12 15:19:06 UTC
(In reply to Jaroslav Suchanek from comment #16)
> Patch proposed upstream by MartinK:
> https://listman.redhat.com/archives/libvir-list/2022-April/229916.html

Patch dismissed upstream by JanT:
https://listman.redhat.com/archives/libvir-list/2022-April/229917.html

Comment 31 Jaroslav Suchanek 2023-07-11 13:07:40 UTC
Closing this as WONTFIX per bug severity/priority.