[Kimchi-devel] [kimchi-devel][PATCH 5/5] Update model for storage volume update

Crístian Viana vianac at linux.vnet.ibm.com
Wed Jan 7 19:44:55 UTC 2015


On 07-01-2015 07:01, lvroyce at linux.vnet.ibm.com wrote:
> +    def update(self, pool, name, params):
> +        vol = self._get_storagevolume(pool, name)
> +        path = vol.path()
> +
> +        size = int(params['chunk_size'])
> +        index = int(params['index'])
> +        pos = size * index
> +        try:
> +            with f_open(path, 'a+') as fp:
> +                with flock(fp, pos, size):
> +                    fp.seek(pos)
> +                    fp.write(params['chunk'].fullvalue())
> +        except Exception as e:
> +            raise OperationFailed('KCHVOL0007E',
> +                                  {'name': name,
> +                                   'pool': pool,
> +                                   'err': e.message})
> +
> +        # Refresh to make sure volume can be found in following lookup
> +        StoragePoolModel.get_storagepool(pool, self.conn).refresh(0)

We should not treat the storage volumes as regular files, that depends 
on the underlying storage pool type (e.g. it won't work with logical 
pools and other types). We should use the function 
"<storageVolume>.upload" so libvirt can put data to a storage volume in 
a way that works for every storage pool type.




More information about the Kimchi-devel mailing list