From: Ian Campbell <Ian.Campbell@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Keir Fraser <keir@xen.org>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Xen-devel <xen-devel@lists.xen.org>,
Euan Harris <euan.harris@citrix.com>,
Jan Beulich <jbeulich@suse.com>, Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH for-4.5 v3] Xen and tools: Fix listing of vcpus when domains lacking any vcpus exist
Date: Wed, 22 Oct 2014 12:27:31 +0100 [thread overview]
Message-ID: <1413977251.19198.10.camel@citrix.com> (raw)
In-Reply-To: <1413910014-4249-1-git-send-email-andrew.cooper3@citrix.com>
On Tue, 2014-10-21 at 17:46 +0100, Andrew Cooper wrote:
> On a system which looks like this:
>
> [root@st04 ~]# xl list
> Name ID Mem VCPUs State Time(s)
> Domain-0 0 752 4 r----- 46699.3
> (null) 1 0 0 --p--- 0.0
> (null) 2 0 0 --p--- 0.0
> (null) 3 0 0 --p--- 0.0
> badger 25 0 1 --p--- 0.0
>
> `xl vcpu-list` failes as so:
>
> [root@st04 ~]# xl vcpu-list
> Name ID VCPU CPU State Time(s) CPU Affinity
> Domain-0 0 0 0 -b- 12171.0 all
> Domain-0 0 1 1 -b- 11779.6 all
> Domain-0 0 2 2 -b- 11599.0 all
> Domain-0 0 3 3 r-- 11007.0 all
> libxl: critical: libxl__calloc: libxl: FATAL ERROR: memory allocation failure (libxl__calloc, 4294935299 x 40)
> : Cannot allocate memory
> libxl: FATAL ERROR: memory allocation failure (libxl__calloc, 4294935299 x 40)
>
> The root cause of this is in Xen. getdomaininfo() has no way of expressing
> "this domain has no vcpus". Previously, info->max_vcpu_id would be returned
> uninitialised in such a case.
>
> Unfortunately, setting it to 0 as a default is not appropriate. A max_vcpu_id
> of 0 and nr_online_cpus of 0 is the valid state for a single vcpu domain which
> is in the process of being destroyed.
>
> As all components are required to add 1 to max_vcpu_id to get the number of
> vcpus, an id of ~0U is not valid to be used. Explicitly define this as an
> invalid max vcpu value, and use it to express "no vcpus" in getdomaininfo()
>
> In libxl, the issue is seen as libxl_list_vcpu() attempts to use the
> uninitialised domaininfo.max_vcpu_id for memory allocation.
>
> Check domaininfo.max_vcpu_id against the new sentinel value
> XEN_INVALID_MAX_VCPU_ID, and return early. This means that it is now valid
> for libxl_list_vcpu() to return NULL for a domain which lacks any vcpus.
>
> As part of this change, remove the pointless call to libxl_get_max_cpus(),
> whose returned value is unconditionally clobbered in the for() loop.
>
> Reported-by: Euan Harris <euan.harris@citrix.com>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Acked-by: Jan Beulich <jbeulich@suse.com>
> CC: Keir Fraser <keir@xen.org>
Tools-side:
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
(libxl_list_vcpu has some rather icky unconventional error handling.
sigh, not your problem here though)
Ian.
next prev parent reply other threads:[~2014-10-22 11:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-21 16:46 [PATCH for-4.5 v3] Xen and tools: Fix listing of vcpus when domains lacking any vcpus exist Andrew Cooper
2014-10-21 17:09 ` Don Slutz
2014-10-22 11:27 ` Ian Campbell [this message]
2014-10-22 16:18 ` Dario Faggioli
2014-10-22 16:27 ` Andrew Cooper
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=1413977251.19198.10.camel@citrix.com \
--to=ian.campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=euan.harris@citrix.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--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 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.