Skip to content
Commit 9c2e1d1a authored by Suzuki Poulose's avatar Suzuki Poulose Committed by Will Deacon
Browse files

kvmtool: virtio-9p: Convert EMFILE error at the server to ENFILE for the guest



If an open at the 9p server(host) fails with EMFILE (Too many open files for
the process), we should return ENFILE(too many open files in the system) to
the guest to indicate the actual status within the guest.

This was uncovered during LTP, where getdtablesize01 fails to open the maximum
number-open-files.

getdtablesize01    0  TINFO  :  Maximum number of files a process can have opened is 1024
getdtablesize01    0  TINFO  :  Checking with the value returned by getrlimit...RLIMIT_NOFILE
getdtablesize01    1  TPASS  :  got correct dtablesize, value is 1024
getdtablesize01    0  TINFO  :  Checking Max num of files that can be opened by a process.Should be: RLIMIT_NOFILE - 1
getdtablesize01    2  TFAIL  :  getdtablesize01.c:102: 974 != 1023

For a more practial impact:

 # ./getdtablesize01 &
[1] 1834
 getdtablesize01    0  TINFO  :  Maximum number of files a process can have opened is 1024
 getdtablesize01    0  TINFO  :  Checking with the value returned by getrlimit...RLIMIT_NOFILE
 getdtablesize01    1  TPASS  :  got correct dtablesize, value is 1024
 getdtablesize01    0  TINFO  :  Checking Max num of files that can be opened by a process.Should be: RLIMIT_NOFILE - 1
 getdtablesize01    2  TFAIL  :  getdtablesize01.c:102: 974 != 1023
 [--- Modified to sleep indefinitely, without closing the files --- ]

 # ls
 bash: /bin/ls: Too many open files

That gives a wrong error message for the bash, when getdtablesize01 has exhausted the system
wide limits, giving false indicators.

With the fix, we get :

 # ls
 bash: /bin/ls: Too many open files in system

Acked-by: default avatarWill Deacon <will.deacon@arm.com>
Signed-off-by: Suzuki Poulose's avatarSuzuki K. Poulose <suzuki.poulose@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 7590908e
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment