From patchwork Wed Jun 26 09:13:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 254643 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 1A2BD2C0087 for ; Wed, 26 Jun 2013 19:21:00 +1000 (EST) Received: from localhost ([::1]:49270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrluM-0006Ao-3F for incoming@patchwork.ozlabs.org; Wed, 26 Jun 2013 05:20:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrloQ-00054H-TP for qemu-devel@nongnu.org; Wed, 26 Jun 2013 05:14:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UrloN-0002ao-KK for qemu-devel@nongnu.org; Wed, 26 Jun 2013 05:14:50 -0400 Received: from [222.73.24.84] (port=10916 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrloM-0002Wy-Th for qemu-devel@nongnu.org; Wed, 26 Jun 2013 05:14:47 -0400 X-IronPort-AV: E=Sophos;i="4.87,943,1363104000"; d="scan'208";a="7688758" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 26 Jun 2013 17:11:38 +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 r5Q9EUvM020395; Wed, 26 Jun 2013 17:14:33 +0800 Received: from G08FNSTD100614.fnst.cn.fujitsu.com ([10.167.233.156]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013062617131763-2496139 ; Wed, 26 Jun 2013 17:13:17 +0800 From: Hu Tao To: qemu-devel@nongnu.org Date: Wed, 26 Jun 2013 17:13:37 +0800 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/26 17:13:17, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/26 17:13:18, Serialize complete at 2013/06/26 17:13:18 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Cc: Vasilis Liaskovitis Subject: [Qemu-devel] [PATCH v5 14/14] Implement dimm-info 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 From: Vasilis Liaskovitis "query-dimm-info" and "info dimm" will give current state of all dimms in the system e.g. dimm0: on dimm1: off dimm2: off dimm3: on etc. Signed-off-by: Vasilis Liaskovitis Signed-off-by: Hu Tao --- hmp-commands.hx | 2 ++ hmp.c | 17 +++++++++++++++++ hmp.h | 1 + hw/mem-hotplug/dimm.c | 43 +++++++++++++++++++++++++++++++++++++++++++ monitor.c | 7 +++++++ qapi-schema.json | 27 +++++++++++++++++++++++++++ 6 files changed, 97 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index b2937c2..6cb1285 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1657,6 +1657,8 @@ show roms show memory-total @item info tpm show the TPM device +@item info dimm +show dimm @end table ETEXI diff --git a/hmp.c b/hmp.c index 0371da9..04586b3 100644 --- a/hmp.c +++ b/hmp.c @@ -683,6 +683,23 @@ void hmp_info_memory(Monitor *mon, const QDict *qdict) qapi_free_MemoryInfo(mem); } +void hmp_info_dimm(Monitor *mon, const QDict *qdict) +{ + DimmInfoList *info; + DimmInfoList *item; + DimmInfo *dimm; + + info = qmp_query_dimm_info(NULL); + for (item = info; item; item = item->next) { + dimm = item->value; + monitor_printf(mon, "dimm %s : %s\n", dimm->dimm, + dimm->state ? "on" : "off"); + dimm->dimm = NULL; + } + + qapi_free_DimmInfoList(info); +} + void hmp_quit(Monitor *mon, const QDict *qdict) { monitor_suspend(mon); diff --git a/hmp.h b/hmp.h index b5a5afb..06cea4e 100644 --- a/hmp.h +++ b/hmp.h @@ -38,6 +38,7 @@ void hmp_info_pci(Monitor *mon, const QDict *qdict); void hmp_info_block_jobs(Monitor *mon, const QDict *qdict); void hmp_info_tpm(Monitor *mon, const QDict *qdict); void hmp_info_memory(Monitor *mon, const QDict *qdict); +void hmp_info_dimm(Monitor *mon, const QDict *qdict); void hmp_quit(Monitor *mon, const QDict *qdict); void hmp_stop(Monitor *mon, const QDict *qdict); void hmp_system_reset(Monitor *mon, const QDict *qdict); diff --git a/hw/mem-hotplug/dimm.c b/hw/mem-hotplug/dimm.c index da31a18..4b08706 100644 --- a/hw/mem-hotplug/dimm.c +++ b/hw/mem-hotplug/dimm.c @@ -170,6 +170,18 @@ static DimmConfig *dimmcfg_find_from_name(DimmBus *bus, const char *name) return NULL; } +static DimmDevice *dimm_find_from_name(DimmBus *bus, const char *name) +{ + DimmDevice *slot; + + QTAILQ_FOREACH(slot, &bus->dimmlist, nextdimm) { + if (!strcmp(slot->qdev.id, name)) { + return slot; + } + } + return NULL; +} + void dimm_setup_fwcfg_layout(uint64_t *fw_cfg_slots) { DimmConfig *slot; @@ -185,6 +197,37 @@ void dimm_setup_fwcfg_layout(uint64_t *fw_cfg_slots) } } +DimmInfoList *qmp_query_dimm_info(Error **errp) +{ + DimmBus *bus; + DimmConfig *slot; + DimmInfoList *head = NULL, *info, *cur_item = NULL; + + QLIST_FOREACH(bus, &memory_buses, next) { + QTAILQ_FOREACH(slot, &bus->dimmconfig_list, nextdimmcfg) { + + info = g_malloc0(sizeof(*info)); + info->value = g_malloc0(sizeof(*info->value)); + info->value->dimm = g_malloc0(sizeof(char) * 32); + strcpy(info->value->dimm, slot->name); + if (dimm_find_from_name(bus, slot->name)) { + info->value->state = 1; + } else { + info->value->state = 0; + } + /* XXX: waiting for the qapi to support GSList */ + if (!cur_item) { + head = cur_item = info; + } else { + cur_item->next = info; + cur_item = info; + } + } + } + + return head; +} + uint64_t get_hp_memory_total(void) { DimmBus *bus; diff --git a/monitor.c b/monitor.c index 14a955e..c2b046c 100644 --- a/monitor.c +++ b/monitor.c @@ -2753,6 +2753,13 @@ static mon_cmd_t info_cmds[] = { .mhandler.cmd = do_trace_print_events, }, { + .name = "dimm", + .args_type = "", + .params = "", + .help = "show active and non active dimms", + .mhandler.cmd = hmp_info_dimm, + }, + { .name = "tpm", .args_type = "", .params = "", diff --git a/qapi-schema.json b/qapi-schema.json index d2940dc..88bbfac 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3621,3 +3621,30 @@ { 'type': 'MemoryInfo', 'data': { 'total': 'int' } } { 'command': 'query-memory', 'returns': 'MemoryInfo' } + +## +# @DimmInfo: +# +# Information about status of dimm device +# +# @dimm: the name of the dimm +# +# @state: 'true' means the dimm device is plugged in, 'false' means +# means the dimm device is plugged out. +# +# Since: 1.6 +# +## +{ 'type': 'DimmInfo', + 'data': {'dimm': 'str', 'state': 'bool'} } + +## +# @query-dimm-info: +# +# Returns the state of dimm devices +# +# Returns: list of @DimmInfo +# +# Since: 1.6 +## +{ 'command': 'query-dimm-info', 'returns': ['DimmInfo'] }