qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/7] hmp queue
@ 2017-09-14 15:04 Dr. David Alan Gilbert (git)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 1/7] hmp: fix "dump-quest-memory" segfault (ppc) Dr. David Alan Gilbert (git)
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2017-09-14 15:04 UTC (permalink / raw)
  To: qemu-devel, lvivier, cohuck, vadim.galitsyn
  Cc: imammedo, thuth, peterx, groug

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

The following changes since commit 9d81b2d2000f41be55a0624a26873f993fb6e928:

  sparc: Fix typedef clash (2017-09-14 15:00:41 +0100)

are available in the git repository at:

  git://github.com/dagrh/qemu.git tags/pull-hmp-20170914

for you to fetch changes up to d0f63c1e291a0c27cafc0e6faec5a84130b012e0:

  hmp: introduce 'info memory_size_summary' command (2017-09-14 15:52:10 +0100)

----------------------------------------------------------------
HMP pull 2017-09-14

----------------------------------------------------------------
Cornelia Huck (1):
      dump: do not dump non-existent guest memory

Laurent Vivier (3):
      hmp: fix "dump-quest-memory" segfault (ppc)
      hmp: fix "dump-quest-memory" segfault (arm)
      tests/hmp: test "none" machine with memory

Vadim Galitsyn (3):
      hmp: extend "info numa" with hotplugged memory information
      qmp: introduce query-memory-size-summary command
      hmp: introduce 'info memory_size_summary' command

 dump.c                                             |  6 ++++
 hmp-commands-info.hx                               | 16 +++++++++++
 hmp.c                                              | 18 ++++++++++++
 hmp.h                                              |  1 +
 hw/mem/pc-dimm.c                                   |  5 ++++
 include/hw/mem/pc-dimm.h                           |  1 +
 include/qemu/typedefs.h                            |  1 +
 include/sysemu/numa.h                              |  7 ++++-
 monitor.c                                          |  9 ++++--
 numa.c                                             | 18 ++++++++----
 qapi-schema.json                                   | 32 ++++++++++++++++++++++
 qmp.c                                              | 13 +++++++++
 stubs/Makefile.objs                                |  2 +-
 stubs/{qmp_pc_dimm_device_list.c => qmp_pc_dimm.c} |  5 ++++
 target/arm/arch_dump.c                             | 11 ++++++--
 target/ppc/arch_dump.c                             | 11 ++++++--
 tests/test-hmp.c                                   |  4 +++
 17 files changed, 146 insertions(+), 14 deletions(-)
 rename stubs/{qmp_pc_dimm_device_list.c => qmp_pc_dimm.c} (68%)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PULL 1/7] hmp: fix "dump-quest-memory" segfault (ppc)
  2017-09-14 15:04 [Qemu-devel] [PULL 0/7] hmp queue Dr. David Alan Gilbert (git)
@ 2017-09-14 15:04 ` Dr. David Alan Gilbert (git)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 2/7] hmp: fix "dump-quest-memory" segfault (arm) Dr. David Alan Gilbert (git)
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2017-09-14 15:04 UTC (permalink / raw)
  To: qemu-devel, lvivier, cohuck, vadim.galitsyn
  Cc: imammedo, thuth, peterx, groug

From: Laurent Vivier <lvivier@redhat.com>

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 <lvivier@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20170913142036.2469-2-lvivier@redhat.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 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 = POWERPC_CPU(first_cpu);
-    PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
+    PowerPCCPU *cpu;
+    PowerPCCPUClass *pcc;
+
+    if (first_cpu == NULL) {
+        return -1;
+    }
+
+    cpu = POWERPC_CPU(first_cpu);
+    pcc = POWERPC_CPU_GET_CLASS(cpu);
 
     info->d_machine = PPC_ELF_MACHINE;
     info->d_class = ELFCLASS;
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PULL 2/7] hmp: fix "dump-quest-memory" segfault (arm)
  2017-09-14 15:04 [Qemu-devel] [PULL 0/7] hmp queue Dr. David Alan Gilbert (git)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 1/7] hmp: fix "dump-quest-memory" segfault (ppc) Dr. David Alan Gilbert (git)
@ 2017-09-14 15:04 ` Dr. David Alan Gilbert (git)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 3/7] dump: do not dump non-existent guest memory Dr. David Alan Gilbert (git)
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2017-09-14 15:04 UTC (permalink / raw)
  To: qemu-devel, lvivier, cohuck, vadim.galitsyn
  Cc: imammedo, thuth, peterx, groug

