Re: [Qemu-devel] [PATCH 4/9] iotests: Use // for Python integer division

2018-10-19 Thread Max Reitz
On 15.10.18 23:13, Cleber Rosa wrote:
> 
> 
> On 10/15/18 10:14 AM, Max Reitz wrote:
>> In Python 3, / is always a floating-point division.  We usually do not
>> want this, and as Python 2.7 understands // as well, change all integer
>> divisions to use that.
>>
>> Signed-off-by: Max Reitz 
>> ---
>>  tests/qemu-iotests/040|  4 ++--
>>  tests/qemu-iotests/044|  2 +-
>>  tests/qemu-iotests/093| 18 +-
>>  tests/qemu-iotests/149|  6 +++---
>>  tests/qemu-iotests/151| 12 ++--
>>  tests/qemu-iotests/163|  2 +-
>>  tests/qemu-iotests/iotests.py |  2 +-
>>  7 files changed, 23 insertions(+), 23 deletions(-)
>>
>> diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
>> index 1cb1ceeb33..b81133a474 100755
>> --- a/tests/qemu-iotests/040
>> +++ b/tests/qemu-iotests/040
>> @@ -195,7 +195,7 @@ class TestSingleDrive(ImageCommitTestCase):
>>  
>>  self.assert_no_active_block_jobs()
>>  result = self.vm.qmp('block-commit', device='drive0', top=mid_img,
>> - base=backing_img, speed=(self.image_len / 4))
>> + base=backing_img, speed=(self.image_len // 4))
>>  self.assert_qmp(result, 'return', {})
>>  result = self.vm.qmp('device_del', id='scsi0')
>>  self.assert_qmp(result, 'return', {})
>> @@ -225,7 +225,7 @@ class TestSingleDrive(ImageCommitTestCase):
>>  
>>  self.assert_no_active_block_jobs()
>>  result = self.vm.qmp('block-commit', device='drive0', top=mid_img,
>> - base=backing_img, speed=(self.image_len / 4))
>> + base=backing_img, speed=(self.image_len // 4))
>>  self.assert_qmp(result, 'return', {})
>>  
>>  result = self.vm.qmp('query-block')
>> diff --git a/tests/qemu-iotests/044 b/tests/qemu-iotests/044
>> index 69e736f687..7ef5e46fe9 100755
>> --- a/tests/qemu-iotests/044
>> +++ b/tests/qemu-iotests/044
>> @@ -86,7 +86,7 @@ class TestRefcountTableGrowth(iotests.QMPTestCase):
>>  off = off + 1024 * 512
>>  
>>  table = b''.join(struct.pack('>Q', (1 << 63) | off + 512 * j)
>> -for j in xrange(0, remaining / 512))
>> +for j in xrange(0, remaining // 512))
>>  fd.write(table)
>>  
>>  
>> diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093
>> index 9d1971a56c..d88fbc182e 100755
>> --- a/tests/qemu-iotests/093
>> +++ b/tests/qemu-iotests/093
>> @@ -69,18 +69,18 @@ class ThrottleTestCase(iotests.QMPTestCase):
>>  # in. The throttled requests won't be executed until we
>>  # advance the virtual clock.
>>  rq_size = 512
>> -rd_nr = max(params['bps'] / rq_size / 2,
>> -params['bps_rd'] / rq_size,
>> -params['iops'] / 2,
>> +rd_nr = max(params['bps'] // rq_size // 2,
>> +params['bps_rd'] // rq_size,
>> +params['iops'] // 2,
>>  params['iops_rd'])
>>  rd_nr *= seconds * 2
>> -rd_nr /= ndrives
>> -wr_nr = max(params['bps'] / rq_size / 2,
>> -params['bps_wr'] / rq_size,
>> -params['iops'] / 2,
>> +rd_nr //= ndrives
>> +wr_nr = max(params['bps'] // rq_size // 2,
>> +params['bps_wr'] // rq_size,
>> +params['iops'] // 2,
>>  params['iops_wr'])
>>  wr_nr *= seconds * 2
>> -wr_nr /= ndrives
>> +wr_nr //= ndrives
>>  
>>  # Send I/O requests to all drives
>>  for i in range(rd_nr):
>> @@ -196,7 +196,7 @@ class ThrottleTestCase(iotests.QMPTestCase):
>>  self.configure_throttle(ndrives, settings)
>>  
>>  # Wait for the bucket to empty so we can do bursts
>> -wait_ns = nsec_per_sec * burst_length * burst_rate / rate
>> +wait_ns = nsec_per_sec * burst_length * burst_rate // rate
>>  self.vm.qtest("clock_step %d" % wait_ns)
>>  
>>  # Test I/O at the max burst rate
>> diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
>> index 1225334cb8..4f363f295f 100755
>> --- a/tests/qemu-iotests/149
>> +++ b/tests/qemu-iotests/149
>> @@ -314,13 +314,13 @@ def test_once(config, qemu_img=False):
>>  image_size = 4 * oneTB
>>  if qemu_img:
>>  iotests.log("# Create image")
>> -qemu_img_create(config, image_size / oneMB)
>> +qemu_img_create(config, image_size // oneMB)
>>  else:
>>  iotests.log("# Create image")
>> -create_image(config, image_size / oneMB)
>> +create_image(config, image_size // oneMB)
>>  
>>  lowOffsetMB = 100
>> -highOffsetMB = 3 * oneTB / oneMB
>> +highOffsetMB = 3 * oneTB // oneMB
>>  
>>  try:
>>  if not qemu_img:
>> diff --git a/tests/qemu-iotests/151 b/tests/qemu-iotests/151
>> index fe53b9f446..1bb74d67c4 

Re: [Qemu-devel] [PATCH 4/9] iotests: Use // for Python integer division

2018-10-15 Thread Cleber Rosa



On 10/15/18 10:14 AM, Max Reitz wrote:
> In Python 3, / is always a floating-point division.  We usually do not
> want this, and as Python 2.7 understands // as well, change all integer
> divisions to use that.
> 
> Signed-off-by: Max Reitz 
> ---
>  tests/qemu-iotests/040|  4 ++--
>  tests/qemu-iotests/044|  2 +-
>  tests/qemu-iotests/093| 18 +-
>  tests/qemu-iotests/149|  6 +++---
>  tests/qemu-iotests/151| 12 ++--
>  tests/qemu-iotests/163|  2 +-
>  tests/qemu-iotests/iotests.py |  2 +-
>  7 files changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
> index 1cb1ceeb33..b81133a474 100755
> --- a/tests/qemu-iotests/040
> +++ b/tests/qemu-iotests/040
> @@ -195,7 +195,7 @@ class TestSingleDrive(ImageCommitTestCase):
>  
>  self.assert_no_active_block_jobs()
>  result = self.vm.qmp('block-commit', device='drive0', top=mid_img,
> - base=backing_img, speed=(self.image_len / 4))
> + base=backing_img, speed=(self.image_len // 4))
>  self.assert_qmp(result, 'return', {})
>  result = self.vm.qmp('device_del', id='scsi0')
>  self.assert_qmp(result, 'return', {})
> @@ -225,7 +225,7 @@ class TestSingleDrive(ImageCommitTestCase):
>  
>  self.assert_no_active_block_jobs()
>  result = self.vm.qmp('block-commit', device='drive0', top=mid_img,
> - base=backing_img, speed=(self.image_len / 4))
> + base=backing_img, speed=(self.image_len // 4))
>  self.assert_qmp(result, 'return', {})
>  
>  result = self.vm.qmp('query-block')
> diff --git a/tests/qemu-iotests/044 b/tests/qemu-iotests/044
> index 69e736f687..7ef5e46fe9 100755
> --- a/tests/qemu-iotests/044
> +++ b/tests/qemu-iotests/044
> @@ -86,7 +86,7 @@ class TestRefcountTableGrowth(iotests.QMPTestCase):
>  off = off + 1024 * 512
>  
>  table = b''.join(struct.pack('>Q', (1 << 63) | off + 512 * j)
> -for j in xrange(0, remaining / 512))
> +for j in xrange(0, remaining // 512))
>  fd.write(table)
>  
>  
> diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093
> index 9d1971a56c..d88fbc182e 100755
> --- a/tests/qemu-iotests/093
> +++ b/tests/qemu-iotests/093
> @@ -69,18 +69,18 @@ class ThrottleTestCase(iotests.QMPTestCase):
>  # in. The throttled requests won't be executed until we
>  # advance the virtual clock.
>  rq_size = 512
> -rd_nr = max(params['bps'] / rq_size / 2,
> -params['bps_rd'] / rq_size,
> -params['iops'] / 2,
> +rd_nr = max(params['bps'] // rq_size // 2,
> +params['bps_rd'] // rq_size,
> +params['iops'] // 2,
>  params['iops_rd'])
>  rd_nr *= seconds * 2
> -rd_nr /= ndrives
> -wr_nr = max(params['bps'] / rq_size / 2,
> -params['bps_wr'] / rq_size,
> -params['iops'] / 2,
> +rd_nr //= ndrives
> +wr_nr = max(params['bps'] // rq_size // 2,
> +params['bps_wr'] // rq_size,
> +params['iops'] // 2,
>  params['iops_wr'])
>  wr_nr *= seconds * 2
> -wr_nr /= ndrives
> +wr_nr //= ndrives
>  
>  # Send I/O requests to all drives
>  for i in range(rd_nr):
> @@ -196,7 +196,7 @@ class ThrottleTestCase(iotests.QMPTestCase):
>  self.configure_throttle(ndrives, settings)
>  
>  # Wait for the bucket to empty so we can do bursts
> -wait_ns = nsec_per_sec * burst_length * burst_rate / rate
> +wait_ns = nsec_per_sec * burst_length * burst_rate // rate
>  self.vm.qtest("clock_step %d" % wait_ns)
>  
>  # Test I/O at the max burst rate
> diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
> index 1225334cb8..4f363f295f 100755
> --- a/tests/qemu-iotests/149
> +++ b/tests/qemu-iotests/149
> @@ -314,13 +314,13 @@ def test_once(config, qemu_img=False):
>  image_size = 4 * oneTB
>  if qemu_img:
>  iotests.log("# Create image")
> -qemu_img_create(config, image_size / oneMB)
> +qemu_img_create(config, image_size // oneMB)
>  else:
>  iotests.log("# Create image")
> -create_image(config, image_size / oneMB)
> +create_image(config, image_size // oneMB)
>  
>  lowOffsetMB = 100
> -highOffsetMB = 3 * oneTB / oneMB
> +highOffsetMB = 3 * oneTB // oneMB
>  
>  try:
>  if not qemu_img:
> diff --git a/tests/qemu-iotests/151 b/tests/qemu-iotests/151
> index fe53b9f446..1bb74d67c4 100755
> --- a/tests/qemu-iotests/151
> +++ b/tests/qemu-iotests/151
> @@ -67,9 +67,9 @@ class TestActiveMirror(iotests.QMPTestCase):
>  

Re: [Qemu-devel] [PATCH 4/9] iotests: Use // for Python integer division

2018-10-15 Thread Eduardo Habkost
On Mon, Oct 15, 2018 at 04:14:48PM +0200, Max Reitz wrote:
> In Python 3, / is always a floating-point division.  We usually do not
> want this, and as Python 2.7 understands // as well, change all integer
> divisions to use that.
> 
> Signed-off-by: Max Reitz 

Reviewed-by: Eduardo Habkost 

-- 
Eduardo



[Qemu-devel] [PATCH 4/9] iotests: Use // for Python integer division

2018-10-15 Thread Max Reitz
In Python 3, / is always a floating-point division.  We usually do not
want this, and as Python 2.7 understands // as well, change all integer
divisions to use that.

Signed-off-by: Max Reitz 
---
 tests/qemu-iotests/040|  4 ++--
 tests/qemu-iotests/044|  2 +-
 tests/qemu-iotests/093| 18 +-
 tests/qemu-iotests/149|  6 +++---
 tests/qemu-iotests/151| 12 ++--
 tests/qemu-iotests/163|  2 +-
 tests/qemu-iotests/iotests.py |  2 +-
 7 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
index 1cb1ceeb33..b81133a474 100755
--- a/tests/qemu-iotests/040
+++ b/tests/qemu-iotests/040
@@ -195,7 +195,7 @@ class TestSingleDrive(ImageCommitTestCase):
 
 self.assert_no_active_block_jobs()
 result = self.vm.qmp('block-commit', device='drive0', top=mid_img,
- base=backing_img, speed=(self.image_len / 4))
+ base=backing_img, speed=(self.image_len // 4))
 self.assert_qmp(result, 'return', {})
 result = self.vm.qmp('device_del', id='scsi0')
 self.assert_qmp(result, 'return', {})
@@ -225,7 +225,7 @@ class TestSingleDrive(ImageCommitTestCase):
 
 self.assert_no_active_block_jobs()
 result = self.vm.qmp('block-commit', device='drive0', top=mid_img,
- base=backing_img, speed=(self.image_len / 4))
+ base=backing_img, speed=(self.image_len // 4))
 self.assert_qmp(result, 'return', {})
 
 result = self.vm.qmp('query-block')
diff --git a/tests/qemu-iotests/044 b/tests/qemu-iotests/044
index 69e736f687..7ef5e46fe9 100755
--- a/tests/qemu-iotests/044
+++ b/tests/qemu-iotests/044
@@ -86,7 +86,7 @@ class TestRefcountTableGrowth(iotests.QMPTestCase):
 off = off + 1024 * 512
 
 table = b''.join(struct.pack('>Q', (1 << 63) | off + 512 * j)
-for j in xrange(0, remaining / 512))
+for j in xrange(0, remaining // 512))
 fd.write(table)
 
 
diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093
index 9d1971a56c..d88fbc182e 100755
--- a/tests/qemu-iotests/093
+++ b/tests/qemu-iotests/093
@@ -69,18 +69,18 @@ class ThrottleTestCase(iotests.QMPTestCase):
 # in. The throttled requests won't be executed until we
 # advance the virtual clock.
 rq_size = 512
-rd_nr = max(params['bps'] / rq_size / 2,
-params['bps_rd'] / rq_size,
-params['iops'] / 2,
+rd_nr = max(params['bps'] // rq_size // 2,
+params['bps_rd'] // rq_size,
+params['iops'] // 2,
 params['iops_rd'])
 rd_nr *= seconds * 2
-rd_nr /= ndrives
-wr_nr = max(params['bps'] / rq_size / 2,
-params['bps_wr'] / rq_size,
-params['iops'] / 2,
+rd_nr //= ndrives
+wr_nr = max(params['bps'] // rq_size // 2,
+params['bps_wr'] // rq_size,
+params['iops'] // 2,
 params['iops_wr'])
 wr_nr *= seconds * 2
-wr_nr /= ndrives
+wr_nr //= ndrives
 
 # Send I/O requests to all drives
 for i in range(rd_nr):
@@ -196,7 +196,7 @@ class ThrottleTestCase(iotests.QMPTestCase):
 self.configure_throttle(ndrives, settings)
 
 # Wait for the bucket to empty so we can do bursts
-wait_ns = nsec_per_sec * burst_length * burst_rate / rate
+wait_ns = nsec_per_sec * burst_length * burst_rate // rate
 self.vm.qtest("clock_step %d" % wait_ns)
 
 # Test I/O at the max burst rate
diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
index 1225334cb8..4f363f295f 100755
--- a/tests/qemu-iotests/149
+++ b/tests/qemu-iotests/149
@@ -314,13 +314,13 @@ def test_once(config, qemu_img=False):
 image_size = 4 * oneTB
 if qemu_img:
 iotests.log("# Create image")
-qemu_img_create(config, image_size / oneMB)
+qemu_img_create(config, image_size // oneMB)
 else:
 iotests.log("# Create image")
-create_image(config, image_size / oneMB)
+create_image(config, image_size // oneMB)
 
 lowOffsetMB = 100
-highOffsetMB = 3 * oneTB / oneMB
+highOffsetMB = 3 * oneTB // oneMB
 
 try:
 if not qemu_img:
diff --git a/tests/qemu-iotests/151 b/tests/qemu-iotests/151
index fe53b9f446..1bb74d67c4 100755
--- a/tests/qemu-iotests/151
+++ b/tests/qemu-iotests/151
@@ -67,9 +67,9 @@ class TestActiveMirror(iotests.QMPTestCase):
 'write -P 1 0 %i' % self.image_len);
 
 # Start some background requests
-for offset in range(1 * self.image_len / 8, 3 * self.image_len / 8, 
1024 * 1024):
+for offset in range(1 * self.image_len // 8, 3 * self.image_len // 8, 
1024 * 1024):