On 09.02.2016 16:52, Olga Krishtal wrote:
> In case of ploop volume, target path of the volume is the path to the
> directory that contains image file named root.hds and DiskDescriptor.xml.
> While using uploadVol and downloadVol callbacks we need to open root.hds
> itself. To accomplish this goal we must change path from
> path/to/ploop directory to path/to/ploop/root.hds
>
> Signed-off-by: Olga Krishtal <[email protected]>
> ---
> src/storage/storage_backend.c | 26 ++++++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
> index 34c9d40..c455908 100644
> --- a/src/storage/storage_backend.c
> +++ b/src/storage/storage_backend.c
> @@ -2025,12 +2025,23 @@ virStorageBackendVolUploadLocal(virConnectPtr conn
> ATTRIBUTE_UNUSED,
> unsigned long long len,
> unsigned int flags)
> {
> + char *path = NULL;
> + char *target_path = vol->target.path;
> + int ret;
> +
> virCheckFlags(0, -1);
> + if (vol->target.format == VIR_STORAGE_FILE_PLOOP) {
> + if (virAsprintf(&path, "%s/%s", vol->target.path, "root.hds") < 0)
> + return -1;
> + target_path = path;
> + }
>
> /* Not using O_CREAT because the file is required to already exist at
> * this point */
> - return virFDStreamOpenBlockDevice(stream, vol->target.path,
> + ret = virFDStreamOpenBlockDevice(stream, target_path,
> offset, len, O_WRONLY);
> + VIR_FREE(path);
> + return ret;
> }
How this upload/download API is used? Can we upload "hds" file and go out
of sync with disk descriptor?
>
> int
> @@ -2042,10 +2053,21 @@ virStorageBackendVolDownloadLocal(virConnectPtr conn
> ATTRIBUTE_UNUSED,
> unsigned long long len,
> unsigned int flags)
> {
> + char *path = NULL;
> + char *target_path = vol->target.path;
> + int ret;
> +
> virCheckFlags(0, -1);
> + if (vol->target.format == VIR_STORAGE_FILE_PLOOP) {
> + if (virAsprintf(&path, "%s/%s", vol->target.path, "root.hds") < 0)
> + return -1;
> + target_path = path;
> + }
>
> - return virFDStreamOpenBlockDevice(stream, vol->target.path,
> + ret = virFDStreamOpenBlockDevice(stream, target_path,
> offset, len, O_RDONLY);
> + VIR_FREE(path);
> + return ret;
> }
>
>
>
--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list