[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 3/7] qapi: Add pass-fd QMP command
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v4 3/7] qapi: Add pass-fd QMP command |
Date: |
Fri, 22 Jun 2012 14:24:40 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 |
On 06/22/2012 12:36 PM, Corey Bryant wrote:
> This patch adds the pass-fd QMP command using the QAPI framework.
> Like the getfd command, it is used to pass a file descriptor via
> SCM_RIGHTS and associate it with a name. However, the pass-fd
> command also returns the received file descriptor, which is a
> difference in behavior from the getfd command, which returns
> nothing. pass-fd also supports a boolean "force" argument that
> can be used to specify that an existing file descriptor is
> associated with the specified name, and that it should become a
> copy of the newly passed file descriptor.
> + if (replace) {
> + /* the existing fd is replaced with the new fd */
> + close(monfd->fd);
> + monfd->fd = fd;
> + return fd;
> + }
> +
> + if (copy) {
Since 'replace' and 'copy' are never both true, should this instead be a
tri-state enum argument instead of two independent bool arguments?
> + /* the existing fd becomes a copy of the new fd */
> + if (dup2(fd, monfd->fd) == -1) {
Broken - you want to use dup3(fd, monfd->fd, O_CLOEXEC) (and fall back
to dup2()+fcntl(F_GETFD/F_SETFD) on platforms where dup3 is not
available; it has been proposed for the next revision of POSIX but right
now is pretty much limited to Linux and Cygwin). Otherwise, you are
undoing the fact that patch 1/7 just changed the 'getfd' list to always
keep all its fds marked cloexec.
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v4 7/7] osdep: Enable qemu_open to dup pre-opened fd, (continued)
[Qemu-devel] [PATCH v4 6/7] block: Convert open calls to qemu_open, Corey Bryant, 2012/06/22
[Qemu-devel] [PATCH v4 3/7] qapi: Add pass-fd QMP command, Corey Bryant, 2012/06/22
- Re: [Qemu-devel] [PATCH v4 3/7] qapi: Add pass-fd QMP command,
Eric Blake <=
Re: [Qemu-devel] [PATCH v4 0/7] file descriptor passing using pass-fd, Daniel P. Berrange, 2012/06/26