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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]