From patchwork Fri Jun 21 06:25:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanlong Gao X-Patchwork-Id: 253142 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 C15902C02BA for ; Fri, 21 Jun 2013 16:39:50 +1000 (EST) Received: from localhost ([::1]:34719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upv0e-0002Ck-6u for incoming@patchwork.ozlabs.org; Fri, 21 Jun 2013 02:39:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upv0D-0002AO-Nz for qemu-devel@nongnu.org; Fri, 21 Jun 2013 02:39:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Upv0C-0004eV-9W for qemu-devel@nongnu.org; Fri, 21 Jun 2013 02:39:21 -0400 Received: from [222.73.24.84] (port=56779 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upv09-00022d-Sn for qemu-devel@nongnu.org; Fri, 21 Jun 2013 02:39:20 -0400 X-IronPort-AV: E=Sophos;i="4.87,910,1363104000"; d="scan'208";a="7624926" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 21 Jun 2013 14:25:22 +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 r5L6SDde022947; Fri, 21 Jun 2013 14:28:15 +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 2013062114270646-2357115 ; Fri, 21 Jun 2013 14:27:06 +0800 From: Wanlong Gao To: qemu-devel@nongnu.org Date: Fri, 21 Jun 2013 14:25:59 +0800 Message-Id: <1371795960-10478-9-git-send-email-gaowanlong@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1.448.gfb7dfaa In-Reply-To: <1371795960-10478-1-git-send-email-gaowanlong@cn.fujitsu.com> References: <1371795960-10478-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/06/21 14:27:06, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/21 14:27:09, Serialize complete at 2013/06/21 14:27:09 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, bsd@redhat.com, pbonzini@redhat.com, y-goto@jp.fujitsu.com, afaerber@suse.de, gaowanlong@cn.fujitsu.com Subject: [Qemu-devel] [PATCH V2 8/9] NUMA: add hmp command set-mpol 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-mpol 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-mpol 0 mem-policy=membind,mem-hostnode=0-1 Signed-off-by: Wanlong Gao --- hmp-commands.hx | 16 ++++++++++++++++ hmp.c | 35 +++++++++++++++++++++++++++++++++++ hmp.h | 1 + 3 files changed, 52 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 915b0d1..417b69f 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1567,6 +1567,22 @@ Executes a qemu-io command on the given block device. ETEXI { + .name = "set-mpol", + .args_type = "nodeid:i,args:s?", + .params = "nodeid [args]", + .help = "set host memory policy for a guest NUMA node", + .mhandler.cmd = hmp_set_mpol, + }, + +STEXI +@item set-mpol @var{nodeid} @var{args} +@findex set-mpol + +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 494a9aa..81bddb1 100644 --- a/hmp.c +++ b/hmp.c @@ -1464,3 +1464,38 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } + +void hmp_set_mpol(Monitor *mon, const QDict *qdict) +{ + Error *local_err = NULL; + bool has_mpol = true; + bool has_hostnode = true; + const char *mpol = NULL; + const char *hostnode = NULL; + QemuOpts *opts; + + uint64_t nodeid = qdict_get_int(qdict, "nodeid"); + const char *args = qdict_get_try_str(qdict, "args"); + + if (args == NULL) { + has_mpol = false; + has_hostnode = false; + } else { + opts = qemu_opts_parse(qemu_find_opts("numa"), args, 1); + if (opts == NULL) { + error_setg(&local_err, "Parsing memory policy args failed"); + } else { + mpol = qemu_opt_get(opts, "mem-policy"); + if (mpol == NULL) { + has_mpol = false; + } + hostnode = qemu_opt_get(opts, "mem-hostnode"); + if (hostnode == NULL) { + has_hostnode = false; + } + } + } + + qmp_set_mpol(nodeid, has_mpol, mpol, has_hostnode, hostnode, &local_err); + hmp_handle_error(mon, &local_err); +} diff --git a/hmp.h b/hmp.h index 56d2e92..81f631b 100644 --- a/hmp.h +++ b/hmp.h @@ -86,5 +86,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_mpol(Monitor *mon, const QDict *qdict); #endif