libvirt/src/util
Michal Privoznik d146105f1e virCommand: Actually acquire pidfile instead of just writing it
Our virCommand module allows us to set a pidfile for commands we
want to spawn. The caller constructs the string of pidfile path
and then uses virCommandSetPidFile() to tell the module to write
the pidfile once the command is ran. This usually works, but has
two flaws:

1) the child process does not hold the pidfile open & locked.
Therefore, the caller (or anybody else) can't use our fancy
virPidFileForceCleanupPath() function to kill the command
afterwards. Also, for everybody else on the system it's
needlessly harder to check if the pid from the pidfile is still
alive or not.

2) if the caller ever makes a mistake and passes the same pidfile
path for two different commands, the start of the second command
will overwrite the pidfile even though the first command might
still be running.

NOTE that this temporarily renders some command spawning
unusable, specifically those code patterns where both
virCommandSetPidFile() is used together with instructing spawned
command to acquire pidfile itself. Fortunately, there is only one
occurrence of such pattern and it is in
qemuProcessStartManagedPRDaemon(). This is fixed in next commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-03-24 15:44:23 +01:00
..
glibcompat.c util: introduce compile time API version checking 2020-01-07 14:42:26 +00:00
glibcompat.h util: add compat impl of g_canonicalize_filename 2020-01-07 14:42:26 +00:00
iohelper.c Remove virutil.h where possible 2020-02-24 23:15:49 +01:00
Makefile.inc.am util: remove virKeyFile 2020-03-23 15:36:02 +01:00
viralloc.c VIR_FREE: Replace internals by g_clear_pointer 2020-03-05 16:22:27 +01:00
viralloc.h VIR_FREE: Replace internals by g_clear_pointer 2020-03-05 16:22:27 +01:00
virarch.c util: add a virArchFromHost() impl for Windows 2020-01-29 14:51:39 +00:00
virarch.h Add a space before ending a comment 2020-01-30 12:32:03 +01:00
virarptable.c src: convert all code to use virsocket.h 2020-01-29 14:51:40 +00:00
virarptable.h
viraudit.c Use g_strerror instead of virStrerror 2020-03-13 17:26:55 +01:00
viraudit.h Use G_GNUC_PRINTF instead of ATTRIBUTE_FMT_PRINTF 2019-10-15 16:14:18 +02:00
virauth.c util: Don't check the output of virGetUserConfigDirectory() 2019-12-20 09:38:43 +01:00
virauth.h
virauthconfig.c util: authconfig: use g_key_file_* 2020-03-23 15:34:28 +01:00
virauthconfig.h Remove virautoclean.h 2019-10-16 12:06:44 +02:00
virbitmap.c virBitmapNewEmpty: Use g_new0 to allocate and remove error checking 2020-03-20 09:47:16 +01:00
virbitmap.h Remove virautoclean.h 2019-10-16 12:06:44 +02:00
virbpf.c virbpf: Set errno instead of reporting errors 2020-03-10 17:10:57 +01:00
virbpf.h util: introduce virbpf helpers 2019-11-15 12:58:00 +01:00
virbuffer.c virBufferTrim: do not accept len 2020-02-03 19:44:38 +01:00
virbuffer.h virBufferTrim: do not accept len 2020-02-03 19:44:38 +01:00
vircgroup.c vircgroup: add virCgroupGetCpuPeriodQuota() 2020-02-23 14:02:24 +01:00
vircgroup.h util: vircgroup: include unistd.h rather than virutil.h 2020-02-24 23:15:49 +01:00
vircgroupbackend.c
vircgroupbackend.h vircgroup: workaround devices in hybrid mode 2019-11-15 12:58:43 +01:00
vircgrouppriv.h vircgroup: introduce virCgroupV2DevicesAttachProg 2019-11-15 12:58:05 +01:00
vircgroupv1.c util: vircgroup: include unistd.h rather than virutil.h 2020-02-24 23:15:49 +01:00
vircgroupv1.h
vircgroupv2.c util: vircgroup: include unistd.h rather than virutil.h 2020-02-24 23:15:49 +01:00
vircgroupv2.h
vircgroupv2devices.c virCgroupV2DevicesAvailable: Print stringified errno in the debug log 2020-03-10 17:10:21 +01:00
vircgroupv2devices.h vircgroupv2devices: Unexport virCgroupV2DevicesAttachProg() 2020-01-06 17:30:17 +01:00
vircommand.c virCommand: Actually acquire pidfile instead of just writing it 2020-03-24 15:44:23 +01:00
vircommand.h Remove virautoclean.h 2019-10-16 12:06:44 +02:00
vircommandpriv.h
virconf.c util: Don't check the output of virGetUserConfigDirectory() 2019-12-20 09:38:43 +01:00
virconf.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
vircrypto.c src: replace verify(expr) with G_STATIC_ASSERT(expr) 2020-01-17 10:02:01 +00:00
vircrypto.h Use G_GNUC_WARN_UNUSED_RESULT instead of ATTRIBUTE_RETURN_CHECK 2019-10-15 11:25:22 +02:00
virdbus.c util: remove unneeded cleanup labels 2019-11-12 17:54:01 +01:00
virdbus.h Revert "dbus: correctly build reply message" 2019-09-10 09:47:13 +02:00
virdbuspriv.h
virdevmapper.c src: assume sys/sysmacros.h always exists on Linux 2020-02-04 14:00:45 +00:00
virdevmapper.h qemu: Create multipath targets for PRs 2020-03-12 08:04:40 +01:00
virdnsmasq.c src: remove usage of strchrnul function 2020-01-29 14:51:39 +00:00
virdnsmasq.h
virebtables.c util: Use g_strdup_printf() instead of virAsprintf() 2019-11-12 16:15:58 +01:00
virebtables.h
virendian.h
virenum.c
virenum.h src: replace verify(expr) with G_STATIC_ASSERT(expr) 2020-01-17 10:02:01 +00:00
virerror.c util: remove virStrerror 2020-03-13 17:26:55 +01:00
virerror.h util: remove virStrerror 2020-03-13 17:26:55 +01:00
virerrorpriv.h
virevent.c util: switch to use the GLib event loop impl 2020-02-07 15:03:53 +00:00
virevent.h event: add API for requiring an event loop impl to be registered 2019-12-18 14:04:59 +00:00
vireventglib.c util: import an event loop impl based on GMainContext 2020-02-07 15:03:53 +00:00
vireventglib.h util: import an event loop impl based on GMainContext 2020-02-07 15:03:53 +00:00
vireventglibwatch.c util: vireventglibwatch: watch for G_IO_HUP and G_IO_ERR 2020-02-24 03:19:25 +01:00
vireventglibwatch.h src: introduce helper API for creating GSource for socket 2020-02-07 15:03:53 +00:00
vireventthread.c src: introduce an abstraction for running event loops 2020-03-11 14:44:04 +00:00
vireventthread.h src: introduce an abstraction for running event loops 2020-03-11 14:44:04 +00:00
virfcp.c util: use g_strdup instead of VIR_STRDUP 2019-10-21 12:51:59 +02:00
virfcp.h
virfdstream.c src: improve thread naming with human targetted names 2020-03-05 12:23:04 +00:00
virfdstream.h
virfile.c virfile: Handle directories in virFileBindMountDevice() 2020-03-20 14:34:32 +01:00
virfile.h src: remove virFilePrintf in favour of g_fprintf 2020-02-04 14:00:45 +00:00
virfilecache.c util: buffer: Remove virBufferCheckError 2019-10-24 19:35:34 +02:00
virfilecache.h
virfirewall.c Remove virutil.h where possible 2020-02-24 23:15:49 +01:00
virfirewall.h Remove virautoclean.h 2019-10-16 12:06:44 +02:00
virfirewalld.c Use g_autofree instead of VIR_AUTOFREE 2019-10-16 12:06:43 +02:00
virfirewalld.h
virfirewalldpriv.h
virfirewallpriv.h
virfirmware.c util: use g_strdup instead of VIR_STRDUP 2019-10-21 12:51:59 +02:00
virfirmware.h Use G_DEFINE_AUTOPTR_CLEANUP_FUNC instead of VIR_DEFINE_AUTOPTR_FUNC 2019-10-16 12:06:43 +02:00
virgettext.c src: optionally include xlocale.h header 2020-02-04 14:00:45 +00:00
virgettext.h
virgic.c Remove virutil.h where possible 2020-02-24 23:15:49 +01:00
virgic.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
virhash.c virHashAddOrUpdateEntry: Simplify allocation of new entry 2020-02-04 13:45:33 +01:00
virhash.h virhash: Fix the expectations of virHashKeyEqual implementations 2020-02-04 13:45:33 +01:00
virhashcode.c Use G_GNUC_FALLTHROUGH instead of ATTRIBUTE_FALLTHROUGH 2019-10-15 16:14:19 +02:00
virhashcode.h Use G_GNUC_NO_INLINE instead of ATTRIBUTE_NOINLINE 2019-10-15 16:14:18 +02:00
virhook.c bhyve: add hooks 2020-02-24 17:25:07 +00:00
virhook.h bhyve: add hooks 2020-02-24 17:25:07 +00:00
virhostcpu.c util: virhostcpu: Fail when fetching CPU Stats for invalid cpu 2020-03-24 11:31:07 +01:00
virhostcpu.h hostcpu: add support for reporting die_id in NUMA topology 2020-01-16 15:11:55 +00:00
virhostcpupriv.h
virhostmem.c src: remove unused sys/utsname.h includes 2020-01-29 14:51:39 +00:00
virhostmem.h
virhostuptime.c virhostuptime: Introduce virHostBootTimeInit() 2020-01-07 17:00:10 +01:00
virhostuptime.h virhostuptime: Introduce virHostBootTimeInit() 2020-01-07 17:00:10 +01:00
viridentity.c util: convert virIdentity class to use GObject 2019-10-14 10:54:42 +01:00
viridentity.h util: convert virIdentity class to use GObject 2019-10-14 10:54:42 +01:00
virinitctl.c src: replace verify(expr) with G_STATIC_ASSERT(expr) 2020-01-17 10:02:01 +00:00
virinitctl.h
viriptables.c src: remove sys/wait.h from many files 2020-02-04 14:00:44 +00:00
viriptables.h network: allow DHCP/DNS/TFTP explicitly in OUTPUT rules 2019-10-18 18:49:54 +01:00
viriscsi.c Remove all the uses that use subtraction in their length argument 2019-12-12 14:24:35 +01:00
viriscsi.h Use G_GNUC_WARN_UNUSED_RESULT instead of ATTRIBUTE_RETURN_CHECK 2019-10-15 11:25:22 +02:00
virjson.c virjson: Deflatten arrays generated by the json->commandline generator 2020-03-20 09:47:16 +01:00
virjson.h util: json: Introduce virJSONValueArrayConcat 2020-02-04 13:45:32 +01:00
virkeycode.c src: replace verify(expr) with G_STATIC_ASSERT(expr) 2020-01-17 10:02:01 +00:00
virkeycode.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
virkmod.c util: Use g_strdup_printf() instead of virAsprintf() 2019-11-12 16:15:58 +01:00
virkmod.h
virlease.c util: json: Convert virJSONValueNewObject() to g_new0 2020-03-05 11:31:38 +01:00
virlease.h
virlockspace.c Use g_strerror instead of virStrerror 2020-03-13 17:26:55 +01:00
virlockspace.h
virlog.c src: convert all code to use virsocket.h 2020-01-29 14:51:40 +00:00
virlog.h util: Use g_strdup_printf() instead of virAsprintf() 2019-11-12 16:15:58 +01:00
virmacaddr.c Remove all use of virHexToBin 2020-02-24 20:25:48 +01:00
virmacaddr.h src: replace verify(expr) with G_STATIC_ASSERT(expr) 2020-01-17 10:02:01 +00:00
virmacmap.c virmacmap: Use g_autofree in virMacMapWriteFileLocked 2020-03-05 18:06:21 +01:00
virmacmap.h
virmdev.c src: replace last_component() with g_path_get_basename() 2020-01-03 15:42:13 +00:00
virmdev.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
virmodule.c virsh: include virutil.h where used 2020-02-24 23:15:50 +01:00
virmodule.h
virnetdev.c util: json: Convert virJSONValueNewObject() to g_new0 2020-03-05 11:31:38 +01:00
virnetdev.h src: conditionalize use of net/if.h 2020-01-29 14:51:40 +00:00
virnetdevbandwidth.c src: add virutil.h to more source files for geteuid() compat 2020-02-25 10:02:15 +00:00
virnetdevbandwidth.h conf: make virDomainNetGetActualBandwidth arg/return value const 2019-11-25 15:29:51 -05:00
virnetdevbridge.c Remove virutil.h where possible 2020-02-24 23:15:49 +01:00
virnetdevbridge.h util: query/set BR_ISOLATED flag on netdevs attached to bridge 2020-02-20 23:07:53 -05:00
virnetdevip.c Remove virutil.h where possible 2020-02-24 23:15:49 +01:00
virnetdevip.h Remove virautoclean.h 2019-10-16 12:06:44 +02:00
virnetdevmacvlan.c src: convert all code to use virsocket.h 2020-01-29 14:51:40 +00:00
virnetdevmacvlan.h conf: return a const from virDomainNetGetActualVirtPortProfile 2019-11-25 15:29:56 -05:00
virnetdevmidonet.c conf: return a const from virDomainNetGetActualVirtPortProfile 2019-11-25 15:29:56 -05:00
virnetdevmidonet.h conf: return a const from virDomainNetGetActualVirtPortProfile 2019-11-25 15:29:56 -05:00
virnetdevopenvswitch.c conf: return a const from virDomainNetGetActualVirtPortProfile 2019-11-25 15:29:56 -05:00
virnetdevopenvswitch.h conf: return a const from virDomainNetGetActualVirtPortProfile 2019-11-25 15:29:56 -05:00
virnetdevtap.c qemu/lxc: plumb isolatedPort from config down through bridge attachment 2020-02-20 23:13:15 -05:00
virnetdevtap.h qemu/lxc: plumb isolatedPort from config down through bridge attachment 2020-02-20 23:13:15 -05:00
virnetdevveth.c Remove virutil.h where possible 2020-02-24 23:15:49 +01:00
virnetdevveth.h Use G_GNUC_WARN_UNUSED_RESULT instead of ATTRIBUTE_RETURN_CHECK 2019-10-15 11:25:22 +02:00
virnetdevvlan.c
virnetdevvlan.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
virnetdevvportprofile.c Add a space before ending a comment 2020-01-30 12:32:03 +01:00
virnetdevvportprofile.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
virnetlink.c Add a space before ending a comment 2020-01-30 12:32:03 +01:00
virnetlink.h m4: virt-libnl: drop libnl-1.0 support 2019-10-23 14:30:47 +02:00
virnodesuspend.c src: improve thread naming with human targetted names 2020-03-05 12:23:04 +00:00
virnodesuspend.h
virnuma.c virsh: include virutil.h where used 2020-02-24 23:15:50 +01:00
virnuma.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
virnvme.c util: Introduce virNVMeDevice module 2019-12-17 10:04:43 +01:00
virnvme.h virhostdev: Include virNVMeDevice module 2019-12-17 10:04:43 +01:00
virobject.c Drop virAtomic module 2020-02-02 16:36:58 +01:00
virobject.h src: replace verify(expr) with G_STATIC_ASSERT(expr) 2020-01-17 10:02:01 +00:00
virpci.c Use g_strerror instead of virStrerror 2020-03-13 17:26:55 +01:00
virpci.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
virperf.c Include unistd.h where used 2020-02-24 23:15:50 +01:00
virperf.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
virpidfile.c Use g_strerror instead of virStrerror 2020-03-13 17:26:55 +01:00
virpidfile.h Use G_GNUC_WARN_UNUSED_RESULT instead of ATTRIBUTE_RETURN_CHECK 2019-10-15 11:25:22 +02:00
virpolkit.c virsh: include virutil.h where used 2020-02-24 23:15:50 +01:00
virpolkit.h
virportallocator.c util: virportallocator: add includes 2020-02-24 23:15:49 +01:00
virportallocator.h
virprobe.h
virprocess.c virprocess: Passthru error from virProcessRunInForkHelper 2020-03-20 16:42:45 +01:00
virprocess.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
virqemu.c virBufferTrim: do not accept len 2020-02-03 19:44:38 +01:00
virqemu.h
virrandom.c Remove virutil.h where possible 2020-02-24 23:15:49 +01:00
virrandom.h Use G_GNUC_NO_INLINE instead of ATTRIBUTE_NOINLINE 2019-10-15 16:14:18 +02:00
virresctrl.c Include unistd.h where used 2020-02-24 23:15:50 +01:00
virresctrl.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
virresctrlpriv.h
virrotatingfile.c util: Use g_strdup_printf() instead of virAsprintf() 2019-11-12 16:15:58 +01:00
virrotatingfile.h
virscsi.c Remove virutil.h where possible 2020-02-24 23:15:49 +01:00
virscsi.h Remove virautoclean.h 2019-10-16 12:06:44 +02:00
virscsihost.c util: Use g_strdup_printf() instead of virAsprintf() 2019-11-12 16:15:58 +01:00
virscsihost.h
virscsivhost.c util: Use g_strdup_printf() instead of virAsprintf() 2019-11-12 16:15:58 +01:00
virscsivhost.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
virseclabel.c util: use g_strdup instead of VIR_STRDUP 2019-10-21 12:51:59 +02:00
virseclabel.h
virsecret.c virSecretLookupDefCopy: Remove return value 2020-03-20 09:47:16 +01:00
virsecret.h virSecretLookupDefCopy: Remove return value 2020-03-20 09:47:16 +01:00
virsocket.c src: implement APIs for passing FDs over UNIX sockets 2020-01-29 14:51:39 +00:00
virsocket.h gnulib: delete all gnulib integration 2020-02-07 15:03:54 +00:00
virsocketaddr.c src: convert all code to use virsocket.h 2020-01-29 14:51:40 +00:00
virsocketaddr.h src: convert all code to use virsocket.h 2020-01-29 14:51:40 +00:00
virstorageencryption.c virStorageEncryptionSecretCopy: Properly copy internals 2020-03-20 09:47:16 +01:00
virstorageencryption.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
virstoragefile.c storage: Parse 'nvme' disk source properties from json:{} pseudo-uri 2020-03-24 14:17:48 +01:00
virstoragefile.h conf: rename 'namespace' property of struct _virStorageSourceNVMeDef 2020-03-24 14:17:47 +01:00
virstoragefilebackend.c
virstoragefilebackend.h
virstring.c src: optionally include xlocale.h header 2020-02-04 14:00:45 +00:00
virstring.h src: replace use of INT_BUFSIZE_BOUND macros 2020-01-17 09:58:43 +00:00
virsysinfo.c src: remove sys/wait.h from many files 2020-02-04 14:00:44 +00:00
virsysinfo.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
virsysinfopriv.h
virsystemd.c Drop virAtomic module 2020-02-02 16:36:58 +01:00
virsystemd.h Remove virautoclean.h 2019-10-16 12:06:44 +02:00
virsystemdpriv.h
virthread.c virthread: Free thread name only after worker has finished 2020-03-06 16:47:20 +01:00
virthread.h src: set the OS level thread name 2020-03-05 12:23:02 +00:00
virthreadjob.c
virthreadjob.h
virthreadpool.c src: improve thread naming with human targetted names 2020-03-05 12:23:04 +00:00
virthreadpool.h src: improve thread naming with human targetted names 2020-03-05 12:23:04 +00:00
virtime.c src: replace gmtime_r/localtime_r/strftime with GDateTime 2020-01-17 10:02:01 +00:00
virtime.h Use G_GNUC_WARN_UNUSED_RESULT instead of ATTRIBUTE_RETURN_CHECK 2019-10-15 11:25:22 +02:00
virtpm.c virBitmapNewEmpty: Use g_new0 to allocate and remove error checking 2020-03-20 09:47:16 +01:00
virtpm.h Use G_GNUC_NO_INLINE instead of ATTRIBUTE_NOINLINE 2019-10-15 16:14:18 +02:00
virtypedparam-public.c util: use g_strdup instead of VIR_STRDUP 2019-10-21 12:51:59 +02:00
virtypedparam.c Remove virutil.h where possible 2020-02-24 23:15:49 +01:00
virtypedparam.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
viruri.c Remove virutil.h where possible 2020-02-24 23:15:49 +01:00
viruri.h util: add helper API for getting URI parameters 2020-01-27 11:02:03 +00:00
virusb.c Remove virutil.h where possible 2020-02-24 23:15:49 +01:00
virusb.h Remove virautoclean.h 2019-10-16 12:06:44 +02:00
virutil.c Use g_strerror instead of virStrerror 2020-03-13 17:26:55 +01:00
virutil.h qemu: Create multipath targets for PRs 2020-03-12 08:04:40 +01:00
viruuid.c util: uuid: remove use of virHexToBin 2020-02-24 20:25:48 +01:00
viruuid.h Use G_GNUC_NO_INLINE instead of ATTRIBUTE_NOINLINE 2019-10-15 16:14:18 +02:00
virvhba.c util: Use g_strdup_printf() instead of virAsprintf() 2019-11-12 16:15:58 +01:00
virvhba.h
virvsock.c src: conditionalize / remove use of sys/ioctl.h 2020-01-17 13:16:58 +00:00
virvsock.h
virxdrdefs.h src: remove all traces of Cygwin support 2020-01-29 14:51:40 +00:00
virxml.c Remove virutil.h where possible 2020-02-24 23:15:49 +01:00
virxml.h util: xml: Make virXMLFormatElement void 2019-10-24 19:35:34 +02:00