From: Laurent Vivier <lvivier@redhat.com>

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 <lvivier@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <20170913142036.2469-3-lvivier@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 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 = ARM_CPU(first_cpu);
-    CPUARMState *env = &cpu->env;
+    ARMCPU *cpu;
+    CPUARMState *env;
     GuestPhysBlock *block;
     hwaddr lowest_addr = ULLONG_MAX;
 
+    if (first_cpu == NULL) {
+        return -1;
+    }
+
+    cpu = ARM_CPU(first_cpu);
+    env = &cpu->env;
+
     /* Take a best guess at the phys_base. If we get it wrong then crash
      * will need '--machdep phys_offset=<phys-offset>' added to its command
      * line, which isn't any worse than assuming we can use zero, but being
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PULL 3/7] dump: do not dump non-existent guest memory
  2017-09-14 15:04 [Qemu-devel] [PULL 0/7] hmp queue Dr. David Alan Gilbert (git)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 1/7] hmp: fix "dump-quest-memory" segfault (ppc) Dr. David Alan Gilbert (git)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 2/7] hmp: fix "dump-quest-memory" segfault (arm) Dr. David Alan Gilbert (git)
@ 2017-09-14 15:04 ` Dr. David Alan Gilbert (git)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 4/7] tests/hmp: test "none" machine with memory Dr. David Alan Gilbert (git)
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2017-09-14 15:04 UTC (permalink / raw)
  To: qemu-devel, lvivier, cohuck, vadim.galitsyn
  Cc: imammedo, thuth, peterx, groug

From: Cornelia Huck <cohuck@redhat.com>

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 <cohuck@redhat.com>
Tested-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
Message-Id: <20170913142036.2469-4-lvivier@redhat.com>
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 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
 
+    /* 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 = get_start_block(s);
     if (s->start == -1) {
         error_setg(errp, QERR_INVALID_PARAMETER, "begin");
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PULL 4/7] tests/hmp: test "none" machine with memory
  2017-09-14 15:04 [Qemu-devel] [PULL 0/7] hmp queue Dr. David Alan Gilbert (git)
                   ` (2 preceding siblings ...)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 3/7] dump: do not dump non-existent guest memory Dr. David Alan Gilbert (git)
@ 2017-09-14 15:04 ` Dr. David Alan Gilbert (git)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 5/7] hmp: extend "info numa" with hotplugged memory information Dr. David Alan Gilbert (git)
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2017-09-14 15:04 UTC (permalink / raw)
  To: qemu-devel, lvivier, cohuck, vadim.galitsyn
  Cc: imammedo, thuth, peterx, groug

From: Laurent Vivier <lvivier@redhat.com>

and add a test case of dump-guest-memory without
"[begin length]" parameters.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Message-Id: <20170913142036.2469-5-lvivier@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 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[] = {
     "mouse_button 0",
     "device_del mouse1",
     "dump-guest-memory /dev/null 0 4096",
+    "dump-guest-memory /dev/null",
     "gdbserver",
     "host_net_add user id=net0",
     "hostfwd_add tcp::43210-:43210",
@@ -159,5 +160,8 @@ int main(int argc, char **argv)
 
     qtest_cb_for_every_machine(add_machine_test_case);
 
+    /* as none machine has no memory by default, add a test case with memory */
+    qtest_add_data_func("hmp/none+2MB", g_strdup("none -m 2"), test_machine);
+
     return g_test_run();
 }
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PULL 5/7] hmp: extend "info numa" with hotplugged memory information
  2017-09-14 15:04 [Qemu-devel] [PULL 0/7] hmp queue Dr. David Alan Gilbert (git)
                   ` (3 preceding siblings ...)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 4/7] tests/hmp: test "none" machine with memory Dr. David Alan Gilbert (git)
@ 2017-09-14 15:04 ` Dr. David Alan Gilbert (git)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 6/7] qmp: introduce query-memory-size-summary command Dr. David Alan Gilbert (git)
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2017-09-14 15:04 UTC (permalink / raw)
  To: qemu-devel, lvivier, cohuck, vadim.galitsyn
  Cc: imammedo, thuth, peterx, groug

From: Vadim Galitsyn <vadim.galitsyn@profitbricks.com>

Report amount of hotplugged memory in addition to total
amount per NUMA node.

Signed-off-by: Vadim Galitsyn <vadim.galitsyn@profitbricks.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: qemu-devel@nongnu.org
Message-Id: <20170829153022.27004-2-vadim.galitsyn@profitbricks.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 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];
 };
 
