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

Re: [libvirt] [PATCH 2/7] Remote driver plumbing for virStorageVolCreateXMLFrom



On Mon, May 04, 2009 at 01:42:57PM -0400, Cole Robinson wrote:
> 
> Signed-off-by: Cole Robinson <crobinso redhat com>
> ---
>  qemud/remote.c                     |   34 ++++++++++++++++++++++++++++++++++
>  qemud/remote_dispatch_args.h       |    1 +
>  qemud/remote_dispatch_prototypes.h |    7 +++++++
>  qemud/remote_dispatch_ret.h        |    1 +
>  qemud/remote_dispatch_table.h      |    5 +++++
>  qemud/remote_protocol.c            |   24 ++++++++++++++++++++++++
>  qemud/remote_protocol.h            |   18 ++++++++++++++++++
>  qemud/remote_protocol.x            |   15 ++++++++++++++-
>  src/remote_internal.c              |   33 +++++++++++++++++++++++++++++++++
>  9 files changed, 137 insertions(+), 1 deletions(-)

ACK, all fine, boring stuff.

Daniel

> 
> diff --git a/qemud/remote.c b/qemud/remote.c
> index 8d24a3a..5ba9430 100644
> --- a/qemud/remote.c
> +++ b/qemud/remote.c
> @@ -3831,6 +3831,40 @@ remoteDispatchStorageVolCreateXml (struct qemud_server *server ATTRIBUTE_UNUSED,
>      return 0;
>  }
>  
> +static int
> +remoteDispatchStorageVolCreateXmlFrom (struct qemud_server *server ATTRIBUTE_UNUSED,
> +                                       struct qemud_client *client ATTRIBUTE_UNUSED,
> +                                       virConnectPtr conn,
> +                                       remote_error *rerr,
> +                                       remote_storage_vol_create_xml_from_args *args,
> +                                       remote_storage_vol_create_xml_from_ret *ret)
> +{
> +    virStoragePoolPtr pool;
> +    virStorageVolPtr clonevol, newvol;
> +
> +    pool = get_nonnull_storage_pool (conn, args->pool);
> +    if (pool == NULL) {
> +        remoteDispatchConnError(rerr, conn);
> +        return -1;
> +    }
> +
> +    clonevol = get_nonnull_storage_vol (conn, args->clonevol);
> +    if (clonevol == NULL) {
> +        remoteDispatchConnError(rerr, conn);
> +        return -1;
> +    }
> +
> +    newvol = virStorageVolCreateXMLFrom (pool, args->xml, args->flags,
> +                                         clonevol);
> +    if (newvol == NULL) {
> +        remoteDispatchConnError(rerr, conn);
> +        return -1;
> +    }
> +
> +    make_nonnull_storage_vol (&ret->vol, newvol);
> +    virStorageVolFree(newvol);
> +    return 0;
> +}
>  
>  static int
>  remoteDispatchStorageVolDelete (struct qemud_server *server ATTRIBUTE_UNUSED,
> diff --git a/qemud/remote_dispatch_args.h b/qemud/remote_dispatch_args.h
> index 58eccf5..8f8b05b 100644
> --- a/qemud/remote_dispatch_args.h
> +++ b/qemud/remote_dispatch_args.h
> @@ -105,3 +105,4 @@
>      remote_domain_get_security_label_args val_remote_domain_get_security_label_args;
>      remote_node_device_create_xml_args val_remote_node_device_create_xml_args;
>      remote_node_device_destroy_args val_remote_node_device_destroy_args;
> +    remote_storage_vol_create_xml_from_args val_remote_storage_vol_create_xml_from_args;
> diff --git a/qemud/remote_dispatch_prototypes.h b/qemud/remote_dispatch_prototypes.h
> index 96dcb2a..1a2d98b 100644
> --- a/qemud/remote_dispatch_prototypes.h
> +++ b/qemud/remote_dispatch_prototypes.h
> @@ -814,6 +814,13 @@ static int remoteDispatchStorageVolCreateXml(
>      remote_error *err,
>      remote_storage_vol_create_xml_args *args,
>      remote_storage_vol_create_xml_ret *ret);
> +static int remoteDispatchStorageVolCreateXmlFrom(
> +    struct qemud_server *server,
> +    struct qemud_client *client,
> +    virConnectPtr conn,
> +    remote_error *err,
> +    remote_storage_vol_create_xml_from_args *args,
> +    remote_storage_vol_create_xml_from_ret *ret);
>  static int remoteDispatchStorageVolDelete(
>      struct qemud_server *server,
>      struct qemud_client *client,
> diff --git a/qemud/remote_dispatch_ret.h b/qemud/remote_dispatch_ret.h
> index 3325c8b..75e2ca6 100644
> --- a/qemud/remote_dispatch_ret.h
> +++ b/qemud/remote_dispatch_ret.h
> @@ -89,3 +89,4 @@
>      remote_domain_get_security_label_ret val_remote_domain_get_security_label_ret;
>      remote_node_get_security_model_ret val_remote_node_get_security_model_ret;
>      remote_node_device_create_xml_ret val_remote_node_device_create_xml_ret;
> +    remote_storage_vol_create_xml_from_ret val_remote_storage_vol_create_xml_from_ret;
> diff --git a/qemud/remote_dispatch_table.h b/qemud/remote_dispatch_table.h
> index ac7f9b9..e601a6c 100644
> --- a/qemud/remote_dispatch_table.h
> +++ b/qemud/remote_dispatch_table.h
> @@ -627,3 +627,8 @@
>      .args_filter = (xdrproc_t) xdr_remote_node_device_destroy_args,
>      .ret_filter = (xdrproc_t) xdr_void,
>  },
> +{   /* StorageVolCreateXmlFrom => 125 */
> +    .fn = (dispatch_fn) remoteDispatchStorageVolCreateXmlFrom,
> +    .args_filter = (xdrproc_t) xdr_remote_storage_vol_create_xml_from_args,
> +    .ret_filter = (xdrproc_t) xdr_remote_storage_vol_create_xml_from_ret,
> +},
> diff --git a/qemud/remote_protocol.c b/qemud/remote_protocol.c
> index af3c792..738f95c 100644
> --- a/qemud/remote_protocol.c
> +++ b/qemud/remote_protocol.c
> @@ -1992,6 +1992,30 @@ xdr_remote_storage_vol_create_xml_ret (XDR *xdrs, remote_storage_vol_create_xml_
>  }
>  
>  bool_t
> +xdr_remote_storage_vol_create_xml_from_args (XDR *xdrs, remote_storage_vol_create_xml_from_args *objp)
> +{
> +
> +         if (!xdr_remote_nonnull_storage_pool (xdrs, &objp->pool))
> +                 return FALSE;
> +         if (!xdr_remote_nonnull_string (xdrs, &objp->xml))
> +                 return FALSE;
> +         if (!xdr_u_int (xdrs, &objp->flags))
> +                 return FALSE;
> +         if (!xdr_remote_nonnull_storage_vol (xdrs, &objp->clonevol))
> +                 return FALSE;
> +        return TRUE;
> +}
> +
> +bool_t
> +xdr_remote_storage_vol_create_xml_from_ret (XDR *xdrs, remote_storage_vol_create_xml_from_ret *objp)
> +{
> +
> +         if (!xdr_remote_nonnull_storage_vol (xdrs, &objp->vol))
> +                 return FALSE;
> +        return TRUE;
> +}
> +
> +bool_t
>  xdr_remote_storage_vol_delete_args (XDR *xdrs, remote_storage_vol_delete_args *objp)
>  {
>  
> diff --git a/qemud/remote_protocol.h b/qemud/remote_protocol.h
> index 9d67e58..9480dce 100644
> --- a/qemud/remote_protocol.h
> +++ b/qemud/remote_protocol.h
> @@ -1120,6 +1120,19 @@ struct remote_storage_vol_create_xml_ret {
>  };
>  typedef struct remote_storage_vol_create_xml_ret remote_storage_vol_create_xml_ret;
>  
> +struct remote_storage_vol_create_xml_from_args {
> +        remote_nonnull_storage_pool pool;
> +        remote_nonnull_string xml;
> +        u_int flags;
> +        remote_nonnull_storage_vol clonevol;
> +};
> +typedef struct remote_storage_vol_create_xml_from_args remote_storage_vol_create_xml_from_args;
> +
> +struct remote_storage_vol_create_xml_from_ret {
> +        remote_nonnull_storage_vol vol;
> +};
> +typedef struct remote_storage_vol_create_xml_from_ret remote_storage_vol_create_xml_from_ret;
> +
>  struct remote_storage_vol_delete_args {
>          remote_nonnull_storage_vol vol;
>          u_int flags;
> @@ -1415,6 +1428,7 @@ enum remote_procedure {
>          REMOTE_PROC_NODE_GET_SECURITY_MODEL = 122,
>          REMOTE_PROC_NODE_DEVICE_CREATE_XML = 123,
>          REMOTE_PROC_NODE_DEVICE_DESTROY = 124,
> +        REMOTE_PROC_STORAGE_VOL_CREATE_XML_FROM = 125,
>  };
>  typedef enum remote_procedure remote_procedure;
>  
> @@ -1623,6 +1637,8 @@ extern  bool_t xdr_remote_storage_vol_lookup_by_path_args (XDR *, remote_storage
>  extern  bool_t xdr_remote_storage_vol_lookup_by_path_ret (XDR *, remote_storage_vol_lookup_by_path_ret*);
>  extern  bool_t xdr_remote_storage_vol_create_xml_args (XDR *, remote_storage_vol_create_xml_args*);
>  extern  bool_t xdr_remote_storage_vol_create_xml_ret (XDR *, remote_storage_vol_create_xml_ret*);
> +extern  bool_t xdr_remote_storage_vol_create_xml_from_args (XDR *, remote_storage_vol_create_xml_from_args*);
> +extern  bool_t xdr_remote_storage_vol_create_xml_from_ret (XDR *, remote_storage_vol_create_xml_from_ret*);
>  extern  bool_t xdr_remote_storage_vol_delete_args (XDR *, remote_storage_vol_delete_args*);
>  extern  bool_t xdr_remote_storage_vol_dump_xml_args (XDR *, remote_storage_vol_dump_xml_args*);
>  extern  bool_t xdr_remote_storage_vol_dump_xml_ret (XDR *, remote_storage_vol_dump_xml_ret*);
> @@ -1837,6 +1853,8 @@ extern bool_t xdr_remote_storage_vol_lookup_by_path_args ();
>  extern bool_t xdr_remote_storage_vol_lookup_by_path_ret ();
>  extern bool_t xdr_remote_storage_vol_create_xml_args ();
>  extern bool_t xdr_remote_storage_vol_create_xml_ret ();
> +extern bool_t xdr_remote_storage_vol_create_xml_from_args ();
> +extern bool_t xdr_remote_storage_vol_create_xml_from_ret ();
>  extern bool_t xdr_remote_storage_vol_delete_args ();
>  extern bool_t xdr_remote_storage_vol_dump_xml_args ();
>  extern bool_t xdr_remote_storage_vol_dump_xml_ret ();
> diff --git a/qemud/remote_protocol.x b/qemud/remote_protocol.x
> index 2c79949..123f6ae 100644
> --- a/qemud/remote_protocol.x
> +++ b/qemud/remote_protocol.x
> @@ -1002,6 +1002,17 @@ struct remote_storage_vol_create_xml_ret {
>      remote_nonnull_storage_vol vol;
>  };
>  
> +struct remote_storage_vol_create_xml_from_args {
> +    remote_nonnull_storage_pool pool;
> +    remote_nonnull_string xml;
> +    unsigned flags;
> +    remote_nonnull_storage_vol clonevol;
> +};
> +
> +struct remote_storage_vol_create_xml_from_ret {
> +    remote_nonnull_storage_vol vol;
> +};
> +
>  struct remote_storage_vol_delete_args {
>      remote_nonnull_storage_vol vol;
>      unsigned flags;
> @@ -1286,7 +1297,9 @@ enum remote_procedure {
>      REMOTE_PROC_NODE_GET_SECURITY_MODEL = 122,
>  
>      REMOTE_PROC_NODE_DEVICE_CREATE_XML = 123,
> -    REMOTE_PROC_NODE_DEVICE_DESTROY = 124
> +    REMOTE_PROC_NODE_DEVICE_DESTROY = 124,
> +
> +    REMOTE_PROC_STORAGE_VOL_CREATE_XML_FROM = 125
>  };
>  
>  /* Custom RPC structure. */
> diff --git a/src/remote_internal.c b/src/remote_internal.c
> index 24226e5..e100767 100644
> --- a/src/remote_internal.c
> +++ b/src/remote_internal.c
> @@ -4508,6 +4508,38 @@ done:
>      return vol;
>  }
>  
> +static virStorageVolPtr
> +remoteStorageVolCreateXMLFrom (virStoragePoolPtr pool,
> +                               const char *xmlDesc,
> +                               unsigned int flags,
> +                               virStorageVolPtr clonevol)
> +{
> +    virStorageVolPtr newvol = NULL;
> +    remote_storage_vol_create_xml_from_args args;
> +    remote_storage_vol_create_xml_from_ret ret;
> +    struct private_data *priv = pool->conn->storagePrivateData;
> +
> +    remoteDriverLock(priv);
> +
> +    make_nonnull_storage_pool (&args.pool, pool);
> +    make_nonnull_storage_vol (&args.clonevol, clonevol);
> +    args.xml = (char *) xmlDesc;
> +    args.flags = flags;
> +
> +    memset (&ret, 0, sizeof ret);
> +    if (call (pool->conn, priv, 0, REMOTE_PROC_STORAGE_VOL_CREATE_XML_FROM,
> +              (xdrproc_t) xdr_remote_storage_vol_create_xml_from_args, (char *) &args,
> +              (xdrproc_t) xdr_remote_storage_vol_create_xml_from_ret, (char *) &ret) == -1)
> +        goto done;
> +
> +    newvol = get_nonnull_storage_vol (pool->conn, ret.vol);
> +    xdr_free ((xdrproc_t) &xdr_remote_storage_vol_create_xml_from_ret, (char *) &ret);
> +
> +done:
> +    remoteDriverUnlock(priv);
> +    return newvol;
> +}
> +
>  static int
>  remoteStorageVolDelete (virStorageVolPtr vol,
>                          unsigned int flags)
> @@ -7027,6 +7059,7 @@ static virStorageDriver storage_driver = {
>      .volLookupByKey = remoteStorageVolLookupByKey,
>      .volLookupByPath = remoteStorageVolLookupByPath,
>      .volCreateXML = remoteStorageVolCreateXML,
> +    .volCreateXMLFrom = remoteStorageVolCreateXMLFrom,
>      .volDelete = remoteStorageVolDelete,
>      .volGetInfo = remoteStorageVolGetInfo,
>      .volGetXMLDesc = remoteStorageVolDumpXML,
> -- 
> 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]