On 01/07/2015 02:44 PM, CrÃstian Viana wrote:
On 07-01-2015 07:01, lvroyce(a)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.
Good point, haven't tried this
api, but will take a look at it .