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

Re: [libvirt] [PATCH 1/7] Add public API stubs for virStorageVolCreateXMLFrom



On Mon, May 04, 2009 at 01:42:56PM -0400, Cole Robinson wrote:
> 
> Signed-off-by: Cole Robinson <crobinso redhat com>
> ---
>  include/libvirt/libvirt.h    |    4 +++
>  include/libvirt/libvirt.h.in |    4 +++
>  src/driver.h                 |    6 ++++
>  src/libvirt.c                |   61 ++++++++++++++++++++++++++++++++++++++++-
>  src/libvirt_public.syms      |    5 +++
>  5 files changed, 78 insertions(+), 2 deletions(-)

ACK, this looks good to me.


Daniel

> 
> diff --git a/include/libvirt/libvirt.h b/include/libvirt/libvirt.h
> index 30f559d..b1e45e4 100644
> --- a/include/libvirt/libvirt.h
> +++ b/include/libvirt/libvirt.h
> @@ -1047,6 +1047,10 @@ const char*             virStorageVolGetKey             (virStorageVolPtr vol);
>  virStorageVolPtr        virStorageVolCreateXML          (virStoragePoolPtr pool,
>                                                           const char *xmldesc,
>                                                           unsigned int flags);
> +virStorageVolPtr        virStorageVolCreateXMLFrom      (virStoragePoolPtr pool,
> +                                                         const char *xmldesc,
> +                                                         unsigned int flags,
> +                                                         virStorageVolPtr clonevol);
>  int                     virStorageVolDelete             (virStorageVolPtr vol,
>                                                           unsigned int flags);
>  int                     virStorageVolRef                (virStorageVolPtr vol);
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index 2f7076f..f5cadb4 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -1047,6 +1047,10 @@ const char*             virStorageVolGetKey             (virStorageVolPtr vol);
>  virStorageVolPtr        virStorageVolCreateXML          (virStoragePoolPtr pool,
>                                                           const char *xmldesc,
>                                                           unsigned int flags);
> +virStorageVolPtr        virStorageVolCreateXMLFrom      (virStoragePoolPtr pool,
> +                                                         const char *xmldesc,
> +                                                         unsigned int flags,
> +                                                         virStorageVolPtr clonevol);
>  int                     virStorageVolDelete             (virStorageVolPtr vol,
>                                                           unsigned int flags);
>  int                     virStorageVolRef                (virStorageVolPtr vol);
> diff --git a/src/driver.h b/src/driver.h
> index c357b76..ff12ada 100644
> --- a/src/driver.h
> +++ b/src/driver.h
> @@ -586,6 +586,11 @@ typedef char *
>  typedef char *
>      (*virDrvStorageVolGetPath)               (virStorageVolPtr vol);
>  
> +typedef virStorageVolPtr
> +    (*virDrvStorageVolCreateXMLFrom)         (virStoragePoolPtr pool,
> +                                              const char *xmldesc,
> +                                              unsigned int flags,
> +                                              virStorageVolPtr clone);
>  
>  
>  typedef struct _virStorageDriver virStorageDriver;
> @@ -633,6 +638,7 @@ struct _virStorageDriver {
>      virDrvStorageVolLookupByKey volLookupByKey;
>      virDrvStorageVolLookupByPath volLookupByPath;
>      virDrvStorageVolCreateXML volCreateXML;
> +    virDrvStorageVolCreateXMLFrom volCreateXMLFrom;
>      virDrvStorageVolDelete volDelete;
>      virDrvStorageVolGetInfo volGetInfo;
>      virDrvStorageVolGetXMLDesc volGetXMLDesc;
> diff --git a/src/libvirt.c b/src/libvirt.c
> index ded18a7..5a51c45 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -6767,6 +6767,65 @@ error:
>  
>  
>  /**
> + * virStorageVolCreateXMLFrom:
> + * @pool: pointer to parent pool for the new volume
> + * @xmldesc: description of volume to create
> + * @flags: flags for creation (unused, pass 0)
> + * @clonevol: storage volume to use as input
> + *
> + * Create a storage volume in the parent pool, using the
> + * 'clonevol' volume as input. Information for the new
> + * volume (name, perms)  are passed via a typical volume
> + * XML description.
> + *
> + * return the storage volume, or NULL on error
> + */
> +virStorageVolPtr
> +virStorageVolCreateXMLFrom(virStoragePoolPtr pool,
> +                           const char *xmldesc,
> +                           unsigned int flags,
> +                           virStorageVolPtr clonevol)
> +{
> +    DEBUG("pool=%p, flags=%u, clonevol=%p", pool, flags, clonevol);
> +
> +    virResetLastError();
> +
> +    if (!VIR_IS_STORAGE_POOL(pool)) {
> +        virLibConnError(NULL, VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
> +        return (NULL);
> +    }
> +
> +    if (!VIR_IS_STORAGE_VOL(clonevol)) {
> +        virLibConnError(NULL, VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__);
> +        return (NULL);
> +    }
> +
> +    if (pool->conn->flags & VIR_CONNECT_RO ||
> +        clonevol->conn->flags & VIR_CONNECT_RO) {
> +        virLibConnError(pool->conn, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
> +        goto error;
> +    }
> +
> +    if (pool->conn->storageDriver &&
> +        pool->conn->storageDriver->volCreateXMLFrom) {
> +        virStorageVolPtr ret;
> +        ret = pool->conn->storageDriver->volCreateXMLFrom (pool, xmldesc,
> +                                                           flags, clonevol);
> +        if (!ret)
> +            goto error;
> +        return ret;
> +    }
> +
> +    virLibConnError (pool->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
> +
> +error:
> +    /* Copy to connection error object for back compatability */
> +    virSetConnError(pool->conn);
> +    return NULL;
> +}
> +
> +
> +/**
>   * virStorageVolDelete:
>   * @vol: pointer to storage volume
>   * @flags: future flags, use 0 for now
> @@ -7009,8 +7068,6 @@ error:
>  }
>  
>  
> -
> -
>  /**
>   * virNodeNumOfDevices:
>   * @conn: pointer to the hypervisor connection
> diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
> index b8f9128..0ea130f 100644
> --- a/src/libvirt_public.syms
> +++ b/src/libvirt_public.syms
> @@ -265,3 +265,8 @@ LIBVIRT_0.6.3 {
>  } LIBVIRT_0.6.1;
>  
>  # .... define new API here using predicted next version number ....
> +
> +LIBVIRT_0.6.4 {
> +    global:
> +	virStorageVolCreateXMLFrom;
> +} LIBVIRT_0.6.3;
> -- 
> 1.6.0.6
> 
> --
> Libvir-list mailing list
> Libvir-list redhat com
> https://www.redhat.com/mailman/listinfo/libvir-list

-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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