Re: [PATCH 4/8] latency: Wire up the remote protocol

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

 



On Wed, Aug 31, 2011 at 04:26:09PM +0800, Osier Yang wrote:
> ---
>  daemon/remote.c              |   81 ++++++++++++++++++++++++++++++++++++++++++
>  src/remote/remote_driver.c   |   69 +++++++++++++++++++++++++++++++++++
>  src/remote/remote_protocol.x |   23 +++++++++++-
>  3 files changed, 172 insertions(+), 1 deletions(-)
> 
> diff --git a/daemon/remote.c b/daemon/remote.c
> index 0f088c6..84784cb 100644
> --- a/daemon/remote.c
> +++ b/daemon/remote.c
> @@ -935,6 +935,87 @@ cleanup:
>  }
>  
>  static int
> +remoteDispatchDomainBlockStatsFlags(virNetServerPtr server ATTRIBUTE_UNUSED,
> +                                    virNetServerClientPtr client ATTRIBUTE_UNUSED,
> +                                    virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
> +                                    virNetMessageErrorPtr rerr,
> +                                    remote_domain_block_stats_flags_args *args,
> +                                    remote_domain_block_stats_flags_ret *ret)
> +{
> +    virDomainBlockStatsFlagsPtr params = NULL;
> +    virDomainPtr dom = NULL;
> +    int i;
> +    const char *path = args->path;
> +    int nparams = args->nparams;
> +    unsigned int flags;
> +    int rv = -1;
> +    struct daemonClientPrivate *priv =
> +        virNetServerClientGetPrivateData(client);
> +
> +    if (!priv->conn) {
> +        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
> +        goto cleanup;
> +    }
> +
> +    if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
> +        goto cleanup;
> +    flags = args->flags;
> +
> +    if (nparams > REMOTE_DOMAIN_BLOCK_STATS_MAX) {
> +        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
> +        goto cleanup;
> +    }
> +    if (VIR_ALLOC_N(params, nparams) < 0) {
> +        virReportOOMError();
> +        goto cleanup;
> +    }
> +
> +    if (virDomainBlockStatsFlags(dom, path, params, &nparams, flags) < 0)
> +        goto cleanup;
> +
> +    /* In this case, we need to send back the number of parameters
> +     * supported
> +     */
> +    if (args->nparams == 0) {
> +        ret->nparams = nparams;
> +        goto success;
> +    }
> +
> +    /* Serialise the block stats. */
> +    ret->params.params_len = nparams;
> +    if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
> +        goto no_memory;
> +
> +    for (i = 0; i < nparams; ++i) {
> +        /* remoteDispatchClientRequest will free this: */
> +        ret->params.params_val[i].field = strdup(params[i].field);
> +        if (ret->params.params_val[i].field == NULL)
> +            goto no_memory;
> +
> +        ret->params.params_val[i].value = params[i].value;
> +    }
> +
> +success:
> +    rv = 0;
> +
> +cleanup:
> +    if (rv < 0) {
> +        virNetMessageSaveError(rerr);
> +        if (ret->params.params_val) {
> +            for (i = 0; i < nparams; i++)
> +                VIR_FREE(ret->params.params_val[i].field);
> +            VIR_FREE(ret->params.params_val);
> +        }
> +    }
> +    VIR_FREE(params);
> +    return rv;
> +
> +no_memory:
> +    virReportOOMError();
> +    goto cleanup;
> +}
> +
> +static int
>  remoteDispatchDomainMemoryPeek(virNetServerPtr server ATTRIBUTE_UNUSED,
>                                 virNetServerClientPtr client ATTRIBUTE_UNUSED,
>                                 virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
> index 603d589..5d3d4dd 100644
> --- a/src/remote/remote_driver.c
> +++ b/src/remote/remote_driver.c
> @@ -1361,6 +1361,74 @@ cleanup:
>  }
>  
>  static int
> +remoteDomainBlockStatsFlags(virDomainPtr domain,
> +                            const char *path,
> +                            virDomainBlockStatsFlagsPtr params,
> +                            int *nparams,
> +                            unsigned int flags)
> +{
> +    int rv = -1;
> +    remote_domain_block_stats_flags_args args;
> +    remote_domain_block_stats_flags_ret ret;
> +    int i = -1;
> +    struct private_data *priv = domain->conn->privateData;
> +
> +    remoteDriverLock(priv);
> +
> +    make_nonnull_domain (&args.dom, domain);
> +    args.nparams = *nparams;
> +    args.path = (char *) path;
> +    args.flags = flags;
> +
> +    memset (&ret, 0, sizeof ret);
> +    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_BLOCK_STATS_FLAGS,
> +              (xdrproc_t) xdr_remote_domain_block_stats_flags_args, (char *) &args,
> +              (xdrproc_t) xdr_remote_domain_block_stats_flags_ret, (char *) &ret) == -1)
> +        goto done;
> +
> +    /* Check the length of the returned list carefully. */
> +    if (ret.params.params_len > REMOTE_DOMAIN_BLOCK_STATS_MAX ||
> +        ret.params.params_len > *nparams) {
> +        remoteError(VIR_ERR_RPC, "%s",
> +                    _("remoteDomainBlockStatsFlags: "
> +                      "returned number of stats exceeds limit"));
> +        goto cleanup;
> +    }
> +
> +    /* Handle the case when the caller does not know the number of stats
> +     * and is asking for the number of stats supported
> +     */
> +    if (*nparams == 0) {
> +        *nparams = ret.nparams;
> +        rv = 0;
> +        goto cleanup;
> +    }
> +
> +    *nparams = ret.params.params_len;
> +
> +    /* Deserialise the result. */
> +    for (i = 0; i < *nparams; ++i) {
> +        if (virStrcpyStatic(params[i].field, ret.params.params_val[i].field) == NULL) {
> +            remoteError(VIR_ERR_INTERNAL_ERROR,
> +                        _("Stats %s too big for destination"),
> +                        ret.params.params_val[i].field);
> +            goto cleanup;
> +        }
> +        params[i].value = ret.params.params_val[i].value;
> +    }
> +
> +    rv = 0;
> +
> +cleanup:
> +    xdr_free ((xdrproc_t) xdr_remote_domain_block_stats_flags_ret,
> +              (char *) &ret);
> +done:
> +    remoteDriverUnlock(priv);
> +    return rv;
> +}
> +
> +
> +static int
>  remoteDomainGetMemoryParameters (virDomainPtr domain,
>                                   virTypedParameterPtr params, int *nparams,
>                                   unsigned int flags)
> @@ -4307,6 +4375,7 @@ static virDriver remote_driver = {
>      .domainMigratePerform = remoteDomainMigratePerform, /* 0.3.2 */
>      .domainMigrateFinish = remoteDomainMigrateFinish, /* 0.3.2 */
>      .domainBlockStats = remoteDomainBlockStats, /* 0.3.2 */
> +    .domainBlockStatsFlags = remoteDomainBlockStatsFlags, /* 0.9.5 */
>      .domainInterfaceStats = remoteDomainInterfaceStats, /* 0.3.2 */
>      .domainMemoryStats = remoteDomainMemoryStats, /* 0.7.5 */
>      .domainBlockPeek = remoteDomainBlockPeek, /* 0.4.2 */
> diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
> index 8f68808..dcd3c09 100644
> --- a/src/remote/remote_protocol.x
> +++ b/src/remote/remote_protocol.x
> @@ -131,6 +131,9 @@ const REMOTE_NODE_CPU_STATS_MAX = 16;
>  /* Upper limit on list of node memory stats. */
>  const REMOTE_NODE_MEMORY_STATS_MAX = 16;
>  
> +/* Upper limit on list of block stats. */
> +const REMOTE_DOMAIN_BLOCK_STATS_MAX = 16;
> +
>  /* Upper limit on number of NUMA cells */
>  const REMOTE_NODE_MAX_CELLS = 1024;
>  
> @@ -331,6 +334,11 @@ struct remote_node_get_memory_stats {
>      unsigned hyper value;
>  };
>  
> +struct remote_domain_block_stats_flags {
> +    remote_nonnull_string field;
> +    hyper value;
> +};
> +
>  /*----- Calls. -----*/
>  
>  /* For each call we may have a 'remote_CALL_args' and 'remote_CALL_ret'
> @@ -544,6 +552,18 @@ struct remote_domain_block_stats_ret { /* insert@2 */
>      hyper errs;
>  };
>  
> +struct remote_domain_block_stats_flags_args {
> +    remote_nonnull_domain dom;
> +    remote_nonnull_string path;
> +    int nparams;
> +    unsigned int flags;
> +};
> +
> +struct remote_domain_block_stats_flags_ret {
> +    remote_domain_block_stats_flags params<REMOTE_DOMAIN_BLOCK_STATS_MAX>;
> +    int nparams;
> +};
> +
>  struct remote_domain_interface_stats_args {
>      remote_nonnull_domain dom;
>      remote_nonnull_string path;
> @@ -2475,7 +2495,8 @@ enum remote_procedure {
>      REMOTE_PROC_DOMAIN_BLOCK_JOB_SET_SPEED = 239, /* autogen autogen */
>      REMOTE_PROC_DOMAIN_BLOCK_PULL = 240, /* autogen autogen */
>  
> -    REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB = 241 /* skipgen skipgen */
> +    REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB = 241, /* skipgen skipgen */
> +    REMOTE_PROC_DOMAIN_BLOCK_STATS_FLAGS = 242 /* skipgen skipgen */
>  
>      /*
>       * Notice how the entries are grouped in sets of 10 ?

  ACK,

Daniel

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

--
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]