meson: Introduce qemu_datadir option

There is no guarantee that QEMU and libvirt have been configured
with the same prefix.

In particular, Homebrew on macOS will pass a different, private
prefix for each package version and then use symlinks to make
the files for a specific version appear in the usual locations.

This works perfectly fine as long as one package doesn't try to
go poking around another package's data - which is exactly what
libvirt needs to do in order to read and parse the QEMU interop
data.

qemu_datadir can now be explicitly provided to make this and
other uncommon scenarios work. The common scenario, where QEMU
and libvirt both use the same prefix, is unaffected.

https://gitlab.com/libvirt/libvirt/-/issues/168

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Andrea Bolognani 2021-11-15 18:13:56 +01:00
parent c46c2e15d1
commit 794af15f24
3 changed files with 7 additions and 1 deletions

View File

@ -1685,6 +1685,12 @@ if not get_option('driver_qemu').disabled()
endif endif
conf.set_quoted('QEMU_MODDIR', qemu_moddir) conf.set_quoted('QEMU_MODDIR', qemu_moddir)
qemu_datadir = get_option('qemu_datadir')
if qemu_datadir == ''
qemu_datadir = datadir / 'qemu'
endif
conf.set_quoted('QEMU_DATADIR', qemu_datadir)
if host_machine.system() in [ 'freebsd', 'darwin' ] if host_machine.system() in [ 'freebsd', 'darwin' ]
default_qemu_user = 'root' default_qemu_user = 'root'
default_qemu_group = 'wheel' default_qemu_group = 'wheel'

View File

@ -62,6 +62,7 @@ option('driver_qemu', type: 'feature', value: 'auto', description: 'QEMU/KVM dri
option('qemu_user', type: 'string', value: '', description: 'username to run QEMU system instance as') option('qemu_user', type: 'string', value: '', description: 'username to run QEMU system instance as')
option('qemu_group', type: 'string', value: '', description: 'groupname to run QEMU system instance as') option('qemu_group', type: 'string', value: '', description: 'groupname to run QEMU system instance as')
option('qemu_moddir', type: 'string', value: '', description: 'set the directory where QEMU modules are located') option('qemu_moddir', type: 'string', value: '', description: 'set the directory where QEMU modules are located')
option('qemu_datadir', type: 'string', value: '', description: 'set the directory where QEMU shared data is located')
option('driver_remote', type: 'feature', value: 'auto', description: 'remote driver') option('driver_remote', type: 'feature', value: 'auto', description: 'remote driver')
option('remote_default_mode', type: 'combo', choices: ['legacy', 'direct'], value: 'direct', description: 'remote driver default mode') option('remote_default_mode', type: 'combo', choices: ['legacy', 'direct'], value: 'direct', description: 'remote driver default mode')
option('driver_secrets', type: 'feature', value: 'auto', description: 'local secrets management driver') option('driver_secrets', type: 'feature', value: 'auto', description: 'local secrets management driver')

View File

@ -80,7 +80,6 @@ qemuBuildFileList(GHashTable *files, const char *dir)
return 0; return 0;
} }
#define QEMU_DATADIR DATADIR "/qemu"
#define QEMU_CONFDIR SYSCONFDIR "/qemu" #define QEMU_CONFDIR SYSCONFDIR "/qemu"
int int