[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1] tools: use integer division in convert-legacy-stream


  • To: Olaf Hering <olaf@xxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 18 Jun 2021 10:42:58 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9sHJWJblTrr0lGRfGH6HlE2YX+loeCDTYTkU0KU8Rgo=; b=PvmbtxR/Fdn5ZXAo05UUSJdwK4WAcX6FeOGyNBrCBPJt2Megn863m/e/q/vm049y9FPH1jYUR438RMGnuXme4nshiEEmC66WocqlbdFQlry6sM+VIEiJ1hTbVbDZsh8lZVJzSBW8Y9zzxcGpmKVOC2LJ5Hhf+PryQH3++eS3s1MpP1v+Apr3LbEsz2Pf+JQ1IEJzqAEvqDD6ZMutyPfdqBgH4WfIrQ2HWw3EvU45GnGcQxRyITAjM7V0XBE0y3w4aZEde7DBzltYtVjhkPX+lcMTkWEx398HfeIy1/YjZZGfjG7m/5g5EovLj2KiG0EZI0QKlmrlaLIU03GIAFIuEA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WudSoL8EhibUTnuLNxzMzeugsd1IY/3Lhs++nVtigPfq7XD9weCpymnK4gBQ1wXzm611/hDy8CJFfr4QNy4l5w+MeYcOovzIuDw+NCwRUi65KDVfqr6kHOrS8ocUKzkVoNwFyfJtAvmoxrmqLe4bqAqmzcGsZsGBYbnqFVSyFGghxLQ7deHrnlqOauL19s11j3AGJHmcdjQDWstI3m/Ilm5MRCJthe2+LZknViM+4kmtxX9HFVZlwlQ4whkiVUvi6SEZrDG8BVY/W0VgUOMhFbJ0FqSxkETXVXr+oDUyYmUiKA53I3qFaeM+v/a7P374KaXl+1FbF9P9Ue5qyNVokg==
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 18 Jun 2021 09:43:50 +0000
  • Ironport-hdrordr: A9a23:Pe+iIK8BF9xVsyqaWVVuk+E1db1zdoMgy1knxilNoENuHPBwxv rAoB1E73PJYVYqOE3Jmbi7Sc69qADnhOBICO4qTMiftWjdyReVxeRZjLcKrAeQYBEWmtQtrJ uINpIOdeEYbmIK//oSgjPIa+rIqePvmMvD6Ja8vhUdOT2CKZsQiTuRYjzrYXGeLzM2YKbReq Dsgvav6wDQA0j+Oa+Adwk4tqX41pL2vaOjRSRDKw8s6QGIgz/twLnmEyKA1hNbdz9U278t/U XMjgS8v8yYwrCG4y6Z81WWw4VdmdPnxNcGLMuQivINIjGprgqzfoxuV5CLoThwiuCy71QBls XKvn4bTopOwkKUWlvwjQrm2gHm3jprwWTl00WkjXzqptG8bC4mCuJa7LgpMCfx2g4FhpVRwa hL12WWu958FhXbhhnw4NDOSlVDile0m3w/iuQe5kYvErf2UIUh6bD3wXklV6vpREnBmcYa+a hVfYHhDc9tABanhyuzhBg3/DTENU5DaytvQSA5y4aoOnZt7ShEJnAjtboid0E7hdkAoql/lp P525tT5fhzp+8tHO9A7bQ6MIeK4lKke2OFDIvEGyWXKEhAAQOXl6LK
  • Ironport-sdr: oncb+Wn1/dOoe/B0nfG/7a+nenUrdYna3xBuA/hFsW/sBnZvCf46BOiRFptlgjBi2xBxTu4oH2 ZG6xqFNhG9kq+FTzucpcjDglBghZpE2jSKXePbEbBxJAv/i2SrFEpd8PRI19Ol62Bmxqv/By5M fnlLOFVkM8USOSYpUu8QufbSLjPhHDexJXxDw44ObJ6is9Aiem+FHaWY3114Z7YCS7Kl7wQGdJ jNOt/R+07y0GEZqgUnldLZFzHDTiZlydboim9k/2wRRn3lt01GxiT32gG7X/rGUCbbFql8fQ6o o2A=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 18/06/2021 10:31, Olaf Hering wrote:
> A single slash gives a float, a double slash gives an int.
>
>     bitmap = unpack_exact("Q" * ((max_id/64) + 1))
> TypeError: can't multiply sequence by non-int of type 'float'
>
> This is broken for unknown reasons since 4.14.

:(

This is a Py2 vs Py3 difference.

To not break Py2.7, we need "from __future__ import division" at the top
of the script, but I doubt this is the only script impacted.

>
> Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
> ---
>  tools/python/scripts/convert-legacy-stream | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
>
> diff --git a/tools/python/scripts/convert-legacy-stream 
> b/tools/python/scripts/convert-legacy-stream
> index ca93a93848..a04c6e4165 100755
> --- a/tools/python/scripts/convert-legacy-stream
> +++ b/tools/python/scripts/convert-legacy-stream
> @@ -163,7 +163,7 @@ def write_libxc_hvm_params(params):
>          raise RuntimeError("Expected even length list of hvm parameters")
>  
>      write_record(libxc.REC_TYPE_hvm_params,
> -                 pack(libxc.HVM_PARAMS_FORMAT, len(params) / 2, 0),
> +                 pack(libxc.HVM_PARAMS_FORMAT, len(params) // 2, 0),
>                   pack("Q" * len(params), *params))
>  
>  def write_libxc_static_data_end():
> @@ -264,8 +264,8 @@ def read_pv_extended_info(vm):
>                            (so_far - total_length, ))
>  
>  def read_pv_p2m_frames(vm):
> -    fpp = 4096 / vm.width
> -    p2m_frame_len = (vm.p2m_size - 1) / fpp + 1
> +    fpp = 4096 // vm.width
> +    p2m_frame_len = (vm.p2m_size - 1) // fpp + 1
>  
>      info("P2M frames: fpp %d, p2m_frame_len %d" % (fpp, p2m_frame_len))
>      write_libxc_pv_p2m_frames(vm, unpack_ulongs(p2m_frame_len))
> @@ -405,7 +405,7 @@ def read_chunks(vm):
>                                    (max_id, legacy.MAX_VCPU_ID))
>  
>              vm.max_vcpu_id = max_id
> -            bitmap = unpack_exact("Q" * ((max_id/64) + 1))
> +            bitmap = unpack_exact("Q" * ((max_id//64) + 1))

While you're changing this, could we make it (max_id // 64) to fix the
style (which I clearly messed up first time around).

~Andrew

>  
>              for idx, word in enumerate(bitmap):
>                  bit_idx = 0
>




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.