From patchwork Thu Feb 23 10:48:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= X-Patchwork-Id: 9588149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A601E604A2 for ; Thu, 23 Feb 2017 10:51:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FFBA28609 for ; Thu, 23 Feb 2017 10:51:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84C49286F8; Thu, 23 Feb 2017 10:51:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 0EED5286AA for ; Thu, 23 Feb 2017 10:51:25 +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 1cgqxI-0005uE-TG; Thu, 23 Feb 2017 10:49:00 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgqxH-0005sk-2n for xen-devel@lists.xen.org; Thu, 23 Feb 2017 10:48:59 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id AC/BD-28097-A1EBEA85; Thu, 23 Feb 2017 10:48:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFIsWRWlGSWpSXmKPExsXilM8ioyu5b12 EwZ2HOhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bim/YFOyUqPq98wNbA+Fe4i5GLQ0hgFaPE 1esdzF2MnEBOtsTZvrVsIAkWgUvMEhPajoAlJAQ8JbbO/whlO0s8apzNDNF9iFHi/uSZTCAJN oFQifbtM1hBbBEBaYlrny8zghQxC8xllPj8bxs7SEJYwELict96MJtFQFXi+IJfYFN5Bfwl7s y6ygixQU7i5rlOsDinQIDEy742Vojz/CUmTp3FCFEvKHFy5hOWLkYOoAXqEuvnCYGE+QWUJLa tvwxWwiwgL9G8dTbzBEbhWUg6ZiF0zEJStYCReRWjRnFqUVlqka6huV5SUWZ6RkluYmaOrqGB qV5uanFxYnpqTmJSsV5yfu4mRmCYMwDBDsaLpz0PMUpyMCmJ8vrsWRchxJeUn1KZkVicEV9Um pNafIhRhoNDSYK3YC9QTrAoNT21Ii0zBxhxMGkJDh4lEd5ekFbe4oLE3OLMdIjUKUZFKXHeHJ A+AZBERmkeXBssyi8xykoJ8zICHSLEU5BalJtZgir/ilGcg1FJmPcqyHiezLwSuOmvgBYzAS2 2dF4LsrgkESEl1cCYyj7l3uwbuRWFn19U++eue2Bptegxl/A/TeZa6c8Kv3TW9zXM1rZ9f9Fk yeHAixM4ZEwED6UWFzQtvpj5KPGKifit3zwN3ZcefH+1a71/i8ct1+sunJKac57LJ4fXli2ab Xn7EeeeYJGP9dv9rOWNV+UYVgvd/i9t+yw6xnoidyjrMZ7TiSeUWIozEg21mIuKEwGQJFro7Q IAAA== X-Env-Sender: marmarek@invisiblethingslab.com X-Msg-Ref: server-2.tower-206.messagelabs.com!1487846937!65724015!1 X-Originating-IP: [66.111.4.28] X-SpamReason: No, hits=0.0 required=7.0 tests=UPPERCASE_25_50 X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33705 invoked from network); 23 Feb 2017 10:48:57 -0000 Received: from out4-smtp.messagingengine.com (HELO out4-smtp.messagingengine.com) (66.111.4.28) by server-2.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 23 Feb 2017 10:48:57 -0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id D9DB2208A3; Thu, 23 Feb 2017 05:48:56 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute7.internal (MEProxy); Thu, 23 Feb 2017 05:48:56 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= smtpout; bh=SCPRYKSjIij2kFptNeqZQYE8Tms=; b=NKpA1xq+t5JiQajBReUQ pHUErFv+dVBbxNb3D8qbhyvhOI/b9SOOb3YTTHH+795HyWzymDyQgodiTqy6Gy33 VLo6GrUv91KxwXt5sDJWba7CF9zoGyPglfxu6CeMByWfcug8Kp7ngU7PMIdnDVjk CC/NquiH0HafAmbVEs0ut6s= X-ME-Sender: X-Sasl-enc: GijPPw56zDieqQFrvtgxJOGMIEAGkES3PWvzSayO9odb 1487846936 Received: from devel-3rdparty.localdomain (89-70-103-23.dynamic.chello.pl [89.70.103.23]) by mail.messagingengine.com (Postfix) with ESMTPA id E3A4824077; Thu, 23 Feb 2017 05:48:55 -0500 (EST) From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xen.org Date: Thu, 23 Feb 2017 11:48:28 +0100 Message-Id: <1487846908-21462-9-git-send-email-marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487846908-21462-1-git-send-email-marmarek@invisiblethingslab.com> References: <1487846908-21462-1-git-send-email-marmarek@invisiblethingslab.com> MIME-Version: 1.0 Organization: Invisible Things Lab Cc: Wei Liu , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Subject: [Xen-devel] [PATCH 8/8] python: handle long type in scripts 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP In Python3 'long' type have been merged into 'int', '1L' syntax is no longer valid. Assign 'int' type to a 'long' variable in python3, so 'long(1)' will give correct result in both python2 and python3. Signed-off-by: Marek Marczykowski-Górecki --- tools/python/xen/migration/libxc.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/tools/python/xen/migration/libxc.py b/tools/python/xen/migration/libxc.py index 85a78f4..6fd3f6d 100644 --- a/tools/python/xen/migration/libxc.py +++ b/tools/python/xen/migration/libxc.py @@ -14,6 +14,10 @@ from struct import calcsize, unpack from xen.migration.verify import StreamError, RecordError, VerifyBase +# In Python3 long type have been merged into int, 1L syntax is no longer valid +if sys.version_info > (3,): + long = int + # Image Header IHDR_FORMAT = "!QIIHHI" @@ -83,23 +87,23 @@ rec_type_to_str = { # page_data PAGE_DATA_FORMAT = "II" -PAGE_DATA_PFN_MASK = (1L << 52) - 1 -PAGE_DATA_PFN_RESZ_MASK = ((1L << 60) - 1) & ~((1L << 52) - 1) +PAGE_DATA_PFN_MASK = (long(1) << 52) - 1 +PAGE_DATA_PFN_RESZ_MASK = ((long(1) << 60) - 1) & ~((long(1) << 52) - 1) # flags from xen/public/domctl.h: XEN_DOMCTL_PFINFO_* shifted by 32 bits PAGE_DATA_TYPE_SHIFT = 60 -PAGE_DATA_TYPE_LTABTYPE_MASK = (0x7L << PAGE_DATA_TYPE_SHIFT) -PAGE_DATA_TYPE_LTAB_MASK = (0xfL << PAGE_DATA_TYPE_SHIFT) -PAGE_DATA_TYPE_LPINTAB = (0x8L << PAGE_DATA_TYPE_SHIFT) # Pinned pagetable - -PAGE_DATA_TYPE_NOTAB = (0x0L << PAGE_DATA_TYPE_SHIFT) # Regular page -PAGE_DATA_TYPE_L1TAB = (0x1L << PAGE_DATA_TYPE_SHIFT) # L1 pagetable -PAGE_DATA_TYPE_L2TAB = (0x2L << PAGE_DATA_TYPE_SHIFT) # L2 pagetable -PAGE_DATA_TYPE_L3TAB = (0x3L << PAGE_DATA_TYPE_SHIFT) # L3 pagetable -PAGE_DATA_TYPE_L4TAB = (0x4L << PAGE_DATA_TYPE_SHIFT) # L4 pagetable -PAGE_DATA_TYPE_BROKEN = (0xdL << PAGE_DATA_TYPE_SHIFT) # Broken -PAGE_DATA_TYPE_XALLOC = (0xeL << PAGE_DATA_TYPE_SHIFT) # Allocate-only -PAGE_DATA_TYPE_XTAB = (0xfL << PAGE_DATA_TYPE_SHIFT) # Invalid +PAGE_DATA_TYPE_LTABTYPE_MASK = (long(0x7) << PAGE_DATA_TYPE_SHIFT) +PAGE_DATA_TYPE_LTAB_MASK = (long(0xf) << PAGE_DATA_TYPE_SHIFT) +PAGE_DATA_TYPE_LPINTAB = (long(0x8) << PAGE_DATA_TYPE_SHIFT) # Pinned pagetable + +PAGE_DATA_TYPE_NOTAB = (long(0x0) << PAGE_DATA_TYPE_SHIFT) # Regular page +PAGE_DATA_TYPE_L1TAB = (long(0x1) << PAGE_DATA_TYPE_SHIFT) # L1 pagetable +PAGE_DATA_TYPE_L2TAB = (long(0x2) << PAGE_DATA_TYPE_SHIFT) # L2 pagetable +PAGE_DATA_TYPE_L3TAB = (long(0x3) << PAGE_DATA_TYPE_SHIFT) # L3 pagetable +PAGE_DATA_TYPE_L4TAB = (long(0x4) << PAGE_DATA_TYPE_SHIFT) # L4 pagetable +PAGE_DATA_TYPE_BROKEN = (long(0xd) << PAGE_DATA_TYPE_SHIFT) # Broken +PAGE_DATA_TYPE_XALLOC = (long(0xe) << PAGE_DATA_TYPE_SHIFT) # Allocate-only +PAGE_DATA_TYPE_XTAB = (long(0xf) << PAGE_DATA_TYPE_SHIFT) # Invalid # x86_pv_info X86_PV_INFO_FORMAT = "BBHI"