From patchwork Tue Dec 18 12:41:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasilis Liaskovitis X-Patchwork-Id: 207100 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D4D0D2C0091 for ; Wed, 19 Dec 2012 00:08:27 +1100 (EST) Received: from localhost ([::1]:45473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkwuH-0002YL-Sd for incoming@patchwork.ozlabs.org; Tue, 18 Dec 2012 08:08:25 -0500 Received: from eggs.gnu.org ([208.118.235.92]:46309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkwVV-0000GT-Sv for qemu-devel@nongnu.org; Tue, 18 Dec 2012 07:42:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TkwVU-00006T-6N for qemu-devel@nongnu.org; Tue, 18 Dec 2012 07:42:49 -0500 Received: from mail-bk0-f53.google.com ([209.85.214.53]:46755) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkwVT-00006D-S8 for qemu-devel@nongnu.org; Tue, 18 Dec 2012 07:42:48 -0500 Received: by mail-bk0-f53.google.com with SMTP id j5so286939bkw.26 for ; Tue, 18 Dec 2012 04:42:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=krpRlDaY0EzrddCgTr4AAOozbUq8m6zsTYMoaLPvPqM=; b=gj9E8U+OFqMjGMe7stfAoqAEez8/QMe0EzyJ0E4ZmIo2beYWTbSp+z9Z5nPg5Jc/L7 CBNpsfUiXlwsjkhr3vJVJDMAQG6I/zYfSvvlfgjtwECyakz0YWtj2grkzthrSyspl2yv 7IL2E4uOY5PVINFpIn/Qr2S7Nf4ibZaqeKs42+5i3xpsy8/CywtAPaCqJsGVTyYf+Wa5 FP76HKL9Ztyw7gYxrXdPH/l947RjFAcUkZbScBKHRnbMuRQJmmPRfiVMex5xND932KPp jWIUTrY3ZKviRajd/w9mC9zN8aCM1HFbLTnNOP2DrsFdpcWaA4Nlw8O5oZnj6g94/CYN gTbw== X-Received: by 10.204.130.87 with SMTP id r23mr659226bks.90.1355834566737; Tue, 18 Dec 2012 04:42:46 -0800 (PST) Received: from dhcp-192-168-178-175.ri.profitbricks.localdomain ([62.217.45.26]) by mx.google.com with ESMTPS id f24sm1169954bkv.7.2012.12.18.04.42.44 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Dec 2012 04:42:45 -0800 (PST) From: Vasilis Liaskovitis To: qemu-devel@nongnu.org, seabios@seabios.org Date: Tue, 18 Dec 2012 13:41:49 +0100 Message-Id: <1355834518-17989-22-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Mailer: git-send-email 1.7.9 In-Reply-To: <1355834518-17989-1-git-send-email-vasilis.liaskovitis@profitbricks.com> References: <1355834518-17989-1-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Gm-Message-State: ALoCoQmlV2z80wUqsLVUoLpFWl+Q7PyNOu5tr/NW8qYdRwrzyJ/fngAVEqAl2eyCNwda8yJF5YM5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.214.53 Cc: Vasilis Liaskovitis , pingfank@linux.vnet.ibm.com, gleb@redhat.com, stefanha@gmail.com, jbaron@redhat.com, blauwirbel@gmail.com, kevin@koconnor.net, kraxel@redhat.com, anthony@codemonkey.ws Subject: [Qemu-devel] [RFC PATCH v4 21/30] 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 "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 --- hmp-commands.hx | 2 ++ hmp.c | 17 +++++++++++++++++ hmp.h | 1 + hw/dimm.c | 43 +++++++++++++++++++++++++++++++++++++++++++ monitor.c | 7 +++++++ qapi-schema.json | 26 ++++++++++++++++++++++++++ 6 files changed, 96 insertions(+), 0 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 3fbd975..65d799e 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1572,6 +1572,8 @@ show qdev device model list show roms @item info memory-total show memory-total +@item info dimm +show dimm @end table ETEXI diff --git a/hmp.c b/hmp.c index fb39b0d..f8456fd 100644 --- a/hmp.c +++ b/hmp.c @@ -635,6 +635,23 @@ void hmp_info_memory_total(Monitor *mon) monitor_printf(mon, "MemTotal: %lu\n", ram_total); } +void hmp_info_dimm(Monitor *mon) +{ + 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 25a3a70..74ac061 100644 --- a/hmp.h +++ b/hmp.h @@ -37,6 +37,7 @@ void hmp_info_balloon(Monitor *mon); void hmp_info_pci(Monitor *mon); void hmp_info_block_jobs(Monitor *mon); void hmp_info_memory_total(Monitor *mon); +void hmp_info_dimm(Monitor *mon); 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/dimm.c b/hw/dimm.c index f181e54..e79f23d 100644 --- a/hw/dimm.c +++ b/hw/dimm.c @@ -174,6 +174,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; @@ -203,6 +215,37 @@ uint64_t get_hp_memory_total(void) return info; } +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; +} + static int dimm_init(DeviceState *s) { DimmBus *bus = DIMM_BUS(qdev_get_parent_bus(s)); diff --git a/monitor.c b/monitor.c index 6e87d0d..de1dcf1 100644 --- a/monitor.c +++ b/monitor.c @@ -2743,6 +2743,13 @@ static mon_cmd_t info_cmds[] = { .mhandler.info = do_trace_print_events, }, { + .name = "dimm", + .args_type = "", + .params = "", + .help = "show active and non active dimms", + .mhandler.info = hmp_info_dimm, + }, + { .name = NULL, }, }; diff --git a/qapi-schema.json b/qapi-schema.json index 33f88d6..5a20577 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2914,6 +2914,32 @@ { 'command': 'query-memory-total', 'returns': 'int' } ## +# @DimmInfo: +# +# Information about status of a memory hotplug command +# +# @dimm: the Dimm associated with the result +# +# @result: the result of the hotplug command +# +# Since: 1.4 +# +## +{ 'type': 'DimmInfo', + 'data': {'dimm': 'str', 'state': 'bool'} } + +## +# @query-dimm-info: +# +# Returns total memory in bytes, including hotplugged dimms +# +# Returns: int +# +# Since: 1.4 +## +{ 'command': 'query-dimm-info', 'returns': ['DimmInfo'] } + +## # @QKeyCode: # # An enumeration of key name.