From patchwork Wed Aug 16 11:06:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Galitsyn X-Patchwork-Id: 801993 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=profitbricks-com.20150623.gappssmtp.com header.i=@profitbricks-com.20150623.gappssmtp.com header.b="rDiyjnTs"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xXRSJ3wbwz9t2y for ; Wed, 16 Aug 2017 21:09:20 +1000 (AEST) Received: from localhost ([::1]:38678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhwCL-0002yN-NX for incoming@patchwork.ozlabs.org; Wed, 16 Aug 2017 07:09:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhw9v-0000lI-Q5 for qemu-devel@nongnu.org; Wed, 16 Aug 2017 07:06:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhw9r-0008EQ-Vx for qemu-devel@nongnu.org; Wed, 16 Aug 2017 07:06:47 -0400 Received: from mail-wr0-x22a.google.com ([2a00:1450:400c:c0c::22a]:35197) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dhw9r-0008Cf-Mk for qemu-devel@nongnu.org; Wed, 16 Aug 2017 07:06:43 -0400 Received: by mail-wr0-x22a.google.com with SMTP id 49so3778212wrw.2 for ; Wed, 16 Aug 2017 04:06:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YRvd8Uqn82GUVZcxLMDIoEm9eRMAJgkPR5U5WVDm0X8=; b=rDiyjnTsPLkt+DUExRjYnxPWks9DXe8tyQA6WaEWJPAffAJjFLvoiB5QTqAsj33ymP EoKBPI8x+6QzwxFuqllBJTxQqiyzDabLtc4IuiC1TiwaLczaPH56H/RmwsEfB6fsKmry iOHeqmQtdXACvEUll3vJWcvhICC9ue6WtLie9EvnRrEgGg4s4UuGRfvLFPcM80A0YcHB Ergu5YvgcvFdBY8AHO4DTL0W0p1YcH669QQt/DP7L4vOYjqeBSbVWfhx6GdMazM1nZhn HHx9dF5nFToVeJzWb5MMPXtQZ2NHSlqdQ+9O+QPmP/7w6205N2D141msZrS4MjwzKBbc IlwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YRvd8Uqn82GUVZcxLMDIoEm9eRMAJgkPR5U5WVDm0X8=; b=mejJ5no8pql4lg1ZZYVbwqj4xTAdfxF39aGKskf/Zqe8jEDVx0EX4pHr9NjyLiuulT Xeu2vE1LBaZD24qsRWcNZHWoDH116locQ5MvXzcaoHXW8Q49pzbN30NQO7jF55tGyzyQ 9gJoLt705SbyJyBNso47Wp/52QCv3OT3YuTSCJRgyH0D1QSYJrsSBZJ5ouELXU6qK5Xq T2JfWLQpjKs3IKGMjw42YNKjLRau0YSDTBhjFH+npHifsOa8/f79aIQGn8BOgJ3Crcq1 7XfPvgANUr/1ktZfUpuxnEGmdDhsHUMTxzz4oR5BANKpyQxN4UHW1TCj7iRXqGw4s2m9 xqJg== X-Gm-Message-State: AHYfb5jeaPMdxtG0YWjX6U0JuODKdJDrhXU36B6frntegdcW0Y1BCx2o Rq6Ht6sZdf828n7q X-Received: by 10.80.205.147 with SMTP id p19mr1644522edi.59.1502881602705; Wed, 16 Aug 2017 04:06:42 -0700 (PDT) Received: from test-VirtualBox.pb.local (ip5b419224.dynamic.kabel-deutschland.de. [91.65.146.36]) by smtp.gmail.com with ESMTPSA id i22sm468620eda.10.2017.08.16.04.06.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Aug 2017 04:06:42 -0700 (PDT) From: Vadim Galitsyn To: Eduardo Habkost , David Hildenbrand , "Dr . David Alan Gilbert" , Markus Armbruster , Igor Mammedov , Eric Blake , qemu-devel@nongnu.org Date: Wed, 16 Aug 2017 13:06:25 +0200 Message-Id: <1502881586-25044-2-git-send-email-vadim.galitsyn@profitbricks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502881586-25044-1-git-send-email-vadim.galitsyn@profitbricks.com> References: <1502881586-25044-1-git-send-email-vadim.galitsyn@profitbricks.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22a Subject: [Qemu-devel] [PATCH v6 2/3] qmp: introduce query-memory-size-summary command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vasilis Liaskovitis , Mohammed Gamal , Eduardo Otubo , Vadim Galitsyn Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Command above provides the following memory information in bytes: * base-memory - size of "base" memory specified with command line option -m. * plugged-memory - amount of memory that was hot-plugged. If target does not have CONFIG_MEM_HOTPLUG enabled, no value is reported. Signed-off-by: Vasilis Liaskovitis Signed-off-by: Mohammed Gamal Signed-off-by: Eduardo Otubo Signed-off-by: Vadim Galitsyn Reviewed-by: Eugene Crosser Cc: Dr. David Alan Gilbert Cc: Markus Armbruster Cc: Igor Mammedov Cc: Eric Blake Cc: qemu-devel@nongnu.org --- hw/mem/pc-dimm.c | 5 +++++ include/hw/mem/pc-dimm.h | 1 + qapi-schema.json | 25 +++++++++++++++++++++++++ qmp.c | 13 +++++++++++++ stubs/Makefile.objs | 2 +- stubs/qmp_pc_dimm.c | 13 +++++++++++++ stubs/qmp_pc_dimm_device_list.c | 8 -------- 7 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 stubs/qmp_pc_dimm.c delete mode 100644 stubs/qmp_pc_dimm_device_list.c diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index ea67b46..6ef2ccd 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -159,6 +159,11 @@ uint64_t pc_existing_dimms_capacity(Error **errp) return cap.size; } +uint64_t get_plugged_memory_size(void) +{ + return pc_existing_dimms_capacity(&error_abort); +} + int qmp_pc_dimm_device_list(Object *obj, void *opaque) { MemoryDeviceInfoList ***prev = opaque; diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index 1e483f2..a56f901 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -95,6 +95,7 @@ int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp); int qmp_pc_dimm_device_list(Object *obj, void *opaque); uint64_t pc_existing_dimms_capacity(Error **errp); +uint64_t get_plugged_memory_size(void); void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, MemoryRegion *mr, uint64_t align, Error **errp); void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms, diff --git a/qapi-schema.json b/qapi-schema.json index 802ea53..23916b7 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4408,6 +4408,31 @@ '*unavailable-features': [ 'str' ], 'typename': 'str' } } ## +# @MemoryInfo: +# +# Actual memory information in bytes. +# +# @base-memory: size of "base" memory specified with command line +# option -m. +# +# @plugged-memory: size memory that can be hot-unplugged. +# +# Since: 2.10.0 +## +{ 'struct': 'MemoryInfo', + 'data' : { 'base-memory': 'size', '*plugged-memory': 'size' } } + +## +# @query-memory-size-summary: +# +# Return the amount of initially allocated and hot-plugged (if +# enabled) memory in bytes. +# +# Since: 2.10.0 +## +{ 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' } + +## # @query-cpu-definitions: # # Return a list of supported virtual CPU definitions diff --git a/qmp.c b/qmp.c index b86201e..e8c3031 100644 --- a/qmp.c +++ b/qmp.c @@ -709,3 +709,16 @@ ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp) return head; } + +MemoryInfo *qmp_query_memory_size_summary(Error **errp) +{ + MemoryInfo *mem_info = g_malloc0(sizeof(MemoryInfo)); + + mem_info->base_memory = ram_size; + + mem_info->plugged_memory = get_plugged_memory_size(); + mem_info->has_plugged_memory = + mem_info->plugged_memory != (uint64_t)-1; + + return mem_info; +} diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index f5b47bf..f7cab5b 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -32,7 +32,7 @@ stub-obj-y += uuid.o stub-obj-y += vm-stop.o stub-obj-y += vmstate.o stub-obj-$(CONFIG_WIN32) += fd-register.o -stub-obj-y += qmp_pc_dimm_device_list.o +stub-obj-y += qmp_pc_dimm.o stub-obj-y += target-monitor-defs.o stub-obj-y += target-get-monitor-def.o stub-obj-y += pc_madt_cpu_entry.o diff --git a/stubs/qmp_pc_dimm.c b/stubs/qmp_pc_dimm.c new file mode 100644 index 0000000..9ddc4f6 --- /dev/null +++ b/stubs/qmp_pc_dimm.c @@ -0,0 +1,13 @@ +#include "qemu/osdep.h" +#include "qom/object.h" +#include "hw/mem/pc-dimm.h" + +int qmp_pc_dimm_device_list(Object *obj, void *opaque) +{ + return 0; +} + +uint64_t get_plugged_memory_size(void) +{ + return (uint64_t)-1; +} diff --git a/stubs/qmp_pc_dimm_device_list.c b/stubs/qmp_pc_dimm_device_list.c deleted file mode 100644 index def2115..0000000 --- a/stubs/qmp_pc_dimm_device_list.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "qemu/osdep.h" -#include "qom/object.h" -#include "hw/mem/pc-dimm.h" - -int qmp_pc_dimm_device_list(Object *obj, void *opaque) -{ - return 0; -}