vhost: fix mem path check
authorOuyang Changchun <changchun.ouyang@intel.com>
Mon, 3 Nov 2014 08:11:53 +0000 (16:11 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Thu, 6 Nov 2014 22:12:02 +0000 (23:12 +0100)
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 <changchun.ouyang@intel.com>
Acked-by: Huawei Xie <huawei.xie@intel.com>
lib/librte_vhost/virtio-net.c

index 50cab24..6d8de09 100644 (file)
@@ -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);