Skip to content

Commit 58026b1

Browse files
committed
python/aqmp: Add dict conversion method to Greeting object
The iotests interface expects to return the greeting as a dict; AQMP offers it as a rich object. Signed-off-by: John Snow <[email protected]> Reviewed-by: Paolo Bonzini <[email protected]> Reviewed-by: Eric Blake <[email protected]> Message-id: [email protected] Signed-off-by: John Snow <[email protected]>
1 parent 6e2f6ec commit 58026b1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

python/qemu/aqmp/models.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
# pylint: disable=too-few-public-methods
99

1010
from collections import abc
11+
import copy
1112
from typing import (
1213
Any,
14+
Dict,
1315
Mapping,
1416
Optional,
1517
Sequence,
@@ -66,6 +68,17 @@ def __init__(self, raw: Mapping[str, Any]):
6668
self._check_member('QMP', abc.Mapping, "JSON object")
6769
self.QMP = QMPGreeting(self._raw['QMP'])
6870

71+
def _asdict(self) -> Dict[str, object]:
72+
"""
73+
For compatibility with the iotests sync QMP wrapper.
74+
75+
The legacy QMP interface needs Greetings as a garden-variety Dict.
76+
77+
This interface is private in the hopes that it will be able to
78+
be dropped again in the near-future. Caller beware!
79+
"""
80+
return dict(copy.deepcopy(self._raw))
81+
6982

7083
class QMPGreeting(Model):
7184
"""

0 commit comments

Comments
 (0)