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: Li Zhang
Subject: Re: [Qemu-devel] [qemu-devel]The problem of QMP command getfd.
Date: Wed, 30 Jan 2013 11:11:29 +0800
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130106 Thunderbird/17.0.2

On 2013年01月29日 00:30, Eric Blake wrote:
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.
You are right, I saw that in libvirt.
Thanks for your suggestions.
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).
Nice. Thanks for your information. :)





reply via email to

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