1lock_protocol = 'lock_protocol.x'
2
3rpc_probe_files += files(lock_protocol)
4
5lock_driver_sources = [
6  'lock_manager.c',
7  'lock_driver_nop.c',
8  'domain_lock.c',
9]
10
11lock_driver_lockd_sources = [
12  'lock_driver_lockd.c',
13]
14
15lock_protocol_generated = []
16
17lock_protocol_generated += custom_target(
18  'lock_protocol.h',
19  input: lock_protocol,
20  output: 'lock_protocol.h',
21  command: [
22    genprotocol_prog, rpcgen_prog, '-h', '@INPUT@', '@OUTPUT@',
23  ],
24)
25
26lock_protocol_generated += custom_target(
27  'lock_protocol.c',
28  input: lock_protocol,
29  output: 'lock_protocol.c',
30  command: [
31    genprotocol_prog, rpcgen_prog, '-c', '@INPUT@', '@OUTPUT@',
32  ],
33)
34
35lock_daemon_sources = files(
36  'lock_daemon.c',
37  'lock_daemon_config.c',
38  'lock_daemon_dispatch.c',
39)
40
41lock_daemon_generated = custom_target(
42  'lock_daemon_dispatch_stubs.h',
43  input: lock_protocol,
44  output: 'lock_daemon_dispatch_stubs.h',
45  command: [
46    gendispatch_prog, '--mode=server',
47    'virLockSpaceProtocol', 'VIR_LOCK_SPACE_PROTOCOL', '@INPUT@',
48  ],
49  capture: true,
50)
51
52sanlock_sources = [
53  'lock_driver_sanlock.c',
54]
55
56sanlock_helper_sources = files(
57  'sanlock_helper.c',
58)
59
60lock_driver_lib = static_library(
61  'virt_lock_driver',
62  [
63    lock_driver_sources,
64  ],
65  dependencies: [
66    src_dep,
67  ],
68  include_directories: [
69    conf_inc_dir,
70  ],
71)
72
73libvirt_libs += lock_driver_lib
74
75if conf.has('WITH_LIBVIRTD')
76  lockd_lib_impl = static_library(
77    'lockd_impl',
78    [
79      files(lock_driver_lockd_sources),
80      lock_protocol_generated,
81    ],
82    include_directories: [
83      conf_inc_dir,
84    ],
85    dependencies: [
86      rpc_dep,
87      sasl_dep,
88      src_dep,
89      xdr_dep,
90    ],
91  )
92
93  check_protocols += {
94    'name': 'lock_protocol',
95    'lib': lockd_lib_impl,
96  }
97
98  lockdriver_dir = libdir / 'libvirt' / 'lock-driver'
99
100  virt_modules += {
101    'name': 'lockd',
102    'name_prefix': '',
103    'sources': [
104      dtrace_gen_objects,
105    ],
106    'link_whole': [
107      lockd_lib_impl,
108    ],
109    'link_args': [
110      libvirt_no_undefined,
111    ],
112    'install_dir': lockdriver_dir,
113  }
114
115  if conf.has('WITH_SANLOCK')
116    virt_modules += {
117      'name': 'sanlock',
118      'name_prefix': '',
119      'sources': [
120        files(sanlock_sources),
121      ],
122      'deps': [
123        sanlock_dep,
124      ],
125      'link_args': [
126        libvirt_no_undefined,
127      ],
128      'install_dir': lockdriver_dir,
129    }
130  endif
131
132  virt_daemons += {
133    'name': 'virtlockd',
134    'sources': [
135      lock_daemon_sources,
136      lock_daemon_generated,
137      lock_protocol_generated,
138    ],
139    'include': [
140      include_directories('.'),
141    ],
142  }
143
144  virt_daemon_units += {
145    'service': 'virtlockd',
146    'service_in': files('virtlockd.service.in'),
147    'name': '',
148    'sockprefix': '',
149    'sockets': [ 'main', 'admin' ],
150    'socket_in': files('virtlockd.socket.in'),
151    'socket_admin_in': files('virtlockd-admin.socket.in'),
152  }
153
154  openrc_init_files += {
155    'name': 'virtlockd',
156    'in_file': files('virtlockd.init.in'),
157  }
158
159  sysconf_files += {
160    'name': 'virtlockd',
161    'file': files('virtlockd.sysconf'),
162  }
163
164  if conf.has('WITH_SANLOCK')
165    virt_helpers += {
166      'name': 'libvirt_sanlock_helper',
167      'sources': [
168        sanlock_helper_sources,
169      ],
170      'include': [
171        conf_inc_dir,
172      ],
173    }
174  endif
175
176  virt_aug_files += files('libvirt_lockd.aug')
177
178  if conf.has('WITH_QEMU')
179    qemu_lockd_conf = configure_file(
180      input: 'lockd.conf',
181      output: 'qemu-lockd.conf',
182      copy: true,
183    )
184    virt_conf_files += qemu_lockd_conf
185    virt_test_aug_files += {
186      'name': 'test_libvirt_lockd.aug',
187      'aug': files('test_libvirt_lockd.aug.in'),
188      'conf': qemu_lockd_conf,
189      'test_name': 'libvirt_lockd',
190      'test_srcdir': meson.current_source_dir(),
191      'test_builddir': meson.current_build_dir(),
192    }
193  endif
194
195  if conf.has('WITH_LIBXL')
196    libxl_lockd_conf = configure_file(
197      input: 'lockd.conf',
198      output: 'libxl-lockd.conf',
199      copy: true,
200    )
201    virt_conf_files += libxl_lockd_conf
202  endif
203
204  if conf.has('WITH_SANLOCK')
205    virt_aug_files += files('libvirt_sanlock.aug')
206
207    if conf.has('WITH_QEMU')
208      qemu_sanlock_conf = configure_file(
209        input: 'sanlock.conf',
210        output: 'qemu-sanlock.conf',
211        copy: true,
212      )
213      virt_conf_files += qemu_sanlock_conf
214      virt_test_aug_files += {
215        'name': 'test_libvirt_sanlock.aug',
216        'aug': files('test_libvirt_sanlock.aug.in'),
217        'conf': qemu_sanlock_conf,
218        'test_name': 'libvirt_sanlock',
219        'test_srcdir': meson.current_source_dir(),
220        'test_builddir': meson.current_build_dir(),
221      }
222    endif
223
224    if conf.has('WITH_LIBXL')
225      libxl_sanlock_conf = configure_file(
226        input: 'sanlock.conf',
227        output: 'libxl-sanlock.conf',
228        copy: true,
229      )
230      virt_conf_files += libxl_sanlock_conf
231    endif
232  endif
233
234  virt_conf_files += files('virtlockd.conf')
235  virt_aug_files += files('virtlockd.aug')
236  virt_test_aug_files += {
237    'name': 'test_virtlockd.aug',
238    'aug': files('test_virtlockd.aug.in'),
239    'conf': files('virtlockd.conf'),
240    'test_name': 'virtlockd',
241    'test_srcdir': meson.current_source_dir(),
242    'test_builddir': meson.current_build_dir(),
243  }
244
245  virt_install_dirs += [
246    localstatedir / 'lib' / 'libvirt' / 'lockd',
247    localstatedir / 'lib' / 'libvirt' / 'lockd' / 'files',
248    runstatedir / 'libvirt' / 'lockd',
249  ]
250
251  if conf.has('WITH_SANLOCK')
252    virt_install_dirs += [
253      localstatedir / 'lib' / 'libvirt' / 'sanlock',
254    ]
255  endif
256endif
257