xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Shannon Zhao <shannon.zhao@linaro.org>
Subject: [PATCH] libxl: fix issues in 38cd0664
Date: Mon, 3 Oct 2016 15:46:02 +0100	[thread overview]
Message-ID: <1475505962-8103-1-git-send-email-wei.liu2@citrix.com> (raw)

A few issues were introduced in 38cd0664 ("libxl/arm: Add the size of
ACPI tables to maxmem"):

1. d_config was not properly initialised and disposed of.
2. using libxl_retrieve_domain_configuration caused thread to
   deadlock itself.

Fix those issues by:

1. properly initialise and dispose of d_config.
2. switch to use libxl__get_domain_configuration.

Note that in theory we can refactor libxl_retrieve_domain_configuration
a bit to get a function without locking, but up until the calculation of
extra memory only relies on static configuration, hence we use the
stored configuration only.

Reported-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Anthony PERARD <anthony.perard@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Shannon Zhao <shannon.zhao@linaro.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libxl/libxl.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 432e5d9..33c5e4c 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -4029,6 +4029,8 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t max_memkb)
     libxl__domain_userdata_lock *lock = NULL;
     libxl_domain_config d_config;
 
+    libxl_domain_config_init(&d_config);
+
     CTX_LOCK;
 
     lock = libxl__lock_domain_userdata(gc, domid);
@@ -4054,7 +4056,7 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t max_memkb)
         goto out;
     }
 
-    rc = libxl_retrieve_domain_configuration(ctx, domid, &d_config);
+    rc = libxl__get_domain_configuration(gc, domid, &d_config);
     if (rc < 0) {
         LOGE(ERROR, "unable to retrieve domain configuration");
         goto out;
@@ -4076,6 +4078,7 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t max_memkb)
 
     rc = 0;
 out:
+    libxl_domain_config_dispose(&d_config);
     if (lock) libxl__unlock_domain_userdata(lock);
     CTX_UNLOCK;
     GC_FREE;
@@ -4177,6 +4180,8 @@ int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid,
     libxl__domain_userdata_lock *lock;
     libxl_domain_config d_config;
 
+    libxl_domain_config_init(&d_config);
+
     CTX_LOCK;
 
     lock = libxl__lock_domain_userdata(gc, domid);
@@ -4185,7 +4190,7 @@ int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid,
         goto out_no_transaction;
     }
 
-    rc = libxl_retrieve_domain_configuration(ctx, domid, &d_config);
+    rc = libxl__get_domain_configuration(gc, domid, &d_config);
     if (rc < 0) {
         LOGE(ERROR, "unable to retrieve domain configuration");
         goto out_no_transaction;
@@ -4318,6 +4323,7 @@ out:
             goto retry_transaction;
 
 out_no_transaction:
+    libxl_domain_config_dispose(&d_config);
     if (lock) libxl__unlock_domain_userdata(lock);
     CTX_UNLOCK;
     GC_FREE;
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

             reply	other threads:[~2016-10-03 14:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-03 14:46 Wei Liu [this message]
2016-10-04  9:48 ` [PATCH] libxl: fix issues in 38cd0664 Ian Jackson
2016-10-04  9:50   ` Wei Liu

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=1475505962-8103-1-git-send-email-wei.liu2@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=shannon.zhao@linaro.org \
    --cc=xen-devel@lists.xenproject.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).