[CRIU] [PATCH] crit: Fix casts for fixed and sfixed types

Ruslan Kuprieiev kupruser at gmail.com
Wed Dec 9 07:03:23 PST 2015


Hm... Grep tells me that we have no double,float in our proto files and 
have only one fixed field
which is so_filter.

Did so_filter look right when decoding inetsk? If so, this is quite 
strange, as we use same
_basic_cast there. And after this patch floating point "fixed" field 
will be decoded into integer,
which also sounds odd.

On 12/09/2015 04:41 PM, Pavel Emelyanov wrote:
> The native pb engine doesn't accept types other than int or long:
>
> ...
>    File "/root/src/criu/pycriu/images/pb2dict.py", line 264, in dict2pb
>      pb_val.append(_dict2pb_cast(field, v))
>    File "/usr/lib/python2.7/site-packages/google/protobuf/internal/containers.py", line 111, in append
>      self._type_checker.CheckValue(value)
>    File "/usr/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.py", line 104, in CheckValue
>      raise TypeError(message)
> TypeError: 1.1258999068426252e+16 has type <type 'float'>, but expected one of: (<type 'int'>, <type 'long'>)
>
> In particular, this is seen when encoding back so_filter field from
> inetsk image.
>
> Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
> ---
>   pycriu/images/pb2dict.py | 10 ++++------
>   1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/pycriu/images/pb2dict.py b/pycriu/images/pb2dict.py
> index 2f975e0..57e6dc6 100644
> --- a/pycriu/images/pb2dict.py
> +++ b/pycriu/images/pb2dict.py
> @@ -24,12 +24,10 @@ import os
>   
>   
>   _basic_cast = {
> -	FD.TYPE_DOUBLE		: float,
> -	FD.TYPE_FLOAT		: float,
> -	FD.TYPE_FIXED64		: float,
> -	FD.TYPE_FIXED32		: float,
> -	FD.TYPE_SFIXED64	: float,
> -	FD.TYPE_SFIXED32	: float,
> +	FD.TYPE_FIXED64		: long,
> +	FD.TYPE_FIXED32		: int,
> +	FD.TYPE_SFIXED64	: long,
> +	FD.TYPE_SFIXED32	: int,
>   
>   	FD.TYPE_INT64		: long,
>   	FD.TYPE_UINT64		: long,



More information about the CRIU mailing list