qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Cc: aliguori@us.ibm.com, ehabkost@redhat.com, lersek@redhat.com,
	qemu-devel@nongnu.org, peter.huangpeng@huawei.com,
	drjones@redhat.com, bsd@redhat.com, hutao@cn.fujitsu.com,
	y-goto@jp.fujitsu.com, pbonzini@redhat.com, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH V12 11/13] NUMA: add hmp command set-mem-policy
Date: Tue, 10 Sep 2013 09:36:46 -0400	[thread overview]
Message-ID: <20130910093646.21441c61@redhat.com> (raw)
In-Reply-To: <1378285422-7361-12-git-send-email-gaowanlong@cn.fujitsu.com>

On Wed, 4 Sep 2013 17:03:40 +0800
Wanlong Gao <gaowanlong@cn.fujitsu.com> wrote:

> Add hmp command set-mem-policy to set host memory policy for a guest
> NUMA node. Then we can also set node's memory policy using
> the monitor command like:
>     (qemu) set-mem-policy 0 policy=membind,relative=false,host-nodes=0-1
> 
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> ---
>  hmp-commands.hx | 16 ++++++++++++++
>  hmp.c           | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  hmp.h           |  1 +
>  3 files changed, 82 insertions(+)
> 
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 65b7f60..b7f6049 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -1587,6 +1587,22 @@ Executes a qemu-io command on the given block device.
>  ETEXI
>  
>      {
> +        .name       = "set-mem-policy",
> +        .args_type  = "nodeid:i,args:s?",
> +        .params     = "nodeid [args]",

Please, document args.

> +        .help       = "set host memory policy for a guest NUMA node",
> +        .mhandler.cmd = hmp_set_mem_policy,
> +    },
> +
> +STEXI
> +@item set-mem-policy @var{nodeid} @var{args}
> +@findex set-mem-policy
> +
> +Set host memory policy for a guest NUMA node
> +
> +ETEXI
> +
> +    {
>          .name       = "info",
>          .args_type  = "item:s?",
>          .params     = "[subcommand]",
> diff --git a/hmp.c b/hmp.c
> index fcca6ae..ae695b0 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -24,6 +24,9 @@
>  #include "ui/console.h"
>  #include "block/qapi.h"
>  #include "qemu-io.h"
> +#include "qapi-visit.h"
> +#include "qapi/opts-visitor.h"
> +#include "qapi/dealloc-visitor.h"
>  
>  static void hmp_handle_error(Monitor *mon, Error **errp)
>  {
> @@ -1514,3 +1517,65 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
>  
>      hmp_handle_error(mon, &err);
>  }
> +
> +void hmp_set_mem_policy(Monitor *mon, const QDict *qdict)
> +{
> +    Error *local_err = NULL;
> +    bool has_policy = true;
> +    bool has_relative = true;
> +    bool has_host_nodes = true;
> +    QemuOpts *opts;
> +    NumaMemOptions *object = NULL;
> +    NumaNodePolicy policy = NUMA_NODE_POLICY_DEFAULT;
> +    bool relative = false;
> +    uint16List *host_nodes = NULL;
> +
> +    uint64_t nodeid = qdict_get_int(qdict, "nodeid");
> +    const char *args = qdict_get_try_str(qdict, "args");
> +
> +    if (args == NULL) {
> +        has_policy = false;
> +        has_relative = false;
> +        has_host_nodes = false;
> +    } else {
> +        opts = qemu_opts_parse(qemu_find_opts("numa"), args, 1);
> +        if (opts == NULL) {
> +            monitor_printf(mon, "Parsing memory policy args failed\n");
> +            return;
> +        } else {
> +            OptsVisitor *ov = opts_visitor_new(opts);
> +            visit_type_NumaMemOptions(opts_get_visitor(ov), &object, NULL,
> +                                      &local_err);
> +            opts_visitor_cleanup(ov);
> +
> +            if (error_is_set(&local_err)) {
> +                goto error;
> +            }
> +
> +            has_policy = object->has_policy;
> +            if (has_policy) {
> +                policy = object->policy;
> +            }
> +            has_relative = object->has_relative;
> +            if (has_relative) {
> +                relative = object->relative;
> +            }
> +            has_host_nodes = object->has_host_nodes;
> +            if (has_host_nodes) {
> +                host_nodes = object->host_nodes;
> +            }
> +        }
> +    }
> +
> +    qmp_set_mem_policy(nodeid, has_policy, policy, has_relative, relative,
> +                       has_host_nodes, host_nodes, &local_err);
> +error:

Nitpick: this is executed on non-error path, so I'd call this label "out".

> +    if (object) {
> +        QapiDeallocVisitor *dv = qapi_dealloc_visitor_new();
> +        visit_type_NumaMemOptions(qapi_dealloc_get_visitor(dv),
> +                                  &object, NULL, NULL);
> +        qapi_dealloc_visitor_cleanup(dv);
> +    }
> +
> +    hmp_handle_error(mon, &local_err);
> +}
> diff --git a/hmp.h b/hmp.h
> index 6c3bdcd..ae09525 100644
> --- a/hmp.h
> +++ b/hmp.h
> @@ -87,5 +87,6 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
>  void hmp_chardev_add(Monitor *mon, const QDict *qdict);
>  void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
>  void hmp_qemu_io(Monitor *mon, const QDict *qdict);
> +void hmp_set_mem_policy(Monitor *mon, const QDict *qdict);
>  
>  #endif

  reply	other threads:[~2013-09-10 13:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-04  9:03 [Qemu-devel] [PATCH V12 00/13] Add support for binding guest numa nodes to host numa nodes Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 01/13] NUMA: move numa related code to new file numa.c Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 02/13] NUMA: check if the total numa memory size is equal to ram_size Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 03/13] NUMA: Add numa_info structure to contain numa nodes info Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 04/13] NUMA: convert -numa option to use OptsVisitor Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 05/13] NUMA: introduce NumaMemOptions Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 06/13] NUMA: add "-numa mem," options Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 07/13] NUMA: expand MAX_NODES from 64 to 128 Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 08/13] NUMA: parse guest numa nodes memory policy Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 09/13] NUMA: set " Wanlong Gao
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 10/13] NUMA: add qmp command set-mem-policy to set memory policy for NUMA node Wanlong Gao
2013-09-09 21:02   ` Luiz Capitulino
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 11/13] NUMA: add hmp command set-mem-policy Wanlong Gao
2013-09-10 13:36   ` Luiz Capitulino [this message]
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 12/13] NUMA: add qmp command query-numa Wanlong Gao
2013-09-10 13:50   ` Luiz Capitulino
2013-09-04  9:03 ` [Qemu-devel] [PATCH V12 13/13] NUMA: convert hmp command info_numa to use qmp command query_numa Wanlong Gao
2013-09-10 14:03   ` Luiz Capitulino
2013-09-09  6:59 ` [Qemu-devel] [PATCH V12 00/13] Add support for binding guest numa nodes to host numa nodes Wanlong Gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130910093646.21441c61@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=bsd@redhat.com \
    --cc=drjones@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=gaowanlong@cn.fujitsu.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=lersek@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=y-goto@jp.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).