-
Story
-
Resolution: Unresolved
-
Normal
-
None
-
None
-
rhel-sst-virtualization-storage
-
ssg_virtualization
-
None
-
False
-
-
None
-
None
-
None
-
None
-
If docs needed, set a value
-
-
Unspecified
-
None
Description of problem:
If I understand correctly new qemu-storage-daemon replace qemu-nbd. New features
added to qemu-storage-daemon may not be available in qemu-nbd. Project using
qemu-nbd (e.g. oVirt, virt-v2v, libnbd) should move to use qemu-storage-daemon.
A very useful feature of qemu-nbd is systemd socket activation is missing in
qemu-storage-daemon. We would like to have it.
Using systemd socket activation eliminate the need to wait until the NBD server
is ready. This can be done today with waiting for the pid file, but it requires
polling when starting the server, and removing the pid file after the server
is terminate. This has to be implemented in all clients using the server.
Supporting systemd socket activation on the server side is relatively simple.
However it seems that qemu-storage-daemon has a better solution - passing listen
socket to the daemon:
Launch the daemon with QMP monitor socket qmp.sock so clients can exe‐
cute QMP commands:
$ qemu-storage-daemon \
--chardev socket,path=qmp.sock,server=on,wait=off,id=char1 \
--monitor chardev=char1
Launch the daemon from Python with a QMP monitor socket using file de‐
scriptor passing so there is no need to busy wait for the QMP monitor
to become available:
#!/usr/bin/env python3
import subprocess
import socket
sock_path = '/var/run/qmp.sock'
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as listen_sock:
listen_sock.bind(sock_path)
listen_sock.listen()
fd = listen_sock.fileno()
subprocess.Popen(
['qemu-storage-daemon',
'--chardev', f'socket,fd=
,server=on,id=char1',
'--monitor', 'chardev=char1'],
pass_fds=[fd],
)
- listen_sock was automatically closed when leaving the 'with' statement
- body. If the daemon process terminated early then the following connect()
- will fail with "Connection refused" because no process has the listen
- socket open anymore. Launch errors can be detected this way.
qmp_sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
qmp_sock.connect(sock_path)
...QMP interaction...
The same socket spawning approach also works with the --nbd-server
addr.type=fd,addr.str=<fd> and --export
type=vhost-user-blk,addr.type=fd,addr.str=<fd> options.
So I'm not sure systemd socket activation is really needed. Opening
this bug for discussion.
- external trackers