Bug 1932785 - [RFE] Add --pidfile option to qemu-storage-daemon
Summary: [RFE] Add --pidfile option to qemu-storage-daemon
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: qemu-kvm
Version: 8.2
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: rc
: 8.4
Assignee: Stefan Hajnoczi
QA Contact: qing.wang
URL:
Whiteboard:
Depends On: 1901323
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-02-25 09:19 UTC by Stefan Hajnoczi
Modified: 2022-10-26 01:36 UTC (History)
7 users (show)

Fixed In Version: qemu-kvm-6.0.0-16.module+el8.5.0+10848+2dccc46d
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-16 07:51:47 UTC
Type: Feature Request
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2021:4684 0 None None None 2021-11-16 07:52:21 UTC

Description Stefan Hajnoczi 2021-02-25 09:19:06 UTC
Description of problem:
Daemons commonly provide a --pidfile option where the process identifier is written when the daemon starts. This can be used to prevent multiple instances of a daemon from being started accidentally and it is also used for sending signals such as SIGTERM or SIGUSR1 to the running daemon.

Richard Jones <rjones> noticed that this feature was missing from qemu-storage-daemon but present in qemu-system-x86_64.

While it is possible to perform daemon shutdown using the QMP socket, it is easier to use the pidfile in cases where the process wishing to initiate shutdown does not have the QMP socket open or does not want to implement QMP.


Version-Release number of selected component (if applicable):
QEMU 5.2 lacks qemu-storage-daemon --pidfile.

Comment 1 Richard W.M. Jones 2021-02-25 11:29:36 UTC
Another case for this is to ensure that the server has started listening
on the socket (so note the server must socket/bind/listen before writing
the pidfile).  The idea is you can poll for creation of the pidfile and
then immediately connect to the socket.

The command I was running was:

qemu-storage-daemon --blockdev raw,file.driver=file,file.filename=/tmp/nbdftEX2V,node-name=disk0 --nbd-server addr.type=unix,addr.path=/tmp/sock --export nbd,node-name=disk0,id=nbd0,name=/

but we found that /tmp/sock (created by q-s-d) is not connectable until
some short window after it has been created on disk.

Comment 2 Richard W.M. Jones 2021-02-25 16:29:08 UTC
FWIW with Stefan's and Dan's help I was able to do synchronization-free
socket passing to qemu-storage-daemon.  It was definitely not obvious and
could do with some documentation.

https://gitlab.com/nbdkit/libnbd/-/commit/89113f484effb0e6c322314ba75c1cbe07a04543

Comment 3 Richard W.M. Jones 2021-02-25 16:30:27 UTC
(I mean race-free rather than synchronization-free)

Comment 6 Stefan Hajnoczi 2021-03-01 15:36:52 UTC
(In reply to Richard W.M. Jones from comment #2)
> FWIW with Stefan's and Dan's help I was able to do synchronization-free
> socket passing to qemu-storage-daemon.  It was definitely not obvious and
> could do with some documentation.
> 
> https://gitlab.com/nbdkit/libnbd/-/commit/
> 89113f484effb0e6c322314ba75c1cbe07a04543

Thank you! I have submitted a documentation patch based on your Python code:
https://lists.gnu.org/archive/html/qemu-devel/2021-03/msg00222.html

Comment 7 Stefan Hajnoczi 2021-03-01 16:33:05 UTC
I have posted a patch:
https://lists.gnu.org/archive/html/qemu-devel/2021-03/msg00236.html

Comment 14 qing.wang 2021-05-17 02:35:03 UTC
Passed test on
Red Hat Enterprise Linux release 8.5 Beta (Ootpa)
4.18.0-305.1.el8.x86_64
qemu-kvm-common-6.0.0-16.module+el8.5.0+10848+2dccc46d.x86_64

Test steps:
1.Check help message:
qemu-storage-daemon -h
--pidfile <path>       write process ID to a file after startup

2.Miss path parameter
qemu-storage-daemon --pidfile 
qemu-storage-daemon: option '--pidfile' requires an argument

3.give full parameter 
qemu-storage-daemon --pidfile /tmp/x.pid

4.pgrep -f qemu-storage-daemon and compare the content of pidfile, it should be same

 $ pgrep -f qemu-storage-daemon
449363
 $ cat /tmp/x.pid 
449363

Comment 16 errata-xmlrpc 2021-11-16 07:51:47 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (virt:av bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:4684


Note You need to log in before you can comment on or make changes to this bug.