qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [qemu-devel]The problem of QMP command getfd.


From: Eric Blake
Subject: Re: [Qemu-devel] [qemu-devel]The problem of QMP command getfd.
Date: Mon, 28 Jan 2013 09:30:21 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

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

[Prev in Thread] Current Thread [Next in Thread]