Re: [PATCH] storage: dir: adapts .wipeVol for ploop volumes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 16.05.2016 09:19, Olga Krishtal wrote:
> The modification of .volWipe callback wipes ploop volume using one of
> given wiping algorithm: dod, nnsa, etc.
> However, in case of ploop volume we need to reinitialize root.hds and DiskDescriptor.xml.
> 
> Signed-off-by: Olga Krishtal <okrishtal@xxxxxxxxxxxxx>
> ---
>  src/storage/storage_backend.c | 58 ++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 52 insertions(+), 6 deletions(-)
> 
> diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
> index d47a76a..367a887 100644
> --- a/src/storage/storage_backend.c
> +++ b/src/storage/storage_backend.c
> @@ -2295,6 +2295,45 @@ virStorageBackendWipeLocal(virStorageVolDefPtr vol,
>      return ret;
>  }
>  
> +static int
> +virStorageBackendVolWipePloop(virStorageVolDefPtr vol)
> +{
> +    virCommandPtr cmd = NULL;
> +    char *target_path = NULL;
> +    char *disk_desc = NULL;
> +    int ret = -1;
> +
> +    if (virAsprintf(&target_path, "%s/root.hds", vol->target.path) < 0)
> +        goto cleanup;
> +
> +    if (virAsprintf(&disk_desc, "%s/DiskDescriptor.xml", vol->target.path) < 0)
> +        goto cleanup;
> +
> +    if (virFileRemove(disk_desc, 0, 0) < 0) {
> +        virReportError(errno, _("Failed to delete DiskDescriptor.xml of volume '%s'"),
> +                       vol->target.path);
> +        goto cleanup;
> +    }
> +    if (virFileRemove(target_path, 0, 0) < 0) {
> +        virReportError(errno, _("failed to delete root.hds of volume '%s'"),
> +                       vol->target.path);
> +        goto cleanup;
> +    }
> +
> +    cmd = virCommandNewArgList("ploop", "init", "-s", NULL);

In virStorageBackendCreatePloop() we try to find this binary prior
executing it. I guess we should do the same here and if not found, deny
whole operation.

> +
> +    virCommandAddArgFormat(cmd, "%lluM", VIR_DIV_UP(vol->target.capacity,
> +                                                        (1024 * 1024)));
> +    virCommandAddArgList(cmd, "-t", "ext4", NULL);
> +    virCommandAddArgFormat(cmd, "%s/root.hds", vol->target.path);

This could be just virCommandAddArg(cmd, target_path);

> +    ret = virCommandRun(cmd, NULL);
> +
> + cleanup:
> +    VIR_FREE(disk_desc);
> +    VIR_FREE(target_path);
> +    virCommandFree(cmd);
> +    return ret;
> +}

Otherwise looking good.

Michal

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]