To change the size of ploop image file we use ploop resize cmd that takes
2 args: new size and path/to/DiskDescriptor.xml
Signed-off-by: Olga Krishtal <okrishtal(a)virtuozzo.com>
---
src/storage/storage_backend.c | 28 ++++++++++++++++++++++++++++
src/storage/storage_backend.h | 5 +++++
src/storage/storage_backend_fs.c | 2 ++
3 files changed, 35 insertions(+)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index c455908..fb4d1b9 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -877,6 +877,34 @@ int virStorageBackendDeletePloop(virConnectPtr conn
ATTRIBUTE_UNUSED,
return virFileDeleteTree(vol->target.path);
}
+int virStoragePloopResize(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+ virStorageVolDefPtr vol,
+ unsigned long long capacity)
+{
+ int ret;
+ char *path = NULL;
+ char *size = NULL;
+ virCommandPtr cmd = NULL;
+
+ if (virAsprintf(&path, "%s/%s", vol->target.path,
"DiskDescriptor.xml") < 0)
+ return -1;
+
+ if (virAsprintf(&size, "%lluM", VIR_DIV_UP(capacity, 512)) < 0) {
+ ret = -1;
+ goto cleanup;
+ }
+ cmd = virCommandNewArgList("ploop", "resize", "-s",
size, path, NULL);
+
+ ret = virCommandRun(cmd, NULL);
+
+ cleanup:
+ virCommandFree(cmd);
+ VIR_FREE(path);
+ VIR_FREE(size);
+ return ret;
+}
+
enum {
QEMU_IMG_BACKING_FORMAT_NONE = 0,
QEMU_IMG_BACKING_FORMAT_FLAG,
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h
index 7d354c5..1de8dfe 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -118,6 +118,11 @@ int virStorageBackendCreatePloop(virConnectPtr conn,
int virStorageBackendDeletePloop(virConnectPtr conn,
virStorageVolDefPtr vol);
+int virStoragePloopResize(virConnectPtr conn,
+ virStoragePoolObjPtr pool,
+ virStorageVolDefPtr vol,
+ unsigned long long capacity);
+
virStorageBackendBuildVolFrom
virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol);
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 2290096..c2d148d 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -1378,6 +1378,8 @@ virStorageBackendFileSystemVolResize(virConnectPtr conn
ATTRIBUTE_UNUSED,
if (vol->target.format == VIR_STORAGE_FILE_RAW) {
return virStorageFileResize(vol->target.path, capacity,
vol->target.allocation, pre_allocate);
+ } else if (vol->target.format == VIR_STORAGE_FILE_PLOOP) {
+ return virStoragePloopResize(conn, pool, vol, capacity);
} else {
if (pre_allocate) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
--
1.8.3.1