diff mbox

[Xen-devel,v4,16/16] libxl/arm: Add the size of ACPI tables to maxmem

Message ID 1471343113-10652-17-git-send-email-zhaoshenglong@huawei.com
State New
Headers show

Commit Message

Shannon Zhao Aug. 16, 2016, 10:25 a.m. UTC
From: Shannon Zhao <shannon.zhao@linaro.org>

While it defines the maximum size of guest ACPI tables in guest
memory layout, here it adds the size to set the target maxmem
to avoid providing less available memory for guest.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl_arm.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Julien Grall Aug. 29, 2016, 7:07 p.m. UTC | #1
Hi Shannon,

On 16/08/2016 06:25, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> While it defines the maximum size of guest ACPI tables in guest
> memory layout, here it adds the size to set the target maxmem
> to avoid providing less available memory for guest.
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  tools/libxl/libxl_arm.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> index d436167..75b2589 100644
> --- a/tools/libxl/libxl_arm.c
> +++ b/tools/libxl/libxl_arm.c
> @@ -103,6 +103,17 @@ int libxl__arch_domain_save_config(libxl__gc *gc,
>  int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
>                                uint32_t domid)
>  {
> +    libxl_domain_build_info *const info = &d_config->b_info;
> +    libxl_ctx *ctx = libxl__gc_owner(gc);
> +
> +    /* Add the size of ACPI tables to maxmem if ACPI is enabled for guest. */
> +    if (libxl_defbool_val(info->acpi) &&
> +        xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
> +        LIBXL_MAXMEM_CONSTANT + GUEST_ACPI_SIZE / 1024) < 0) {

Why can't we use the estimate size here? It would be better than 
increasing by a constant again the max size (I doubt the ACPI tables 
will be 2MB every time).

Also, this looks like quite unsafe. If someone decides to change the 
default size, (s)he would have to replicate the new algo here.

Wei, Ian, do you have any suggestion to avoid duplication?

> +        LOGE(ERROR, "Couldn't set max memory");
> +        return ERROR_FAIL;
> +    }
> +
>      return 0;
>  }
>
>

Regards,
diff mbox

Patch

diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index d436167..75b2589 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -103,6 +103,17 @@  int libxl__arch_domain_save_config(libxl__gc *gc,
 int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
                               uint32_t domid)
 {
+    libxl_domain_build_info *const info = &d_config->b_info;
+    libxl_ctx *ctx = libxl__gc_owner(gc);
+
+    /* Add the size of ACPI tables to maxmem if ACPI is enabled for guest. */
+    if (libxl_defbool_val(info->acpi) &&
+        xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
+        LIBXL_MAXMEM_CONSTANT + GUEST_ACPI_SIZE / 1024) < 0) {
+        LOGE(ERROR, "Couldn't set max memory");
+        return ERROR_FAIL;
+    }
+
     return 0;
 }