* [PATCH] librte_vhost: Fix the path test issue @ 2014-11-03 8:11 Ouyang Changchun [not found] ` <1415002313-15661-1-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Ouyang Changchun @ 2014-11-03 8:11 UTC (permalink / raw) To: dev-VfR2kkLFssw Commit aec8283d47d4e4366b6 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. Signed-off-by: Changchun Ouyang <changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> --- 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 8015dd8..3fa1274 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -237,7 +237,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); -- 1.8.4.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <1415002313-15661-1-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] librte_vhost: Fix the path test issue [not found] ` <1415002313-15661-1-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> @ 2014-11-06 2:38 ` Xie, Huawei [not found] ` <C37D651A908B024F974696C65296B57B0F2E28C3-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org> 2014-11-06 20:53 ` Xie, Huawei 1 sibling, 1 reply; 6+ messages in thread From: Xie, Huawei @ 2014-11-06 2:38 UTC (permalink / raw) To: Ouyang, Changchun, dev-VfR2kkLFssw@public.gmane.org > 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); Changchun: For some strange file, according to API description, we shouldn't check resolved_path as it is undefined. To make the loop go on, we could use "continue" when we detect path is NULL. RETURN VALUE If there is no error, realpath() returns a pointer to the resolved_path. Otherwise it returns a NULL pointer, and the contents of the array resolved_path are undefined, and errno is set to indicate the error. ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <C37D651A908B024F974696C65296B57B0F2E28C3-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>]
* Re: [PATCH] librte_vhost: Fix the path test issue [not found] ` <C37D651A908B024F974696C65296B57B0F2E28C3-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org> @ 2014-11-06 5:20 ` Ouyang, Changchun [not found] ` <F52918179C57134FAEC9EA62FA2F9625118818BA-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Ouyang, Changchun @ 2014-11-06 5:20 UTC (permalink / raw) To: Xie, Huawei, dev-VfR2kkLFssw@public.gmane.org Hi Huawei, Thanks for the comments, And my response as follows. > -----Original Message----- > From: Xie, Huawei > Sent: Thursday, November 6, 2014 10:39 AM > To: Ouyang, Changchun; dev-VfR2kkLFssw@public.gmane.org > Subject: RE: [dpdk-dev] [PATCH] librte_vhost: Fix the path test issue > > > 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); > Changchun: > For some strange file, according to API description, we shouldn't check > resolved_path as it is undefined. > To make the loop go on, we could use "continue" when we detect path is > NULL. > > RETURN VALUE > If there is no error, realpath() returns a pointer to the resolved_path. > > Otherwise it returns a NULL pointer, and the contents of the array > resolved_path are undefined, and errno is set to indicate the error. After my investigation this issue and find out using continue doesn't work. The reason is procmap.fname itself is "/dev/hugepages/qemu_back_mem.pc.ram.zxfqLq", It is not a normal path, so in this case, path is null, while resolved-path is /dev/hugepages/qemu_back_mem.pc.ram.zxfqLq If 'continue' is used, then procmap.fname could not be hit in the directory list, And then app will exit after report: Failed to find memory file for pid.... So I have to keep it. Thanks again Changchun ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <F52918179C57134FAEC9EA62FA2F9625118818BA-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org>]
* Re: [PATCH] librte_vhost: Fix the path test issue [not found] ` <F52918179C57134FAEC9EA62FA2F9625118818BA-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org> @ 2014-11-06 20:47 ` Xie, Huawei 0 siblings, 0 replies; 6+ messages in thread From: Xie, Huawei @ 2014-11-06 20:47 UTC (permalink / raw) To: Ouyang, Changchun, dev-VfR2kkLFssw@public.gmane.org > -----Original Message----- > From: Ouyang, Changchun > Sent: Wednesday, November 05, 2014 10:20 PM > To: Xie, Huawei; dev-VfR2kkLFssw@public.gmane.org > Cc: Ouyang, Changchun > Subject: RE: [dpdk-dev] [PATCH] librte_vhost: Fix the path test issue > > Hi Huawei, > Thanks for the comments, > And my response as follows. > > > -----Original Message----- > > From: Xie, Huawei > > Sent: Thursday, November 6, 2014 10:39 AM > > To: Ouyang, Changchun; dev-VfR2kkLFssw@public.gmane.org > > Subject: RE: [dpdk-dev] [PATCH] librte_vhost: Fix the path test issue > > > > > 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); > > Changchun: > > For some strange file, according to API description, we shouldn't check > > resolved_path as it is undefined. > > To make the loop go on, we could use "continue" when we detect path is > > NULL. > > > > RETURN VALUE > > If there is no error, realpath() returns a pointer to the resolved_path. > > > > Otherwise it returns a NULL pointer, and the contents of the array > > resolved_path are undefined, and errno is set to indicate the error. > > After my investigation this issue and find out using continue doesn't work. > > The reason is procmap.fname itself is > "/dev/hugepages/qemu_back_mem.pc.ram.zxfqLq", > It is not a normal path, so in this case, path is null, while resolved-path is > /dev/hugepages/qemu_back_mem.pc.ram.zxfqLq > > If 'continue' is used, then procmap.fname could not be hit in the directory list, > And then app will exit after report: Failed to find memory file for pid.... I did some investigation. This is due to that qemu unlink the file after it maps the huge page file. So this is a special case, it is ok we check the resolved path when path is NULL if errno indicates "No such file or directory". > > So I have to keep it. > > Thanks again > Changchun ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] librte_vhost: Fix the path test issue [not found] ` <1415002313-15661-1-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 2014-11-06 2:38 ` Xie, Huawei @ 2014-11-06 20:53 ` Xie, Huawei [not found] ` <C37D651A908B024F974696C65296B57B0F2E3828-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org> 1 sibling, 1 reply; 6+ messages in thread From: Xie, Huawei @ 2014-11-06 20:53 UTC (permalink / raw) To: Ouyang, Changchun, dev-VfR2kkLFssw@public.gmane.org > -----Original Message----- > From: dev [mailto:dev-bounces-VfR2kkLFssw@public.gmane.org] On Behalf Of Ouyang Changchun > Sent: Monday, November 03, 2014 1:12 AM > To: dev-VfR2kkLFssw@public.gmane.org > Subject: [dpdk-dev] [PATCH] librte_vhost: Fix the path test issue > > Commit aec8283d47d4e4366b6 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. > > Signed-off-by: Changchun Ouyang <changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > --- > 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 8015dd8..3fa1274 100644 > --- a/lib/librte_vhost/virtio-net.c > +++ b/lib/librte_vhost/virtio-net.c > @@ -237,7 +237,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); > -- > 1.8.4.2 Acked-by: Huawei Xie <huawei.xie-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <C37D651A908B024F974696C65296B57B0F2E3828-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>]
* Re: [PATCH] librte_vhost: Fix the path test issue [not found] ` <C37D651A908B024F974696C65296B57B0F2E3828-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org> @ 2014-11-06 22:13 ` Thomas Monjalon 0 siblings, 0 replies; 6+ messages in thread From: Thomas Monjalon @ 2014-11-06 22:13 UTC (permalink / raw) To: Ouyang, Changchun; +Cc: dev-VfR2kkLFssw > > Commit aec8283d47d4e4366b6 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. > > > > Signed-off-by: Changchun Ouyang <changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > > Acked-by: Huawei Xie <huawei.xie-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> Applied with Huawei's explanation. Thanks -- Thomas ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-11-06 22:13 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-11-03 8:11 [PATCH] librte_vhost: Fix the path test issue Ouyang Changchun [not found] ` <1415002313-15661-1-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 2014-11-06 2:38 ` Xie, Huawei [not found] ` <C37D651A908B024F974696C65296B57B0F2E28C3-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org> 2014-11-06 5:20 ` Ouyang, Changchun [not found] ` <F52918179C57134FAEC9EA62FA2F9625118818BA-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org> 2014-11-06 20:47 ` Xie, Huawei 2014-11-06 20:53 ` Xie, Huawei [not found] ` <C37D651A908B024F974696C65296B57B0F2E3828-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org> 2014-11-06 22:13 ` Thomas Monjalon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).