qemu-iotests: migrate away from HMP ("make HMP optional" follow-up)
Subsystems (7)
PATCH 87/88 qemu-iotests: remove HMP framework support
In reply to Marc-André LureauAll tests have been migrated to QMP. Remove:
- _require_hmp() from common.rc
- _filter_hmp() from common.filter
- _filter_hmp from pipelines in common.qemu
- HMP monitor mode from _launch_qemu() in common.qemu
- hmp() method from iotests.py VM class
- _verify_hmp() and require_hmp parameter from iotests.py
--- tests/qemu-iotests/common.filter | 7 ------- tests/qemu-iotests/common.qemu | 34 +++++++++++----------------------- tests/qemu-iotests/common.rc | 8 -------- tests/qemu-iotests/iotests.py | 28 +--------------------------- 4 files changed, 12 insertions(+), 65 deletions(-)
tests/qemu-iotests/common.filter +0 -7
@@ -102,13 +102,6 @@ _filter_qmp() -e ' QMP_VERSION' } -# readline makes HMP command strings so long that git complains -_filter_hmp() -{ - gsed -e $'s/^\\((qemu) \\)\\?.*\e\\[D/\\1/g' \ - -e $'s/\e\\[K//g' -} - # replace block job offset _filter_block_job_offset() {
tests/qemu-iotests/common.qemu +11 -23
@@ -119,7 +119,7 @@ _timed_wait_for() if [ -z "${silent}" ] && [ -z "${mismatch_only}" ]; then echo "${resp}" | _filter_testdir | _filter_qemu \ - | _filter_qemu_io | _filter_qmp | _filter_hmp + | _filter_qemu_io | _filter_qmp fi if [ -n "${failure_match}" ]; then grep -q "${failure_match}" < <(echo "${resp}")
@@ -134,7 +134,7 @@ _timed_wait_for() fi if [ -z "${silent}" ] && [ -n "${mismatch_only}" ]; then echo "${resp}" | _filter_testdir | _filter_qemu \ - | _filter_qemu_io | _filter_qmp | _filter_hmp + | _filter_qemu_io | _filter_qmp fi done
@@ -244,7 +244,7 @@ _check_cached_events() grep -q "$match" < <(echo "${ev}") if [ $? -eq 0 ] && [ $matched = 0 ]; then echo "${ev}" | _filter_testdir | _filter_qemu \ - | _filter_qemu_io | _filter_qmp | _filter_hmp + | _filter_qemu_io | _filter_qmp matched=1 else QEMU_EVENTS="${QEMU_EVENTS:+${QEMU_EVENTS}%}${ev}"
@@ -312,9 +312,6 @@ _run_qmp_job() # Launch a QEMU process. # # Input parameters: -# $qemu_comm_method: set this variable to 'monitor' (case insensitive) -# to use the QEMU HMP monitor for communication. -# Otherwise, the default of QMP is used. # $qmp_pretty: Set this variable to 'y' to enable QMP pretty printing. # $keep_stderr: Set this variable to 'y' to keep QEMU's stderr output on stderr. # If this variable is empty, stderr will be redirected to stdout.
@@ -327,16 +324,10 @@ _launch_qemu() local fifo_out= local fifo_in= - if (shopt -s nocasematch; [[ "${qemu_comm_method}" == "monitor" ]]) - then - comm="-monitor stdio" + if [ "$qmp_pretty" = "y" ]; then + comm="-monitor none -qmp-pretty stdio" else - local qemu_comm_method="qmp" - if [ "$qmp_pretty" = "y" ]; then - comm="-monitor none -qmp-pretty stdio" - else - comm="-monitor none -qmp stdio" - fi + comm="-monitor none -qmp stdio" fi fifo_out=${QEMU_FIFO_OUT}_${_QEMU_HANDLE}
@@ -379,13 +370,10 @@ _launch_qemu() QEMU_IN[${_QEMU_HANDLE}]=${_in_fd} QEMU_STATUS[${_QEMU_HANDLE}]=0 - if [ "${qemu_comm_method}" == "qmp" ] - then - # Don't print response, since it has version information in it - silent=yes _timed_wait_for ${_QEMU_HANDLE} "capabilities" - if [ "$qmp_pretty" = "y" ]; then - silent=yes _timed_wait_for ${_QEMU_HANDLE} "^}" - fi + # Don't print response, since it has version information in it + silent=yes _timed_wait_for ${_QEMU_HANDLE} "capabilities" + if [ "$qmp_pretty" = "y" ]; then + silent=yes _timed_wait_for ${_QEMU_HANDLE} "^}" fi QEMU_HANDLE=${_QEMU_HANDLE} let _QEMU_HANDLE++
@@ -416,7 +404,7 @@ _cleanup_qemu() if [ -n "${wait}" ]; then cat <&${QEMU_OUT[$i]} | _filter_testdir | _filter_qemu \ - | _filter_qemu_io | _filter_qmp | _filter_hmp + | _filter_qemu_io | _filter_qmp fi rm -f "${QEMU_FIFO_IN}_${i}" "${QEMU_FIFO_OUT}_${i}" eval "exec ${QEMU_IN[$i]}<&-" # close file descriptors
tests/qemu-iotests/common.rc +0 -8
@@ -995,14 +995,6 @@ _notrun_on_fuse_error() esac } -_require_hmp() -{ - if echo quit | $QEMU -M none -display none -monitor stdio 2>&1 | - grep -q "HMP monitor is not available"; then - _notrun "HMP monitor not available" - fi -} - # Check that we have a file system that allows huge (but very sparse) files # _require_large_file()
tests/qemu-iotests/iotests.py +1 -27
@@ -934,14 +934,6 @@ def add_paused(self): self._args.append('-S') return self - def hmp(self, command_line: str, use_log: bool = False) -> QMPMessage: - cmd = 'human-monitor-command' - kwargs: Dict[str, Any] = {'command-line': command_line} - if use_log: - return self.qmp_log(cmd, **kwargs) - else: - return self.qmp(cmd, **kwargs) - def pause_drive(self, drive: str, event: Optional[str] = None) -> None: """Pause drive r/w operations""" if not event:
@@ -954,12 +946,6 @@ def resume_drive(self, drive: str) -> None: """Resume drive r/w operations""" self.qmp_qemu_io(drive, f'remove_break bp_{drive}') - def hmp_qemu_io(self, drive: str, cmd: str, - use_log: bool = False, qdev: bool = False) -> QMPMessage: - """Write to a given drive using an HMP command""" - d = '-d ' if qdev else '' - return self.hmp(f'qemu-io {d}{drive} "{cmd}"', use_log=use_log) - def qmp_qemu_io(self, drive: str, cmd: str, use_log: bool = False, qdev: bool = False) -> str: """Write to a given drive using the x-qemu-io QMP command"""
@@ -1464,15 +1450,6 @@ def _verify_formats(required_formats: Sequence[str] = ()) -> None: notrun(f'formats {usf_list} are not whitelisted') -def _verify_hmp() -> None: - args = [qemu_prog] + qemu_opts + ['-M', 'none', '-monitor', 'stdio'] - with subprocess.Popen(args, stdin=subprocess.PIPE, - stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - universal_newlines=True) as subp: - out, _ = subp.communicate('quit\n') - if 'HMP monitor is not available' in out: - notrun('HMP monitor not available') - def _verify_virtio_blk() -> None: out = qemu_pipe('-M', 'none', '-device', 'help') if 'virtio-blk' not in out:
@@ -1711,8 +1688,7 @@ def execute_setup_common(supported_fmts: Sequence[str] = (), supported_protocols: Sequence[str] = (), unsupported_protocols: Sequence[str] = (), required_fmts: Sequence[str] = (), - unsupported_imgopts: Sequence[str] = (), - require_hmp: bool = False) -> bool: + unsupported_imgopts: Sequence[str] = ()) -> bool: """ Perform necessary setup for either script-style or unittest-style tests.
@@ -1733,8 +1709,6 @@ def execute_setup_common(supported_fmts: Sequence[str] = (), _verify_formats(required_fmts) _verify_virtio_blk() _verify_imgopts(unsupported_imgopts) - if require_hmp: - _verify_hmp() return debug
Signature · 1 line
2.56.0.rc0.29.g47ce80527c56
PATCH 88/88 block/monitor: redirect HMP qemu-io to HMP stream
In reply to Marc-André LureauNow that all tests have been converted to rely on QMP stream result, we can also redirect HMP output.
--- block/monitor/block-hmp-cmds.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
block/monitor/block-hmp-cmds.c +1 -2
@@ -553,8 +553,7 @@ void hmp_qemu_io(MonitorHMP *hmp, const QDict *qdict)return ; } -/* use stdout and not monitor_puts() for compatiblity reasons */ -printf ("%s" , out->human_readable_text); +monitor_puts (MONITOR (hmp), out->human_readable_text); } static void print_block_info(MonitorHMP *hmp, BlockInfo *info,
Signature · 1 line
2.56.0.rc0.29.g47ce80527c56
Am 22.09.2026 um 22:17 hat Marc-André Lureau geschrieben:
Quoted 6 lines
Hi,
This series migrates all qemu-iotests away from HMP, so that the test framework no longer depends on it and can execute with --disable-hmp. This can simplify the tests, as they don't need to check/grep on stdout, HMP & QMP but can rely increasingly on QMP alone.
Hm... Doesn't this mean that HMP loses all of its test coverage? I don't feel that's a good idea.
Most tests are based on diffing stdout anyway, so I don't expect this removal simplifies them much. I'll have to look at the individual patches, but I'd rather expect that their output becomes harder to read instead.
What are the general plans with HMP? Are we expecting most builds to have HMP disabled in the future? (Why? It's useful for human users.)
I think most tests probably combine testing the HMP interface with testing the backend functionality. If we really expect missing HMP to be a relevant case in the future, these parts need to be separated so that the backend test can run with QMP only while the HMP interface tests run only when HMP is available.
Not sure how this is best done without effectively running all tests twice. Maybe there is a middle ground of converting some tests to QMP and making other tests explicitgly depend on HMP (i.e. they are skipped if HMP isn't available).
Kevin
Hi
Quoted 11 lines · Kevin Wolf
Am 22.09.2026 um 22:17 hat Marc-André Lureau geschrieben:
Quoted 6 lines
Hi,
This series migrates all qemu-iotests away from HMP, so that the test framework no longer depends on it and can execute with --disable-hmp. This can simplify the tests, as they don't need to check/grep on stdout, HMP & QMP but can rely increasingly on QMP alone.
Hm... Doesn't this mean that HMP loses all of its test coverage? I don't feel that's a good idea.
You're right that we shouldn't lose HMP coverage, the question is where it belongs?
HMP is supposed to be just a frontend to QMP. Imho, testing that interface is not the scope of qemu-iotests. We should have dedicated tests for this, and better coverage.
Also, most of what qemu-iotests exercice of HMP is simply qemu-io, which is the same with QMP.
Quoted 4 lines
Most tests are based on diffing stdout anyway, so I don't expect this removal simplifies them much. I'll have to look at the individual patches, but I'd rather expect that their output becomes harder to read instead.
Yes, if we want "human readable" dumps, it is a bit more verbose in JSON. But it's often better to have structured output you can test, instead of bare strings that do not have stability guarantee.
Quoted 3 lines
What are the general plans with HMP? Are we expecting most builds to have HMP disabled in the future? (Why? It's useful for human users.)
I expect QEMU will keep offering a "human" monitor by default. But QMP should be a superset, so other "human" interfaces and tools can be developped with the same functionality it offers.
Quoted 10 lines
I think most tests probably combine testing the HMP interface with testing the backend functionality. If we really expect missing HMP to be a relevant case in the future, these parts need to be separated so that the backend test can run with QMP only while the HMP interface tests run only when HMP is available.
Not sure how this is best done without effectively running all tests twice. Maybe there is a middle ground of converting some tests to QMP and making other tests explicitgly depend on HMP (i.e. they are skipped if HMP isn't available).
That could work, but maintaining two variants (or conditional paths) per test adds burden without improving HMP coverage. The current tests exercise HMP incidentally, not deliberately. A cleaner split: migrate qemu-iotests fully to QMP for backend correctness, and add dedicated HMP tests that intentionally validate the monitor frontend. I will work on it for the next iteration.
thanks
Am 22.09.2026 um 22:17 hat Marc-André Lureau geschrieben:
Quoted 10 lines
Hi,
This series migrates all qemu-iotests away from HMP, so that the test framework no longer depends on it and can execute with --disable-hmp. This can simplify the tests, as they don't need to check/grep on stdout, HMP & QMP but can rely increasingly on QMP alone.
The series is organized as follows: preparatory patches, monitor infrastructure, test infrastructure, test migrations, cleanup.
Quoted 6 lines
x-query-qtree (info qtree) is introduced to make test 172 migration easier, but arguably, qom-list could be extended instead.
All migrated tests have been verified to pass.
Signed-off-by Marc-André Lureau <[email protected]>
Argh, noticed only now that the Cc: list is a bit short. Everyone seeing only this email, please check the series and my reply on qemu-devel (and add the necessary CCs when replying).
Please don't forget to CC at least qemu-block for v2.
Kevin
Quoted 14 lines · Kevin Wolf
Am 22.09.2026 um 22:17 hat Marc-André Lureau geschrieben:
Quoted 13 lines
Hi,
This series migrates all qemu-iotests away from HMP, so that the test framework no longer depends on it and can execute with --disable-hmp. This can simplify the tests, as they don't need to check/grep on stdout, HMP & QMP but can rely increasingly on QMP alone.
The series is organized as follows: preparatory patches, monitor infrastructure, test infrastructure, test migrations, cleanup.
x-query-qtree (info qtree) is introduced to make test 172 migration easier, but arguably, qom-list could be extended instead.
Quoted 7 lines
Quoted 3 lines
All migrated tests have been verified to pass.
Signed-off-by Marc-André Lureau <[email protected]>Argh, noticed only now that the Cc: list is a bit short. Everyone seeing only this email, please check the series and my reply on qemu-devel (and add the necessary CCs when replying).
Here are the original authors of test cases. I will take a look at the ones that I wrote but I can help with the leftovers too:
001 Christoph Hellwig
002 Christoph Hellwig
003 Christoph Hellwig
004 Christoph Hellwig
005 Christoph Hellwig
007 Christoph Hellwig
008 Christoph Hellwig
009 Christoph Hellwig
010 Christoph Hellwig
011 Christoph Hellwig
012 Christoph Hellwig
013 Christoph Hellwig
014 Christoph Hellwig
015 Kevin Wolf
017 Kevin Wolf
018 Kevin Wolf
019 Kevin Wolf
020 Kevin Wolf
021 Christoph Hellwig
022 Kevin Wolf
023 Kevin Wolf
024 Kevin Wolf
025 Stefan Hajnoczi
026 Kevin Wolf
027 Stefan Hajnoczi
028 Stefan Hajnoczi
029 Kevin Wolf
030 Stefan Hajnoczi
031 Kevin Wolf
032 Kevin Wolf
033 Paolo Bonzini
034 Kevin Wolf
035 Kevin Wolf
036 Stefan Hajnoczi
037 Kevin Wolf
038 Kevin Wolf
039 Stefan Hajnoczi
040 Jeff Cody
041 Paolo Bonzini
042 Kevin Wolf
043 Stefan Hajnoczi
044 Kevin Wolf
045 Corey Bryant
046 Kevin Wolf
047 Kevin Wolf
048 Miroslav Rezanina
049 Kevin Wolf
050 Paolo Bonzini
051 Kevin Wolf
052 Stefan Hajnoczi
053 Stefan Hajnoczi
054 Kevin Wolf
055 Stefan Hajnoczi
056 Ian Main
057 Wenchao Xia
058 Wenchao Xia
059 Fam Zheng
060 Max Reitz
061 Max Reitz
062 Max Reitz
063 Alexandre Derumier
064 Jeff Cody
065 Max Reitz
066 Max Reitz
068 Max Reitz
069 Max Reitz
070 Jeff Cody
071 Max Reitz
072 Max Reitz
073 Kevin Wolf
074 Fam Zheng
075 Stefan Hajnoczi
076 Kevin Wolf
077 Kevin Wolf
078 Kevin Wolf
079 Hu Tao
080 Kevin Wolf
081 Benoît Canet
082 Kevin Wolf
083 Stefan Hajnoczi
084 Jeff Cody
085 Jeff Cody
086 Kevin Wolf
087 Kevin Wolf
088 Kevin Wolf
089 Max Reitz
090 Max Reitz
091 Jeff Cody
092 Kevin Wolf
093 Fam Zheng
094 Max Reitz
095 Jeff Cody
096 Alberto Garcia
097 Max Reitz
098 Max Reitz
099 Max Reitz
101 Stefan Hajnoczi
102 Max Reitz
103 Max Reitz
104 Hu Tao
105 Fam Zheng
106 Max Reitz
107 Max Reitz
108 Max Reitz
109 Kevin Wolf
110 Max Reitz
111 Max Reitz
112 Max Reitz
113 Max Reitz
114 Kevin Wolf
115 Max Reitz
116 Stefan Hajnoczi
117 Max Reitz
118 Max Reitz
119 Max Reitz
120 Max Reitz
121 Max Reitz
122 Kevin Wolf
123 Max Reitz
124 John Snow
125 Max Reitz
126 Max Reitz
127 Max Reitz
128 Stefan Hajnoczi
129 Fam Zheng
130 Kevin Wolf
131 Denis V. Lunev
132 Fam Zheng
133 Kevin Wolf
134 Daniel P. Berrange
135 Jeff Cody
136 Alberto Garcia
137 Kevin Wolf
138 Max Reitz
139 Alberto Garcia
140 Max Reitz
141 Max Reitz
142 Kevin Wolf
143 Max Reitz
144 Jeff Cody
145 Kevin Wolf
146 Jeff Cody
147 Max Reitz
148 Alberto Garcia
149 Daniel P. Berrange
150 Max Reitz
151 Max Reitz
152 Fam Zheng
153 Fam Zheng
154 Kevin Wolf
155 Max Reitz
156 Max Reitz
157 Kevin Wolf
158 Daniel P. Berrange
159 Reda Sallahi
160 Reda Sallahi
161 Alberto Garcia
162 Max Reitz
163 Pavel Butsykin
165 Vladimir Sementsov-Ogievskiy
170 Reda Sallahi
171 Tomáš Golembiovský
172 Kevin Wolf
173 Jeff Cody
174 Nir Soffer
175 Nir Soffer
176 Daniel P. Berrange
177 Eric Blake
178 Stefan Hajnoczi
179 Eric Blake
181 Kevin Wolf
182 Fam Zheng
184 Manos Pitsidianakis
185 Kevin Wolf
186 Kevin Wolf
187 Kevin Wolf
188 Daniel P. Berrange
189 Daniel P. Berrange
190 Eric Blake
191 Kevin Wolf
192 Fam Zheng
194 Stefan Hajnoczi
195 Kevin Wolf
196 Vladimir Sementsov-Ogievskiy
197 Eric Blake
198 Daniel P. Berrange
200 Jeff Cody
201 Daniel Henrique Barboza
202 Stefan Hajnoczi
203 Stefan Hajnoczi
204 Eric Blake
205 Vladimir Sementsov-Ogievskiy
206 Kevin Wolf
207 Kevin Wolf
208 Stefan Hajnoczi
209 Vladimir Sementsov-Ogievskiy
210 Kevin Wolf
211 Kevin Wolf
212 Kevin Wolf
213 Kevin Wolf
214 Max Reitz
215 Max Reitz
216 Max Reitz
217 Max Reitz
218 Max Reitz
219 Kevin Wolf
220 Eric Blake
221 Eric Blake
223 Eric Blake
224 Max Reitz
225 Max Reitz
226 John Snow
227 Kevin Wolf
228 Max Reitz
229 Jeff Cody
231 Jeff Cody
232 Kevin Wolf
233 Daniel P. Berrangé
234 Kevin Wolf
235 Vladimir Sementsov-Ogievskiy
236 John Snow
237 Kevin Wolf
238 Stefan Hajnoczi
239 yuchenlin
240 Alberto Garcia
241 Eric Blake
242 Andrey Shinkevich
243 Kevin Wolf
244 Kevin Wolf
245 Alberto Garcia
246 John Snow
247 Kevin Wolf
248 Vladimir Sementsov-Ogievskiy
249 Alberto Garcia
250 Vladimir Sementsov-Ogievskiy
251 Max Reitz
252 Max Reitz
253 Max Reitz
254 Vladimir Sementsov-Ogievskiy
255 Kevin Wolf
256 John Snow
257 John Snow
258 Max Reitz
259 Max Reitz
260 Vladimir Sementsov-Ogievskiy
261 Max Reitz
262 Kevin Wolf
263 Maxim Levitsky
264 Vladimir Sementsov-Ogievskiy
265 Max Reitz
266 Max Reitz
267 Kevin Wolf
268 Alberto Garcia
270 Max Reitz
271 Alberto Garcia
272 Max Reitz
273 Kevin Wolf
274 Kevin Wolf
277 Andrey Shinkevich
279 Stefan Hajnoczi
280 Kevin Wolf
281 Sergio Lopez
282 Daniel Henrique Barboza
283 Vladimir Sementsov-Ogievskiy
284 Daniel P. Berrangé
286 Max Reitz
287 Denis Plotnikov
288 Stefan Hajnoczi
289 Max Reitz
290 Alberto Garcia
292 Alberto Garcia
293 Maxim Levitsky
294 Maxim Levitsky
295 Maxim Levitsky
296 Maxim Levitsky
297 Kevin Wolf
298 Vladimir Sementsov-Ogievskiy
299 Vladimir Sementsov-Ogievskiy
300 Max Reitz
301 Eric Blake
302 Nir Soffer
303 Andrey Shinkevich
304 Stefan Reiter
305 Alberto Garcia
307 Kevin Wolf
308 Max Reitz
310 Andrey Shinkevich
312 Alberto Garcia
313 Alberto Garcia
314 Andrey Drobyshev
Stefan