+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 QDict *qdict)
 static void hmp_info_numa(Monitor *mon, const QDict *qdict)
 {
     int i;
-    uint64_t *node_mem;
+    NumaNodeMem *node_mem;
     CpuInfoList *cpu_list, *cpu;
 
     cpu_list = qmp_query_cpus(&error_abort);
-    node_mem = g_new0(uint64_t, nb_numa_nodes);
+    node_mem = g_new0(NumaNodeMem, nb_numa_nodes);
+
     query_numa_node_mem(node_mem);
     monitor_printf(mon, "%d nodes\n", nb_numa_nodes);
     for (i = 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(MemoryRegion *mr, Object *owner,
     }
 }
 
-static void numa_stat_memory_devices(uint64_t node_mem[])
+static void numa_stat_memory_devices(NumaNodeMem node_mem[])
 {
     MemoryDeviceInfoList *info_list = NULL;
     MemoryDeviceInfoList **prev = &info_list;
     MemoryDeviceInfoList *info;
+    PCDIMMDeviceInfo     *pcdimm_info;
 
     qmp_pc_dimm_device_list(qdev_get_machine(), &prev);
     for (info = info_list; info; info = info->next) {
@@ -603,9 +604,16 @@ static void numa_stat_memory_devices(uint64_t node_mem[])
 
         if (value) {
             switch (value->type) {
-            case MEMORY_DEVICE_INFO_KIND_DIMM:
-                node_mem[value->u.dimm.data->node] += value->u.dimm.data->size;
+            case MEMORY_DEVICE_INFO_KIND_DIMM: {
+                pcdimm_info = value->u.dimm.data;
+                node_mem[pcdimm_info->node].node_mem += pcdimm_info->size;
+                if (pcdimm_info->hotpluggable && pcdimm_info->hotplugged) {
+                    node_mem[pcdimm_info->node].node_plugged_mem +=
+                        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);
 }
 
-void query_numa_node_mem(uint64_t node_mem[])
+void query_numa_node_mem(NumaNodeMem node_mem[])
 {
     int i;
 
@@ -624,7 +632,7 @@ void query_numa_node_mem(uint64_t node_mem[])
 
     numa_stat_memory_devices(node_mem);
     for (i = 0; i < nb_numa_nodes; i++) {
-        node_mem[i] += numa_info[i].node_mem;
+        node_mem[i].node_mem += numa_info[i].node_mem;
     }
 }
 
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PULL 6/7] qmp: introduce query-memory-size-summary command
  2017-09-14 15:04 [Qemu-devel] [PULL 0/7] hmp queue Dr. David Alan Gilbert (git)
                   ` (4 preceding siblings ...)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 5/7] hmp: extend "info numa" with hotplugged memory information Dr. David Alan Gilbert (git)
@ 2017-09-14 15:04 ` Dr. David Alan Gilbert (git)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 7/7] hmp: introduce 'info memory_size_summary' command Dr. David Alan Gilbert (git)
  2017-09-14 16:58 ` [Qemu-devel] [PULL 0/7] hmp queue Peter Maydell
  7 siblings, 0 replies; 9+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2017-09-14 15:04 UTC (permalink / raw)
  To: qemu-devel, lvivier, cohuck, vadim.galitsyn
  Cc: imammedo, thuth, peterx, groug

From: Vadim Galitsyn <vadim.galitsyn@profitbricks.com>

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 <vasilis.liaskovitis@profitbricks.com>
Signed-off-by: Mohammed Gamal <mohammed.gamal@profitbricks.com>
Signed-off-by: Eduardo Otubo <eduardo.otubo@profitbricks.com>
Signed-off-by: Vadim Galitsyn <vadim.galitsyn@profitbricks.com>
Reviewed-by: Eugene Crosser <evgenii.cherkashin@profitbricks.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org
Message-Id: <20170829153022.27004-3-vadim.galitsyn@profitbricks.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
  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 => qmp_pc_dimm.c} |  5 ++++
 6 files changed, 57 insertions(+), 1 deletion(-)
 rename stubs/{qmp_pc_dimm_device_list.c => 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;
 }
 
+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 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);
 
 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' } }
 
 ##
+# @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 **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 4a33495911..c7594796c3 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -33,7 +33,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_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;
+}
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PULL 7/7] hmp: introduce 'info memory_size_summary' command
  2017-09-14 15:04 [Qemu-devel] [PULL 0/7] hmp queue Dr. David Alan Gilbert (git)
                   ` (5 preceding siblings ...)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 6/7] qmp: introduce query-memory-size-summary command Dr. David Alan Gilbert (git)
@ 2017-09-14 15:04 ` Dr. David Alan Gilbert (git)
  2017-09-14 16:58 ` [Qemu-devel] [PULL 0/7] hmp queue Peter Maydell
  7 siblings, 0 replies; 9+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2017-09-14 15:04 UTC (permalink / raw)
  To: qemu-devel, lvivier, cohuck, vadim.galitsyn
  Cc: imammedo, thuth, peterx, groug

From: Vadim Galitsyn <vadim.galitsyn@profitbricks.com>

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 <vasilis.liaskovitis@profitbricks.com>
Signed-off-by: Mohammed Gamal <mohammed.gamal@profitbricks.com>
Signed-off-by: Eduardo Otubo <eduardo.otubo@profitbricks.com>
Signed-off-by: Vadim Galitsyn <vadim.galitsyn@profitbricks.com>
Reviewed-by: Eugene Crosser <evgenii.cherkashin@profitbricks.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org
Message-Id: <20170829153022.27004-4-vadim.galitsyn@profitbricks.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
  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
     },
 
 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       = "memory_size_summary",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the amount of initially allocated and "
+                      "present hotpluggable (if enabled) memory in bytes.",
+        .cmd        = hmp_info_memory_size_summary,
+    },
+
+STEXI
 @end table
 ETEXI
 
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 QDict *qdict)
     hmp_handle_error(mon, &err);
     qapi_free_GuidInfo(info);
 }
