On Fri, Mar 15, 2013 at 02:07:01PM +0800, Wenchao Xia wrote: > δΊ 2013-3-13 20:40, Stefan Hajnoczi ει: > >This is why I asked about the array. A dict of ImageInfos is needed, > >they can refer to each other by key. > > > >If we go with an array we're painting ourselves into a corner. > > > >If we go with a dict it's more complicated and may not be used much. > > > >I'd go for the dict but we need a policy for choosing keys (names) for > >the ImageInfo elements. Perhaps BlockDeviceInfo['file'] is the key for > >the top-level image and then ImageInfo['backing-filename'] for the > >backing chain. > > > >Stefan > > > > Since ImageInfo already have key 'backing-filename', which stands for > the information got in this image, not from the backing image, > add a new key 'bakcing-image' for recursive linking: > > { 'type': 'ImageInfo', > 'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool', > '*actual-size': 'int', 'virtual-size': 'int', > '*cluster-size': 'int', '*encrypted': 'bool', > '*backing-filename': 'str', '*full-backing-filename': 'str', > '*backing-filename-format': 'str', > '*backing-image": 'ImageInfo', > '*snapshots': ['SnapshotInfo'] } } > > Then insert ImageInfo into BlockDeviceInfo, with key 'images', since > 'file' is already used which may break compatibility if we change it. > 'images' uses an array for the case when multiple images exist in > top level, not for backing chain. > > { 'type': 'BlockDeviceInfo', > 'data': { 'file': 'str', 'ro': 'bool', 'drv': 'str', > '*backing_file': 'str', 'backing_file_depth': 'int', > 'encrypted': 'bool', 'encryption_key_missing': 'bool', > 'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int', > 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int', > 'images': ['ImageInfo']} }}
Sounds good. Stefan