libvirt/src/qemu
Peter Krempa d29e0f3d4a qemuProcessStop: Prevent crash when qemuDomainObjStopWorker() unlocks the VM
'qemuDomainObjStopWorker()' which is meant to dispose of the event loop
thread for the monitor unlocks the VM object while disposing the thread
to prevent possible deadlocks with events waiting on the monitor thread.

Unfortunately 'qemuDomainObjStopWorker()' is called *before* the VM is
marked as inactive by clearing 'vm->def->id', but at the same time it's
no longer marked as 'beingDestroyed' when we're inside
'qemuProcessStop()'.

If 'vm' would be kept locked this wouldn't be a problem. Same way it's
not a problem for anything that uses non-ASYNC VM jobs, or when the
monitor is accessed in an async job, as the 'destroy' job interlocks
with those.

It is a problem for code inside an async job which uses
'qemuDomainObjWait()' though. The API contract of qemuDomainObjWait()
ensures the caller that the VM on successful return from it, but in this
specific reason it's not the case, as both 'beingDestroyed' is already
false, and 'vm->def->id' is not yet cleared.

To fix the issue move the 'qemuDomainObjStopWorker()' call *after*
clearing 'vm->def->id' and also add a note stating what the function is
doing.

Fixes: 860a999802
Closes: https://gitlab.com/libvirt/libvirt/-/issues/640
Reported-by: luzhipeng <luzhipeng@cestc.cn>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2024-06-20 09:58:21 +02:00
..
libvirt_qemu_probes.d
libvirt-qemu.sysusers.conf qemu: Add sysusers config file for qemu & kvm user/groups 2024-02-13 16:59:57 +01:00
libvirtd_qemu.aug qemu: Tweak augeas schema 2024-03-20 18:37:58 +01:00
meson.build meson: allow systemd sysusersdir to be changed 2024-06-13 10:23:11 +01:00
postcopy-migration.sysctl
qemu_agent.c qemu: Fix guest-sync response time in qga command 2024-02-22 09:51:23 +01:00
qemu_agent.h
qemu_alias.c qemu: Drop qemuDomainFindSCSIControllerModel() 2024-01-30 10:58:13 +01:00
qemu_alias.h
qemu_backup.c qemuBlockJobProcessEventConcludedBackup: Handle potentially NULL 'job->disk' 2024-06-20 09:52:54 +02:00
qemu_backup.h qemuBlockJobProcessEventConcludedBackup: Handle potentially NULL 'job->disk' 2024-06-20 09:52:54 +02:00
qemu_block.c qemuBlockStorageSourceNeedsFormatLayer: Stop formatting 'raw' driver when not needed 2024-02-02 16:03:08 +01:00
qemu_block.h qemuBlockStorageSourceNeedsFormatLayer: Stop formatting 'raw' driver when not needed 2024-02-02 16:03:08 +01:00
qemu_blockjob.c qemuBlockJobProcessEventConcludedBackup: Handle potentially NULL 'job->disk' 2024-06-20 09:52:54 +02:00
qemu_blockjob.h
qemu_capabilities.c qemu_capabilities: Remove unused struct 2024-05-13 03:14:14 +02:00
qemu_capabilities.h qemu_capabilities: Add QEMU_CAPS_DEVICE_VIRTIO_SOUND capability 2024-05-02 15:37:53 +02:00
qemu_capspriv.h qemu: capabilities: Unexport 'virQEMUCapsAddMachine' 2023-09-06 14:09:46 +02:00
qemu_cgroup.c qemu: Add support for /dev/userfaultfd 2024-02-13 17:44:26 +01:00
qemu_cgroup.h
qemu_checkpoint.c qemu: Use 'format' nodename accessors for block dirty bitmap operations 2023-10-17 14:16:17 +02:00
qemu_checkpoint.h
qemu_command.c qemu: fix qemu command for pci hostdevs and ramfb='off' 2024-05-20 12:42:18 -05:00
qemu_command.h qemu: Implement support for hotplugging evdev input devices 2024-05-16 14:56:59 +02:00
qemu_conf.c qemu: add runtime config option for nbdkit 2024-01-04 14:34:40 -06:00
qemu_conf.h qemu: add runtime config option for nbdkit 2024-01-04 14:34:40 -06:00
qemu_dbus.c
qemu_dbus.h
qemu_domain_address.c conf: Introduce support for virtio-sound devices 2024-05-02 15:38:32 +02:00
qemu_domain_address.h qemu: Move qemuDomainGetSCSIControllerModel() 2024-01-30 10:58:13 +01:00
qemu_domain.c qemuDomainObjWait: Add documentation 2024-06-20 09:52:55 +02:00
qemu_domain.h qemu: Change return type of qemuDomainFixupCPUs to void 2024-04-17 17:36:59 +02:00
qemu_domainjob.c
qemu_domainjob.h
qemu_driver.c qemu: implement iommu coldplug/unplug 2024-06-18 12:17:50 +02:00
qemu_driver.h
qemu_extdevice.c qemu: add a 'chain' parameter to nbdkit start/stop 2024-02-12 16:13:17 -06:00
qemu_extdevice.h
qemu_fd.c
qemu_fd.h
qemu_firmware.c qemu: Make firmware parsing failures non-fatal 2024-03-04 14:36:39 +01:00
qemu_firmware.h qemu: Match NVRAM template extension for new domains 2023-08-21 13:51:32 +02:00
qemu_hostdev.c conf: replace virHostdevIsVFIODevice with virHostdevIsPCIDevice 2024-01-07 23:58:44 -05:00
qemu_hostdev.h
qemu_hotplug.c qemu: hotplug: Validate definition of 'FS' device after address allocation 2024-05-31 12:54:32 +02:00
qemu_hotplug.h
qemu_interface.c hypervisor: Move domain interface mgmt methods 2024-02-02 10:58:26 +01:00
qemu_interface.h hypervisor: Move domain interface mgmt methods 2024-02-02 10:58:26 +01:00
qemu_interop_config.c
qemu_interop_config.h
qemu_logcontext.c qemu: move qemuProcessReadLog() to qemuLogContext 2023-09-19 14:28:50 -05:00
qemu_logcontext.h qemu: move qemuProcessReadLog() to qemuLogContext 2023-09-19 14:28:50 -05:00
qemu_migration_cookie.c qemu: domain: Drop added features from migratable CPU 2024-03-14 16:15:06 +01:00
qemu_migration_cookie.h
qemu_migration_params.c qemu: migration: Don't use empty string for 'tls-hostname' NBD blockdev 2024-04-24 13:45:56 +02:00
qemu_migration_params.h qemu: Enable postcopy-preempt migration capability 2024-01-08 22:41:23 +01:00
qemu_migration_paramspriv.h
qemu_migration.c qemuMigrationDstPrepareStorage: Annotate that existance of 'volume' disks is checked elswhere 2024-02-21 14:15:49 +01:00
qemu_migration.h
qemu_monitor_json.c lib: Annotate more function as NULL terminated 2024-06-06 09:29:58 +02:00
qemu_monitor_json.h qemu: implement qemuDomainGraphicsReload 2024-03-08 17:00:15 +01:00
qemu_monitor_priv.h qemu: monitor: Use 'backing-mask-protocol' for blockjobs when available 2024-02-02 16:03:08 +01:00
qemu_monitor_text.c
qemu_monitor_text.h
qemu_monitor.c qemu: implement qemuDomainGraphicsReload 2024-03-08 17:00:15 +01:00
qemu_monitor.h lib: Annotate more function as NULL terminated 2024-06-06 09:29:58 +02:00
qemu_namespace.c virDomainRNGDef: Convert 'backend' field to proper enum type 2023-09-15 10:35:11 +02:00
qemu_namespace.h
qemu_nbdkit.c qemu: handle adding/removing nbdkit-backed disk sources 2024-02-12 16:13:17 -06:00
qemu_nbdkit.h qemu: add a 'chain' parameter to nbdkit start/stop 2024-02-12 16:13:17 -06:00
qemu_nbdkitpriv.h tests: add tests for nbdkit invocation 2023-09-19 14:28:50 -05:00
qemu_passt.c meson: Stop looking for passt at build time 2023-12-05 11:50:44 +01:00
qemu_passt.h
qemu_process.c qemuProcessStop: Prevent crash when qemuDomainObjStopWorker() unlocks the VM 2024-06-20 09:58:21 +02:00
qemu_process.h qemu: process: Extract host setup of disk device into helpers 2023-10-27 15:04:20 +02:00
qemu_processpriv.h
qemu_qapi.c
qemu_qapi.h
qemu_saveimage.c qemu_saveimage: add zstd to supported compression formats 2024-05-06 14:56:58 +02:00
qemu_saveimage.h qemu_saveimage: move qemuSaveImageStartProcess to qemu_process 2023-10-09 13:56:49 +02:00
qemu_security.c qemu: Add support for /dev/userfaultfd 2024-02-13 17:44:26 +01:00
qemu_security.h qemu: Add support for /dev/userfaultfd 2024-02-13 17:44:26 +01:00
qemu_shim.c
qemu_slirp.c
qemu_slirp.h
qemu_snapshot.c qemu_snapshot: fix memory leak when reverting external snapshot 2024-05-29 15:23:55 +02:00
qemu_snapshot.h
qemu_tpm.c qemu: Move error messages onto a single line 2023-09-04 09:35:36 +02:00
qemu_tpm.h
qemu_validate.c qemu_validate: Validate support for SCSI emulation support in 'virtio-blk' devices 2024-06-12 08:21:12 +02:00
qemu_validate.h
qemu_vhost_user_gpu.c
qemu_vhost_user_gpu.h
qemu_vhost_user.c
qemu_vhost_user.h
qemu_virtiofs.c qemu: virtiofs: error out if getting the group or user name fails 2024-03-18 15:20:24 +01:00
qemu_virtiofs.h
qemu.conf.in qemu_saveimage: add zstd to supported compression formats 2024-05-06 14:56:58 +02:00
test_libvirtd_qemu.aug.in qemu: Add support for /dev/userfaultfd 2024-02-13 17:44:26 +01:00
virtqemud.init.in
virtqemud.service.extra.in systemd: Set service_extra_in/socket_extra_in everywhere 2023-10-25 12:19:32 +02:00
virtqemud.socket.extra.in systemd: Set service_extra_in/socket_extra_in everywhere 2023-10-25 12:19:32 +02:00