[libvirt] [PATCH 3/7] storage:dir: .deleteVol callback for ploop volume

Maxim Nestratov mnestratov at virtuozzo.com
Mon Feb 8 16:07:51 UTC 2016


08.02.2016 16:04, Olga Krishtal пишет:
> Deletes whole directory of a ploop volume. To delete ploop image it has
> to be unmounted.
>
> Signed-off-by: Olga Krishtal <okrishtal at virtuozzo.com>
> ---
>   src/storage/storage_backend.c    | 6 ++++++
>   src/storage/storage_backend.h    | 2 ++
>   src/storage/storage_backend_fs.c | 5 ++++-
>   3 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
> index 6bd4618..be57630 100644
> --- a/src/storage/storage_backend.c
> +++ b/src/storage/storage_backend.c
> @@ -861,6 +861,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 56f6ef7..0df1880 100644
> --- a/src/storage/storage_backend_fs.c
> +++ b/src/storage/storage_backend_fs.c
> @@ -1247,7 +1247,6 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
>       switch ((virStorageVolType) vol->type) {
>       case VIR_STORAGE_VOL_FILE:
>       case VIR_STORAGE_VOL_DIR:
> -    case VIR_STORAGE_VOL_PLOOP:

This chunk is unnecessary if you remove related one from patch #1

>           if (virFileRemove(vol->target.path, vol->target.perms->uid,
>                             vol->target.perms->gid) < 0) {
>               /* Silently ignore failures where the vol has already gone away */
> @@ -1264,6 +1263,10 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
>               }
>           }
>           break;
> +    case VIR_STORAGE_VOL_PLOOP:
> +        if (virStorageBackendDeletePloop(conn, vol) < 0)
> +            return -1;
> +        break;
>       case VIR_STORAGE_VOL_BLOCK:
>       case VIR_STORAGE_VOL_NETWORK:
>       case VIR_STORAGE_VOL_NETDIR:




More information about the libvir-list mailing list