[CRIU] [PATCH] net: Don't fail if there is no ip dump data

Pavel Emelyanov xemul at parallels.com
Thu Mar 21 05:37:30 EDT 2013


On 03/21/2013 10:11 AM, Cyrill Gorcunov wrote:
> If we met empy file just continue execution.

Why is that correct?

> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  net.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/net.c b/net.c
> index 444f78e..33bd857 100644
> --- a/net.c
> +++ b/net.c
> @@ -13,6 +13,9 @@
>  #include "crtools.h"
>  #include "sk-inet.h"
>  
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +
>  #include "protobuf.h"
>  #include "protobuf/netdev.pb-c.h"
>  
> @@ -320,6 +323,18 @@ static int restore_ip_dump(int type, int pid, char *cmd)
>  
>  	ret = fd = open_image_ro(type, pid);
>  	if (fd >= 0) {
> +		struct stat st;
> +
> +		if (fstat(fd, &st)) {
> +			pr_perror("Failed to obtain stat on file\n");
> +			return -1;
> +		} else if (st.st_size == 0) {
> +			/*
> +			 * Empty file, just get out.
> +			 */
> +			return 0;
> +		}
> +
>  		ret = run_ip_tool(cmd, "restore", fd, -1);
>  		close(fd);
>  	}
> 




More information about the CRIU mailing list