From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBWC5-0008Ok-0y for qemu-devel@nongnu.org; Fri, 01 Mar 2013 15:04:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UBWBz-0005Nn-RK for qemu-devel@nongnu.org; Fri, 01 Mar 2013 15:04:36 -0500 Received: from mail-oa0-f51.google.com ([209.85.219.51]:39239) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBWBz-0005Nj-MT for qemu-devel@nongnu.org; Fri, 01 Mar 2013 15:04:31 -0500 Received: by mail-oa0-f51.google.com with SMTP id h2so6388684oag.10 for ; Fri, 01 Mar 2013 12:04:30 -0800 (PST) From: Anthony Liguori In-Reply-To: <512FF819.7050505@redhat.com> References: <512FF819.7050505@redhat.com> Date: Fri, 01 Mar 2013 14:04:05 -0600 Message-ID: <87k3pqzy2y.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] virtio-rng and fd passing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , "qemu-devel@nongnu.org" , Stefan Berger Eric Blake writes: > Stefan Berger and I discovered on IRC that virtio-rng is unable to > support fd passing. We attempted: > > qemu-system-x86_64 ... -add-fd set=4,fd=34,opaque=RDONLY:/dev/urandom > -object rng-random,id=rng0,filename=/dev/fdset/4 -device > virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x6 Why are you using th rng-random backend instead of the rng-egd backend? You can pass chardevs to the egd backend. It's really not a good idea to pass a fd via rng-rangom. Regards, Anthony Liguori > > qemu-system-x86_64: -device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x6: > Could not open '/dev/fdset/4' > > Looks like this code is the culprit, in backends/rng-random.c: > > static void rng_random_opened(RngBackend *b, Error **errp) > { > RndRandom *s = RNG_RANDOM(b); > > if (s->filename == NULL) { > error_set(errp, QERR_INVALID_PARAMETER_VALUE, > "filename", "a valid filename"); > } else { > s->fd = open(s->filename, O_RDONLY | O_NONBLOCK); > > For fd passing to work, we have to use qemu_open() instead of raw > open(). Is there any way to enforce that all files being opened by qemu > go through the appropriate qemu_open() wrapper? > > Meanwhile, we have a quandary on the libvirt side of things: qemu 1.4 > supports fd passing in general, but does not support it for rng. I > guess the same is true for -blockdev - we don't (yet) have a way to do > fd passing for backing files. Do we need some sort of QMP command that > will let libvirt query for a particular device whether that device is > known to support fd passing, so that libvirt can use fd passing for all > supported devices, while falling back to older direct open()s, and to > know which instance of qemu can safely have open() blocked at the > SELinux or syscall blacklist level? > > -- > Eric Blake eblake redhat com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org