From: Jim Fehlig <jfehlig@suse.com>
To: libvir-list@redhat.com
Cc: Juergen Gross <JGross@suse.com>, Wei Liu <wei.liu2@citrix.com>,
xen-devel@lists.xen.org
Subject: Re: [PATCH] libxl: fix dom0 autoballooning with Xen 4.8
Date: Wed, 01 Feb 2017 16:00:54 -0700 [thread overview]
Message-ID: <589268A6.8030302@suse.com> (raw)
In-Reply-To: <20170119175005.10220-1-jfehlig@suse.com>
Jim Fehlig wrote:
> xen.git commit 57f8b13c changed several of the libxl memory
> get/set functions to take 64 bit parameters. The libvirt
> libxl driver still uses uint32_t variables for these various
> parameters, which is particularly problematic for the
> libxl_set_memory_target() function.
>
> When dom0 autoballooning is enabled, libvirt (like xl) determines
> the memory needed to start a domain and the memory available. If
> memory available is less than memory needed, dom0 is ballooned
> down by passing a negative value to libxl_set_memory_target()
> 'target_memkb' parameter. Prior to xen.git commit 57f8b13c,
> 'target_memkb' was an int32_t. Subtracting a larger uint32 from
> a smaller uint32 and assigning it to int32 resulted in a negative
> number. After commit 57f8b13c, the same subtraction is widened
> to a int64, resulting in a large positive number. The simple
> fix taken by this patch is to assign the difference of the
> uint32 values to a temporary int32 variable, which is then
> passed to 'target_memkb' parameter of libxl_set_memory_target().
>
> Note that it is undesirable to change libvirt to use 64 bit
> variables since it requires setting LIBXL_API_VERSION to 0x040800.
> Currently libvirt supports LIBXL_API_VERSION >= 0x040400,
> essentially Xen >= 4.4.
Any comments on this patch? xen-devel is already in cc, but I'll add Wei (one of
the Xen tools maintainers) and Juergen (author of commit 57f8b13c) for some
additional exposure :-).
Currently, "out-of-the-box" Xen >= 4.8 + libvirt setup (dom0 autoballooning
enabled) is broken without this fix.
Regards,
Jim
>
> Signed-off-by: Jim Fehlig <jfehlig@suse.com>
> ---
> src/libxl/libxl_domain.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
> index a5314b0..ed73cd2 100644
> --- a/src/libxl/libxl_domain.c
> +++ b/src/libxl/libxl_domain.c
> @@ -909,6 +909,7 @@ libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config *d_config)
> {
> uint32_t needed_mem;
> uint32_t free_mem;
> + int32_t target_mem;
> int tries = 3;
> int wait_secs = 10;
>
> @@ -922,7 +923,8 @@ libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config *d_config)
> if (free_mem >= needed_mem)
> return 0;
>
> - if (libxl_set_memory_target(ctx, 0, free_mem - needed_mem,
> + target_mem = free_mem - needed_mem;
> + if (libxl_set_memory_target(ctx, 0, target_mem,
> /* relative */ 1, 0) < 0)
> goto error;
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-02-01 23:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-19 17:50 [PATCH] libxl: fix dom0 autoballooning with Xen 4.8 Jim Fehlig
2017-02-01 23:00 ` Jim Fehlig [this message]
2017-02-02 11:42 ` Wei Liu
2017-02-02 18:15 ` Jim Fehlig
2017-02-03 19:18 ` [libvirt] " Martin Kletzander
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=589268A6.8030302@suse.com \
--to=jfehlig@suse.com \
--cc=JGross@suse.com \
--cc=libvir-list@redhat.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/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 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).