Files
qemu/system/meson.build
Richard W.M. Jones 886898baad Implement -run-with exit-with-parent=on
Libguestfs wants to use qemu to run a captive appliance.  When the
program linked to libguestfs exits, we want qemu to be cleaned up.
Libguestfs goes to great lengths to do this at the moment: it either
forks a separate process to ensure clean-up is done, or it asks
libvirt to clean up the qemu process.  However this is complicated and
not totally reliable.

On Linux, FreeBSD and macOS, there are mechanisms to ensure a signal
or message is delivered to a process when its parent process goes
away.  The qemu test suite even uses this mechanism on Linux (see
PR_SET_PDEATHSIG in tests/qtest/libqtest.c).

In nbdkit we have long had the concept of running nbdkit captively,
and we have the nbdkit --exit-with-parent flag to help
(https://libguestfs.org/nbdkit-captive.1.html#EXIT-WITH-PARENT)

This commit adds the same mechanism.  The syntax is:

  qemu -run-with exit-with-parent=on [...]

This is not a feature that most typical users of qemu (for running
general purpose, long-lived VMs) should use, so it defaults to off.

The exit-with-parent.[ch] files are copied from nbdkit, where they
have a 3-clause BSD license which is compatible with qemu:

https://gitlab.com/nbdkit/nbdkit/-/tree/master/common/utils?ref_type=heads

Thanks: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2025-11-03 10:05:39 +00:00

46 lines
917 B
Meson

specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: [files(
'arch_init.c',
'globals-target.c',
)])
system_ss.add(files(
'vl.c',
), sdl, libpmem, libdaxctl)
system_ss.add(files(
'balloon.c',
'bootdevice.c',
'cpus.c',
'cpu-timers.c',
'datadir.c',
'dirtylimit.c',
'dma-helpers.c',
'exit-with-parent.c',
'globals.c',
'ioport.c',
'ram-block-attributes.c',
'memory_mapping.c',
'memory.c',
'physmem.c',
'qdev-monitor.c',
'qtest.c',
'rtc.c',
'runstate-action.c',
'runstate-hmp-cmds.c',
'runstate.c',
'tpm-hmp-cmds.c',
'watchpoint.c',
))
if have_tpm
system_ss.add(files('tpm.c'))
endif
system_ss.add(when: seccomp, if_true: files('qemu-seccomp.c'))
system_ss.add(when: 'CONFIG_DEVICE_TREE',
if_true: [fdt, files('device_tree.c')],
if_false: files('device_tree-stub.c'))
if host_os == 'linux'
system_ss.add(files('async-teardown.c'))
endif