[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] docs: show how to spawn qemu-storage-daemon with fd passing
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH] docs: show how to spawn qemu-storage-daemon with fd passing |
Date: |
Mon, 1 Mar 2021 16:55:31 +0000 |
On Mon, Mar 01, 2021 at 04:06:47PM +0000, Daniel P. Berrangé wrote:
> On Mon, Mar 01, 2021 at 09:49:21AM -0600, Eric Blake wrote:
> > On 3/1/21 9:41 AM, Daniel P. Berrangé wrote:
> > > On Mon, Mar 01, 2021 at 03:31:59PM +0000, Stefan Hajnoczi wrote:
> > >> The QMP monitor, NBD server, and vhost-user-blk export all support file
> > >> descriptor passing. This is a useful technique because it allows the
> > >> parent process to spawn and wait for qemu-storage-daemon without busy
> > >> waiting, which may delay startup due to arbitrary sleep() calls.
> > >>
> > >> This Python example is inspired by the test case written for libnbd by
> > >> Richard W.M. Jones <rjones@redhat.com>:
> > >> https://gitlab.com/nbdkit/libnbd/-/commit/89113f484effb0e6c322314ba75c1cbe07a04543
> > >>
> > >> Thanks to Daniel P. Berrangé <berrange@redhat.com> for suggestions on
> > >> how to get this working. Now let's document it!
> > >>
> >
> > >> + sock_path = '/tmp/qmp-{}.sock'.format(os.getpid())
> > >
> > > Example code inevitably gets cut+paste into real world apps, and this
> > > example is a tmpfile CVE flaw. At least put it in $CWD instead.
> >
> > Except $CWD may be too long for a sock file name to be created.
> > Creating the sock in a securely-created subdirectory of /tmp is more
> > reliable.
>
> $XDG_RUNTIME_DIR then, which is /run/user/$UID, so safely per user on all
> modern OS.
Both you and Rich mentioned this. I'll change it to /var/run/qsd.pid.
I'll also update the /tmp/nbd.sock example in the documentation.
Stefan
signature.asc
Description: PGP signature
Re: [PATCH] docs: show how to spawn qemu-storage-daemon with fd passing, Daniel P . Berrangé, 2021/03/01