All of lore.kernel.org
 help / color / mirror / Atom feed
From: Don Slutz <dslutz@verizon.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: xen-devel@lists.xensource.com, Wei Liu <wei.liu2@citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Don Slutz <dslutz@verizon.com>, hanyandong <hanyandong@iie.ac.cn>
Subject: Re: [PATCH v2 for-4.5] libxl: account for romfile memory
Date: Wed, 26 Nov 2014 15:17:08 -0500	[thread overview]
Message-ID: <54763544.9070207@terremark.com> (raw)
In-Reply-To: <1416919412-10104-1-git-send-email-stefano.stabellini@eu.citrix.com>

On 11/25/14 07:43, Stefano Stabellini wrote:
> Account for the extra memory needed for the rom files of any emulated nics:
> QEMU uses xc_domain_populate_physmap_exact to allocate the memory for
> each them. Assume 256K each.

I have seen that this is no longer planned for 4.5, but I do think that 
libxl will
still be changed for this.

so

>   int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint32_t max_memkb)
>   {
>       GC_INIT(ctx);
>       char *mem, *endptr;
>       uint32_t memorykb;
>       char *dompath = libxl__xs_get_dompath(gc, domid);
> -    int rc = 1;
> +    int rc = 1, romsize;
>   
>       mem = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/memory/target", dompath));
>       if (!mem) {
> @@ -4550,11 +4577,18 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint32_t max_memkb)
>           LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "memory_static_max must be greater than or or equal to memory_dynamic_max\n");
>           goto out;
>       }
> -    rc = xc_domain_setmaxmem(ctx->xch, domid, max_memkb + LIBXL_MAXMEM_CONSTANT);
> +    rc = libxl__get_rom_memory_kb(gc, domid, NULL);
> +    if (rc < 0)
> +        goto out;
> +    romsize = rc;
> +    rc = xc_domain_setmaxmem(ctx->xch, domid,
> +                             max_memkb + LIBXL_MAXMEM_CONSTANT
> +                             + romsize);

Keeping LIBXL_MAXMEM_CONSTANT is wrong.  Should be dropped.

>       if (rc != 0) {
>           LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
>                   "xc_domain_setmaxmem domid=%d memkb=%d failed "
> -                "rc=%d\n", domid, max_memkb + LIBXL_MAXMEM_CONSTANT, rc);
> +                "rc=%d\n", domid, max_memkb + LIBXL_MAXMEM_CONSTANT +
> +                romsize, rc);
>           goto out;
>       }
>   

And here.

> @@ -4683,7 +4717,7 @@ int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid,
>           int32_t target_memkb, int relative, int enforce)
>   {
>       GC_INIT(ctx);
> -    int rc = 1, abort_transaction = 0;
> +    int rc = 1, abort_transaction = 0, romsize;
>       uint32_t memorykb = 0, videoram = 0;
>       uint32_t current_target_memkb = 0, new_target_memkb = 0;
>       uint32_t current_max_memkb = 0;
> @@ -4769,12 +4803,19 @@ retry_transaction:
>   
>       if (enforce) {
>           memorykb = new_target_memkb;
> +        rc = libxl__get_rom_memory_kb(gc, domid, NULL);
> +        if (rc < 0) {
> +            abort_transaction = 1;
> +            goto out;
> +        }
> +        romsize = rc;
>           rc = xc_domain_setmaxmem(ctx->xch, domid, memorykb +
> -                LIBXL_MAXMEM_CONSTANT);
> +                LIBXL_MAXMEM_CONSTANT + romsize);

And here.

>           if (rc != 0) {
>               LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
>                       "xc_domain_setmaxmem domid=%d memkb=%d failed "
> -                    "rc=%d\n", domid, memorykb + LIBXL_MAXMEM_CONSTANT, rc);
> +                    "rc=%d\n", domid, memorykb + LIBXL_MAXMEM_CONSTANT +
> +                    romsize, rc);
>               abort_transaction = 1;
>               goto out;
>           }
> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> index 74ea84b..733f4c7 100644
> --- a/tools/libxl/libxl_dom.c
> +++ b/tools/libxl/libxl_dom.c
> @@ -305,7 +305,7 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
>       libxl_domain_build_info *const info = &d_config->b_info;
>       libxl_ctx *ctx = libxl__gc_owner(gc);
>       char *xs_domid, *con_domid;
> -    int rc;
> +    int rc, romsize;
>   
>       if (xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus) != 0) {
>           LOG(ERROR, "Couldn't set max vcpu count");
> @@ -405,8 +405,12 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
>           }
>       }
>   
> +	rc = libxl__get_rom_memory_kb(gc, domid, d_config);
> +	if (rc < 0)
> +		return rc;
> +	romsize = rc;
>       if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
> -        LIBXL_MAXMEM_CONSTANT) < 0) {
> +        LIBXL_MAXMEM_CONSTANT + romsize) < 0) {
>           LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't set max memory");
>           return ERROR_FAIL;
>       }
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 4361421..33826ea 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -90,6 +90,7 @@
>   #define LIBXL_XENCONSOLE_LIMIT 1048576
>   #define LIBXL_XENCONSOLE_PROTOCOL "vt100"
>   #define LIBXL_MAXMEM_CONSTANT 1024
> +#define LIBXL_ROMSIZE_KB 256
>   #define LIBXL_PV_EXTRA_MEMORY 1024
>   #define LIBXL_HVM_EXTRA_MEMORY 2048

This should be "romsize" + 1024 as far as I know.

>   #define LIBXL_MIN_DOM0_MEM (128*1024)
> @@ -1023,6 +1024,12 @@ _hidden char * libxl__domain_pvcontrol_read(libxl__gc *gc,
>   _hidden int libxl__domain_pvcontrol_write(libxl__gc *gc, xs_transaction_t t,
>                                             uint32_t domid, const char *cmd);
>   
> +/* Returns the amount of extra mem required to allocate roms or an libxl
> + * error code on error.
> + * The *d_config parameter is optional.
> + */
> +_hidden int libxl__get_rom_memory_kb(libxl__gc *gc, uint32_t domid, libxl_domain_config *d_config);
> +
>   /* from xl_device */
>   _hidden char *libxl__device_disk_string_of_backend(libxl_disk_backend backend);
>   _hidden char *libxl__device_disk_string_of_format(libxl_disk_format format);

     -Don Slutz

      parent reply	other threads:[~2014-11-26 20:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-25 12:43 [PATCH v2 for-4.5] libxl: account for romfile memory Stefano Stabellini
2014-11-25 14:24 ` Ian Campbell
2014-11-25 16:49   ` Stefano Stabellini
2014-11-25 16:56     ` Ian Campbell
2014-11-25 17:04       ` Wei Liu
2014-11-25 17:05       ` Stefano Stabellini
2014-11-26  9:32         ` Ian Campbell
2014-11-26 12:39           ` Stefano Stabellini
2014-11-26 13:04             ` Ian Campbell
2014-11-26 14:40               ` Konrad Rzeszutek Wilk
2014-11-26 20:05                 ` Don Slutz
2015-01-08 13:52     ` Ian Campbell
2014-11-26 20:17 ` Don Slutz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54763544.9070207@terremark.com \
    --to=dslutz@verizon.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=hanyandong@iie.ac.cn \
    --cc=ian.jackson@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.