DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] librte_vhost: Fix the path test issue
@ 2014-11-03  8:11 Ouyang Changchun
  2014-11-06  2:38 ` Xie, Huawei
  2014-11-06 20:53 ` Xie, Huawei
  0 siblings, 2 replies; 6+ messages in thread
From: Ouyang Changchun @ 2014-11-03  8:11 UTC (permalink / raw)
  To: dev

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@intel.com>
---
 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	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] librte_vhost: Fix the path test issue
  2014-11-03  8:11 [dpdk-dev] [PATCH] librte_vhost: Fix the path test issue Ouyang Changchun
@ 2014-11-06  2:38 ` Xie, Huawei
  2014-11-06  5:20   ` Ouyang, Changchun
  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

>  		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

* Re: [dpdk-dev] [PATCH] librte_vhost: Fix the path test issue
  2014-11-06  2:38 ` Xie, Huawei
@ 2014-11-06  5:20   ` Ouyang, Changchun
  2014-11-06 20:47     ` Xie, Huawei
  0 siblings, 1 reply; 6+ messages in thread
From: Ouyang, Changchun @ 2014-11-06  5:20 UTC (permalink / raw)
  To: Xie, Huawei, dev

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@dpdk.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

* Re: [dpdk-dev] [PATCH] librte_vhost: Fix the path test issue
  2014-11-06  5:20   ` Ouyang, Changchun
@ 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



> -----Original Message-----
> From: Ouyang, Changchun
> Sent: Wednesday, November 05, 2014 10:20 PM
> To: Xie, Huawei; dev@dpdk.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@dpdk.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: [dpdk-dev] [PATCH] librte_vhost: Fix the path test issue
  2014-11-03  8:11 [dpdk-dev] [PATCH] librte_vhost: Fix the path test issue Ouyang Changchun
  2014-11-06  2:38 ` Xie, Huawei
@ 2014-11-06 20:53 ` Xie, Huawei
  2014-11-06 22:13   ` Thomas Monjalon
  1 sibling, 1 reply; 6+ messages in thread
From: Xie, Huawei @ 2014-11-06 20:53 UTC (permalink / raw)
  To: Ouyang, Changchun, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ouyang Changchun
> Sent: Monday, November 03, 2014 1:12 AM
> To: dev@dpdk.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@intel.com>
> ---
>  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@intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] librte_vhost: Fix the path test issue
  2014-11-06 20:53 ` Xie, Huawei
@ 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

> > 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@intel.com>
> 
> Acked-by: Huawei Xie <huawei.xie@intel.com>

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:04 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 [dpdk-dev] [PATCH] librte_vhost: Fix the path test issue Ouyang Changchun
2014-11-06  2:38 ` Xie, Huawei
2014-11-06  5:20   ` Ouyang, Changchun
2014-11-06 20:47     ` Xie, Huawei
2014-11-06 20:53 ` Xie, Huawei
2014-11-06 22:13   ` Thomas Monjalon

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git