On 2013年01月28日 21:28, Stefan Hajnoczi wrote:
On Mon, Jan 28, 2013 at 03:27:01PM +0800, Li Zhang wrote:
Hi all,

I am trying to executing qmp command getfd according to qmp-commands.hx.

{ "execute": "getfd", "arguments": { "fdname": "fd1" } }

Every time, it returns the error.

{
     "error": {
         "class": "GenericError",
         "desc": "No file descriptor supplied via SCM_RIGHTS"
     }
}

This error is related with SCM_RIGHTS.
I don't know about SCM at all.

Can anyone give some hints about this?
The "getfd" command allows the client to pass a file descriptor to QEMU
and give it a name.  Later that file descriptor can be used by QEMU.

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.

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.

Thanks
--Li

Stefan


Reply via email to