From patchwork Wed Jul 17 09:29:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanlong Gao X-Patchwork-Id: 259655 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B2D132C0091 for ; Wed, 17 Jul 2013 19:40:07 +1000 (EST) Received: from localhost ([::1]:33946 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzODN-0006qP-It for incoming@patchwork.ozlabs.org; Wed, 17 Jul 2013 05:40:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzO5K-0002pH-DZ for qemu-devel@nongnu.org; Wed, 17 Jul 2013 05:31:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UzO5G-00044B-HC for qemu-devel@nongnu.org; Wed, 17 Jul 2013 05:31:46 -0400 Received: from [222.73.24.84] (port=35041 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzO5G-00040G-5J for qemu-devel@nongnu.org; Wed, 17 Jul 2013 05:31:42 -0400 X-IronPort-AV: E=Sophos;i="4.89,678,1367942400"; d="scan'208";a="7922777" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 17 Jul 2013 17:28:29 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r6H9VPhX011307; Wed, 17 Jul 2013 17:31:27 +0800 Received: from G08FNSTD121251.fnst.cn.fujitsu.com ([10.167.233.84]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013071717293528-2993222 ; Wed, 17 Jul 2013 17:29:35 +0800 From: Wanlong Gao To: qemu-devel@nongnu.org Date: Wed, 17 Jul 2013 17:29:31 +0800 Message-Id: <1374053373-30499-11-git-send-email-gaowanlong@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.2.634.g7a3187e In-Reply-To: <1374053373-30499-1-git-send-email-gaowanlong@cn.fujitsu.com> References: <1374053373-30499-1-git-send-email-gaowanlong@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/07/17 17:29:35, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/07/17 17:29:37, Serialize complete at 2013/07/17 17:29:37 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Cc: aliguori@us.ibm.com, ehabkost@redhat.com, lersek@redhat.com, peter.huangpeng@huawei.com, lcapitulino@redhat.com, bsd@redhat.com, y-goto@jp.fujitsu.com, pbonzini@redhat.com, afaerber@suse.de, gaowanlong@cn.fujitsu.com Subject: [Qemu-devel] [PATCH V5 10/12] NUMA: add hmp command set-mem-policy X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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,host-nodes=0-1 Signed-off-by: Wanlong Gao --- hmp-commands.hx | 16 ++++++++++++++++ hmp.c | 36 ++++++++++++++++++++++++++++++++++++ hmp.h | 1 + 3 files changed, 53 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 8c6b91a..fe3a26f 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]", + .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 dc4d8d4..7798339 100644 --- a/hmp.c +++ b/hmp.c @@ -1510,3 +1510,39 @@ 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_host_nodes = true; + const char *policy = NULL; + const char *host_nodes = NULL; + QemuOpts *opts; + + uint64_t nodeid = qdict_get_int(qdict, "nodeid"); + const char *args = qdict_get_try_str(qdict, "args"); + + if (args == NULL) { + has_policy = 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 { + policy = qemu_opt_get(opts, "policy"); + if (policy == NULL) { + has_policy = false; + } + host_nodes = qemu_opt_get(opts, "hostnode"); + if (host_nodes == NULL) { + has_host_nodes = false; + } + } + } + + qmp_set_mem_policy(nodeid, has_policy, policy, has_host_nodes, host_nodes, &local_err); + 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