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 <okrishtal(a)virtuozzo.com>
---
src/storage/storage_backend.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 1b4ffbc..2afcc7c 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -2016,12 +2016,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->type == VIR_STORAGE_VOL_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;
}
int
@@ -2033,10 +2044,20 @@ virStorageBackendVolDownloadLocal(virConnectPtr conn
ATTRIBUTE_UNUSED,
unsigned long long len,
unsigned int flags)
{
- virCheckFlags(0, -1);
+ char *path = NULL;
+ char *target_path = vol->target.path;
+ int ret;
+ if (vol->type == VIR_STORAGE_VOL_PLOOP) {
+ if (virAsprintf(&path, "%s/%s", vol->target.path,
"root.hds") < 0)
+ return -1;
+ target_path = path;
+ }
- return virFDStreamOpenBlockDevice(stream, vol->target.path,
+ virCheckFlags(0, -1);
+ ret = virFDStreamOpenBlockDevice(stream, target_path,
offset, len, O_RDONLY);
+ VIR_FREE(path);
+ return ret;
}
--
1.8.3.1