1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
if not have_ga
if get_option('guest_agent_msi').enabled()
error('Guest agent MSI requested, but the guest agent is not being built')
endif
have_qga_vss = false
subdir_done()
endif
have_qga_vss = get_option('qga_vss') \
.require(host_os == 'windows',
error_message: 'VSS support requires Windows') \
.require('cpp' in all_languages,
error_message: 'VSS support requires a C++ compiler') \
.require(have_vss, error_message: '''VSS support requires VSS headers.
If your Visual Studio installation doesn't have the VSS headers,
Please download and install Microsoft VSS SDK:
http://www.microsoft.com/en-us/download/details.aspx?id=23490
On POSIX-systems, MinGW should provide headers in >=10.0 releases.
you can extract the SDK headers by:
$ scripts/extract-vsssdk-headers setup.exe
The headers are extracted in the directory 'inc/win2003'.
Then run configure with: --extra-cxxflags="-isystem /path/to/vss/inc/win2003"''') \
.require(midl.found() or widl.found(),
error_message: 'VSS support requires midl or widl') \
.require(not get_option('prefer_static'),
error_message: 'VSS support requires dynamic linking with GLib') \
.allowed()
all_qga = []
qga_qapi_outputs = [
'qga-qapi-commands.c',
'qga-qapi-commands.h',
'qga-qapi-emit-events.c',
'qga-qapi-emit-events.h',
'qga-qapi-events.c',
'qga-qapi-events.h',
'qga-qapi-init-commands.c',
'qga-qapi-init-commands.h',
'qga-qapi-introspect.c',
'qga-qapi-introspect.h',
'qga-qapi-types.c',
'qga-qapi-types.h',
'qga-qapi-visit.c',
'qga-qapi-visit.h',
]
# Problem: to generate trace events, we'd have to add the .trace-events
# file to qapi_trace_events like we do in qapi/meson.build. Since
# qapi_trace_events is used by trace/meson.build, we'd have to move
# subdir('qga') above subdir('trace') in the top-level meson.build.
# Can't, because it would break the dependency of qga on qemuutil (which
# depends on trace_ss). Not worth solving now; simply suppress trace
# event generation instead.
qga_qapi_files = custom_target('QGA QAPI files',
output: qga_qapi_outputs,
input: 'qapi-schema.json',
command: [ qapi_gen, '-o', 'qga', '-p', 'qga-', '@INPUT0@',
'--suppress-tracing' ],
depend_files: qapi_gen_depends)
qga_ss = ss.source_set()
qga_ss.add(qga_qapi_files.to_list())
qga_ss.add(files(
'commands.c',
'guest-agent-command-state.c',
'main.c',
'cutils.c',
))
if host_os == 'windows'
qga_ss.add(files(
'channel-win32.c',
'commands-win32.c',
'service-win32.c',
'vss-win32.c'
))
else
qga_ss.add(files(
'channel-posix.c',
'commands-posix.c',
'commands-posix-ssh.c',
))
if host_os == 'linux'
qga_ss.add(files('commands-linux.c'))
elif host_os in bsd_oses
qga_ss.add(files('commands-bsd.c'))
endif
endif
qga_ss = qga_ss.apply({})
gen_tlb = []
qga_libs = []
if host_os == 'windows'
qga_libs += ['-lws2_32', '-lwinmm', '-lpowrprof', '-lwtsapi32', '-lwininet', '-liphlpapi', '-lnetapi32',
'-lsetupapi', '-lcfgmgr32']
if have_qga_vss
qga_libs += ['-lole32', '-loleaut32', '-lshlwapi', '-lstdc++', '-Wl,--enable-stdcall-fixup']
subdir('vss-win32')
endif
endif
qga_objs = []
if host_os == 'windows'
windmc = find_program('windmc', required: true)
windres = find_program('windres', required: true)
msgrc = custom_target('messages-win32.rc',
input: 'messages-win32.mc',
output: ['messages-win32.rc', 'MSG00409.bin', 'messages-win32.h'],
command: [windmc, '-h', '@OUTDIR@', '-r', '@OUTDIR@', '@INPUT@'])
msgobj = custom_target('messages-win32.o',
input: msgrc[0],
output: 'messages-win32.o',
command: [windres, '-I', '@OUTDIR@', '-o', '@OUTPUT@', '@INPUT@'])
qga_objs = [msgobj]
endif
qga = executable('qemu-ga', qga_ss.sources() + qga_objs,
link_args: qga_libs,
dependencies: [qemuutil, libudev],
install: true)
all_qga += qga
if host_os == 'windows'
qemu_ga_msi_arch = {
'x86': ['-D', 'Arch=32'],
'x86_64': ['-a', 'x64', '-D', 'Arch=64']
}
wixl = not_found
if cpu in qemu_ga_msi_arch
wixl = find_program('wixl', required: get_option('guest_agent_msi'))
elif get_option('guest_agent_msi').enabled()
error('CPU not supported for building guest agent installation package')
endif
if wixl.found()
deps = [gen_tlb, qga]
qemu_ga_msi_vss = []
if have_qga_vss
qemu_ga_msi_vss = ['-D', 'InstallVss']
deps += qga_vss
endif
if glib.version().version_compare('<2.73.2')
libpcre = 'libpcre1'
else
libpcre = 'libpcre2'
endif
qga_msi_version = get_option('qemu_ga_version') == '' \
? meson.project_version() \
: get_option('qemu_ga_version')
qga_msi = custom_target('QGA MSI',
input: files('installer/qemu-ga.wxs'),
output: 'qemu-ga-@0@.msi'.format(host_arch),
depends: deps,
command: [
wixl, '-o', '@OUTPUT0@', '@INPUT0@',
qemu_ga_msi_arch[cpu],
qemu_ga_msi_vss,
'-D', 'BUILD_DIR=' + meson.project_build_root(),
'-D', 'BIN_DIR=' + glib_pc.get_variable('bindir'),
'-D', 'QEMU_GA_VERSION=' + qga_msi_version,
'-D', 'QEMU_GA_MANUFACTURER=' + get_option('qemu_ga_manufacturer'),
'-D', 'QEMU_GA_DISTRO=' + get_option('qemu_ga_distro'),
'-D', 'LIBPCRE=' + libpcre,
])
all_qga += [qga_msi]
alias_target('msi', qga_msi)
endif
else
if get_option('guest_agent_msi').enabled()
error('MSI guest agent package is available only for MinGW Windows cross-compilation')
endif
install_emptydir(get_option('localstatedir') / 'run')
endif
alias_target('qemu-ga', all_qga)
test_env = environment()
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
# disable qga-ssh-test for now. glib's G_TEST_OPTION_ISOLATE_DIRS triggers
# the leak detector in build-oss-fuzz Gitlab CI test. we should re-enable
# this when an alternative is implemented or when the underlying glib
# issue is identified/fix
#if host_os != 'windows'
if false
srcs = [files('commands-posix-ssh.c')]
i = 0
foreach output: qga_qapi_outputs
if output.startswith('qga-qapi-types') or output.startswith('qga-qapi-visit')
srcs += qga_qapi_files[i]
endif
i = i + 1
endforeach
qga_ssh_test = executable('qga-ssh-test', srcs,
dependencies: [qemuutil],
c_args: ['-DQGA_BUILD_UNIT_TEST'])
test('qga-ssh-test',
qga_ssh_test,
env: test_env,
suite: ['unit', 'qga'])
endif
|