From 4e3eff86cf8090604ff869001d999dc4bfaad617 Mon Sep 17 00:00:00 2001 From: Ouyang Changchun Date: Mon, 3 Nov 2014 16:11:53 +0800 Subject: [PATCH] vhost: fix mem path check Commit aec8283d47 fixes the compilation issue, but it leads to one runtime issue: early exit wrongly. In some case, 'path' is NULL, but 'resolved_path' has effective path, it should continue going ahead rather than exit. This is due to that qemu unlink the file after it maps the huge page file. In this special case, it is ok to check the resolved path when path is NULL if errno indicates "No such file or directory". Signed-off-by: Changchun Ouyang Acked-by: Huawei Xie --- lib/librte_vhost/virtio-net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index 50cab24ce8..6d8de09430 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -247,7 +247,7 @@ host_memory_map(struct virtio_net *dev, struct virtio_memory *mem, snprintf(memfile, PATH_MAX, "/proc/%u/fd/%s", pid, dptr->d_name); path = realpath(memfile, resolved_path); - if (path == NULL) { + if ((path == NULL) && (strlen(resolved_path) == 0)) { RTE_LOG(ERR, VHOST_CONFIG, "(%"PRIu64") Failed to resolve fd directory\n", dev->device_fh); -- 2.20.1