From patchwork Mon Apr 11 01:42:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenzhong Duan X-Patchwork-Id: 8795801 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 098C59F39A for ; Mon, 11 Apr 2016 01:46:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2EF0320254 for ; Mon, 11 Apr 2016 01:46:24 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 553EA20251 for ; Mon, 11 Apr 2016 01:46:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1apQsu-00027i-9F; Mon, 11 Apr 2016 01:43:24 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1apQst-00027c-L9 for xen-devel@lists.xen.org; Mon, 11 Apr 2016 01:43:23 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 16/54-09532-A310B075; Mon, 11 Apr 2016 01:43:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHIsWRWlGSWpSXmKPExsXSO6nOVdeKkTv c4MFLRYslHxezODB6HN39mymAMYo1My8pvyKBNePFCcGCndwVl97NY21gbODoYuTiEBJYxiTx ef0ENghnEpPE/vYbUM55RoljvUtZIZwORok9K9cwdTFycrAJGEismf6NDcQWFrCUeLDsCFARB 1CRssTeX/UgYREBdYklZyexg9jMAkYSkxvfsYDY/AIiEr+bH4HFeYFqLu86DzaGRUBV4veHNj BbVCBaYvehe1A1ghInZz5hgZhjJjFv80NmCFteYvvbOWC2hICxRPvbi2wTGAVnIWmZhaRlFpK WBYzMqxjVi1OLylKLdA31kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzECw5YBCHYw 7nzudIhRkoNJSZTX6iVHuBBfUn5KZUZicUZ8UWlOavEhRhkODiUJXgkG7nAhwaLU9NSKtMwcY ATBpCU4eJREeGtB0rzFBYm5xZnpEKlTjLocW2bcX8skxJKXn5cqJc6rBFIkAFKUUZoHNwIWzZ cYZaWEeRmBjhLiKUgtys0sQZV/xSjOwagkzKsLMoUnM68EbtMroCOYgI549o8T5IiSRISUVAO j5SGXusknd9r43j0ereOsEeTo1/9P8VHJyy8fzl8zzSgzUPkeNt/35C6e9ceqPxuURvIJ348x ujD/fvHVIIMj3VfO/az68mmJ8nWmDf1P71QtueQ46VZD6Hs1u39fLKSS69f0Nkufn/d4e2nnR ZfrxkE7PndxTDBdYt06+TvDCc1mvUmfE8tmKLEUZyQaajEXFScCAO+1XPDhAgAA X-Env-Sender: zhenzhong.duan@oracle.com X-Msg-Ref: server-15.tower-21.messagelabs.com!1460339000!8521043!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31176 invoked from network); 11 Apr 2016 01:43:22 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-15.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Apr 2016 01:43:22 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u3B1hKhT006092 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 11 Apr 2016 01:43:20 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u3B1hJc1026269 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 11 Apr 2016 01:43:19 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u3B1hIe8011071 for ; Mon, 11 Apr 2016 01:43:19 GMT Received: from [192.168.67.107] (/124.192.35.88) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 10 Apr 2016 18:43:18 -0700 From: Zhenzhong Duan To: xen-devel Organization: Oracle Message-ID: <570B0121.60306@oracle.com> Date: Mon, 11 Apr 2016 09:42:57 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 X-Source-IP: aserv0022.oracle.com [141.146.126.234] Subject: [Xen-devel] [PATCH] Fix cpumap setting before passing to XEN X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Reply-To: zhenzhong.duan@oracle.com Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It's tool's duty to pass a correct cpumap to XEN. On a host with less than 64 CPUS, it just shows below error. [root@localhost /]# xm vcpu-pin 3 all all Error: Cannot pin vcpu: 0 to cpu: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63] - (22, 'Invalid argument') The fix make it same as in xl code. Signed-off-by: Zhenzhong Duan Reviewed-by: Konrad Rzeszutek Wilk ? --- tools/python/xen/lowlevel/xc/xc.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index c40a4e9..2f4898d 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -243,13 +243,15 @@ static PyObject *pyxc_vcpu_setaffinity(XcObject *self, for ( i = 0; i < PyList_Size(cpulist); i++ ) { long cpu = PyInt_AsLong(PyList_GetItem(cpulist, i)); - if ( cpu < 0 || cpu >= nr_cpus ) + if ( cpu < 0 ) { free(cpumap); errno = EINVAL; PyErr_SetFromErrno(xc_error_obj); return NULL; } + if ( cpu >= nr_cpus ) + continue; cpumap[cpu / 8] |= 1 << (cpu % 8); } }