build-sys: make HMP source files conditional on have_hmp
Exclude all *-hmp-cmds.c files and HMP-only source files from the build when HMP is disabled. Also conditionalise the hmp-commands.hx header generation and the test-hmp qtest. Acked-by: Dr. David Alan Gilbert <dave@treblig.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260828-qemu-no-hmp-v5-45-9227de146347@redhat.com>
Marc-André Lureau committed
Aug 28, 2026 at 16:04 UTC
34c5de5c6d6049b7cd0d475a32da8760f35c0ab5
23 files changed
+86
-32
audio/meson.build
+3
-1
@@ -9,7 +9,9 @@ audio_ss.add(files(
9
))
10
11
# deprecated since v10.2, to be removed
12
-system_ss.add(files('audio-hmp-cmds.c', 'wavcapture.c'))
12
+if have_hmp
13
+ system_ss.add(files('audio-hmp-cmds.c', 'wavcapture.c'))
14
+endif
15
16
audio_modules = {}
17
foreach m : [
backends/meson.build
+4
-1
@@ -1,6 +1,5 @@
1
system_ss.add([files(
2
'cryptodev-builtin.c',
3
- 'cryptodev-hmp-cmds.c',
3
'cryptodev.c',
4
'hostmem-ram.c',
5
'hostmem.c',
@@ -10,6 +9,10 @@ system_ss.add([files(
9
'confidential-guest-support.c',
10
), numa])
11
12
+if have_hmp
13
+ system_ss.add(files('cryptodev-hmp-cmds.c'))
14
+endif
15
+
16
if host_os != 'windows'
17
system_ss.add(files('rng-random.c'))
18
if host_os != 'emscripten'
block/monitor/meson.build
+3
-1
@@ -1,3 +1,5 @@
1
-system_ss.add(files('block-hmp-cmds.c'))
1
+if have_hmp
2
+ system_ss.add(files('block-hmp-cmds.c'))
3
+endif
4
block_ss.add(files('bitmap-qmp-cmds.c'))
5
system_ss.add(files('qmp-cmds.c'))
chardev/meson.build
+4
-1
@@ -30,11 +30,14 @@ endif
30
chardev_ss = chardev_ss.apply({})
31
32
system_ss.add(files(
33
- 'char-hmp-cmds.c',
33
'msmouse.c',
34
'wctablet.c',
35
'testdev.c'))
36
37
+if have_hmp
38
+ system_ss.add(files('char-hmp-cmds.c'))
39
+endif
40
+
41
chardev_modules = {}
42
43
if brlapi.found()
disas/meson.build
+3
-1
@@ -20,5 +20,7 @@ common_ss.add(when: 'CONFIG_TCG', if_true: files(
20
'objdump.c'
21
))
22
common_ss.add(files('disas-common.c'))
23
-system_ss.add(files('disas-mon.c'))
23
+if have_hmp
24
+ system_ss.add(files('disas-mon.c'))
25
+endif
26
specific_ss.add(capstone)
dump/meson.build
+4
-1
@@ -1,3 +1,6 @@
1
-system_ss.add([files('dump.c', 'dump-hmp-cmds.c'), snappy, lzo])
1
+system_ss.add([files('dump.c'), snappy, lzo])
2
+if have_hmp
3
+ system_ss.add(files('dump-hmp-cmds.c'))
4
+endif
5
specific_ss.add(when: 'CONFIG_WINDUMP', if_true: files('win_dump-x86.c'))
6
system_ss.add(when: 'CONFIG_WINDUMP', if_false: files('win_dump-stubs.c'))
hw/core/meson.build
+3
-2
@@ -26,13 +26,11 @@ system_ss.add(when: 'CONFIG_SPLIT_IRQ', if_true: files('split-irq.c'))
26
system_ss.add(when: 'CONFIG_XILINX_AXI', if_true: files('stream.c'))
27
system_ss.add(when: 'CONFIG_PLATFORM_BUS', if_true: files('sysbus-fdt.c'))
28
system_ss.add(when: 'CONFIG_EIF', if_true: [files('eif.c'), zlib, libcbor, gnutls])
29
-
29
system_ss.add(files(
30
'cpu-system.c',
31
'fw-path-provider.c',
32
'hotplug.c',
33
'loader.c',
35
- 'machine-hmp-cmds.c',
34
'machine-qmp-cmds.c',
35
'machine.c',
36
'nmi.c',
@@ -46,6 +44,9 @@ system_ss.add(files(
44
'vm-change-state-handler.c',
45
'clock-vmstate.c',
46
))
47
+if have_hmp
48
+ system_ss.add(files('machine-hmp-cmds.c'))
49
+endif
50
user_ss.add(files(
51
'cpu-user.c',
52
'qdev-user.c',
hw/i386/meson.build
+3
-1
@@ -24,7 +24,9 @@ i386_ss.add(when: 'CONFIG_VTD', if_true: files('intel_iommu.c'))
24
i386_ss.add(when: 'CONFIG_VTD_ACCEL', if_true: files('intel_iommu_accel.c'))
25
i386_ss.add(when: 'CONFIG_SGX', if_true: files('sgx-epc.c','sgx.c'),
26
if_false: files('sgx-stub.c'))
27
-stub_ss.add(files('sgx-hmp-stub.c'))
27
+if have_hmp
28
+ stub_ss.add(files('sgx-hmp-stub.c'))
29
+endif
30
31
i386_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-common.c'))
32
i386_ss.add(when: 'CONFIG_PC', if_true: files(
hw/net/meson.build
+3
-1
@@ -67,6 +67,8 @@ system_ss.add(when: 'CONFIG_ROCKER', if_true: files(
67
'rocker/rocker_world.c',
68
))
69
stub_ss.add(files('rocker/rocker-stubs.c'))
70
-system_ss.add(files('rocker/rocker-hmp-cmds.c'))
70
+if have_hmp
71
+ system_ss.add(files('rocker/rocker-hmp-cmds.c'))
72
+endif
73
74
subdir('can')
hw/pci/meson.build
+3
-1
@@ -5,12 +5,14 @@ pci_ss.add(files(
5
'pci.c',
6
'pci_bridge.c',
7
'pci_host.c',
8
- 'pci-hmp-cmds.c',
8
'pci-qmp-cmds.c',
9
'pcie_sriov.c',
10
'shpc.c',
11
'slotid_cap.c'
12
))
13
+if have_hmp
14
+ pci_ss.add(files('pci-hmp-cmds.c'))
15
+endif
16
# The functions in these modules can be used by devices too. Since we
17
# allow plugging PCIe devices into PCI buses, include them even if
18
# CONFIG_PCI_EXPRESS=n.
hw/virtio/meson.build
+3
-1
@@ -100,6 +100,8 @@ stub_ss.add(files('vhost-user-stub.c'))
100
stub_ss.add(files('virtio-stub.c'))
101
stub_ss.add(files('virtio-md-stubs.c'))
102
103
-system_ss.add(files('virtio-hmp-cmds.c'))
103
+if have_hmp
104
+ system_ss.add(files('virtio-hmp-cmds.c'))
105
+endif
106
107
system_ss.add(when: 'CONFIG_ACPI', if_true: files('virtio-acpi.c'))
meson.build
+1
-1
@@ -3548,7 +3548,7 @@ hx_headers = [
3548
['qemu-options.hx', 'qemu-options.def'],
3549
['qemu-img-cmds.hx', 'qemu-img-cmds.h'],
3550
]
3551
-if have_system
3551
+if have_system and have_hmp
3552
hx_headers += [
3553
['hmp-commands.hx', 'hmp-commands.h'],
3554
['hmp-commands-info.hx', 'hmp-commands-info.h'],
migration/meson.build
+3
-1
@@ -36,7 +36,9 @@ system_ss.add(files(
36
'socket.c',
37
'tls.c',
38
), gnutls, zlib)
39
-system_ss.add([spice_headers, files('migration-hmp-cmds.c'), spice])
39
+if have_hmp
40
+ system_ss.add([spice_headers, files('migration-hmp-cmds.c'), spice])
41
+endif
42
43
if get_option('replication').allowed()
44
system_ss.add(files('colo-failover.c', 'colo.c', 'multifd-colo.c'))
monitor/hmp.c
-2
@@ -1731,9 +1731,7 @@ static int get_monitor_def(MonitorHMP *hmp, int64_t *pval, const char *name)
1731
if (cs == NULL) {
1732
return -1;
1733
}
1734
-#ifdef CONFIG_HMP
1734
md = cs->cc->sysemu_ops->monitor_defs;
1736
-#endif
1735
if (md == NULL) {
1736
return -1;
1737
}
monitor/meson.build
+7
-2
@@ -2,8 +2,13 @@ qmp_ss.add(files('monitor.c', 'qmp.c', 'qmp-cmds-control.c'))
2
3
system_ss.add(files(
4
'fds.c',
5
- 'hmp-cmds.c',
6
- 'hmp.c',
5
'qemu-config-qmp.c',
6
'qmp-cmds.c',
7
))
8
+
9
+if have_hmp
10
+ system_ss.add(files(
11
+ 'hmp-cmds.c',
12
+ 'hmp.c',
13
+ ))
14
+endif
net/meson.build
+3
-1
@@ -8,7 +8,6 @@ system_ss.add(files(
8
'filter-mirror.c',
9
'filter.c',
10
'hub.c',
11
- 'net-hmp-cmds.c',
11
'net.c',
12
'queue.c',
13
'socket.c',
@@ -16,6 +15,9 @@ system_ss.add(files(
15
'stream_data.c',
16
'util.c',
17
))
18
+if have_hmp
19
+ system_ss.add(files('net-hmp-cmds.c'))
20
+endif
21
22
if get_option('replication').allowed() or \
23
get_option('colo_proxy').allowed()
qom/meson.build
+3
-1
@@ -10,4 +10,6 @@ if have_system
10
endif
11
12
qmp_ss.add(files('qom-qmp-cmds.c'))
13
-system_ss.add(files('qom-hmp-cmds.c'))
13
+if have_hmp
14
+ system_ss.add(files('qom-hmp-cmds.c'))
15
+endif
stats/meson.build
+4
-1
@@ -1 +1,4 @@
1
-system_ss.add(files('stats-hmp-cmds.c', 'stats-qmp-cmds.c'))
1
+system_ss.add(files('stats-qmp-cmds.c'))
2
+if have_hmp
3
+ system_ss.add(files('stats-hmp-cmds.c'))
4
+endif
stubs/meson.build
+7
-5
@@ -86,11 +86,13 @@ if have_system
86
stub_ss.add(files('qmp-cpu.c'))
87
stub_ss.add(files('qmp-cpu-s390x.c'))
88
stub_ss.add(files('qmp-cpu-s390x-kvm.c'))
89
- stub_ss.add(files('hmp-cmd-info_mem.c'))
90
- stub_ss.add(files('hmp-cmd-info_sev.c'))
91
- stub_ss.add(files('hmp-cmd-info_tlb.c'))
92
- stub_ss.add(files('hmp-cmds-hw-s390x.c'))
93
- stub_ss.add(files('hmp-cmds-target-i386.c'))
89
+ if have_hmp
90
+ stub_ss.add(files('hmp-cmd-info_mem.c'))
91
+ stub_ss.add(files('hmp-cmd-info_sev.c'))
92
+ stub_ss.add(files('hmp-cmd-info_tlb.c'))
93
+ stub_ss.add(files('hmp-cmds-hw-s390x.c'))
94
+ stub_ss.add(files('hmp-cmds-target-i386.c'))
95
+ endif
96
endif
97
98
if have_system or have_user
system/meson.build
+8
-3
@@ -9,7 +9,6 @@ system_ss.add(files(
9
'cpus.c',
10
'cpu-timers.c',
11
'dirtylimit.c',
12
- 'dirtylimit-hmp-cmds.c',
12
'dma-helpers.c',
13
'exit-with-parent.c',
14
'globals.c',
@@ -24,12 +23,18 @@ system_ss.add(files(
23
'qtest.c',
24
'rtc.c',
25
'runstate-action.c',
27
- 'runstate-hmp-cmds.c',
26
'runstate.c',
29
- 'tpm-hmp-cmds.c',
27
'watchpoint.c',
28
))
29
30
+if have_hmp
31
+ system_ss.add(files(
32
+ 'dirtylimit-hmp-cmds.c',
33
+ 'runstate-hmp-cmds.c',
34
+ 'tpm-hmp-cmds.c',
35
+ ))
36
+endif
37
+
38
if have_tpm
39
system_ss.add(files('tpm.c'))
40
endif
tests/qtest/meson.build
+7
-1
@@ -26,7 +26,13 @@ qtests_generic = [
26
'qmp-test',
27
'qmp-cmd-test',
28
'qom-test',
29
- 'test-hmp',
29
+]
30
+if have_hmp
31
+ qtests_generic += [
32
+ 'test-hmp',
33
+ ]
34
+endif
35
+qtests_generic += [
36
'qos-test',
37
'readconfig-test',
38
'netdev-socket',
trace/meson.build
+4
-1
@@ -1,4 +1,7 @@
1
-system_ss.add(files('control-target.c', 'trace-hmp-cmds.c'))
1
+system_ss.add(files('control-target.c'))
2
+if have_hmp
3
+ system_ss.add(files('trace-hmp-cmds.c'))
4
+endif
5
trace_rs_targets = []
6
trace_events_files = []
7
foreach item : [ '.' ] + trace_events_subdirs + qapi_trace_events
ui/meson.build
+3
-1
@@ -56,10 +56,12 @@ system_ss.add(png)
56
system_ss.add(files(
57
'input-barrier.c',
58
'input.c',
59
- 'ui-hmp-cmds.c',
59
'ui-qmp-cmds.c',
60
'util.c',
61
))
62
+if have_hmp
63
+ system_ss.add(files('ui-hmp-cmds.c'))
64
+endif
65
system_ss.add(ui)
66
system_ss.add(when: pixman, if_true: files('console-vc.c'), if_false: files('console-vc-stubs.c'))
67
if dbus_display