From: Wei Liu Subject: [PATCH for-4.6 v2 2/3] xl: error out if vNUMA specifies more vcpus than pcpus Date: Thu, 13 Aug 2015 16:41:19 +0100 Message-ID: <1439480480-20939-3-git-send-email-wei.liu2@citrix.com> References: <1439480480-20939-1-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZPvzV-0003ks-Cp for xen-devel@lists.xenproject.org; Thu, 13 Aug 2015 17:08:33 +0000 In-Reply-To: <1439480480-20939-1-git-send-email-wei.liu2@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: Wei Liu , Dario Faggioli , Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org ... but allow user to override that check by specifying maxvcpus= in xl configuration file. Signed-off-by: Wei Liu --- tools/libxl/xl_cmdimpl.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 078acd1..5fde8fa 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1202,11 +1202,27 @@ static void parse_vnuma_config(const XLU_Config *config, } /* User has specified maxvcpus= */ - if (b_info->max_vcpus != 0 && b_info->max_vcpus != max_vcpus) { - fprintf(stderr, "xl: vnuma vcpus and maxvcpus= mismatch\n"); - exit(1); - } else + if (b_info->max_vcpus != 0) { + if (b_info->max_vcpus != max_vcpus) { + fprintf(stderr, "xl: vnuma vcpus and maxvcpus= mismatch\n"); + exit(1); + } + } else { + int host_cpus = libxl_get_online_cpus(ctx); + + if (host_cpus < 0) { + fprintf(stderr, "Failed to get online cpus\n"); + exit(1); + } + + if (host_cpus < max_vcpus) { + fprintf(stderr, "xl: vnuma specifies more vcpus than pcpus, "\ + "use maxvcpus= to override this check.\n"); + exit(1); + } + b_info->max_vcpus = max_vcpus; + } /* User has specified maxmem= */ if (b_info->max_memkb != LIBXL_MEMKB_DEFAULT && -- 2.1.4