120cf5cb4SPaolo Bonziniif not have_ga 220cf5cb4SPaolo Bonzini if get_option('guest_agent_msi').enabled() 320cf5cb4SPaolo Bonzini error('Guest agent MSI requested, but the guest agent is not being built') 420cf5cb4SPaolo Bonzini endif 58821a389SMarc-André Lureau have_qga_vss = false 620cf5cb4SPaolo Bonzini subdir_done() 720cf5cb4SPaolo Bonziniendif 820cf5cb4SPaolo Bonzini 98821a389SMarc-André Lureauhave_qga_vss = get_option('qga_vss') \ 108821a389SMarc-André Lureau .require(targetos == 'windows', 118821a389SMarc-André Lureau error_message: 'VSS support requires Windows') \ 128821a389SMarc-André Lureau .require(link_language == 'cpp', 138821a389SMarc-André Lureau error_message: 'VSS support requires a C++ compiler') \ 148821a389SMarc-André Lureau .require(have_vss, error_message: '''VSS support requires VSS headers. 158821a389SMarc-André Lureau If your Visual Studio installation doesn't have the VSS headers, 168821a389SMarc-André Lureau Please download and install Microsoft VSS SDK: 178821a389SMarc-André Lureau http://www.microsoft.com/en-us/download/details.aspx?id=23490 18b770f6ceSMarc-André Lureau On POSIX-systems, MinGW should provide headers in >=10.0 releases. 198821a389SMarc-André Lureau you can extract the SDK headers by: 208821a389SMarc-André Lureau $ scripts/extract-vsssdk-headers setup.exe 218821a389SMarc-André Lureau The headers are extracted in the directory 'inc/win2003'. 228821a389SMarc-André Lureau Then run configure with: --extra-cxxflags="-isystem /path/to/vss/inc/win2003"''') \ 2323011f44SMarc-André Lureau .require(midl.found() or widl.found(), 2423011f44SMarc-André Lureau error_message: 'VSS support requires midl or widl') \ 25a0cbd2e8SPaolo Bonzini .require(not get_option('prefer_static'), 26e23460ceSMarc-André Lureau error_message: 'VSS support requires dynamic linking with GLib') \ 278821a389SMarc-André Lureau .allowed() 288821a389SMarc-André Lureau 2987263685SPaolo Bonziniall_qga = [] 3087263685SPaolo Bonzini 31f15bff25SPaolo Bonziniqga_qapi_outputs = [ 32f15bff25SPaolo Bonzini 'qga-qapi-commands.c', 33f15bff25SPaolo Bonzini 'qga-qapi-commands.h', 34f15bff25SPaolo Bonzini 'qga-qapi-emit-events.c', 35f15bff25SPaolo Bonzini 'qga-qapi-emit-events.h', 36f15bff25SPaolo Bonzini 'qga-qapi-events.c', 37f15bff25SPaolo Bonzini 'qga-qapi-events.h', 38f15bff25SPaolo Bonzini 'qga-qapi-init-commands.c', 39f15bff25SPaolo Bonzini 'qga-qapi-init-commands.h', 40f15bff25SPaolo Bonzini 'qga-qapi-introspect.c', 41f15bff25SPaolo Bonzini 'qga-qapi-introspect.h', 42f15bff25SPaolo Bonzini 'qga-qapi-types.c', 43f15bff25SPaolo Bonzini 'qga-qapi-types.h', 44f15bff25SPaolo Bonzini 'qga-qapi-visit.c', 45f15bff25SPaolo Bonzini 'qga-qapi-visit.h', 46f15bff25SPaolo Bonzini] 47f15bff25SPaolo Bonzini 48378dfa48SVladimir Sementsov-Ogievskiy# Problem: to generate trace events, we'd have to add the .trace-events 49378dfa48SVladimir Sementsov-Ogievskiy# file to qapi_trace_events like we do in qapi/meson.build. Since 50378dfa48SVladimir Sementsov-Ogievskiy# qapi_trace_events is used by trace/meson.build, we'd have to move 51378dfa48SVladimir Sementsov-Ogievskiy# subdir('qga') above subdir('trace') in the top-level meson.build. 52378dfa48SVladimir Sementsov-Ogievskiy# Can't, because it would break the dependency of qga on qemuutil (which 53378dfa48SVladimir Sementsov-Ogievskiy# depends on trace_ss). Not worth solving now; simply suppress trace 54378dfa48SVladimir Sementsov-Ogievskiy# event generation instead. 55f15bff25SPaolo Bonziniqga_qapi_files = custom_target('QGA QAPI files', 56db16115fSPeter Maydell output: qga_qapi_outputs, 57f15bff25SPaolo Bonzini input: 'qapi-schema.json', 58761a1a48SVladimir Sementsov-Ogievskiy command: [ qapi_gen, '-o', 'qga', '-p', 'qga-', '@INPUT0@', 59761a1a48SVladimir Sementsov-Ogievskiy '--suppress-tracing' ], 60f15bff25SPaolo Bonzini depend_files: qapi_gen_depends) 61acfdaac5SPaolo Bonzini 62f15bff25SPaolo Bonziniqga_ss = ss.source_set() 632a127f96SMarc-André Lureauqga_ss.add(qga_qapi_files.to_list()) 64f15bff25SPaolo Bonziniqga_ss.add(files( 65f15bff25SPaolo Bonzini 'commands.c', 66f15bff25SPaolo Bonzini 'guest-agent-command-state.c', 67f15bff25SPaolo Bonzini 'main.c', 680edbfbe3SMarc-André Lureau 'cutils.c', 69f15bff25SPaolo Bonzini)) 70f15bff25SPaolo Bonziniqga_ss.add(when: 'CONFIG_POSIX', if_true: files( 71f15bff25SPaolo Bonzini 'channel-posix.c', 728d769ec7SMarc-André Lureau 'commands-posix.c', 738d769ec7SMarc-André Lureau 'commands-posix-ssh.c', 748d769ec7SMarc-André Lureau)) 75518b0d80SAlexander Ivanovqga_ss.add(when: 'CONFIG_LINUX', if_true: files( 76518b0d80SAlexander Ivanov 'commands-linux.c', 77518b0d80SAlexander Ivanov)) 78bad0001eSAlexander Ivanovqga_ss.add(when: 'CONFIG_BSD', if_true: files( 79bad0001eSAlexander Ivanov 'commands-bsd.c', 80bad0001eSAlexander Ivanov)) 81f15bff25SPaolo Bonziniqga_ss.add(when: 'CONFIG_WIN32', if_true: files( 82f15bff25SPaolo Bonzini 'channel-win32.c', 83f15bff25SPaolo Bonzini 'commands-win32.c', 84f15bff25SPaolo Bonzini 'service-win32.c', 85f15bff25SPaolo Bonzini 'vss-win32.c' 86f15bff25SPaolo Bonzini)) 87f15bff25SPaolo Bonzini 88f15bff25SPaolo Bonziniqga_ss = qga_ss.apply(config_host, strict: false) 89f15bff25SPaolo Bonzini 90328ec32dSMarc-André Lureaugen_tlb = [] 9187263685SPaolo Bonziniqga_libs = [] 9287263685SPaolo Bonziniif targetos == 'windows' 933015321dSMarc-André Lureau qga_libs += ['-lws2_32', '-lwinmm', '-lpowrprof', '-lwtsapi32', '-lwininet', '-liphlpapi', '-lnetapi32', 943015321dSMarc-André Lureau '-lsetupapi', '-lcfgmgr32'] 958821a389SMarc-André Lureau if have_qga_vss 9687263685SPaolo Bonzini qga_libs += ['-lole32', '-loleaut32', '-lshlwapi', '-lstdc++', '-Wl,--enable-stdcall-fixup'] 9787263685SPaolo Bonzini subdir('vss-win32') 9887263685SPaolo Bonzini endif 99328ec32dSMarc-André Lureauendif 100328ec32dSMarc-André Lureau 101f9f0e617SAndrey Drobyshevqga_objs = [] 102f9f0e617SAndrey Drobyshevif targetos == 'windows' 103f9f0e617SAndrey Drobyshev windmc = find_program('windmc', required: true) 104f9f0e617SAndrey Drobyshev windres = find_program('windres', required: true) 105f9f0e617SAndrey Drobyshev 106f9f0e617SAndrey Drobyshev msgrc = custom_target('messages-win32.rc', 107f9f0e617SAndrey Drobyshev input: 'messages-win32.mc', 108f9f0e617SAndrey Drobyshev output: ['messages-win32.rc', 'MSG00409.bin', 'messages-win32.h'], 109f9f0e617SAndrey Drobyshev command: [windmc, '-h', '@OUTDIR@', '-r', '@OUTDIR@', '@INPUT@']) 110f9f0e617SAndrey Drobyshev msgobj = custom_target('messages-win32.o', 111f9f0e617SAndrey Drobyshev input: msgrc[0], 112f9f0e617SAndrey Drobyshev output: 'messages-win32.o', 113f9f0e617SAndrey Drobyshev command: [windres, '-I', '@OUTDIR@', '-o', '@OUTPUT@', '@INPUT@']) 114f9f0e617SAndrey Drobyshev 115f9f0e617SAndrey Drobyshev qga_objs = [msgobj] 116f9f0e617SAndrey Drobyshevendif 117f9f0e617SAndrey Drobyshev 118f9f0e617SAndrey Drobyshevqga = executable('qemu-ga', qga_ss.sources() + qga_objs, 11987263685SPaolo Bonzini link_args: qga_libs, 12087263685SPaolo Bonzini dependencies: [qemuutil, libudev], 12187263685SPaolo Bonzini install: true) 12287263685SPaolo Bonziniall_qga += qga 12387263685SPaolo Bonzini 12487263685SPaolo Bonziniif targetos == 'windows' 125b846ab7cSPaolo Bonzini qemu_ga_msi_arch = { 126b846ab7cSPaolo Bonzini 'x86': ['-D', 'Arch=32'], 127b846ab7cSPaolo Bonzini 'x86_64': ['-a', 'x64', '-D', 'Arch=64'] 128b846ab7cSPaolo Bonzini } 129b846ab7cSPaolo Bonzini wixl = not_found 130b846ab7cSPaolo Bonzini if cpu in qemu_ga_msi_arch 131b846ab7cSPaolo Bonzini wixl = find_program('wixl', required: get_option('guest_agent_msi')) 132b846ab7cSPaolo Bonzini elif get_option('guest_agent_msi').enabled() 133b846ab7cSPaolo Bonzini error('CPU not supported for building guest agent installation package') 134b846ab7cSPaolo Bonzini endif 135b846ab7cSPaolo Bonzini 136328ec32dSMarc-André Lureau if wixl.found() 137328ec32dSMarc-André Lureau deps = [gen_tlb, qga] 138b846ab7cSPaolo Bonzini qemu_ga_msi_vss = [] 1398821a389SMarc-André Lureau if have_qga_vss 140b846ab7cSPaolo Bonzini qemu_ga_msi_vss = ['-D', 'InstallVss'] 141328ec32dSMarc-André Lureau deps += qga_vss 142328ec32dSMarc-André Lureau endif 1439ca180bcSAndrey Drobyshev if glib.version() < '2.73.2' 1449ca180bcSAndrey Drobyshev libpcre = 'libpcre1' 1459ca180bcSAndrey Drobyshev else 1469ca180bcSAndrey Drobyshev libpcre = 'libpcre2' 1479ca180bcSAndrey Drobyshev endif 148328ec32dSMarc-André Lureau qga_msi = custom_target('QGA MSI', 149328ec32dSMarc-André Lureau input: files('installer/qemu-ga.wxs'), 1506bee0960SMarc-André Lureau output: 'qemu-ga-@0@.msi'.format(host_arch), 151328ec32dSMarc-André Lureau depends: deps, 152328ec32dSMarc-André Lureau command: [ 153328ec32dSMarc-André Lureau wixl, '-o', '@OUTPUT0@', '@INPUT0@', 154b846ab7cSPaolo Bonzini qemu_ga_msi_arch[cpu], 155b846ab7cSPaolo Bonzini qemu_ga_msi_vss, 156ca5765c8SPaolo Bonzini '-D', 'BUILD_DIR=' + meson.project_build_root(), 157*91a2e688SPaolo Bonzini '-D', 'BIN_DIR=' + glib_pc.get_variable('bindir'), 1584f3c5778SMarc-André Lureau '-D', 'QEMU_GA_VERSION=' + config_host['QEMU_GA_VERSION'], 1594f3c5778SMarc-André Lureau '-D', 'QEMU_GA_MANUFACTURER=' + config_host['QEMU_GA_MANUFACTURER'], 1604f3c5778SMarc-André Lureau '-D', 'QEMU_GA_DISTRO=' + config_host['QEMU_GA_DISTRO'], 1619ca180bcSAndrey Drobyshev '-D', 'LIBPCRE=' + libpcre, 162328ec32dSMarc-André Lureau ]) 163588a19faSPaolo Bonzini all_qga += [qga_msi] 164328ec32dSMarc-André Lureau alias_target('msi', qga_msi) 1657272fc72SMarc-André Lureau endif 1668ab1aabcSMarc-André Lureauelse 167b846ab7cSPaolo Bonzini if get_option('guest_agent_msi').enabled() 168b846ab7cSPaolo Bonzini error('MSI guest agent package is available only for MinGW Windows cross-compilation') 169b846ab7cSPaolo Bonzini endif 1708a29c205SPaolo Bonzini install_emptydir(get_option('localstatedir') / 'run') 1717272fc72SMarc-André Lureauendif 172588a19faSPaolo Bonzini 173588a19faSPaolo Bonzinialias_target('qemu-ga', all_qga) 1748d769ec7SMarc-André Lureau 1758d769ec7SMarc-André Lureautest_env = environment() 1768d769ec7SMarc-André Lureautest_env.set('G_TEST_SRCDIR', meson.current_source_dir()) 1778d769ec7SMarc-André Lureautest_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) 1788d769ec7SMarc-André Lureau 1798d769ec7SMarc-André Lureau# disable qga-ssh-test for now. glib's G_TEST_OPTION_ISOLATE_DIRS triggers 1808d769ec7SMarc-André Lureau# the leak detector in build-oss-fuzz Gitlab CI test. we should re-enable 1818d769ec7SMarc-André Lureau# this when an alternative is implemented or when the underlying glib 1828d769ec7SMarc-André Lureau# issue is identified/fix 1838d769ec7SMarc-André Lureau#if 'CONFIG_POSIX' in config_host 1848d769ec7SMarc-André Lureauif false 185cad97c08SMarc-André Lureau srcs = [files('commands-posix-ssh.c')] 186cad97c08SMarc-André Lureau i = 0 187cad97c08SMarc-André Lureau foreach output: qga_qapi_outputs 188cad97c08SMarc-André Lureau if output.startswith('qga-qapi-types') or output.startswith('qga-qapi-visit') 189cad97c08SMarc-André Lureau srcs += qga_qapi_files[i] 190cad97c08SMarc-André Lureau endif 191cad97c08SMarc-André Lureau i = i + 1 192cad97c08SMarc-André Lureau endforeach 193cad97c08SMarc-André Lureau qga_ssh_test = executable('qga-ssh-test', srcs, 1948d769ec7SMarc-André Lureau dependencies: [qemuutil], 1958d769ec7SMarc-André Lureau c_args: ['-DQGA_BUILD_UNIT_TEST']) 1968d769ec7SMarc-André Lureau 1978d769ec7SMarc-André Lureau test('qga-ssh-test', 1988d769ec7SMarc-André Lureau qga_ssh_test, 1998d769ec7SMarc-André Lureau env: test_env, 2008d769ec7SMarc-André Lureau suite: ['unit', 'qga']) 2018d769ec7SMarc-André Lureauendif 202