On 2016-11-27 17:21, Ralf Ramsauer wrote:
> We do have magic bytes in configfile headers for distunguishing cell and
> system configurations. Add this check to jailhouse-cell-linux to avoid
> passing system configurations to jailhouse-cell-linux.
> 
> Signed-off-by: Ralf Ramsauer <[email protected]>
> ---
>  tools/jailhouse-cell-linux | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/jailhouse-cell-linux b/tools/jailhouse-cell-linux
> index 151f3e41b2..1a08f8a100 100755
> --- a/tools/jailhouse-cell-linux
> +++ b/tools/jailhouse-cell-linux
> @@ -509,12 +509,13 @@ class MemoryRegion:
>  
>  
>  class Config:
> -    _HEADER_FORMAT = '8x32s4xIIIIIIIII'
> +    _HEADER_FORMAT = '8s32s4xIIIIIIIII'
>  
>      def __init__(self, config_file):
>          self.data = config_file.read()
>  
> -        (name,
> +        (signature,
> +         name,
>           self.flags,
>           self.cpu_set_size,
>           self.num_memory_regions,
> @@ -525,6 +526,9 @@ class Config:
>           self.num_pci_caps,
>           self.vpci_irq_base) = \
>              struct.unpack_from(Config._HEADER_FORMAT, self.data)
> +        if str(signature.decode()) != 'JAILCELL':
> +            print('Not a cell configuration: %s' % config_file.name, 
> file=sys.stderr)
> +            exit(1)
>          self.name = str(name.decode())
>  
>          memregion_offs = struct.calcsize(Config._HEADER_FORMAT) + \
> 

Was writing something similar today while adding a revision number for
config formats. I'm integrating your patch, after fixing its pep8 error
(over-long line), though.

Jan

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to