diff mbox

[v2,2/4] check if we have space left for hotplugged memory

Message ID 74c6e9c8f1b968bab55148a45862f19a3fc7c27b.1402912665.git.hutao@cn.fujitsu.com
State New
Headers show

Commit Message

Hu Tao June 16, 2014, 10:05 a.m. UTC
If pc-dimm is specified on qemu command line, but only with
-m size (aka not -m size,maxmem,slots) then qemu will core dump.

This patch fixes the problem.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---
 hw/mem/pc-dimm.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Igor Mammedov June 16, 2014, 10:44 a.m. UTC | #1
On Mon, 16 Jun 2014 18:05:42 +0800
Hu Tao <hutao@cn.fujitsu.com> wrote:

> If pc-dimm is specified on qemu command line, but only with
> -m size (aka not -m size,maxmem,slots) then qemu will core dump.
> 
> This patch fixes the problem.
> 
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  hw/mem/pc-dimm.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> index 8c26568..a57b9a3 100644
> --- a/hw/mem/pc-dimm.c
> +++ b/hw/mem/pc-dimm.c
> @@ -107,6 +107,13 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
>      uint64_t new_addr, ret = 0;
>      uint64_t address_space_end = address_space_start + address_space_size;
>  
> +    if (address_space_size == 0) {
> +        error_setg(errp, "no space left for hotplugged memory. did you forget "
> +                   "maxmem and slots on "
> +                   "-m(aka -m size,maxmem=maxmem,slots=slots)?");
CLI format here could get out off sync from actual one. Maybe just
"no space left in hotplug memory range" 

> +        goto out;
> +    }
> +
>      assert(address_space_end > address_space_size);
>      object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list);
>
Igor Mammedov June 16, 2014, 10:47 a.m. UTC | #2
On Mon, 16 Jun 2014 18:05:42 +0800
Hu Tao <hutao@cn.fujitsu.com> wrote:

> If pc-dimm is specified on qemu command line, but only with
> -m size (aka not -m size,maxmem,slots) then qemu will core dump.
> 
> This patch fixes the problem.
> 
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  hw/mem/pc-dimm.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> index 8c26568..a57b9a3 100644
> --- a/hw/mem/pc-dimm.c
> +++ b/hw/mem/pc-dimm.c
> @@ -107,6 +107,13 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
another suggestion is to put check in pc_dimm_plug() hotplug handler.

>      uint64_t new_addr, ret = 0;
>      uint64_t address_space_end = address_space_start + address_space_size;
>  
> +    if (address_space_size == 0) {
> +        error_setg(errp, "no space left for hotplugged memory. did you forget "
> +                   "maxmem and slots on "
> +                   "-m(aka -m size,maxmem=maxmem,slots=slots)?");
> +        goto out;
> +    }
> +
>      assert(address_space_end > address_space_size);
>      object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list);
>
diff mbox

Patch

diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 8c26568..a57b9a3 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -107,6 +107,13 @@  uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
     uint64_t new_addr, ret = 0;
     uint64_t address_space_end = address_space_start + address_space_size;
 
+    if (address_space_size == 0) {
+        error_setg(errp, "no space left for hotplugged memory. did you forget "
+                   "maxmem and slots on "
+                   "-m(aka -m size,maxmem=maxmem,slots=slots)?");
+        goto out;
+    }
+
     assert(address_space_end > address_space_size);
     object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list);