[CRIU] Re: [PATCH] parasite: Refactor code to follow calling convention

Pavel Emelyanov xemul at parallels.com
Fri Mar 16 10:31:43 EDT 2012


On 03/16/2012 06:04 PM, Cyrill Gorcunov wrote:
> It happened some routines in parasite service code
> were not following calling convention so I fixed the
> callers and added a comment about adding new code here.
> 
> At the same time the 3 error code madness is dropped
> as being requested by Pavel -- now we return one error
> code only.

After a bit more thinking. We now have 3 return values:

1. line where an error occurred
2. some abstract ret on status
3. the return code from call

The 1st one can be eliminated by simply emitting a log message. We couldn't
do it before and now we can.

The 2nd one used to be the errno from the syscall, but yet again -- we
can write it into log now and thus don't really need.

The return code can now only denote whether an operation succeeded or not.

That said, we don't need the whole parasite_status_t at all now. Do we?

> The PARASITE_ERR_ codes were dropped as well due to
> become redundant.
> 
> The status of parasite service routine is set via
> SET_PARASITE helpers
> 
>  - SET_PARASITE_ERR, if you have some error code
>    to return
> 
>  - SET_PARASITE_RET, if you have some value to return,
>    but you don't know if it's error or not (basically
>    it's simply semanatic wrapper over SET_PARASITE_ERR,
>    should be used in places where _ERR version migh confuse
>    the reader)
> 
> In case if there is no error -- just return 0. The calling
> code should not expect to find anything sane in parasite_status_t
> because parasite code might not touch it at all.
> 
> Same time, due to this convention the parasite's
> dump_socket_queue is getting rid of third @err
> member, because it's now returned as a regular
> error code.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>


More information about the CRIU mailing list