[libvirt] [PATCHv4 05/15] util: use SCM_RIGHTS in virFileOperation when needed

Eric Blake eblake at redhat.com
Sat Mar 26 15:20:14 UTC 2011


On 03/10/2011 05:03 AM, Daniel P. Berrange wrote:
>> +
>> +            /* See if fd was transferred.  */
>> +            cmsg = CMSG_FIRSTHDR(&msg);
>> +            if (cmsg && cmsg->cmsg_len == CMSG_LEN(sizeof(fd)) &&
>> +                cmsg->cmsg_level == SOL_SOCKET &&
>> +                cmsg->cmsg_type == SCM_RIGHTS) {
>> +                memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd));
>> +            }
> 
> Also might be nice to create two helper methods for this
> 
>   int virFileHandleSendToSocket(int unixfd, int sendfd);
>   int virFileHandleRecvFromSocket(int unixfd);
> 
> which we can also use in the monitor code that does the
> same thing

Actually, my plans are to import the gnulib module passfd, which defines
sendfd()/recvfd(), and use those.  But I'd rather defer that to
post-0.9.0, and keep this patch doing things manually, in case someone
ever needs to backport these patches to RHEL without also pulling in a
gnulib submodule update.

Unfortunately, the monitor code probably can't use sendfd(), because it
makes assumptions that the receiver is using recvfd() but the qemu
monitor code is actually expecting to parse the fd off the 'getfd'
monitor command rather than a one-byte dummy command.  But we may have
other places where sendfd/recvfd makes sense (such as if we need to
temporarily change umask while creating a socket).

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110326/06e77795/attachment-0001.sig>


More information about the libvir-list mailing list