On 17.02.2016 14:40, Olga Krishtal wrote: > 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@xxxxxxxxxxxxx> > --- > src/storage/storage_backend.c | 33 +++++++++++++++++++++++++++++++++ > src/storage/storage_backend.h | 3 +++ > src/storage/storage_backend_fs.c | 2 ++ > 3 files changed, 38 insertions(+) > > diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c > index ac44fdf..18d414c 100644 > --- a/src/storage/storage_backend.c > +++ b/src/storage/storage_backend.c > @@ -875,6 +875,39 @@ int virStorageBackendDeletePloop(virStorageVolDefPtr vol) > return virFileDeleteTree(vol->target.path); > } > > +int virStoragePloopResize(virStorageVolDefPtr vol, > + unsigned long long capacity) > +{ > + int ret = -1; > + char *path = NULL; > + char *size = NULL; > + virCommandPtr cmd = NULL; > + char *create_tool = NULL; strange name > + > + create_tool = virFindFileInPath("ploop"); > + if (!create_tool) { > + virReportError(VIR_ERR_INTERNAL_ERROR, > + "%s", _("unable to find ploop, please install " > + "ploop tools")); > + return -1; > + } > + if (virAsprintf(&path, "%s/DiskDescriptor.xml", vol->target.path) < 0) > + return -1; > + > + if (virAsprintf(&size, "%lluM", VIR_DIV_UP(capacity, (1024 * 1024))) < 0) > + goto cleanup; use virCommandAddArgFormat > + > + cmd = virCommandNewArgList(create_tool, "resize", "-s", size, path, NULL); > + > + ret = virCommandRun(cmd, NULL); > + > + cleanup: > + virCommandFree(cmd); > + VIR_FREE(path); > + VIR_FREE(size); > + return ret; you need to free 'create_tool' as well > +} > + > 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 3529755..65e91dc 100644 > --- a/src/storage/storage_backend.h > +++ b/src/storage/storage_backend.h > @@ -117,6 +117,9 @@ int virStorageBackendCreatePloop(virConnectPtr conn, > > int virStorageBackendDeletePloop(virStorageVolDefPtr vol); > > +int virStoragePloopResize(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 f494fd2..abb6e47 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(vol, capacity); > } else { > if (pre_allocate) { > virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", > -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list