From: Andrew Cooper Subject: [PATCH for-4.5 1/2] xen/domctl: Fix getdomaininfo() of a domain without vcpus Date: Mon, 20 Oct 2014 17:21:32 +0100 Message-ID: <1413822093-1621-2-git-send-email-andrew.cooper3@citrix.com> References: <1413822093-1621-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1413822093-1621-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Keir Fraser , Ian Campbell , Andrew Cooper , Ian Jackson , Jan Beulich , Wei Liu List-Id: xen-devel@lists.xenproject.org In the case that a domain has not got any vcpus, getdomaininfo() leaves info->max_vcpu_id uninitialised, which causes a problem for toolstacks. 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() Reported-by: Euan Harris Signed-off-by: Andrew Cooper CC: Keir Fraser CC: Jan Beulich CC: Ian Campbell CC: Ian Jackson CC: Wei Liu --- xen/common/domctl.c | 1 + xen/include/public/domctl.h | 1 + 2 files changed, 2 insertions(+) diff --git a/xen/common/domctl.c b/xen/common/domctl.c index b6f9708..d9c2635 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -156,6 +156,7 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info) struct vcpu_runstate_info runstate; info->domain = d->domain_id; + info->max_vcpu_id = XEN_INVALID_MAX_VCPU_ID; info->nr_online_vcpus = 0; info->ssidref = 0; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index f519524..58b19e7 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -108,6 +108,7 @@ struct xen_domctl_getdomaininfo { uint64_aligned_t shared_info_frame; /* GMFN of shared_info struct */ uint64_aligned_t cpu_time; uint32_t nr_online_vcpus; /* Number of VCPUs currently online. */ +#define XEN_INVALID_MAX_VCPU_ID (~0U) /* Domain has no vcpus? */ uint32_t max_vcpu_id; /* Maximum VCPUID in use by this domain. */ uint32_t ssidref; xen_domain_handle_t handle; -- 1.7.10.4