mirror of
				https://github.com/qemu/qemu.git
				synced 2025-10-31 04:06:46 +00:00 
			
		
		
		
	 7c47752608
			
		
	
	
		7c47752608
		
	
	
	
	
		
			
			Use the program search path to find the Python 3 interpreter.
Patch created mechanically by running:
  $ sed -i "s,^#\!/usr/bin/\(env\ \)\?python$,#\!/usr/bin/env python3," \
      $(git grep -lF '#!/usr/bin/env python' \
      | xargs grep -L 'if __name__.*__main__')
Reported-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Suggested-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200130163232.10446-11-philmd@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
		
	
			
		
			
				
	
	
		
			145 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			145 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env python3
 | |
| #
 | |
| # Test VPC and file image creation
 | |
| #
 | |
| # Copyright (C) 2019 Red Hat, Inc.
 | |
| #
 | |
| # This program is free software; you can redistribute it and/or modify
 | |
| # it under the terms of the GNU General Public License as published by
 | |
| # the Free Software Foundation; either version 2 of the License, or
 | |
| # (at your option) any later version.
 | |
| #
 | |
| # This program is distributed in the hope that it will be useful,
 | |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of
 | |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | |
| # GNU General Public License for more details.
 | |
| #
 | |
| # You should have received a copy of the GNU General Public License
 | |
| # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |
| #
 | |
| 
 | |
| import iotests
 | |
| from iotests import imgfmt
 | |
| 
 | |
| 
 | |
| # Successful image creation (defaults)
 | |
| def implicit_defaults(vm, file_path):
 | |
|     iotests.log("=== Successful image creation (defaults) ===")
 | |
|     iotests.log("")
 | |
| 
 | |
|     # 8 heads, 964 cyls/head, 17 secs/cyl
 | |
|     # (Close to 64 MB)
 | |
|     size = 8 * 964 * 17 * 512
 | |
| 
 | |
|     vm.blockdev_create({ 'driver': imgfmt,
 | |
|                          'file': 'protocol-node',
 | |
|                          'size': size })
 | |
| 
 | |
| 
 | |
| # Successful image creation (explicit defaults)
 | |
| def explicit_defaults(vm, file_path):
 | |
|     iotests.log("=== Successful image creation (explicit defaults) ===")
 | |
|     iotests.log("")
 | |
| 
 | |
|     # 16 heads, 964 cyls/head, 17 secs/cyl
 | |
|     # (Close to 128 MB)
 | |
|     size = 16 * 964 * 17 * 512
 | |
| 
 | |
|     vm.blockdev_create({ 'driver': imgfmt,
 | |
|                          'file': 'protocol-node',
 | |
|                          'size': size,
 | |
|                          'subformat': 'dynamic',
 | |
|                          'force-size': False })
 | |
| 
 | |
| 
 | |
| # Successful image creation (non-default options)
 | |
| def non_defaults(vm, file_path):
 | |
|     iotests.log("=== Successful image creation (non-default options) ===")
 | |
|     iotests.log("")
 | |
| 
 | |
|     # Not representable in CHS (fine with force-size=True)
 | |
|     size = 1048576
 | |
| 
 | |
|     vm.blockdev_create({ 'driver': imgfmt,
 | |
|                          'file': 'protocol-node',
 | |
|                          'size': size,
 | |
|                          'subformat': 'fixed',
 | |
|                          'force-size': True })
 | |
| 
 | |
| 
 | |
| # Size not representable in CHS with force-size=False
 | |
| def non_chs_size_without_force(vm, file_path):
 | |
|     iotests.log("=== Size not representable in CHS ===")
 | |
|     iotests.log("")
 | |
| 
 | |
|     # Not representable in CHS (will not work with force-size=False)
 | |
|     size = 1048576
 | |
| 
 | |
|     vm.blockdev_create({ 'driver': imgfmt,
 | |
|                          'file': 'protocol-node',
 | |
|                          'size': size,
 | |
|                          'force-size': False })
 | |
| 
 | |
| 
 | |
| # Zero size
 | |
| def zero_size(vm, file_path):
 | |
|     iotests.log("=== Zero size===")
 | |
|     iotests.log("")
 | |
| 
 | |
|     vm.blockdev_create({ 'driver': imgfmt,
 | |
|                          'file': 'protocol-node',
 | |
|                          'size': 0 })
 | |
| 
 | |
| 
 | |
| # Maximum CHS size
 | |
| def maximum_chs_size(vm, file_path):
 | |
|     iotests.log("=== Maximum CHS size===")
 | |
|     iotests.log("")
 | |
| 
 | |
|     vm.blockdev_create({ 'driver': imgfmt,
 | |
|                          'file': 'protocol-node',
 | |
|                          'size': 16 * 65535 * 255 * 512 })
 | |
| 
 | |
| 
 | |
| # Actual maximum size
 | |
| def maximum_size(vm, file_path):
 | |
|     iotests.log("=== Actual maximum size===")
 | |
|     iotests.log("")
 | |
| 
 | |
|     vm.blockdev_create({ 'driver': imgfmt,
 | |
|                          'file': 'protocol-node',
 | |
|                          'size': 0xff000000 * 512,
 | |
|                          'force-size': True })
 | |
| 
 | |
| 
 | |
| def main():
 | |
|     for test_func in [implicit_defaults, explicit_defaults, non_defaults,
 | |
|                       non_chs_size_without_force, zero_size, maximum_chs_size,
 | |
|                       maximum_size]:
 | |
| 
 | |
|         with iotests.FilePath('t.vpc') as file_path, \
 | |
|              iotests.VM() as vm:
 | |
| 
 | |
|             vm.launch()
 | |
| 
 | |
|             iotests.log('--- Creating empty file ---')
 | |
|             vm.blockdev_create({ 'driver': 'file',
 | |
|                                  'filename': file_path,
 | |
|                                  'size': 0 })
 | |
| 
 | |
|             vm.qmp_log('blockdev-add', driver='file', filename=file_path,
 | |
|                        node_name='protocol-node',
 | |
|                        filters=[iotests.filter_qmp_testfiles])
 | |
|             iotests.log('')
 | |
| 
 | |
|             print_info = test_func(vm, file_path)
 | |
|             iotests.log('')
 | |
| 
 | |
|             vm.shutdown()
 | |
|             iotests.img_info_log(file_path)
 | |
| 
 | |
| 
 | |
| iotests.script_main(main,
 | |
|                     supported_fmts=['vpc'],
 | |
|                     supported_protocols=['file'])
 |