Re: [libvirt] [PATCH 2/6] storage:dir: .deleteVol callback for ploop volume

2016-02-17 Thread Nikolay Shirokovskiy


On 17.02.2016 14:40, Olga Krishtal wrote:
> Deletes whole directory of a ploop volume. To delete ploop image it has
> to be unmounted.
> 
> Signed-off-by: Olga Krishtal 
> ---
>  src/storage/storage_backend.c| 5 +
>  src/storage/storage_backend.h| 1 +
>  src/storage/storage_backend_fs.c | 5 +
>  3 files changed, 11 insertions(+)
> 
> diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
> index d70642e..9f0e020 100644
> --- a/src/storage/storage_backend.c
> +++ b/src/storage/storage_backend.c
> @@ -870,6 +870,11 @@ int virStorageBackendCreatePloop(virConnectPtr conn 
> ATTRIBUTE_UNUSED,
>  return ret;
>  }
>  
> +int virStorageBackendDeletePloop(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..3529755 100644
> --- a/src/storage/storage_backend.h
> +++ b/src/storage/storage_backend.h
> @@ -115,6 +115,7 @@ int virStorageBackendCreatePloop(virConnectPtr conn,
>   virStorageVolDefPtr inputvol,
>   unsigned int flags);
>  
> +int virStorageBackendDeletePloop(virStorageVolDefPtr vol);
>  
>  virStorageBackendBuildVolFrom
>  virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol,
> diff --git a/src/storage/storage_backend_fs.c 
> b/src/storage/storage_backend_fs.c
> index 80c7e9e..f494fd2 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(vol) < 0)
> +return -1;
> +break;
> +}

Let's get rid of function to be consistent with inplace virFileRemove below.

>  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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 2/6] storage:dir: .deleteVol callback for ploop volume

2016-02-17 Thread Olga Krishtal
Deletes whole directory of a ploop volume. To delete ploop image it has
to be unmounted.

Signed-off-by: Olga Krishtal 
---
 src/storage/storage_backend.c| 5 +
 src/storage/storage_backend.h| 1 +
 src/storage/storage_backend_fs.c | 5 +
 3 files changed, 11 insertions(+)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index d70642e..9f0e020 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -870,6 +870,11 @@ int virStorageBackendCreatePloop(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 return ret;
 }
 
+int virStorageBackendDeletePloop(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..3529755 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -115,6 +115,7 @@ int virStorageBackendCreatePloop(virConnectPtr conn,
  virStorageVolDefPtr inputvol,
  unsigned int flags);
 
+int virStorageBackendDeletePloop(virStorageVolDefPtr vol);
 
 virStorageBackendBuildVolFrom
 virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol,
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 80c7e9e..f494fd2 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(vol) < 0)
+return -1;
+break;
+}
 if (virFileRemove(vol->target.path, vol->target.perms->uid,
   vol->target.perms->gid) < 0) {
 /* Silently ignore failures where the vol has already gone away */
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 2/6] storage:dir: .deleteVol callback for ploop volume

2016-02-10 Thread Nikolay Shirokovskiy


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 
> ---
>  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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 2/6] storage:dir: .deleteVol callback for ploop volume

2016-02-10 Thread Olga Krishtal

On 10/02/16 12:43, Nikolay Shirokovskiy wrote:


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 
---
  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 I introduce one more function, we will suffer from one extra call 
every vol-delete call.

Moreover, it won't change the appearance:

 case VIR_STORAGE_VOL_FILE:
 case VIR_STORAGE_VOL_DIR:
+if (!extra_switch_func()) {
+return -1;
+break

So, it looks the same.

+}
  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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 2/6] storage:dir: .deleteVol callback for ploop volume

2016-02-09 Thread Olga Krishtal
Deletes whole directory of a ploop volume. To delete ploop image it has
to be unmounted.

Signed-off-by: Olga Krishtal 
---
 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;
+}
 if (virFileRemove(vol->target.path, vol->target.perms->uid,
   vol->target.perms->gid) < 0) {
 /* Silently ignore failures where the vol has already gone away */
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list