From nobody Tue Nov 4 16:10:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504021118300286.7414701070138; Tue, 29 Aug 2017 08:38:38 -0700 (PDT) Received: from localhost ([::1]:45551 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmib6-00082b-7L for importer@patchew.org; Tue, 29 Aug 2017 11:38:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmiTU-0001g1-Sl for qemu-devel@nongnu.org; Tue, 29 Aug 2017 11:30:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmiTS-0003ls-Te for qemu-devel@nongnu.org; Tue, 29 Aug 2017 11:30:44 -0400 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:34544) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dmiTS-0003jo-6C for qemu-devel@nongnu.org; Tue, 29 Aug 2017 11:30:42 -0400 Received: by mail-wm0-x22e.google.com with SMTP id f13so20764685wme.1 for ; Tue, 29 Aug 2017 08:30:42 -0700 (PDT) Received: from debian-jessie.pb.local ([62.217.45.26]) by smtp.gmail.com with ESMTPSA id x7sm1702459wme.34.2017.08.29.08.30.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Aug 2017 08:30:40 -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=Rmup1Ba50jVanzfChDI7GeLqywjrNvgF0h9KyJ+eny8=; b=hWT2q8QSju3Q5v4H6fxrqk8633HPxEQ+H2AoXXdkGqeMpfmT7V8xRqn8ZLDRrd/WEL RwdruET8BclZQWy6ZZ2CXz99qOJhhZghuN0TYvh0r+P3mVEi3xHBPFmMiTjl7bHWO1Md H7FmXuqDyJval2LUoiUDRTXIG8wJSd6KGAh+QlL1XdfjGAfrMr0LNGq3hnQV7J62wb4F b9qheboPL3DBdbegfn7rDAcVldjG3cdiFe2pEzsELELQIGu62GYsxVc8NKVVC9FboqSd tPnlI9ZSxI91LENjLkdkIqmrZDTMoNHnfKtzMNOWcyV4PVhuM+OMoQXAjSH0rV3FQU3V DxDg== 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=Rmup1Ba50jVanzfChDI7GeLqywjrNvgF0h9KyJ+eny8=; b=OWrzOBpQW7HPF0YkFdfP/pK2aWA0INuAl0bxZW8arCKwPNRMjuQNbNqbb7B6HYWwWj p3gOuEvoqrGzYZFTM/Zlyy+D/fyz2CVEfNHBKynsCPzYYCUxtfUIAVdYvrki8Fzw8YsW wPDKcXlNyOItdYlzg4ruZwrSK0yqOadYgcq+6tfV8XCc81XGkzU+nm2aHD8GOS6CSIJa MZhUNm+QE+CkR4toC6NcAcLaHyJMhIAk9/k2augP5CSMbZJcAA9QF8sSEX6yNHLzCdXJ KaR7ik6nuTYBj2QNesPpMp2X0k/VtLrCgHwcruFRXe13J1CxmArXEnv7+Q6fwxbpq6Sg 6A6A== X-Gm-Message-State: AHYfb5gdp/wbPsCU2oDOqy8SGZnPb55ttfk/OlMANiR9z/uBn0TzMpKn kia2N6xsSMkA+g6W X-Received: by 10.28.5.135 with SMTP id 129mr69299wmf.110.1504020641136; Tue, 29 Aug 2017 08:30:41 -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: Tue, 29 Aug 2017 17:30:21 +0200 Message-Id: <20170829153022.27004-3-vadim.galitsyn@profitbricks.com> X-Mailer: git-send-email 2.13.1.394.g41dd433 In-Reply-To: <20170829153022.27004-1-vadim.galitsyn@profitbricks.com> References: <20170829153022.27004-1-vadim.galitsyn@profitbricks.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22e Subject: [Qemu-devel] [PATCH v7 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a new query-memory-size-summary command which 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 --- qapi-schema.json | 32 ++++++++++++++++++= ++++ include/hw/mem/pc-dimm.h | 1 + hw/mem/pc-dimm.c | 5 ++++ qmp.c | 13 +++++++++ stubs/{qmp_pc_dimm_device_list.c =3D> qmp_pc_dimm.c} | 5 ++++ stubs/Makefile.objs | 2 +- 6 files changed, 57 insertions(+), 1 deletion(-) rename stubs/{qmp_pc_dimm_device_list.c =3D> qmp_pc_dimm.c} (68%) diff --git a/qapi-schema.json b/qapi-schema.json index 802ea53d00..9402ac3b3a 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4407,6 +4407,38 @@ 'data': { 'name': 'str', '*migration-safe': 'bool', 'static': 'bool', '*unavailable-features': [ 'str' ], 'typename': 'str' } } =20 +## +# @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. This field +# is omitted if target does support memory hotplug +# (i.e. CONFIG_MEM_HOTPLUG not defined on build time). +# +# Since: 2.11.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. +# +# Example: +# +# -> { "execute": "query-memory-size-summary" } +# <- { "return": { "base-memory": 4294967296, "plugged-memory": 0 } } +# +# Since: 2.11.0 +## +{ 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' } + ## # @query-cpu-definitions: # diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index 6f8c3eb1b3..d83b957829 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); =20 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/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index bdf6649083..66eace5a5c 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; } =20 +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 =3D opaque; diff --git a/qmp.c b/qmp.c index b86201e349..e8c303116a 100644 --- a/qmp.c +++ b/qmp.c @@ -709,3 +709,16 @@ ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **er= rp) =20 return head; } + +MemoryInfo *qmp_query_memory_size_summary(Error **errp) +{ + MemoryInfo *mem_info =3D g_malloc0(sizeof(MemoryInfo)); + + mem_info->base_memory =3D ram_size; + + mem_info->plugged_memory =3D get_plugged_memory_size(); + mem_info->has_plugged_memory =3D + mem_info->plugged_memory !=3D (uint64_t)-1; + + return mem_info; +} diff --git a/stubs/qmp_pc_dimm_device_list.c b/stubs/qmp_pc_dimm.c similarity index 68% rename from stubs/qmp_pc_dimm_device_list.c rename to stubs/qmp_pc_dimm.c index def211564d..9ddc4f619a 100644 --- a/stubs/qmp_pc_dimm_device_list.c +++ b/stubs/qmp_pc_dimm.c @@ -6,3 +6,8 @@ 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/Makefile.objs b/stubs/Makefile.objs index e69c217aff..f5f139f310 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -33,7 +33,7 @@ stub-obj-y +=3D uuid.o stub-obj-y +=3D vm-stop.o stub-obj-y +=3D vmstate.o stub-obj-$(CONFIG_WIN32) +=3D fd-register.o -stub-obj-y +=3D qmp_pc_dimm_device_list.o +stub-obj-y +=3D qmp_pc_dimm.o stub-obj-y +=3D target-monitor-defs.o stub-obj-y +=3D target-get-monitor-def.o stub-obj-y +=3D pc_madt_cpu_entry.o --=20 2.13.1.394.g41dd433