+
+void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict)
+{
+    Error *err = NULL;
+    MemoryInfo *info = 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);
 
 #endif
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PULL 0/7] hmp queue
  2017-09-14 15:04 [Qemu-devel] [PULL 0/7] hmp queue Dr. David Alan Gilbert (git)
                   ` (6 preceding siblings ...)
  2017-09-14 15:04 ` [Qemu-devel] [PULL 7/7] hmp: introduce 'info memory_size_summary' command Dr. David Alan Gilbert (git)
@ 2017-09-14 16:58 ` Peter Maydell
  7 siblings, 0 replies; 9+ messages in thread
From: Peter Maydell @ 2017-09-14 16:58 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git)
  Cc: QEMU Developers, Laurent Vivier, Cornelia Huck, vadim.galitsyn,
	Igor Mammedov, Thomas Huth, Greg Kurz, Peter Xu

On 14 September 2017 at 16:04, Dr. David Alan Gilbert (git)
<dgilbert@redhat.com> wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> The following changes since commit 9d81b2d2000f41be55a0624a26873f993fb6e928:
>
>   sparc: Fix typedef clash (2017-09-14 15:00:41 +0100)
>
> are available in the git repository at:
>
>   git://github.com/dagrh/qemu.git tags/pull-hmp-20170914
>
> for you to fetch changes up to d0f63c1e291a0c27cafc0e6faec5a84130b012e0:
>
>   hmp: introduce 'info memory_size_summary' command (2017-09-14 15:52:10 +0100)
>
> ----------------------------------------------------------------
> HMP pull 2017-09-14
>
> ----------------------------------------------------------------
> Cornelia Huck (1):
>       dump: do not dump non-existent guest memory
>
> Laurent Vivier (3):
>       hmp: fix "dump-quest-memory" segfault (ppc)
>       hmp: fix "dump-quest-memory" segfault (arm)
>       tests/hmp: test "none" machine with memory
>
> Vadim Galitsyn (3):
>       hmp: extend "info numa" with hotplugged memory information
>       qmp: introduce query-memory-size-summary command
>       hmp: introduce 'info memory_size_summary' command

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-09-14 16:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-14 15:04 [Qemu-devel] [PULL 0/7] hmp queue Dr. David Alan Gilbert (git)
2017-09-14 15:04 ` [Qemu-devel] [PULL 1/7] hmp: fix "dump-quest-memory" segfault (ppc) Dr. David Alan Gilbert (git)
2017-09-14 15:04 ` [Qemu-devel] [PULL 2/7] hmp: fix "dump-quest-memory" segfault (arm) Dr. David Alan Gilbert (git)
2017-09-14 15:04 ` [Qemu-devel] [PULL 3/7] dump: do not dump non-existent guest memory Dr. David Alan Gilbert (git)
2017-09-14 15:04 ` [Qemu-devel] [PULL 4/7] tests/hmp: test "none" machine with memory Dr. David Alan Gilbert (git)
2017-09-14 15:04 ` [Qemu-devel] [PULL 5/7] hmp: extend "info numa" with hotplugged memory information Dr. David Alan Gilbert (git)
2017-09-14 15:04 ` [Qemu-devel] [PULL 6/7] qmp: introduce query-memory-size-summary command Dr. David Alan Gilbert (git)
2017-09-14 15:04 ` [Qemu-devel] [PULL 7/7] hmp: introduce 'info memory_size_summary' command Dr. David Alan Gilbert (git)
2017-09-14 16:58 ` [Qemu-devel] [PULL 0/7] hmp queue Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).