On 01/28/2013 07:16 AM, Li Zhang wrote:
>>
>> The QMP client must send '{ "execute": "getfd", "arguments": { "fdname":
>> "fd1" } }' together with SCM_RIGHTS CMSG.  You are getting the error
>> because you sent the "getfd" command but forgot to include a file
>> descriptor using SCM_RIGHTS.
>>
>> SCM_RIGHTS is a feature of UNIX domain sockets.  It allows one process
>> to pass a file descriptor to another process through the UNIX domain
>> socket.  See "man 7 unix" and "man 3 cmsg" for details.

You can also look at how libvirt uses this code, for an example of what
it takes to use SCM_RIGHTS.

>>
>> Look at monitor.c:qmp_getfd() to understand how this works.  The QEMU
>> code to receive a passed file descriptor is in
>> qemu-char.c:unix_process_msgfd().
> Thanks a lot for your detailed explanation and suggestions.
> I will look into the code to understand how it works.

Additionally, using the 'getfd' command is not very robust; new code
should be preferring to use the 'add-fd' command family, as fdsets are
less prone to leaked fds; this also uses SCM_RIGHTS.  However, libvirt
does not yet have example code for using 'add-fd' (I'm slowly working on
adding that).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to