[libvirt] [PATCH 4/9] Implement the public API for vol wiping

Daniel Veillard veillard at redhat.com
Wed Mar 17 13:13:37 UTC 2010


On Mon, Mar 15, 2010 at 10:13:26PM -0400, David Allan wrote:
> ---
>  src/libvirt.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 47 insertions(+), 0 deletions(-)
> 
> diff --git a/src/libvirt.c b/src/libvirt.c
> index 1d9b878..74b075b 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -8479,6 +8479,53 @@ error:
> 
> 
>  /**
> + * virStorageVolWipe:
> + * @vol: pointer to storage volume
> + * @flags: future flags, use 0 for now

  "optional flags" sounds better to me

> + *
> + * Ensure data previously on a volume is not accessible to future reads
> + *
> + * Returns 0 on success, or -1 on error
> + */
> +int
> +virStorageVolWipe(virStorageVolPtr vol,
> +                  unsigned int flags)
> +{
> +    virConnectPtr conn;
> +    VIR_DEBUG("vol=%p, flags=%u", vol, flags);
> +
> +    virResetLastError();
> +
> +    if (!VIR_IS_CONNECTED_STORAGE_VOL(vol)) {
> +        virLibStorageVolError(NULL, VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__);
> +        virDispatchError(NULL);
> +        return (-1);
> +    }
> +
> +    conn = vol->conn;
> +    if (conn->flags & VIR_CONNECT_RO) {
> +        virLibStorageVolError(vol, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
> +        goto error;
> +    }
> +
> +    if (conn->storageDriver && conn->storageDriver->volWipe) {
> +        int ret;
> +        ret = conn->storageDriver->volWipe(vol, flags);
> +        if (ret < 0) {
> +            goto error;
> +        }
> +        return ret;
> +    }
> +
> +    virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
> +
> +error:
> +    virDispatchError(vol->conn);
> +    return -1;
> +}
> +
> +
> +/**
>   * virStorageVolFree:
>   * @vol: pointer to storage volume
>   *

ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list