From nobody Sat May 18 23:55:14 2024 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; 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 1505401762818436.8089831129571; Thu, 14 Sep 2017 08:09:22 -0700 (PDT) Received: from localhost ([::1]:48328 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsVlZ-0001vN-PV for importer@patchew.org; Thu, 14 Sep 2017 11:09:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsVhK-0006F4-06 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsVhI-00029o-Ol for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:04:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42852) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsVhI-00028j-IF for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:04:56 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9941DC058EB7; Thu, 14 Sep 2017 15:04:55 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA6E117AD7; Thu, 14 Sep 2017 15:04:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9941DC058EB7 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dgilbert@redhat.com From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, lvivier@redhat.com, cohuck@redhat.com, vadim.galitsyn@profitbricks.com Date: Thu, 14 Sep 2017 16:04:41 +0100 Message-Id: <20170914150447.19352-2-dgilbert@redhat.com> In-Reply-To: <20170914150447.19352-1-dgilbert@redhat.com> References: <20170914150447.19352-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 14 Sep 2017 15:04:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/7] hmp: fix "dump-quest-memory" segfault (ppc) 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: imammedo@redhat.com, thuth@redhat.com, groug@kaod.org, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Laurent Vivier Running QEMU with qemu-system-ppc64 -M none -nographic -m 256 and executing dump-guest-memory /dev/null 0 8192 results in segfault Fix by checking if we have CPU, and exit with error if there is no CPU: (qemu) dump-guest-memory /dev/null this feature or command is not currently supported Signed-off-by: Laurent Vivier Reviewed-by: Greg Kurz Reviewed-by: Thomas Huth Message-Id: <20170913142036.2469-2-lvivier@redhat.com> Acked-by: David Gibson Signed-off-by: Dr. David Alan Gilbert --- target/ppc/arch_dump.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/target/ppc/arch_dump.c b/target/ppc/arch_dump.c index 8e9397aa58..95b9ab6f29 100644 --- a/target/ppc/arch_dump.c +++ b/target/ppc/arch_dump.c @@ -224,8 +224,15 @@ typedef struct NoteFuncDescStruct NoteFuncDesc; int cpu_get_dump_info(ArchDumpInfo *info, const struct GuestPhysBlockList *guest_phys_blocks) { - PowerPCCPU *cpu =3D POWERPC_CPU(first_cpu); - PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); + PowerPCCPU *cpu; + PowerPCCPUClass *pcc; + + if (first_cpu =3D=3D NULL) { + return -1; + } + + cpu =3D POWERPC_CPU(first_cpu); + pcc =3D POWERPC_CPU_GET_CLASS(cpu); =20 info->d_machine =3D PPC_ELF_MACHINE; info->d_class =3D ELFCLASS; --=20 2.13.5 From nobody Sat May 18 23:55:14 2024 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; 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 1505401602369969.5772615541875; Thu, 14 Sep 2017 08:06:42 -0700 (PDT) Received: from localhost ([::1]:48318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsViz-0007e9-JH for importer@patchew.org; Thu, 14 Sep 2017 11:06:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsVhL-0006G3-NM for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsVhK-0002Bq-NY for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:04:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33868) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsVhK-0002B3-Hp for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:04:58 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 901B6883C9; Thu, 14 Sep 2017 15:04:57 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2FAB17DFF; Thu, 14 Sep 2017 15:04:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 901B6883C9 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dgilbert@redhat.com From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, lvivier@redhat.com, cohuck@redhat.com, vadim.galitsyn@profitbricks.com Date: Thu, 14 Sep 2017 16:04:42 +0100 Message-Id: <20170914150447.19352-3-dgilbert@redhat.com> In-Reply-To: <20170914150447.19352-1-dgilbert@redhat.com> References: <20170914150447.19352-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 14 Sep 2017 15:04:57 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/7] hmp: fix "dump-quest-memory" segfault (arm) 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: imammedo@redhat.com, thuth@redhat.com, groug@kaod.org, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Laurent Vivier Running QEMU with qemu-system-aarch64 -M none -nographic -m 256 and executing dump-guest-memory /dev/null 0 8192 results in segfault Fix by checking if we have CPU, and exit with error if there is no CPU: (qemu) dump-guest-memory /dev/null this feature or command is not currently supported Signed-off-by: Laurent Vivier Reviewed-by: Thomas Huth Reviewed-by: Greg Kurz Message-Id: <20170913142036.2469-3-lvivier@redhat.com> Reviewed-by: Eric Auger Tested-by: Eric Auger Signed-off-by: Dr. David Alan Gilbert --- target/arm/arch_dump.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c index 1a9861f69b..9e5b2fb31c 100644 --- a/target/arm/arch_dump.c +++ b/target/arm/arch_dump.c @@ -273,11 +273,18 @@ int arm_cpu_write_elf32_note(WriteCoreDumpFunction f,= CPUState *cs, int cpu_get_dump_info(ArchDumpInfo *info, const GuestPhysBlockList *guest_phys_blocks) { - ARMCPU *cpu =3D ARM_CPU(first_cpu); - CPUARMState *env =3D &cpu->env; + ARMCPU *cpu; + CPUARMState *env; GuestPhysBlock *block; hwaddr lowest_addr =3D ULLONG_MAX; =20 + if (first_cpu =3D=3D NULL) { + return -1; + } + + cpu =3D ARM_CPU(first_cpu); + env =3D &cpu->env; + /* Take a best guess at the phys_base. If we get it wrong then crash * will need '--machdep phys_offset=3D' added to its comm= and * line, which isn't any worse than assuming we can use zero, but being --=20 2.13.5 From nobody Sat May 18 23:55:14 2024 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; 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 150540197603335.28313123350597; Thu, 14 Sep 2017 08:12:56 -0700 (PDT) Received: from localhost ([::1]:48348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsVp0-0005rp-Qj for importer@patchew.org; Thu, 14 Sep 2017 11:12:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsVhX-0006TF-96 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsVhT-0002Id-DJ for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37134) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsVhT-0002Hm-81 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:07 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38D667E444; Thu, 14 Sep 2017 15:05:06 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id D92FD18239; Thu, 14 Sep 2017 15:04:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 38D667E444 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dgilbert@redhat.com From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, lvivier@redhat.com, cohuck@redhat.com, vadim.galitsyn@profitbricks.com Date: Thu, 14 Sep 2017 16:04:43 +0100 Message-Id: <20170914150447.19352-4-dgilbert@redhat.com> In-Reply-To: <20170914150447.19352-1-dgilbert@redhat.com> References: <20170914150447.19352-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 14 Sep 2017 15:05:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/7] dump: do not dump non-existent guest memory 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: imammedo@redhat.com, thuth@redhat.com, groug@kaod.org, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Cornelia Huck It does not really make sense to dump memory that is not there. Moreover, that fixes a segmentation fault when calling dump-guest-memory with no filter for a machine with no memory defined. New behaviour is: (qemu) dump-guest-memory /dev/null dump: no guest memory to dump (qemu) dump-guest-memory /dev/null 0 4096 dump: no guest memory to dump Signed-off-by: Cornelia Huck Tested-by: Laurent Vivier Reviewed-by: Laurent Vivier Reviewed-by: Greg Kurz Reviewed-by: Peter Xu Message-Id: <20170913142036.2469-4-lvivier@redhat.com> Signed-off-by: Laurent Vivier Signed-off-by: Dr. David Alan Gilbert --- dump.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dump.c b/dump.c index a79773d0f7..d2093e141b 100644 --- a/dump.c +++ b/dump.c @@ -1536,6 +1536,12 @@ static void dump_init(DumpState *s, int fd, bool has= _format, fprintf(stderr, "DUMP: total memory to dump: %lu\n", s->total_size); #endif =20 + /* it does not make sense to dump non-existent memory */ + if (!s->total_size) { + error_setg(errp, "dump: no guest memory to dump"); + goto cleanup; + } + s->start =3D get_start_block(s); if (s->start =3D=3D -1) { error_setg(errp, QERR_INVALID_PARAMETER, "begin"); --=20 2.13.5 From nobody Sat May 18 23:55:14 2024 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; 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 1505401902786311.3431388133704; Thu, 14 Sep 2017 08:11:42 -0700 (PDT) Received: from localhost ([::1]:48342 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsVnp-0004VL-Md for importer@patchew.org; Thu, 14 Sep 2017 11:11:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsVhv-0006x0-Sy for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsVhq-0002fd-8Y for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47174) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsVhq-0002ep-2y for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:30 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1F8C28123A; Thu, 14 Sep 2017 15:05:29 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FACD17DFF; Thu, 14 Sep 2017 15:05:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1F8C28123A Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dgilbert@redhat.com From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, lvivier@redhat.com, cohuck@redhat.com, vadim.galitsyn@profitbricks.com Date: Thu, 14 Sep 2017 16:04:44 +0100 Message-Id: <20170914150447.19352-5-dgilbert@redhat.com> In-Reply-To: <20170914150447.19352-1-dgilbert@redhat.com> References: <20170914150447.19352-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 14 Sep 2017 15:05:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/7] tests/hmp: test "none" machine with memory 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: imammedo@redhat.com, thuth@redhat.com, groug@kaod.org, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Laurent Vivier and add a test case of dump-guest-memory without "[begin length]" parameters. Signed-off-by: Laurent Vivier Reviewed-by: Thomas Huth Reviewed-by: Cornelia Huck Message-Id: <20170913142036.2469-5-lvivier@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- tests/test-hmp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test-hmp.c b/tests/test-hmp.c index 729c0339f7..d124e81850 100644 --- a/tests/test-hmp.c +++ b/tests/test-hmp.c @@ -35,6 +35,7 @@ static const char *hmp_cmds[] =3D { "mouse_button 0", "device_del mouse1", "dump-guest-memory /dev/null 0 4096", + "dump-guest-memory /dev/null", "gdbserver", "host_net_add user id=3Dnet0", "hostfwd_add tcp::43210-:43210", @@ -159,5 +160,8 @@ int main(int argc, char **argv) =20 qtest_cb_for_every_machine(add_machine_test_case); =20 + /* as none machine has no memory by default, add a test case with memo= ry */ + qtest_add_data_func("hmp/none+2MB", g_strdup("none -m 2"), test_machin= e); + return g_test_run(); } --=20 2.13.5 From nobody Sat May 18 23:55:14 2024 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; 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 1505401666140670.536954960642; Thu, 14 Sep 2017 08:07:46 -0700 (PDT) Received: from localhost ([::1]:48323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsVk1-0000H7-3h for importer@patchew.org; Thu, 14 Sep 2017 11:07:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsVi3-00078N-ON for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsVi0-0002oK-G0 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38424) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsVi0-0002nS-7h for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:40 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C6A87E42F; Thu, 14 Sep 2017 15:05:39 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6849417DFF; Thu, 14 Sep 2017 15:05:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3C6A87E42F Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dgilbert@redhat.com From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, lvivier@redhat.com, cohuck@redhat.com, vadim.galitsyn@profitbricks.com Date: Thu, 14 Sep 2017 16:04:45 +0100 Message-Id: <20170914150447.19352-6-dgilbert@redhat.com> In-Reply-To: <20170914150447.19352-1-dgilbert@redhat.com> References: <20170914150447.19352-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 14 Sep 2017 15:05:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/7] hmp: extend "info numa" with hotplugged memory information 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: imammedo@redhat.com, thuth@redhat.com, groug@kaod.org, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vadim Galitsyn Report amount of hotplugged memory in addition to total amount per NUMA node. Signed-off-by: Vadim Galitsyn Cc: Eduardo Habkost Cc: David Hildenbrand Cc: qemu-devel@nongnu.org Message-Id: <20170829153022.27004-2-vadim.galitsyn@profitbricks.com> Reviewed-by: Igor Mammedov Signed-off-by: Dr. David Alan Gilbert --- include/qemu/typedefs.h | 1 + include/sysemu/numa.h | 7 ++++++- monitor.c | 9 ++++++--- numa.c | 18 +++++++++++++----- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 39bc8351a3..163550214c 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -58,6 +58,7 @@ typedef struct MSIMessage MSIMessage; typedef struct NetClientState NetClientState; typedef struct NetFilterState NetFilterState; typedef struct NICInfo NICInfo; +typedef struct NumaNodeMem NumaNodeMem; typedef struct PcGuestInfo PcGuestInfo; typedef struct PCIBridge PCIBridge; typedef struct PCIBus PCIBus; diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 610eece211..5c6df2820b 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -24,9 +24,14 @@ struct node_info { uint8_t distance[MAX_NODES]; }; =20 +struct NumaNodeMem { + uint64_t node_mem; + uint64_t node_plugged_mem; +}; + extern NodeInfo numa_info[MAX_NODES]; void parse_numa_opts(MachineState *ms); -void query_numa_node_mem(uint64_t node_mem[]); +void query_numa_node_mem(NumaNodeMem node_mem[]); extern QemuOptsList qemu_numa_opts; void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node); void numa_unset_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node); diff --git a/monitor.c b/monitor.c index 9239f7adde..058045b3cb 100644 --- a/monitor.c +++ b/monitor.c @@ -1710,11 +1710,12 @@ static void hmp_info_mtree(Monitor *mon, const QDic= t *qdict) static void hmp_info_numa(Monitor *mon, const QDict *qdict) { int i; - uint64_t *node_mem; + NumaNodeMem *node_mem; CpuInfoList *cpu_list, *cpu; =20 cpu_list =3D qmp_query_cpus(&error_abort); - node_mem =3D g_new0(uint64_t, nb_numa_nodes); + node_mem =3D g_new0(NumaNodeMem, nb_numa_nodes); + query_numa_node_mem(node_mem); monitor_printf(mon, "%d nodes\n", nb_numa_nodes); for (i =3D 0; i < nb_numa_nodes; i++) { @@ -1727,7 +1728,9 @@ static void hmp_info_numa(Monitor *mon, const QDict *= qdict) } monitor_printf(mon, "\n"); monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i, - node_mem[i] >> 20); + node_mem[i].node_mem >> 20); + monitor_printf(mon, "node %d plugged: %" PRId64 " MB\n", i, + node_mem[i].node_plugged_mem >> 20); } qapi_free_CpuInfoList(cpu_list); g_free(node_mem); diff --git a/numa.c b/numa.c index e32af04cd2..fe066ad2f8 100644 --- a/numa.c +++ b/numa.c @@ -591,11 +591,12 @@ void memory_region_allocate_system_memory(MemoryRegio= n *mr, Object *owner, } } =20 -static void numa_stat_memory_devices(uint64_t node_mem[]) +static void numa_stat_memory_devices(NumaNodeMem node_mem[]) { MemoryDeviceInfoList *info_list =3D NULL; MemoryDeviceInfoList **prev =3D &info_list; MemoryDeviceInfoList *info; + PCDIMMDeviceInfo *pcdimm_info; =20 qmp_pc_dimm_device_list(qdev_get_machine(), &prev); for (info =3D info_list; info; info =3D info->next) { @@ -603,9 +604,16 @@ static void numa_stat_memory_devices(uint64_t node_mem= []) =20 if (value) { switch (value->type) { - case MEMORY_DEVICE_INFO_KIND_DIMM: - node_mem[value->u.dimm.data->node] +=3D value->u.dimm.data= ->size; + case MEMORY_DEVICE_INFO_KIND_DIMM: { + pcdimm_info =3D value->u.dimm.data; + node_mem[pcdimm_info->node].node_mem +=3D pcdimm_info->siz= e; + if (pcdimm_info->hotpluggable && pcdimm_info->hotplugged) { + node_mem[pcdimm_info->node].node_plugged_mem +=3D + pcdimm_info->size; + } break; + } + default: break; } @@ -614,7 +622,7 @@ static void numa_stat_memory_devices(uint64_t node_mem[= ]) qapi_free_MemoryDeviceInfoList(info_list); } =20 -void query_numa_node_mem(uint64_t node_mem[]) +void query_numa_node_mem(NumaNodeMem node_mem[]) { int i; =20 @@ -624,7 +632,7 @@ void query_numa_node_mem(uint64_t node_mem[]) =20 numa_stat_memory_devices(node_mem); for (i =3D 0; i < nb_numa_nodes; i++) { - node_mem[i] +=3D numa_info[i].node_mem; + node_mem[i].node_mem +=3D numa_info[i].node_mem; } } =20 --=20 2.13.5 From nobody Sat May 18 23:55:14 2024 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; 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 1505402003618386.69827976338036; Thu, 14 Sep 2017 08:13:23 -0700 (PDT) Received: from localhost ([::1]:48349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsVpS-0006QU-RH for importer@patchew.org; Thu, 14 Sep 2017 11:13:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsViF-0007Nr-Ud for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:06:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsViC-0002xK-Gr for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45136) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsViB-0002wo-V3 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:52 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 10A0861467; Thu, 14 Sep 2017 15:05:51 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85B7817DFF; Thu, 14 Sep 2017 15:05:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 10A0861467 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dgilbert@redhat.com From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, lvivier@redhat.com, cohuck@redhat.com, vadim.galitsyn@profitbricks.com Date: Thu, 14 Sep 2017 16:04:46 +0100 Message-Id: <20170914150447.19352-7-dgilbert@redhat.com> In-Reply-To: <20170914150447.19352-1-dgilbert@redhat.com> References: <20170914150447.19352-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 14 Sep 2017 15:05:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 6/7] 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: imammedo@redhat.com, thuth@redhat.com, groug@kaod.org, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vadim Galitsyn 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 Message-Id: <20170829153022.27004-3-vadim.galitsyn@profitbricks.com> Reviewed-by: Igor Mammedov Signed-off-by: Dr. David Alan Gilbert Fixup comments as per Igor's review Added 'of' from Vadim's reply --- hw/mem/pc-dimm.c | 5 ++++ include/hw/mem/pc-dimm.h | 1 + qapi-schema.json | 32 ++++++++++++++++++= ++++ qmp.c | 13 +++++++++ stubs/Makefile.objs | 2 +- stubs/{qmp_pc_dimm_device_list.c =3D> qmp_pc_dimm.c} | 5 ++++ 6 files changed, 57 insertions(+), 1 deletion(-) rename stubs/{qmp_pc_dimm_device_list.c =3D> qmp_pc_dimm.c} (68%) 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/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/qapi-schema.json b/qapi-schema.json index f3af2cb851..cdff39a456 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1966,6 +1966,38 @@ '*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 of memory that can be hot-unplugged. This field +# is omitted if target doesn't 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 present hotpluggable (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: # # Return a list of supported virtual CPU definitions 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/Makefile.objs b/stubs/Makefile.objs index 4a33495911..c7594796c3 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 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; +} --=20 2.13.5 From nobody Sat May 18 23:55:14 2024 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; 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 150540182282497.06381348532011; Thu, 14 Sep 2017 08:10:22 -0700 (PDT) Received: from localhost ([::1]:48333 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsVmX-0002u0-5e for importer@patchew.org; Thu, 14 Sep 2017 11:10:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsViI-0007Px-6h for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsViH-00032Z-3k for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsViG-000311-Rc for qemu-devel@nongnu.org; Thu, 14 Sep 2017 11:05:57 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB3B8329E; Thu, 14 Sep 2017 15:05:55 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58B9117DFF; Thu, 14 Sep 2017 15:05:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EB3B8329E Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dgilbert@redhat.com From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, lvivier@redhat.com, cohuck@redhat.com, vadim.galitsyn@profitbricks.com Date: Thu, 14 Sep 2017 16:04:47 +0100 Message-Id: <20170914150447.19352-8-dgilbert@redhat.com> In-Reply-To: <20170914150447.19352-1-dgilbert@redhat.com> References: <20170914150447.19352-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 14 Sep 2017 15:05:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 7/7] hmp: introduce 'info 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: imammedo@redhat.com, thuth@redhat.com, groug@kaod.org, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vadim Galitsyn Add 'info memory_size_summary' command which is a sibling of QMP command query-memory-size-summary. It 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 Message-Id: <20170829153022.27004-4-vadim.galitsyn@profitbricks.com> Reviewed-by: Igor Mammedov Signed-off-by: Dr. David Alan Gilbert Fixed up comments from Igor's review --- hmp-commands-info.hx | 16 ++++++++++++++++ hmp.c | 18 ++++++++++++++++++ hmp.h | 1 + 3 files changed, 35 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 4ab7fcee98..1c6772597d 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -851,6 +851,22 @@ ETEXI }, =20 STEXI +@item info memory_size_summary +@findex memory_size_summary +Display the amount of initially allocated and present hotpluggable (if +enabled) memory in bytes. +ETEXI + + { + .name =3D "memory_size_summary", + .args_type =3D "", + .params =3D "", + .help =3D "show the amount of initially allocated and " + "present hotpluggable (if enabled) memory in bytes.", + .cmd =3D hmp_info_memory_size_summary, + }, + +STEXI @end table ETEXI =20 diff --git a/hmp.c b/hmp.c index cd046c6d71..0fb2bc7043 100644 --- a/hmp.c +++ b/hmp.c @@ -2862,3 +2862,21 @@ void hmp_info_vm_generation_id(Monitor *mon, const Q= Dict *qdict) hmp_handle_error(mon, &err); qapi_free_GuidInfo(info); } + +void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + MemoryInfo *info =3D qmp_query_memory_size_summary(&err); + if (info) { + monitor_printf(mon, "base memory: %" PRIu64 "\n", + info->base_memory); + + if (info->has_plugged_memory) { + monitor_printf(mon, "plugged memory: %" PRIu64 "\n", + info->plugged_memory); + } + + qapi_free_MemoryInfo(info); + } + hmp_handle_error(mon, &err); +} diff --git a/hmp.h b/hmp.h index 1ff455295e..3605003e4c 100644 --- a/hmp.h +++ b/hmp.h @@ -145,5 +145,6 @@ void hmp_info_dump(Monitor *mon, const QDict *qdict); void hmp_info_ramblock(Monitor *mon, const QDict *qdict); void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict); void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict); +void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict); =20 #endif --=20 2.13.5