aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuzuki K. Poulose <suzuki.poulose@arm.com>2015-01-16 11:30:10 +0000
committerWill Deacon <will.deacon@arm.com>2015-06-01 16:39:55 +0100
commit9c2e1d1a08e6aa44d433de1ab219aae7eb2b2526 (patch)
treea5c4ba78b9afeeb20b17ef52507b66bf5f2da693
parent7590908e507230e50d36a9ce80a82b3c21363ba8 (diff)
downloadkvmtool-9c2e1d1a08e6aa44d433de1ab219aae7eb2b2526.tar.gz
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: Will Deacon <will.deacon@arm.com> Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r--virtio/9p.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/virtio/9p.c b/virtio/9p.c
index 9073a1e2..b24c0f2d 100644
--- a/virtio/9p.c
+++ b/virtio/9p.c
@@ -152,6 +152,10 @@ static void virtio_p9_error_reply(struct p9_dev *p9dev,
{
u16 tag;
+ /* EMFILE at server implies ENFILE for the VM */
+ if (err == EMFILE)
+ err = ENFILE;
+
pdu->write_offset = VIRTIO_9P_HDR_LEN;
virtio_p9_pdu_writef(pdu, "d", err);
*outlen = pdu->write_offset;