On 09.02.2016 16:52, Olga Krishtal wrote: > Deletes whole directory of a ploop volume. To delete ploop image it has > to be unmounted. > > Signed-off-by: Olga Krishtal <okrishtal@xxxxxxxxxxxxx> > --- > src/storage/storage_backend.c | 6 ++++++ > src/storage/storage_backend.h | 2 ++ > src/storage/storage_backend_fs.c | 5 +++++ > 3 files changed, 13 insertions(+) > > diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c > index 039a540..34c9d40 100644 > --- a/src/storage/storage_backend.c > +++ b/src/storage/storage_backend.c > @@ -871,6 +871,12 @@ int virStorageBackendCreatePloop(virConnectPtr conn ATTRIBUTE_UNUSED, > return ret; > } > > +int virStorageBackendDeletePloop(virConnectPtr conn ATTRIBUTE_UNUSED, > + virStorageVolDefPtr vol) > +{ > + return virFileDeleteTree(vol->target.path); > +} > + > 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 852d6ed..7d354c5 100644 > --- a/src/storage/storage_backend.h > +++ b/src/storage/storage_backend.h > @@ -115,6 +115,8 @@ int virStorageBackendCreatePloop(virConnectPtr conn, > virStorageVolDefPtr inputvol, > unsigned int flags); > > +int virStorageBackendDeletePloop(virConnectPtr conn, > + virStorageVolDefPtr vol); > > virStorageBackendBuildVolFrom > virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol, > diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c > index 80c7e9e..2290096 100644 > --- a/src/storage/storage_backend_fs.c > +++ b/src/storage/storage_backend_fs.c > @@ -1245,6 +1245,11 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED, > switch ((virStorageVolType) vol->type) { > case VIR_STORAGE_VOL_FILE: > case VIR_STORAGE_VOL_DIR: > + if (vol->target.format == VIR_STORAGE_FILE_PLOOP) { > + if (virStorageBackendDeletePloop(conn, vol) < 0) > + return -1; > + break; break at this level is not easy to follow. Can we introduce a function which will have another switch inside for types of volume types? > + } > if (virFileRemove(vol->target.path, vol->target.perms->uid, > vol->target.perms->gid) < 0) { > /* Silently ignore failures where the vol has already gone away */ > -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list