[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 44/56] python/qemu/machine: QEMUMachine: improve qmp() method
From: |
Hanna Reitz |
Subject: |
[PULL 44/56] python/qemu/machine: QEMUMachine: improve qmp() method |
Date: |
Wed, 1 Sep 2021 17:16:07 +0200 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
We often call qmp() with unpacking dict, like qmp('foo', **{...}).
mypy don't really like it, it thinks that passed unpacked dict is a
positional argument and complains that it type should be bool (because
second argument of qmp() is conv_keys: bool).
Allow passing dict directly, simplifying interface, and giving a way to
satisfy mypy.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Message-Id: <20210824083856.17408-25-vsementsov@virtuozzo.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
python/qemu/machine/machine.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py
index 3fde73cf10..6ec18570d9 100644
--- a/python/qemu/machine/machine.py
+++ b/python/qemu/machine/machine.py
@@ -578,11 +578,21 @@ def _qmp_args(cls, conv_keys: bool,
return args
def qmp(self, cmd: str,
- conv_keys: bool = True,
+ args_dict: Optional[Dict[str, object]] = None,
+ conv_keys: Optional[bool] = None,
**args: Any) -> QMPMessage:
"""
Invoke a QMP command and return the response dict
"""
+ 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)
return self._qmp.cmd(cmd, args=qmp_args)
--
2.31.1
- [PULL 37/56] block/copy-before-write: bdrv_cbw_append(): drop unused compress arg, (continued)
- [PULL 37/56] block/copy-before-write: bdrv_cbw_append(): drop unused compress arg, Hanna Reitz, 2021/09/01
- [PULL 35/56] block/copy-before-write: cbw_init(): rename variables, Hanna Reitz, 2021/09/01
- [PULL 38/56] block/copy-before-write: cbw_init(): use options, Hanna Reitz, 2021/09/01
- [PULL 40/56] block/block-copy: make setting progress optional, Hanna Reitz, 2021/09/01
- [PULL 41/56] block/copy-before-write: make public block driver, Hanna Reitz, 2021/09/01
- [PULL 34/56] block/copy-before-write: introduce cbw_init(), Hanna Reitz, 2021/09/01
- [PULL 39/56] block/copy-before-write: initialize block-copy bitmap, Hanna Reitz, 2021/09/01
- [PULL 42/56] qapi: publish copy-before-write filter, Hanna Reitz, 2021/09/01
- [PULL 44/56] python/qemu/machine: QEMUMachine: improve qmp() method,
Hanna Reitz <=
- [PULL 43/56] python/qemu/machine.py: refactor _qemu_args(), Hanna Reitz, 2021/09/01
- [PULL 45/56] python:QEMUMachine: template typing for self returning methods, Hanna Reitz, 2021/09/01
- [PULL 46/56] iotests/222: fix pylint and mypy complains, Hanna Reitz, 2021/09/01
- [PULL 48/56] iotests: move 222 to tests/image-fleecing, Hanna Reitz, 2021/09/01
- [PULL 49/56] iotests.py: hmp_qemu_io: support qdev, Hanna Reitz, 2021/09/01
- [PULL 50/56] iotests/image-fleecing: proper source device, Hanna Reitz, 2021/09/01
- [PULL 47/56] iotests/222: constantly use single quotes for strings, Hanna Reitz, 2021/09/01
- [PULL 51/56] iotests/image-fleecing: rename tgt_node, Hanna Reitz, 2021/09/01
- [PULL 52/56] iotests/image-fleecing: prepare for adding new test-case, Hanna Reitz, 2021/09/01
- [PULL 53/56] iotests/image-fleecing: add test-case for copy-before-write filter, Hanna Reitz, 2021/09/01