introduce QEMUMachind.cmd()
cover introduce QEMUMachind.cmd()
Hi all!
I always dreamed about getting rid of pattern
result = self.vm.qmp(...)
self.assert_qmp(result, 'return', {})Here is a suggestion to switch to
self.vm.cmd(...)
pattern instead.
I'm not sure we really want to update so many tests. May be just commit patch 01, and use new interface for new code. On the other hand, old code always used as an example to write the new one.
The series is based on John's python branch.
Vladimir Sementsov-Ogievskiy (2):
python/machine.py: upgrade vm.command() method
iotests: use vm.cmd() instead of vm.qmp() where appropriate
python/qemu/machine/machine.py | 16 +- tests/qemu-iotests/030 | 168 +++---- tests/qemu-iotests/040 | 167 +++--- tests/qemu-iotests/041 | 474 ++++++++---------- tests/qemu-iotests/045 | 15 +- tests/qemu-iotests/055 | 61 +-- tests/qemu-iotests/056 | 23 +- tests/qemu-iotests/093 | 41 +- tests/qemu-iotests/118 | 221 ++++---- tests/qemu-iotests/124 | 69 ++- tests/qemu-iotests/129 | 13 +- tests/qemu-iotests/132 | 5 +- tests/qemu-iotests/139 | 43 +- tests/qemu-iotests/147 | 30 +- tests/qemu-iotests/151 | 40 +- tests/qemu-iotests/155 | 53 +- tests/qemu-iotests/165 | 7 +- tests/qemu-iotests/196 | 3 +- tests/qemu-iotests/205 | 6 +- tests/qemu-iotests/245 | 245 ++++----- tests/qemu-iotests/256 | 34 +- tests/qemu-iotests/257 | 36 +- tests/qemu-iotests/264 | 31 +- tests/qemu-iotests/281 | 21 +- tests/qemu-iotests/295 | 27 +- tests/qemu-iotests/296 | 14 +- tests/qemu-iotests/298 | 13 +- tests/qemu-iotests/300 | 50 +- tests/qemu-iotests/iotests.py | 6 +- .../tests/migrate-bitmaps-postcopy-test | 31 +- tests/qemu-iotests/tests/migrate-bitmaps-test | 37 +- .../qemu-iotests/tests/migrate-during-backup | 40 +- .../qemu-iotests/tests/migration-permissions | 9 +- tests/qemu-iotests/tests/mirror-top-perms | 15 +- 34 files changed, 821 insertions(+), 1243 deletions(-)
Signature · 1 line
2.35.1
PATCH 1/2 python/machine.py: upgrade vm.command() method
The method is not popular, we prefer use vm.qmp() and then check success by hand.. But that's not optimal. To simplify movement to vm.command() support same interface improvements like in vm.qmp() and rename to shorter vm.cmd().
--- python/qemu/machine/machine.py | 16 ++++++++++++--- tests/qemu-iotests/256 | 34 ++++++++++++++++---------------- tests/qemu-iotests/257 | 36 +++++++++++++++++----------------- 3 files changed, 48 insertions(+), 38 deletions(-)
python/qemu/machine/machine.py +13 -3
@@ -648,14 +648,24 @@ def qmp(self, cmd: str, self._quit_issued = True return ret - def command(self, cmd: str, - conv_keys: bool = True, - **args: Any) -> QMPReturnValue: + def cmd(self, cmd: str, + args_dict: Optional[Dict[str, object]] = None, + conv_keys: Optional[bool] = None, + **args: Any) -> QMPReturnValue: """ Invoke a QMP command. On success return the response dict. On failure raise an exception. """ + if args_dict is not None: + assert not args + assert conv_keys is None + args = args_dict + conv_keys = False + + if conv_keys is None: + conv_keys = True + qmp_args = self._qmp_args(conv_keys, args) ret = self._qmp.command(cmd, **qmp_args) if cmd == 'quit':
tests/qemu-iotests/256 +17 -17
@@ -40,25 +40,25 @@ with iotests.FilePath('img0') as img0_path, \ def create_target(filepath, name, size): basename = os.path.basename(filepath) nodename = "file_{}".format(basename) - log(vm.command('blockdev-create', job_id='job1', - options={ - 'driver': 'file', - 'filename': filepath, - 'size': 0, - })) + log(vm.cmd('blockdev-create', job_id='job1', + options={ + 'driver': 'file', + 'filename': filepath, + 'size': 0, + })) vm.run_job('job1') - log(vm.command('blockdev-add', driver='file', - node_name=nodename, filename=filepath)) - log(vm.command('blockdev-create', job_id='job2', - options={ - 'driver': iotests.imgfmt, - 'file': nodename, - 'size': size, - })) + log(vm.cmd('blockdev-add', driver='file', + node_name=nodename, filename=filepath)) + log(vm.cmd('blockdev-create', job_id='job2', + options={ + 'driver': iotests.imgfmt, + 'file': nodename, + 'size': size, + })) vm.run_job('job2') - log(vm.command('blockdev-add', driver=iotests.imgfmt, - node_name=name, - file=nodename)) + log(vm.cmd('blockdev-add', driver=iotests.imgfmt, + node_name=name, + file=nodename)) log('--- Preparing images & VM ---\n') vm.add_object('iothread,id=iothread0')
tests/qemu-iotests/257 +18 -18
@@ -160,26 +160,26 @@ class Drive: file_node_name = "file_{}".format(basename) vm = self.vm - log(vm.command('blockdev-create', job_id='bdc-file-job', - options={ - 'driver': 'file', - 'filename': self.path, - 'size': 0, - })) + log(vm.cmd('blockdev-create', job_id='bdc-file-job', + options={ + 'driver': 'file', + 'filename': self.path, + 'size': 0, + })) vm.run_job('bdc-file-job') - log(vm.command('blockdev-add', driver='file', - node_name=file_node_name, filename=self.path)) - - log(vm.command('blockdev-create', job_id='bdc-fmt-job', - options={ - 'driver': fmt, - 'file': file_node_name, - 'size': size, - })) + log(vm.cmd('blockdev-add', driver='file', + node_name=file_node_name, filename=self.path)) + + log(vm.cmd('blockdev-create', job_id='bdc-fmt-job', + options={ + 'driver': fmt, + 'file': file_node_name, + 'size': size, + })) vm.run_job('bdc-fmt-job') - log(vm.command('blockdev-add', driver=fmt, - node_name=name, - file=file_node_name)) + log(vm.cmd('blockdev-add', driver=fmt, + node_name=name, + file=file_node_name)) self.fmt = fmt self.size = size self.node = name
Signature · 1 line
2.35.1
Re: [PATCH 1/2] python/machine.py: upgrade vm.command() method
Quoted 17 lines · Vladimir Sementsov-Ogievskiy
The method is not popular, we prefer use
vm.qmp()and then check success by hand.. But that's not optimal. To simplify movement tovm.command()support same interface improvements like invm.qmp()and rename to shortervm.cmd().Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- python/qemu/machine/machine.py | 16 ++++++++++++--- tests/qemu-iotests/256 | 34 ++++++++++++++++---------------- tests/qemu-iotests/257 | 36 +++++++++++++++++----------------- 3 files changed, 48 insertions(+), 38 deletions(-)python/qemu/machine/machine.py +0
-0
python/qemu/machine/machine.py def qmp(self, cmd: str, · line 651
Quoted 7 lines
python/qemu/machine/machine.py +1
-3@@ -648,14 +648,24 @@ def qmp(self, cmd: str, self._quit_issued = True return ret - def command(self, cmd: str, - conv_keys: bool = True, - **args: Any) -> QMPReturnValue: + def cmd(self, cmd: str,
FYI, the original 'command' name matches semantics of 'command' in the QEMUMonitorProtocol class. The QEMUMonitorProtocol class has a 'cmd' method that matches semantics of 'qmp' in QEMUMachine.
I think it is desirable to have consistency between naming in the two classes.
The current use of both 'cmd' and 'command' in QEMUMonitorProtocol is horrible naming though. How is anyone supposed to remember which name raises the exception and which doesn't ? Urgh.
I agree with your desire to simplify things, but if anything I would suggest we change both QEMUMonitorProtocol and QEMUMachine to have a convention more like python's subprocess module:
- 'cmd' runs without error checking, just returning the reply data as is
- 'check_cmd' calls 'cmd' but raises an exception on error.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 1/2] python/machine.py: upgrade vm.command() method
Quoted 33 lines · Daniel P. Berrangé
Quoted 5 lines · Vladimir Sementsov-Ogievskiy
The method is not popular, we prefer use
vm.qmp()and then check success by hand.. But that's not optimal. To simplify movement tovm.command()support same interface improvements like invm.qmp()and rename to shortervm.cmd().Review
Quoted 8 lines
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- python/qemu/machine/machine.py | 16 ++++++++++++--- tests/qemu-iotests/256 | 34 ++++++++++++++++---------------- tests/qemu-iotests/257 | 36 +++++++++++++++++----------------- 3 files changed, 48 insertions(+), 38 deletions(-)(quoted diff) +0
-0
b/python/qemu/machine/machine.pypython/qemu/machine/machine.py def qmp(self, cmd: str, · line 651
Quoted 11 lines
index
07ac5a710b..a3fb840b93100644python/qemu/machine/machine.py +1
-3@@ -648,14 +648,24 @@ def qmp(self, cmd: str, self._quit_issued = True return ret - def command(self, cmd: str, - conv_keys: bool = True, - **args: Any) -> QMPReturnValue: + def cmd(self, cmd: str,FYI, the original 'command' name matches semantics of 'command' in the QEMUMonitorProtocol class. The QEMUMonitorProtocol class has a 'cmd' method that matches semantics of 'qmp' in QEMUMachine.
Quoted 3 lines
I think it is desirable to have consistency between naming in the two classes.
Broadly agree.
Quoted 4 lines
The current use of both 'cmd' and 'command' in QEMUMonitorProtocol is horrible naming though. How is anyone supposed to remember which name raises the exception and which doesn't ? Urgh.
Also agree.
Quoted 9 lines
I agree with your desire to simplify things, but if anything I would suggest we change both QEMUMonitorProtocol and QEMUMachine to have a convention more like python's subprocess module:
- 'cmd' runs without error checking, just returning the reply data as is
- '
check_cmd' calls 'cmd' but raises an exception on error.
Not sure I'm on board here, though.
For what it's worth, in async qmp I added a single method "execute()", mimicking the name of the field used over the wire. It uses semantics like command() here, in that it raises an exception on error and returns only the response data and not the entire QMP response.
I'm in favor of, broadly, an approach wherein the default behavior raises an exception and the caller must opt-in to squelch it; either via try-except or a check=False argument. It should be a conscious decision.
(I realize this is not what the majority of iotests already does, but I consider that a problem to fix and not a feature. See also my recent efforts to make qemu_img() and qemu_io() raise a CalledProcessError by default to improve failed test diagnostics and remove logical errors from several iotests.)
Over time, I want to migrate machine.py off of the legacy.py interface and onto the native async qmp. I believe using asyncio subprocess and asyncio qmp will give better failure characteristics and better error readouts.
I've prototyped this a little, but it's a big project and there are still pre-requisites to hit before I worry about it too much. Maybe this summer I'll tackle it. Anyway, that's nobody else's problem right now, but I have a predisposition to not want to steer far away from what the async api provides. Just some roadmap info in case we need to collaborate better on the future of this module.
--js
Quoted 1 line
Re: [PATCH 1/2] python/machine.py: upgrade vm.command() method
Quoted 63 lines · John Snow
Quoted 33 lines · Daniel P. Berrangé
Quoted 5 lines · Vladimir Sementsov-Ogievskiy
The method is not popular, we prefer use
vm.qmp()and then check success by hand.. But that's not optimal. To simplify movement tovm.command()support same interface improvements like invm.qmp()and rename to shortervm.cmd().Review
Quoted 8 lines
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- python/qemu/machine/machine.py | 16 ++++++++++++--- tests/qemu-iotests/256 | 34 ++++++++++++++++---------------- tests/qemu-iotests/257 | 36 +++++++++++++++++----------------- 3 files changed, 48 insertions(+), 38 deletions(-)(quoted diff) +0
-0
b/python/qemu/machine/machine.pypython/qemu/machine/machine.py def qmp(self, cmd: str, · line 651
Quoted 11 lines
index
07ac5a710b..a3fb840b93100644python/qemu/machine/machine.py +1
-3@@ -648,14 +648,24 @@ def qmp(self, cmd: str, self._quit_issued = True return ret - def command(self, cmd: str, - conv_keys: bool = True, - **args: Any) -> QMPReturnValue: + def cmd(self, cmd: str,FYI, the original 'command' name matches semantics of 'command' in the QEMUMonitorProtocol class. The QEMUMonitorProtocol class has a 'cmd' method that matches semantics of 'qmp' in QEMUMachine.
Quoted 3 lines
I think it is desirable to have consistency between naming in the two classes.
Broadly agree.
Quoted 4 lines
The current use of both 'cmd' and 'command' in QEMUMonitorProtocol is horrible naming though. How is anyone supposed to remember which name raises the exception and which doesn't ? Urgh.
Also agree.
Quoted 9 lines
I agree with your desire to simplify things, but if anything I would suggest we change both QEMUMonitorProtocol and QEMUMachine to have a convention more like python's subprocess module:
- 'cmd' runs without error checking, just returning the reply data as is
- '
check_cmd' calls 'cmd' but raises an exception on error.Not sure I'm on board here, though.
Quoted 8 lines
For what it's worth, in async qmp I added a single method "
execute()", mimicking the name of the field used over the wire. It uses semantics likecommand()here, in that it raises an exception on error and returns only the response data and not the entire QMP response.I'm in favor of, broadly, an approach wherein the default behavior raises an exception and the caller must opt-in to squelch it; either via try-except or a check=False argument. It should be a conscious decision.
I'd be happy with a single 'cmd' method with 'check=False' to turn off exceptions on demand.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 1/2] python/machine.py: upgrade vm.command() method
In reply to Vladimir Sementsov-OgievskiyQuoted 1 line · Vladimir Sementsov-Ogievskiy
The method is not popular, we prefer use
vm.qmp()and then check
Suddenly I found, that I missed a lot of existing users: in scripts, in avocado tests.
Do you prefer to rename the method to "cmd()", and change all the occurrences, or keep longer "command()" name and update the second patch?
$ git grep '\.command('
docs/devel/testing.rst: res = self.vm.command('human-monitor-command',
docs/devel/testing.rst: first_res = first_machine.command(
docs/devel/testing.rst: second_res = second_machine.command(
docs/devel/testing.rst: third_res = self.get_vm(name='third_machine').command(
python/qemu/machine/machine.py: ret = self._qmp.command(cmd, **qmp_args)
python/qemu/utils/qemu_ga_client.py: return self.command('guest-' + name.replace('_', '-'), **kwds)
python/qemu/utils/qom.py: rsp = self.qmp.command(
python/qemu/utils/qom.py: rsp = self.qmp.command(
python/qemu/utils/qom.py: rsp = self.qmp.command('qom-get', path=path,
python/qemu/utils/qom_common.py: rsp = self.qmp.command('qom-list', path=path)
python/qemu/utils/qom_fuse.py: data = str(self.qmp.command('qom-get', path=path, property=prop))
python/qemu/utils/qom_fuse.py: return prefix + str(self.qmp.command('qom-get', path=path,
scripts/device-crash-test: types = vm.command('qom-list-types', **kwargs)
scripts/device-crash-test: devhelp = vm.command('human-monitor-command', **args)
scripts/device-crash-test: self.machines = list(m['name'] for m in vm.command('query-machines'))
scripts/device-crash-test: self.kvm_available = vm.command('query-kvm')['enabled']
scripts/render_block_graph.py: bds_nodes = qmp.command('query-named-block-nodes')
scripts/render_block_graph.py: job_nodes = qmp.command('query-block-jobs')
scripts/render_block_graph.py: block_graph = qmp.command('x-debug-query-block-graph')
tests/avocado/avocado_qemu/__init__.py: res = self.vm.command('human-monitor-command',
tests/avocado/cpu_queries.py: cpus = self.vm.command('query-cpu-definitions')
tests/avocado/cpu_queries.py: e = self.vm.command('query-cpu-model-expansion', model=model, type='full')
tests/avocado/hotplug_cpu.py: self.vm.command('device_add',
tests/avocado/info_usernet.py: res = self.vm.command('human-monitor-command',
tests/avocado/machine_arm_integratorcp.py: self.vm.command('human-monitor-command', command_line='stop')
tests/avocado/machine_arm_integratorcp.py: self.vm.command('human-monitor-command',
tests/avocado/machine_m68k_nextcube.py: self.vm.command('human-monitor-command',
tests/avocado/machine_mips_malta.py: self.vm.command('human-monitor-command', command_line='stop')
tests/avocado/machine_mips_malta.py: self.vm.command('human-monitor-command',
tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('device_del', id='rn1')
tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('device_del', id='rn2')
tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('device_add', driver='virtio-net-ccw',
tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('device_del', id='net_4711')
tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('human-monitor-command', command_line='balloon 96')
tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('human-monitor-command', command_line='balloon 128')
tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('screendump', filename=ppmfile.name)
tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('object-add', qom_type='cryptodev-backend-builtin',
tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('device_add', driver='virtio-crypto-ccw', id='crypdev0',
tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('device_del', id='crypdev0')
tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('object-del', id='cbe0')
tests/avocado/migration.py: return vm.command('query-migrate')['status'] in ('completed', 'failed')
tests/avocado/migration.py: self.assertEqual(src_vm.command('query-migrate')['status'], 'completed')
tests/avocado/migration.py: self.assertEqual(dst_vm.command('query-migrate')['status'], 'completed')
tests/avocado/migration.py: self.assertEqual(dst_vm.command('query-status')['status'], 'running')
tests/avocado/migration.py: self.assertEqual(src_vm.command('query-status')['status'],'postmigrate')
tests/avocado/pc_cpu_hotplug_props.py: self.assertEquals(len(self.vm.command('query-cpus-fast')), 2)
tests/avocado/version.py: res = self.vm.command('human-monitor-command',
tests/avocado/virtio_check_params.py: output = vm.command('human-monitor-command',
tests/avocado/virtio_check_params.py: machines = [m['name'] for m in vm.command('query-machines')]
tests/avocado/virtio_version.py: return devtype in [d['name'] for d in vm.command('qom-list-types', implements=implements)]
tests/avocado/virtio_version.py: pcibuses = vm.command('query-pci')
tests/avocado/x86_cpu_model_versions.py: cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
tests/avocado/x86_cpu_model_versions.py: cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
tests/avocado/x86_cpu_model_versions.py: cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
tests/avocado/x86_cpu_model_versions.py: cpu_path = self.vm.command('query-cpus-fast')[0].get('qom-path')
tests/avocado/x86_cpu_model_versions.py: return self.vm.command('qom-get', path=cpu_path, property=prop)
tests/docker/docker.py: dkr.command(cmd="pull", quiet=args.quiet,
tests/docker/docker.py: dkr.command(cmd="tag", quiet=args.quiet,
tests/docker/docker.py: return Docker().command("images", argv, args.quiet)
tests/migration/guestperf/engine.py: info = vm.command("query-migrate")
tests/migration/guestperf/engine.py: vcpus = src.command("query-cpus-fast")
tests/migration/guestperf/engine.py: resp = src.command("migrate-set-capabilities",
tests/migration/guestperf/engine.py: resp = src.command("migrate-set-parameters",
tests/migration/guestperf/engine.py: resp = src.command("migrate-set-capabilities",
tests/migration/guestperf/engine.py: resp = dst.command("migrate-set-capabilities",
tests/migration/guestperf/engine.py: resp = src.command("migrate-set-parameters",
tests/migration/guestperf/engine.py: resp = src.command("migrate-set-parameters",
tests/migration/guestperf/engine.py: resp = src.command("migrate-set-capabilities",
tests/migration/guestperf/engine.py: resp = src.command("migrate-set-parameters",
tests/migration/guestperf/engine.py: resp = dst.command("migrate-set-capabilities",
tests/migration/guestperf/engine.py: resp = dst.command("migrate-set-parameters",
tests/migration/guestperf/engine.py: resp = src.command("migrate-set-capabilities",
tests/migration/guestperf/engine.py: resp = dst.command("migrate-set-capabilities",
tests/migration/guestperf/engine.py: resp = src.command("migrate-set-parameters",
tests/migration/guestperf/engine.py: resp = src.command("migrate-set-capabilities",
tests/migration/guestperf/engine.py: resp = src.command("migrate-set-parameters",
tests/migration/guestperf/engine.py: resp = dst.command("migrate-set-capabilities",
tests/migration/guestperf/engine.py: resp = dst.command("migrate-set-parameters",
tests/migration/guestperf/engine.py: resp = src.command("migrate", uri=connect_uri)
tests/migration/guestperf/engine.py: dst.command("cont")
tests/migration/guestperf/engine.py: src.command("migrate_cancel")
tests/migration/guestperf/engine.py: src.command("migrate_cancel")
tests/migration/guestperf/engine.py: resp = src.command("migrate-start-postcopy")
tests/migration/guestperf/engine.py: resp = src.command("stop")Quoted 139 lines
success by hand.. But that's not optimal. To simplify movement to
vm.command()support same interface improvements like invm.qmp()and rename to shortervm.cmd().Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- python/qemu/machine/machine.py | 16 ++++++++++++--- tests/qemu-iotests/256 | 34 ++++++++++++++++---------------- tests/qemu-iotests/257 | 36 +++++++++++++++++----------------- 3 files changed, 48 insertions(+), 38 deletions(-)python/qemu/machine/machine.py +13
-3@@ -648,14 +648,24 @@ def qmp(self, cmd: str, self._quit_issued = True return ret - def command(self, cmd: str, - conv_keys: bool = True, - **args: Any) -> QMPReturnValue: + def cmd(self, cmd: str, + args_dict: Optional[Dict[str, object]] = None, + conv_keys: Optional[bool] = None, + **args: Any) -> QMPReturnValue: """ Invoke a QMP command. On success return the response dict. On failure raise an exception. """ + if args_dict is not None: + assert not args + assert conv_keys is None + args = args_dict + conv_keys = False + + if conv_keys is None: + conv_keys = True + qmp_args = self._qmp_args(conv_keys, args) ret = self._qmp.command(cmd, **qmp_args) if cmd == 'quit':tests/qemu-iotests/256 +17
-17@@ -40,25 +40,25 @@ with iotests.FilePath('img0') as img0_path, \ def create_target(filepath, name, size): basename = os.path.basename(filepath) nodename = "file_{}".format(basename) - log(vm.command('blockdev-create', job_id='job1', - options={ - 'driver': 'file', - 'filename': filepath, - 'size': 0, - })) + log(vm.cmd('blockdev-create', job_id='job1', + options={ + 'driver': 'file', + 'filename': filepath, + 'size': 0, + })) vm.run_job('job1') - log(vm.command('blockdev-add', driver='file', - node_name=nodename, filename=filepath)) - log(vm.command('blockdev-create', job_id='job2', - options={ - 'driver': iotests.imgfmt, - 'file': nodename, - 'size': size, - })) + log(vm.cmd('blockdev-add', driver='file', + node_name=nodename, filename=filepath)) + log(vm.cmd('blockdev-create', job_id='job2', + options={ + 'driver': iotests.imgfmt, + 'file': nodename, + 'size': size, + })) vm.run_job('job2') - log(vm.command('blockdev-add', driver=iotests.imgfmt, - node_name=name, - file=nodename)) + log(vm.cmd('blockdev-add', driver=iotests.imgfmt, + node_name=name, + file=nodename)) log('--- Preparing images & VM ---\n') vm.add_object('iothread,id=iothread0')tests/qemu-iotests/257 +18
-18@@ -160,26 +160,26 @@ class Drive: file_node_name = "file_{}".format(basename) vm = self.vm - log(vm.command('blockdev-create', job_id='bdc-file-job', - options={ - 'driver': 'file', - 'filename': self.path, - 'size': 0, - })) + log(vm.cmd('blockdev-create', job_id='bdc-file-job', + options={ + 'driver': 'file', + 'filename': self.path, + 'size': 0, + })) vm.run_job('bdc-file-job') - log(vm.command('blockdev-add', driver='file', - node_name=file_node_name, filename=self.path)) - - log(vm.command('blockdev-create', job_id='bdc-fmt-job', - options={ - 'driver': fmt, - 'file': file_node_name, - 'size': size, - })) + log(vm.cmd('blockdev-add', driver='file', + node_name=file_node_name, filename=self.path)) + + log(vm.cmd('blockdev-create', job_id='bdc-fmt-job', + options={ + 'driver': fmt, + 'file': file_node_name, + 'size': size, + })) vm.run_job('bdc-fmt-job') - log(vm.command('blockdev-add', driver=fmt, - node_name=name, - file=file_node_name)) + log(vm.cmd('blockdev-add', driver=fmt, + node_name=name, + file=file_node_name)) self.fmt = fmt self.size = size self.node = name
Signature · 2 lines
Best regards, Vladimir
Re: [PATCH 1/2] python/machine.py: upgrade vm.command() method
Quoted 9 lines · Vladimir Sementsov-Ogievskiy
Quoted 1 line · Vladimir Sementsov-Ogievskiy
The method is not popular, we prefer use
vm.qmp()and then checkSuddenly I found, that I missed a lot of existing users: in scripts, in avocado tests.
Do you prefer to rename the method to "
cmd()", and change all the occurrences, or keep longer "command()" name and update the second patch?
I don't have a strong preference, I think.
In (async) qmp I use .execute() as the form that raises exception, and ._raw() as the form that doesn't. I use execute_msg() as an exception-raising form that takes a Mapping[str, obj].
Notably, I tried to hide any interface that didn't raise exception, and the interfaces that remain always return the inner return field and not the entire wire object.
command() IIRC has historically been the exception-raising version and cmd() has been the C-like version. (cmd_obj works like my execute_msg, except it doesn't raise, and returns the entire reply.)
command() is longer, but there's precedent and continuity for it working this way. But shorter names are nicer for line length, so...
...Go with what you feel is subjectively nicest? (That's not helpful, sorry.)
oh, also: IIRC, command() also does not return the entire response object. This is how execute() works, but it might be a lot of churn to convert users of cmd() over to this form. It's something I want to do eventually anyway, but it's a lot for me to dump on your plate, so don't worry about that aspect.
--js
Quoted 312 lines
$ git grep '\.command(' docs/devel/testing.rst: res = self.vm.command('human-monitor-command', docs/devel/testing.rst: first_res = first_machine.command( docs/devel/testing.rst: second_res = second_machine.command( docs/devel/testing.rst: third_res = self.get_vm(name='third_machine').command( python/qemu/machine/machine.py: ret = self._qmp.command(cmd, **qmp_args) python/qemu/utils/qemu_ga_client.py: return self.command('guest-' + name.replace('_', '-'), **kwds) python/qemu/utils/qom.py: rsp = self.qmp.command( python/qemu/utils/qom.py: rsp = self.qmp.command( python/qemu/utils/qom.py: rsp = self.qmp.command('qom-get', path=path, python/qemu/utils/qom_common.py: rsp = self.qmp.command('qom-list', path=path) python/qemu/utils/qom_fuse.py: data = str(self.qmp.command('qom-get', path=path, property=prop)) python/qemu/utils/qom_fuse.py: return prefix + str(self.qmp.command('qom-get', path=path, scripts/device-crash-test: types = vm.command('qom-list-types', **kwargs) scripts/device-crash-test: devhelp = vm.command('human-monitor-command', **args) scripts/device-crash-test: self.machines = list(m['name'] for m in vm.command('query-machines')) scripts/device-crash-test: self.kvm_available = vm.command('query-kvm')['enabled'] scripts/render_block_graph.py: bds_nodes = qmp.command('query-named-block-nodes') scripts/render_block_graph.py: job_nodes = qmp.command('query-block-jobs') scripts/render_block_graph.py: block_graph = qmp.command('x-debug-query-block-graph') tests/avocado/avocado_qemu/__init__.py: res = self.vm.command('human-monitor-command', tests/avocado/cpu_queries.py: cpus = self.vm.command('query-cpu-definitions') tests/avocado/cpu_queries.py: e = self.vm.command('query-cpu-model-expansion', model=model, type='full') tests/avocado/hotplug_cpu.py: self.vm.command('device_add', tests/avocado/info_usernet.py: res = self.vm.command('human-monitor-command', tests/avocado/machine_arm_integratorcp.py: self.vm.command('human-monitor-command', command_line='stop') tests/avocado/machine_arm_integratorcp.py: self.vm.command('human-monitor-command', tests/avocado/machine_m68k_nextcube.py: self.vm.command('human-monitor-command', tests/avocado/machine_mips_malta.py: self.vm.command('human-monitor-command', command_line='stop') tests/avocado/machine_mips_malta.py: self.vm.command('human-monitor-command', tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('device_del', id='rn1') tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('device_del', id='rn2') tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('device_add', driver='virtio-net-ccw', tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('device_del', id='net_4711') tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('human-monitor-command', command_line='balloon 96') tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('human-monitor-command', command_line='balloon 128') tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('screendump', filename=ppmfile.name) tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('object-add', qom_type='cryptodev-backend-builtin', tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('device_add', driver='virtio-crypto-ccw', id='crypdev0', tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('device_del', id='crypdev0') tests/avocado/machine_s390_ccw_virtio.py: self.vm.command('object-del', id='cbe0') tests/avocado/migration.py: return vm.command('query-migrate')['status'] in ('completed', 'failed') tests/avocado/migration.py: self.assertEqual(src_vm.command('query-migrate')['status'], 'completed') tests/avocado/migration.py: self.assertEqual(dst_vm.command('query-migrate')['status'], 'completed') tests/avocado/migration.py: self.assertEqual(dst_vm.command('query-status')['status'], 'running') tests/avocado/migration.py: self.assertEqual(src_vm.command('query-status')['status'],'postmigrate') tests/avocado/pc_cpu_hotplug_props.py: self.assertEquals(len(self.vm.command('query-cpus-fast')), 2) tests/avocado/version.py: res = self.vm.command('human-monitor-command', tests/avocado/virtio_check_params.py: output = vm.command('human-monitor-command', tests/avocado/virtio_check_params.py: machines = [m['name'] for m in vm.command('query-machines')] tests/avocado/virtio_version.py: return devtype in [d['name'] for d in vm.command('qom-list-types', implements=implements)] tests/avocado/virtio_version.py: pcibuses = vm.command('query-pci') tests/avocado/x86_cpu_model_versions.py: cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions')) tests/avocado/x86_cpu_model_versions.py: cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions')) tests/avocado/x86_cpu_model_versions.py: cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions')) tests/avocado/x86_cpu_model_versions.py: cpu_path = self.vm.command('query-cpus-fast')[0].get('qom-path') tests/avocado/x86_cpu_model_versions.py: return self.vm.command('qom-get', path=cpu_path, property=prop) tests/docker/docker.py: dkr.command(cmd="pull", quiet=args.quiet, tests/docker/docker.py: dkr.command(cmd="tag", quiet=args.quiet, tests/docker/docker.py: return Docker().command("images", argv, args.quiet) tests/migration/guestperf/engine.py: info = vm.command("query-migrate") tests/migration/guestperf/engine.py: vcpus = src.command("query-cpus-fast") tests/migration/guestperf/engine.py: resp = src.command("migrate-set-capabilities", tests/migration/guestperf/engine.py: resp = src.command("migrate-set-parameters", tests/migration/guestperf/engine.py: resp = src.command("migrate-set-capabilities", tests/migration/guestperf/engine.py: resp = dst.command("migrate-set-capabilities", tests/migration/guestperf/engine.py: resp = src.command("migrate-set-parameters", tests/migration/guestperf/engine.py: resp = src.command("migrate-set-parameters", tests/migration/guestperf/engine.py: resp = src.command("migrate-set-capabilities", tests/migration/guestperf/engine.py: resp = src.command("migrate-set-parameters", tests/migration/guestperf/engine.py: resp = dst.command("migrate-set-capabilities", tests/migration/guestperf/engine.py: resp = dst.command("migrate-set-parameters", tests/migration/guestperf/engine.py: resp = src.command("migrate-set-capabilities", tests/migration/guestperf/engine.py: resp = dst.command("migrate-set-capabilities", tests/migration/guestperf/engine.py: resp = src.command("migrate-set-parameters", tests/migration/guestperf/engine.py: resp = src.command("migrate-set-capabilities", tests/migration/guestperf/engine.py: resp = src.command("migrate-set-parameters", tests/migration/guestperf/engine.py: resp = dst.command("migrate-set-capabilities", tests/migration/guestperf/engine.py: resp = dst.command("migrate-set-parameters", tests/migration/guestperf/engine.py: resp = src.command("migrate", uri=connect_uri) tests/migration/guestperf/engine.py: dst.command("cont") tests/migration/guestperf/engine.py: src.command("migrate_cancel") tests/migration/guestperf/engine.py: src.command("migrate_cancel") tests/migration/guestperf/engine.py: resp = src.command("migrate-start-postcopy") tests/migration/guestperf/engine.py: resp = src.command("stop")Quoted 4 lines
success by hand.. But that's not optimal. To simplify movement to
vm.command()support same interface improvements like invm.qmp()and rename to shortervm.cmd().Review
Quoted 8 lines
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- python/qemu/machine/machine.py | 16 ++++++++++++--- tests/qemu-iotests/256 | 34 ++++++++++++++++---------------- tests/qemu-iotests/257 | 36 +++++++++++++++++----------------- 3 files changed, 48 insertions(+), 38 deletions(-)(quoted diff) +0
-0
b/python/qemu/machine/machine.pyQuoted 117 lines
index
07ac5a710b..a3fb840b93100644python/qemu/machine/machine.py +13
-3@@ -648,14 +648,24 @@ def qmp(self, cmd: str, self._quit_issued = True return ret - def command(self, cmd: str, - conv_keys: bool = True, - **args: Any) -> QMPReturnValue: + def cmd(self, cmd: str, + args_dict: Optional[Dict[str, object]] = None, + conv_keys: Optional[bool] = None, + **args: Any) -> QMPReturnValue: """ Invoke a QMP command. On success return the response dict. On failure raise an exception. """ + if args_dict is not None: + assert not args + assert conv_keys is None + args = args_dict + conv_keys = False + + if conv_keys is None: + conv_keys = True + qmp_args = self._qmp_args(conv_keys, args) ret = self._qmp.command(cmd, **qmp_args) if cmd == 'quit':tests/qemu-iotests/256 +17
-17@@ -40,25 +40,25 @@ with iotests.FilePath('img0') as img0_path, \ def create_target(filepath, name, size): basename = os.path.basename(filepath) nodename = "file_{}".format(basename) - log(vm.command('blockdev-create', job_id='job1', - options={ - 'driver': 'file', - 'filename': filepath, - 'size': 0, - })) + log(vm.cmd('blockdev-create', job_id='job1', + options={ + 'driver': 'file', + 'filename': filepath, + 'size': 0, + })) vm.run_job('job1') - log(vm.command('blockdev-add', driver='file', - node_name=nodename, filename=filepath)) - log(vm.command('blockdev-create', job_id='job2', - options={ - 'driver': iotests.imgfmt, - 'file': nodename, - 'size': size, - })) + log(vm.cmd('blockdev-add', driver='file', + node_name=nodename, filename=filepath)) + log(vm.cmd('blockdev-create', job_id='job2', + options={ + 'driver': iotests.imgfmt, + 'file': nodename, + 'size': size, + })) vm.run_job('job2') - log(vm.command('blockdev-add', driver=iotests.imgfmt, - node_name=name, - file=nodename)) + log(vm.cmd('blockdev-add', driver=iotests.imgfmt, + node_name=name, + file=nodename)) log('--- Preparing images & VM ---\n') vm.add_object('iothread,id=iothread0')tests/qemu-iotests/257 +15
-15@@ -160,26 +160,26 @@ class Drive: file_node_name = "file_{}".format(basename) vm = self.vm - log(vm.command('blockdev-create', job_id='bdc-file-job', - options={ - 'driver': 'file', - 'filename': self.path, - 'size': 0, - })) + log(vm.cmd('blockdev-create', job_id='bdc-file-job', + options={ + 'driver': 'file', + 'filename': self.path, + 'size': 0, + })) vm.run_job('bdc-file-job') - log(vm.command('blockdev-add', driver='file', - node_name=file_node_name, filename=self.path)) - - log(vm.command('blockdev-create', job_id='bdc-fmt-job', - options={ - 'driver': fmt, - 'file': file_node_name, - 'size': size, - })) + log(vm.cmd('blockdev-add', driver='file', + node_name=file_node_name, filename=self.path)) + + log(vm.cmd('blockdev-create', job_id='bdc-fmt-job', + options={ + 'driver': fmt, + 'file': file_node_name, + 'size': size, + }))tests/qemu-iotests/257 class Drive: · line 185
Quoted 10 lines
tests/qemu-iotests/257 +3
-3vm.run_job('bdc-fmt-job') - log(vm.command('blockdev-add', driver=fmt, - node_name=name, - file=file_node_name)) + log(vm.cmd('blockdev-add', driver=fmt, + node_name=name, + file=file_node_name)) self.fmt = fmt self.size = size self.node = name--
Best regards,
Vladimir
PATCH 2/2 iotests: use vm.cmd() instead of vm.qmp() where appropriate
In reply to Vladimir Sementsov-OgievskiyChecking success by hand every time is tedious. Let's use cmd() method instead which does this check for us.
--- tests/qemu-iotests/030 | 168 +++---- tests/qemu-iotests/040 | 167 +++--- tests/qemu-iotests/041 | 474 ++++++++---------- tests/qemu-iotests/045 | 15 +- tests/qemu-iotests/055 | 61 +-- tests/qemu-iotests/056 | 23 +- tests/qemu-iotests/093 | 41 +- tests/qemu-iotests/118 | 221 ++++---- tests/qemu-iotests/124 | 69 ++- tests/qemu-iotests/129 | 13 +- tests/qemu-iotests/132 | 5 +- tests/qemu-iotests/139 | 43 +- tests/qemu-iotests/147 | 30 +- tests/qemu-iotests/151 | 40 +- tests/qemu-iotests/155 | 53 +- tests/qemu-iotests/165 | 7 +- tests/qemu-iotests/196 | 3 +- tests/qemu-iotests/205 | 6 +- tests/qemu-iotests/245 | 245 ++++----- tests/qemu-iotests/264 | 31 +- tests/qemu-iotests/281 | 21 +- tests/qemu-iotests/295 | 27 +- tests/qemu-iotests/296 | 14 +- tests/qemu-iotests/298 | 13 +- tests/qemu-iotests/300 | 50 +- tests/qemu-iotests/iotests.py | 6 +- .../tests/migrate-bitmaps-postcopy-test | 31 +- tests/qemu-iotests/tests/migrate-bitmaps-test | 37 +- .../qemu-iotests/tests/migrate-during-backup | 40 +- .../qemu-iotests/tests/migration-permissions | 9 +- tests/qemu-iotests/tests/mirror-top-perms | 15 +- 31 files changed, 773 insertions(+), 1205 deletions(-)
tests/qemu-iotests/030 +62 -106
@@ -56,8 +56,7 @@ class TestSingleDrive(iotests.QMPTestCase): def test_stream(self): self.assert_no_active_block_jobs() - result = self.vm.qmp('block-stream', device='drive0') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0') self.wait_until_completed()
@@ -75,8 +74,7 @@ class TestSingleDrive(iotests.QMPTestCase): qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', mid_img), 'image file map matches backing file before streaming') - result = self.vm.qmp('block-stream', device='mid', job_id='stream-mid') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='mid', job_id='stream-mid') self.wait_until_completed(drive='stream-mid')
@@ -91,8 +89,7 @@ class TestSingleDrive(iotests.QMPTestCase): self.assert_no_active_block_jobs() self.vm.pause_drive('drive0') - result = self.vm.qmp('block-stream', device='drive0') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0') self.pause_job('drive0', wait=False) self.vm.resume_drive('drive0')
@@ -105,8 +102,7 @@ class TestSingleDrive(iotests.QMPTestCase): result = self.vm.qmp('query-block-jobs') self.assert_qmp(result, 'return[0]/offset', offset) - result = self.vm.qmp('block-job-resume', device='drive0') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-resume', device='drive0') self.wait_until_completed()
@@ -124,8 +120,7 @@ class TestSingleDrive(iotests.QMPTestCase): empty_map = qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', test_img) # This is a no-op: no data should ever be copied from the base image - result = self.vm.qmp('block-stream', device='drive0', base=mid_img) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0', base=mid_img) self.wait_until_completed()
@@ -138,8 +133,7 @@ class TestSingleDrive(iotests.QMPTestCase): def test_stream_partial(self): self.assert_no_active_block_jobs() - result = self.vm.qmp('block-stream', device='drive0', base=backing_img) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0', base=backing_img) self.wait_until_completed()
@@ -165,24 +159,22 @@ class TestSingleDrive(iotests.QMPTestCase): qemu_img('create', '-f', iotests.imgfmt, ro_top_path, str(self.image_len)) - result = self.vm.qmp('blockdev-add', - node_name='ro-top', - driver=iotests.imgfmt, - read_only=True, - file={ - 'driver': 'file', - 'filename': ro_top_path, - 'read-only': True - }, - backing='mid') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('blockdev-add', + node_name='ro-top', + driver=iotests.imgfmt, + read_only=True, + file={ + 'driver': 'file', + 'filename': ro_top_path, + 'read-only': True + }, + backing='mid') result = self.vm.qmp('block-stream', job_id='stream', device='ro-top', base_node='base') self.assert_qmp(result, 'error/desc', 'Block node is read-only') - result = self.vm.qmp('blockdev-del', node_name='ro-top') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('blockdev-del', node_name='ro-top') class TestParallelOps(iotests.QMPTestCase):
@@ -246,10 +238,9 @@ class TestParallelOps(iotests.QMPTestCase): node_name = 'node%d' % i job_id = 'stream-%s' % node_name pending_jobs.append(job_id) - result = self.vm.qmp('block-stream', device=node_name, - job_id=job_id, bottom=f'node{i-1}', - speed=1024) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device=node_name, + job_id=job_id, bottom=f'node{i-1}', + speed=1024) # Do this in reverse: After unthrottling them, some jobs may finish # before we have unthrottled all of them. This will drain their
@@ -261,8 +252,7 @@ class TestParallelOps(iotests.QMPTestCase): # Starting from the top (i.e. in reverse) does not have this problem: # When a job finishes, the ones below it are not advanced. for job in reversed(pending_jobs): - result = self.vm.qmp('block-job-set-speed', device=job, speed=0) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-set-speed', device=job, speed=0) # Wait for all jobs to be finished. while len(pending_jobs) > 0:
@@ -288,10 +278,9 @@ class TestParallelOps(iotests.QMPTestCase): self.assert_no_active_block_jobs() # Set a speed limit to make sure that this job blocks the rest - result = self.vm.qmp('block-stream', device='node4', - job_id='stream-node4', base=self.imgs[1], - filter_node_name='stream-filter', speed=1024*1024) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='node4', + job_id='stream-node4', base=self.imgs[1], + filter_node_name='stream-filter', speed=1024*1024) result = self.vm.qmp('block-stream', device='node5', job_id='stream-node5', base=self.imgs[2]) self.assert_qmp(result, 'error/desc',
@@ -319,8 +308,7 @@ class TestParallelOps(iotests.QMPTestCase): self.assert_qmp(result, 'error/desc', "Node 'node2' is busy: block device is in use by block job: stream") - result = self.vm.qmp('block-job-set-speed', device='stream-node4', speed=0) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-set-speed', device='stream-node4', speed=0) self.wait_until_completed(drive='stream-node4') self.assert_no_active_block_jobs()
@@ -332,8 +320,7 @@ class TestParallelOps(iotests.QMPTestCase): self.assert_no_active_block_jobs() # Set a speed limit to make sure that this job blocks the rest - result = self.vm.qmp('block-commit', device='drive0', top=self.imgs[5], base=self.imgs[3], job_id='commit-node3', speed=1024*1024) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-commit', device='drive0', top=self.imgs[5], base=self.imgs[3], job_id='commit-node3', speed=1024*1024) result = self.vm.qmp('block-stream', device='node3', job_id='stream-node3') self.assert_qmp(result, 'error/desc',
@@ -356,8 +343,7 @@ class TestParallelOps(iotests.QMPTestCase): self.assert_qmp(result, 'error/desc', "Node 'drive0' is busy: block device is in use by block job: commit") - result = self.vm.qmp('block-job-set-speed', device='commit-node3', speed=0) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-set-speed', device='commit-node3', speed=0) self.wait_until_completed(drive='commit-node3')
@@ -368,23 +354,20 @@ class TestParallelOps(iotests.QMPTestCase): self.assert_no_active_block_jobs() # Set a speed limit to make sure that this job blocks the rest - result = self.vm.qmp('block-commit', device='drive0', base=self.imgs[3], job_id='commit-drive0', speed=1024*1024) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-commit', device='drive0', base=self.imgs[3], job_id='commit-drive0', speed=1024*1024) result = self.vm.qmp('block-stream', device='node5', base=self.imgs[3], job_id='stream-node6') self.assert_qmp(result, 'error/desc', "Node 'node5' is busy: block device is in use by block job: commit") - result = self.vm.qmp('block-job-set-speed', device='commit-drive0', speed=0) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-set-speed', device='commit-drive0', speed=0) event = self.vm.event_wait(name='BLOCK_JOB_READY') self.assert_qmp(event, 'data/device', 'commit-drive0') self.assert_qmp(event, 'data/type', 'commit') self.assert_qmp_absent(event, 'data/error') - result = self.vm.qmp('block-job-complete', device='commit-drive0') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-complete', device='commit-drive0') self.wait_until_completed(drive='commit-drive0')
@@ -395,18 +378,16 @@ class TestParallelOps(iotests.QMPTestCase): self.assert_no_active_block_jobs() # Commit from node2 into node0 - result = self.vm.qmp('block-commit', device='drive0', - top=self.imgs[2], base=self.imgs[0], - filter_node_name='commit-filter', speed=1024*1024) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-commit', device='drive0', + top=self.imgs[2], base=self.imgs[0], + filter_node_name='commit-filter', speed=1024*1024) # Stream from node2 into node4 result = self.vm.qmp('block-stream', device='node4', base_node='node2', job_id='node4') self.assert_qmp(result, 'error/desc', "Cannot freeze 'backing' link to 'commit-filter'") - result = self.vm.qmp('block-job-set-speed', device='drive0', speed=0) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-set-speed', device='drive0', speed=0) self.wait_until_completed() self.assert_no_active_block_jobs()
@@ -419,18 +400,15 @@ class TestParallelOps(iotests.QMPTestCase): self.assert_no_active_block_jobs() # Commit from node2 into node0 - result = self.vm.qmp('block-commit', device='drive0', - top_node='node2', base_node='node0', - filter_node_name='commit-filter', speed=1024*1024) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-commit', device='drive0', + top_node='node2', base_node='node0', + filter_node_name='commit-filter', speed=1024*1024) # Stream from node2 into node4 - result = self.vm.qmp('block-stream', device='node4', - base_node='commit-filter', job_id='node4') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='node4', + base_node='commit-filter', job_id='node4') - result = self.vm.qmp('block-job-set-speed', device='drive0', speed=0) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-set-speed', device='drive0', speed=0) self.vm.run_job(job='drive0', auto_dismiss=True) self.vm.run_job(job='node4', auto_dismiss=True)
@@ -449,12 +427,10 @@ class TestParallelOps(iotests.QMPTestCase): self.assert_no_active_block_jobs() # Stream from node0 into node2 - result = self.vm.qmp('block-stream', device='node2', base_node='node0', job_id='node2') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='node2', base_node='node0', job_id='node2') # Commit from the active layer into node3 - result = self.vm.qmp('block-commit', device='drive0', base=self.imgs[3]) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-commit', device='drive0', base=self.imgs[3]) # Wait for all jobs to be finished. pending_jobs = ['node2', 'drive0']
@@ -481,16 +457,13 @@ class TestParallelOps(iotests.QMPTestCase): self.assert_no_active_block_jobs() # Stream from node0 into node4 - result = self.vm.qmp('block-stream', device='node4', base_node='node0', job_id='node4', speed=1024*1024) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='node4', base_node='node0', job_id='node4', speed=1024*1024) # Commit from the active layer into node5 - result = self.vm.qmp('block-commit', device='drive0', base=self.imgs[5], speed=1024*1024) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-commit', device='drive0', base=self.imgs[5], speed=1024*1024) for job in ['drive0', 'node4']: - result = self.vm.qmp('block-job-set-speed', device=job, speed=0) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-set-speed', device=job, speed=0) # Wait for all jobs to be finished. pending_jobs = ['node4', 'drive0']
@@ -539,8 +512,7 @@ class TestParallelOps(iotests.QMPTestCase): "'base' and 'base-node' cannot be specified at the same time") # Success: the base node is a backing file of the top node - result = self.vm.qmp('block-stream', device='node4', base_node='node2', job_id='stream') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='node4', base_node='node2', job_id='stream') self.wait_until_completed(drive='stream')
@@ -594,8 +566,7 @@ class TestQuorum(iotests.QMPTestCase): self.assert_no_active_block_jobs() - result = self.vm.qmp('block-stream', device='node0', job_id='stream-node0') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='node0', job_id='stream-node0') self.wait_until_completed(drive='stream-node0')
@@ -623,8 +594,7 @@ class TestSmallerBackingFile(iotests.QMPTestCase): def test_stream(self): self.assert_no_active_block_jobs() - result = self.vm.qmp('block-stream', device='drive0') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0') self.wait_until_completed()
@@ -681,8 +651,7 @@ class TestEIO(TestErrors): def test_report(self): self.assert_no_active_block_jobs() - result = self.vm.qmp('block-stream', device='drive0') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0') completed = False error = False
@@ -709,8 +678,7 @@ class TestEIO(TestErrors): def test_ignore(self): self.assert_no_active_block_jobs() - result = self.vm.qmp('block-stream', device='drive0', on_error='ignore') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0', on_error='ignore') error = False completed = False
@@ -743,8 +711,7 @@ class TestEIO(TestErrors): def test_stop(self): self.assert_no_active_block_jobs() - result = self.vm.qmp('block-stream', device='drive0', on_error='stop') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0', on_error='stop') error = False completed = False
@@ -766,8 +733,7 @@ class TestEIO(TestErrors): self.assert_qmp(result, 'return[0]/offset', self.STREAM_BUFFER_SIZE) self.assert_qmp(result, 'return[0]/io-status', 'failed') - result = self.vm.qmp('block-job-resume', device='drive0') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-resume', device='drive0') result = self.vm.qmp('query-block-jobs') if result == {'return': []}:
@@ -793,8 +759,7 @@ class TestEIO(TestErrors): def test_enospc(self): self.assert_no_active_block_jobs() - result = self.vm.qmp('block-stream', device='drive0', on_error='enospc') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0', on_error='enospc') completed = False error = False
@@ -839,8 +804,7 @@ class TestENOSPC(TestErrors): def test_enospc(self): self.assert_no_active_block_jobs() - result = self.vm.qmp('block-stream', device='drive0', on_error='enospc') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0', on_error='enospc') error = False completed = False
@@ -862,8 +826,7 @@ class TestENOSPC(TestErrors): self.assert_qmp(result, 'return[0]/offset', self.STREAM_BUFFER_SIZE) self.assert_qmp(result, 'return[0]/io-status', 'nospace') - result = self.vm.qmp('block-job-resume', device='drive0') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-resume', device='drive0') result = self.vm.qmp('query-block-jobs') if result == {'return': []}:
@@ -908,8 +871,7 @@ class TestStreamStop(iotests.QMPTestCase): self.assert_no_active_block_jobs() self.vm.pause_drive('drive0') - result = self.vm.qmp('block-stream', device='drive0') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0') time.sleep(0.1) events = self.vm.get_qmp_events(wait=False)
@@ -942,11 +904,9 @@ class TestSetSpeed(iotests.QMPTestCase): def perf_test_throughput(self): self.assert_no_active_block_jobs() - result = self.vm.qmp('block-stream', device='drive0') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0') - result = self.vm.qmp('block-job-set-speed', device='drive0', speed=8 * 1024 * 1024) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-set-speed', device='drive0', speed=8 * 1024 * 1024) self.wait_until_completed()
@@ -956,16 +916,14 @@ class TestSetSpeed(iotests.QMPTestCase): self.assert_no_active_block_jobs() self.vm.pause_drive('drive0') - result = self.vm.qmp('block-stream', device='drive0') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0') # Default speed is 0 result = self.vm.qmp('query-block-jobs') self.assert_qmp(result, 'return[0]/device', 'drive0') self.assert_qmp(result, 'return[0]/speed', 0) - result = self.vm.qmp('block-job-set-speed', device='drive0', speed=8 * 1024 * 1024) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-set-speed', device='drive0', speed=8 * 1024 * 1024) # Ensure the speed we set was accepted result = self.vm.qmp('query-block-jobs')
@@ -976,8 +934,7 @@ class TestSetSpeed(iotests.QMPTestCase): self.vm.pause_drive('drive0') # Check setting speed in block-stream works - result = self.vm.qmp('block-stream', device='drive0', speed=4 * 1024 * 1024) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0', speed=4 * 1024 * 1024) result = self.vm.qmp('query-block-jobs') self.assert_qmp(result, 'return[0]/device', 'drive0')
@@ -994,8 +951,7 @@ class TestSetSpeed(iotests.QMPTestCase): self.assert_no_active_block_jobs() self.vm.pause_drive('drive0') - result = self.vm.qmp('block-stream', device='drive0') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-stream', device='drive0') result = self.vm.qmp('block-job-set-speed', device='drive0', speed=-1) self.assert_qmp(result, 'error/desc', "Parameter 'speed' expects a non-negative value")
tests/qemu-iotests/040 +69 -98
301 lines not on this page · raw message
tests/qemu-iotests/041 +201 -273
811 lines not on this page · raw message
tests/qemu-iotests/045 +5 -10
@@ -77,8 +77,7 @@ class TestFdSets(iotests.QMPTestCase): self.vm.shutdown() def test_remove_fdset(self): - result = self.vm.qmp('remove-fd', fdset_id=2) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('remove-fd', fdset_id=2) result = self.vm.qmp('query-fdsets') self.assert_qmp(result, 'return[0]/fdset-id', 1) self.assert_qmp(result, 'return[1]/fdset-id', 0)
@@ -90,8 +89,7 @@ class TestFdSets(iotests.QMPTestCase): def test_remove_fd(self): result = self.vm.qmp('query-fdsets') fd_image3 = result['return'][0]['fds'][0]['fd'] - result = self.vm.qmp('remove-fd', fdset_id=2, fd=fd_image3) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('remove-fd', fdset_id=2, fd=fd_image3) result = self.vm.qmp('query-fdsets') self.assert_qmp(result, 'return[0]/fdset-id', 2) self.assert_qmp(result, 'return[1]/fdset-id', 1)
@@ -151,8 +149,7 @@ class TestSCMFd(iotests.QMPTestCase): def test_getfd(self): self._send_fd_by_SCM() - result = self.vm.qmp('getfd', fdname='image0:r') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('getfd', fdname='image0:r') def test_getfd_invalid_fdname(self): self._send_fd_by_SCM()
@@ -163,10 +160,8 @@ class TestSCMFd(iotests.QMPTestCase): def test_closefd(self): self._send_fd_by_SCM() - result = self.vm.qmp('getfd', fdname='image0:r') - self.assert_qmp(result, 'return', {}) - result = self.vm.qmp('closefd', fdname='image0:r') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('getfd', fdname='image0:r') + self.vm.cmd('closefd', fdname='image0:r') def test_closefd_fd_not_found(self): fdname = 'image0:r'
tests/qemu-iotests/055 +21 -40
172 lines not on this page · raw message
tests/qemu-iotests/056 +9 -14
@@ -75,9 +75,8 @@ class TestSyncModesNoneAndTop(iotests.QMPTestCase): def test_complete_top(self): self.assert_no_active_block_jobs() - result = self.vm.qmp('drive-backup', device='drive0', sync='top', - format=iotests.imgfmt, target=target_img) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('drive-backup', device='drive0', sync='top', + format=iotests.imgfmt, target=target_img) self.wait_until_completed(check_offset=False)
@@ -89,9 +88,8 @@ class TestSyncModesNoneAndTop(iotests.QMPTestCase): def test_cancel_sync_none(self): self.assert_no_active_block_jobs() - result = self.vm.qmp('drive-backup', device='drive0', - sync='none', target=target_img) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('drive-backup', device='drive0', + sync='none', target=target_img) time.sleep(1) self.vm.hmp_qemu_io('drive0', 'write -P0x5e 0 512') self.vm.hmp_qemu_io('drive0', 'aio_flush')
@@ -115,18 +113,15 @@ class TestBeforeWriteNotifier(iotests.QMPTestCase): def test_before_write_notifier(self): self.vm.pause_drive("drive0") - result = self.vm.qmp('drive-backup', device='drive0', - sync='full', target=target_img, - format="file", speed=1) - self.assert_qmp(result, 'return', {}) - result = self.vm.qmp('block-job-pause', device="drive0") - self.assert_qmp(result, 'return', {}) + self.vm.cmd('drive-backup', device='drive0', + sync='full', target=target_img, + format="file", speed=1) + self.vm.cmd('block-job-pause', device="drive0") # Speed is low enough that this must be an uncopied range, which will # trigger the before write notifier self.vm.hmp_qemu_io('drive0', 'aio_write -P 1 512512 512') self.vm.resume_drive("drive0") - result = self.vm.qmp('block-job-resume', device="drive0") - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-resume', device="drive0") event = self.cancel_and_wait() self.assert_qmp(event, 'data/type', 'backup')
tests/qemu-iotests/093 +14 -27
89 lines not on this page · raw message
tests/qemu-iotests/118 +90 -131
415 lines not on this page · raw message
tests/qemu-iotests/124 +31 -38
128 lines not on this page · raw message
tests/qemu-iotests/129 +4 -9
@@ -55,11 +55,9 @@ class TestStopWithBlockJob(iotests.QMPTestCase): def do_test_stop(self, cmd, **args): """Test 'stop' while block job is running on a throttled drive. The 'stop' command shouldn't drain the job""" - result = self.vm.qmp(cmd, **args) - self.assert_qmp(result, 'return', {}) + self.vm.cmd(cmd, **args) - result = self.vm.qmp("stop") - self.assert_qmp(result, 'return', {}) + self.vm.cmd("stop") result = self.vm.qmp("query-block-jobs") self.assert_qmp(result, 'return[0]/status', 'running')
@@ -87,7 +85,7 @@ class TestStopWithBlockJob(iotests.QMPTestCase): iotests.qemu_img('create', '-f', iotests.imgfmt, self.overlay_img, '1G') - result = self.vm.qmp('blockdev-add', **{ + self.vm.cmd('blockdev-add', { 'node-name': 'overlay', 'driver': iotests.imgfmt, 'file': {
@@ -95,11 +93,8 @@ class TestStopWithBlockJob(iotests.QMPTestCase): 'filename': self.overlay_img } }) - self.assert_qmp(result, 'return', {}) - result = self.vm.qmp('blockdev-snapshot', - node='source', overlay='overlay') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('blockdev-snapshot', node='source', overlay='overlay') self.do_test_stop('block-commit', device='drive0', top_node='source')
tests/qemu-iotests/132 +2 -3
@@ -47,9 +47,8 @@ class TestSingleDrive(iotests.QMPTestCase): pass def test_mirror_discard(self): - result = self.vm.qmp('drive-mirror', device='drive0', sync='full', - target=target_img) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('drive-mirror', device='drive0', sync='full', + target=target_img) self.vm.hmp_qemu_io('drive0', 'discard 0 64k') self.complete_and_wait('drive0') self.vm.shutdown()
tests/qemu-iotests/139 +14 -29
111 lines not on this page · raw message
tests/qemu-iotests/147 +11 -19
@@ -58,8 +58,7 @@ class NBDBlockdevAddBase(iotests.QMPTestCase): def client_test(self, filename, address, export=None, node_name='nbd-blockdev', delete=True): bao = self.blockdev_add_options(address, export, node_name) - result = self.vm.qmp('blockdev-add', **bao) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('blockdev-add', **bao) found = False result = self.vm.qmp('query-named-block-nodes')
@@ -75,8 +74,7 @@ class NBDBlockdevAddBase(iotests.QMPTestCase): self.assertTrue(found) if delete: - result = self.vm.qmp('blockdev-del', node_name=node_name) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('blockdev-del', node_name=node_name) class QemuNBD(NBDBlockdevAddBase):
@@ -158,16 +156,14 @@ class BuiltinNBD(NBDBlockdevAddBase): self.assert_qmp(result, 'return', {}) if export_name is None: - result = self.server.qmp('nbd-server-add', device='nbd-export') + self.server.cmd('nbd-server-add', device='nbd-export') else: - result = self.server.qmp('nbd-server-add', device='nbd-export', - name=export_name) - self.assert_qmp(result, 'return', {}) + self.server.cmd('nbd-server-add', device='nbd-export', + name=export_name) if export_name2 is not None: - result = self.server.qmp('nbd-server-add', device='nbd-export', - name=export_name2) - self.assert_qmp(result, 'return', {}) + self.server.cmd('nbd-server-add', device='nbd-export', + name=export_name2) return True
@@ -175,8 +171,7 @@ class BuiltinNBD(NBDBlockdevAddBase): self.assertTrue(self._try_server_up(address, export_name, export_name2)) def _server_down(self): - result = self.server.qmp('nbd-server-stop') - self.assert_qmp(result, 'return', {}) + self.server.cmd('nbd-server-stop') def do_test_inet(self, export_name=None): while True:
@@ -218,10 +213,8 @@ class BuiltinNBD(NBDBlockdevAddBase): flatten_sock_addr(address), 'exp1', 'node1', False) self.client_test('nbd://localhost:%i/%s' % (nbd_port, 'exp2'), flatten_sock_addr(address), 'exp2', 'node2', False) - result = self.vm.qmp('blockdev-del', node_name='node1') - self.assert_qmp(result, 'return', {}) - result = self.vm.qmp('blockdev-del', node_name='node2') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('blockdev-del', node_name='node1') + self.vm.cmd('blockdev-del', node_name='node2') self._server_down() def test_inet6(self):
@@ -272,8 +265,7 @@ class BuiltinNBD(NBDBlockdevAddBase): result = self.vm.send_fd_scm(fd=sockfd.fileno()) self.assertEqual(result, 0, 'Failed to send socket FD') - result = self.vm.qmp('getfd', fdname='nbd-fifo') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('getfd', fdname='nbd-fifo') address = { 'type': 'fd', 'data': { 'str': 'nbd-fifo' } }
tests/qemu-iotests/151 +18 -22
@@ -75,14 +75,13 @@ class TestActiveMirror(iotests.QMPTestCase): self.vm.hmp_qemu_io('source', 'aio_write -z %i 1M' % offset) # Start the block job - result = self.vm.qmp('blockdev-mirror', - job_id='mirror', - filter_node_name='mirror-node', - device='source-node', - target='target-node', - sync='full', - copy_mode='write-blocking') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('blockdev-mirror', + job_id='mirror', + filter_node_name='mirror-node', + device='source-node', + target='target-node', + sync='full', + copy_mode='write-blocking') # Start some more requests for offset in range(3 * self.image_len // 8, 5 * self.image_len // 8, 1024 * 1024):
@@ -121,23 +120,21 @@ class TestActiveMirror(iotests.QMPTestCase): result = self.vm.hmp_qemu_io('source', 'write -P 1 0 2M') # Start the block job (very slowly) - result = self.vm.qmp('blockdev-mirror', - job_id='mirror', - filter_node_name='mirror-node', - device='source-node', - target='target-node', - sync='full', - copy_mode='write-blocking', - buf_size=(1048576 // 4), - speed=1) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('blockdev-mirror', + job_id='mirror', + filter_node_name='mirror-node', + device='source-node', + target='target-node', + sync='full', + copy_mode='write-blocking', + buf_size=(1048576 // 4), + speed=1) # Start an unaligned request to a dirty area result = self.vm.hmp_qemu_io('source', 'write -P 2 %i 1' % (1048576 + 42)) # Let the job finish - result = self.vm.qmp('block-job-set-speed', device='mirror', speed=0) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-set-speed', device='mirror', speed=0) self.complete_and_wait(drive='mirror') self.potential_writes_in_flight = False
@@ -185,8 +182,7 @@ class TestActiveMirror(iotests.QMPTestCase): # After resuming 4, one of 2 and 3 goes first and set in_flight_bitmap, # so the other will wait for it. - result = self.vm.qmp('block-job-set-speed', device='mirror', speed=0) - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-job-set-speed', device='mirror', speed=0) self.complete_and_wait(drive='mirror') self.potential_writes_in_flight = False
tests/qemu-iotests/155 +21 -32
91 lines not on this page · raw message
tests/qemu-iotests/165 +2 -5
@@ -116,9 +116,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): sha256_2 = self.getSha256() assert sha256_1 != sha256_2 # Otherwise, it's not very interesting. - result = self.vm.qmp('block-dirty-bitmap-clear', node='drive0', - name='bitmap0') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('block-dirty-bitmap-clear', node='drive0', name='bitmap0') # Start with regions1
@@ -137,7 +135,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): assert sha256_1 == self.getSha256() # Reopen to RW - result = self.vm.qmp('blockdev-reopen', options=[{ + self.vm.cmd('blockdev-reopen', options=[{ 'node-name': 'node0', 'driver': iotests.imgfmt, 'file': {
@@ -146,7 +144,6 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): }, 'read-only': False }]) - self.assert_qmp(result, 'return', {}) # Check that bitmap is reopened to RW and we can write to it. self.writeRegions(regions2)
tests/qemu-iotests/196 +1 -2
@@ -45,8 +45,7 @@ class TestInvalidateAutoclear(iotests.QMPTestCase): self.vm_b.add_incoming("exec: cat '" + migfile + "'") def test_migration(self): - result = self.vm_a.qmp('migrate', uri='exec:cat>' + migfile) - self.assert_qmp(result, 'return', {}); + self.vm_a.cmd('migrate', uri='exec:cat>' + migfile) self.assertNotEqual(self.vm_a.event_wait("STOP"), None) with open(disk, 'r+b') as f:
tests/qemu-iotests/205 +2 -4
@@ -44,10 +44,8 @@ class TestNbdServerRemove(iotests.QMPTestCase): } } - result = self.vm.qmp('nbd-server-start', addr=address) - self.assert_qmp(result, 'return', {}) - result = self.vm.qmp('nbd-server-add', device='drive0', name='exp') - self.assert_qmp(result, 'return', {}) + self.vm.cmd('nbd-server-start', addr=address) + self.vm.cmd('nbd-server-add', device='drive0', name='exp') def tearDown(self): self.vm.shutdown()
tests/qemu-iotests/245 +86 -159
172 lines not on this page · raw message
tests/qemu-iotests/300 +18 -32
50 lines not on this page · raw message
tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test +12 -19
Lines of this file are not shown. View the raw message.
tests/qemu-iotests/tests/migrate-bitmaps-test +11 -26
Lines of this file are not shown. View the raw message.
tests/qemu-iotests/tests/migrate-during-backup +16 -24
Lines of this file are not shown. View the raw message.
tests/qemu-iotests/tests/migration-permissions +4 -5
Lines of this file are not shown. View the raw message.
tests/qemu-iotests/tests/mirror-top-perms +6 -9
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.35.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH 2/2] iotests: use vm.cmd() instead of vm.qmp() where appropriate
Quoted 6 lines · Vladimir Sementsov-Ogievskiy
Checking success by hand every time is tedious. Let's use
cmd()method instead which does this check for us.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>---
31 files changed, 773 insertions(+), 1205 deletions(-)
Big, but mechanical.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 5 lines · Vladimir Sementsov-Ogievskiy
Hi all!
I always dreamed about getting rid of pattern
Quoted 8 lines
result = self.vm.qmp(...) self.assert_qmp(result, 'return', {})Here is a suggestion to switch to
self.vm.cmd(...)pattern instead.
Yeah, I am absolutely on board for this!
Quoted 4 lines
I'm not sure we really want to update so many tests. May be just commit patch 01, and use new interface for new code. On the other hand, old code always used as an example to write the new one.
I think it's worth updating all the old tests ... especially if you've already done it here. We could even do something like what I did with qemu_img() and qemu_io() and have the uncaught exception print a bunch of information to the screen to help make it extremely obvious as to what failed and why.
If you can rebase this, I'd love to review it more carefully - it aligns with my own selfish goals and interests :) The Python branch was merged recently and so we should be all set.
Quoted 34 lines
The series is based on John's python branch.
Vladimir Sementsov-Ogievskiy (2):
python/machine.py: upgradevm.command()method
iotests: usevm.cmd()instead ofvm.qmp()where appropriatepython/qemu/machine/machine.py | 16 +- tests/qemu-iotests/030 | 168 +++---- tests/qemu-iotests/040 | 167 +++--- tests/qemu-iotests/041 | 474 ++++++++---------- tests/qemu-iotests/045 | 15 +- tests/qemu-iotests/055 | 61 +-- tests/qemu-iotests/056 | 23 +- tests/qemu-iotests/093 | 41 +- tests/qemu-iotests/118 | 221 ++++---- tests/qemu-iotests/124 | 69 ++- tests/qemu-iotests/129 | 13 +- tests/qemu-iotests/132 | 5 +- tests/qemu-iotests/139 | 43 +- tests/qemu-iotests/147 | 30 +- tests/qemu-iotests/151 | 40 +- tests/qemu-iotests/155 | 53 +- tests/qemu-iotests/165 | 7 +- tests/qemu-iotests/196 | 3 +- tests/qemu-iotests/205 | 6 +- tests/qemu-iotests/245 | 245 ++++----- tests/qemu-iotests/256 | 34 +- tests/qemu-iotests/257 | 36 +- tests/qemu-iotests/264 | 31 +- tests/qemu-iotests/281 | 21 +- tests/qemu-iotests/295 | 27 +- tests/qemu-iotests/296 | 14 +- tests/qemu-iotests/298 | 13 +-
Quoted 8 lines
tests/qemu-iotests/300 | 50 +- tests/qemu-iotests/iotests.py | 6 +- .../tests/migrate-bitmaps-postcopy-test | 31 +- tests/qemu-iotests/tests/migrate-bitmaps-test | 37 +- .../qemu-iotests/tests/migrate-during-backup | 40 +- .../qemu-iotests/tests/migration-permissions | 9 +- tests/qemu-iotests/tests/mirror-top-perms | 15 +- 34 files changed, 821 insertions(+), 1243 deletions(-)
Is there anything missing, to your knowledge?
--js
Quoted 76 lines · John Snow
Quoted 5 lines · Vladimir Sementsov-Ogievskiy
Hi all!
I always dreamed about getting rid of pattern
Quoted 8 lines
result = self.vm.qmp(...) self.assert_qmp(result, 'return', {})Here is a suggestion to switch to
self.vm.cmd(...)pattern instead.
Yeah, I am absolutely on board for this!
Quoted 4 lines
I'm not sure we really want to update so many tests. May be just commit patch 01, and use new interface for new code. On the other hand, old code always used as an example to write the new one.
I think it's worth updating all the old tests ... especially if you've already done it here. We could even do something like what I did with
qemu_img()andqemu_io()and have the uncaught exception print a bunch of information to the screen to help make it extremely obvious as to what failed and why.If you can rebase this, I'd love to review it more carefully - it aligns with my own selfish goals and interests :) The Python branch was merged recently and so we should be all set.
Quoted 34 lines
The series is based on John's python branch.
Vladimir Sementsov-Ogievskiy (2):
python/machine.py: upgradevm.command()method
iotests: usevm.cmd()instead ofvm.qmp()where appropriatepython/qemu/machine/machine.py | 16 +- tests/qemu-iotests/030 | 168 +++---- tests/qemu-iotests/040 | 167 +++--- tests/qemu-iotests/041 | 474 ++++++++---------- tests/qemu-iotests/045 | 15 +- tests/qemu-iotests/055 | 61 +-- tests/qemu-iotests/056 | 23 +- tests/qemu-iotests/093 | 41 +- tests/qemu-iotests/118 | 221 ++++---- tests/qemu-iotests/124 | 69 ++- tests/qemu-iotests/129 | 13 +- tests/qemu-iotests/132 | 5 +- tests/qemu-iotests/139 | 43 +- tests/qemu-iotests/147 | 30 +- tests/qemu-iotests/151 | 40 +- tests/qemu-iotests/155 | 53 +- tests/qemu-iotests/165 | 7 +- tests/qemu-iotests/196 | 3 +- tests/qemu-iotests/205 | 6 +- tests/qemu-iotests/245 | 245 ++++----- tests/qemu-iotests/256 | 34 +- tests/qemu-iotests/257 | 36 +- tests/qemu-iotests/264 | 31 +- tests/qemu-iotests/281 | 21 +- tests/qemu-iotests/295 | 27 +- tests/qemu-iotests/296 | 14 +- tests/qemu-iotests/298 | 13 +-Quoted 8 lines
tests/qemu-iotests/300 | 50 +- tests/qemu-iotests/iotests.py | 6 +- .../tests/migrate-bitmaps-postcopy-test | 31 +- tests/qemu-iotests/tests/migrate-bitmaps-test | 37 +- .../qemu-iotests/tests/migrate-during-backup | 40 +- .../qemu-iotests/tests/migration-permissions | 9 +- tests/qemu-iotests/tests/mirror-top-perms | 15 +- 34 files changed, 821 insertions(+), 1243 deletions(-)
Quoted 2 lines
Is there anything missing, to your knowledge?
Don't remember) I hope, I'd write in commit message, if there was something :) Will rebase soon.
Signature · 2 lines
Best regards, Vladimir