On Thu, Nov 11, 2010 at 10:30:47AM -0600, Anthony Liguori wrote: > On 11/11/2010 09:55 AM, Daniel P. Berrange wrote: > >On Thu, Nov 11, 2010 at 04:47:41PM +0100, Markus Armbruster wrote: > >>>>> 3. Query Commands > >>>>> ================= > >>>>> > >>>>In the real human monitor, cpu-index is state (Monitor member mon_cpu). > >>>>For pass through, you shift that state into the client (argument > >>>>cpu-index). Is there any other state that could need shifting? You > >>>>mention getfd. > >>>> > >>>Surprisingly or not, this is a very important question for QMP itself. > >>> > >>>Anthony has said that we should make it stateless, and I do think this > >>>is good because it seems to simplify things considerably. > >>> > >>>However, I haven't thought about how to make things like getfd stateless. > >>> > >>Hmm, that sounds like we should investigate the getfd problem sooner > >>rather than later. > >> > >The SCM_RIGHTS code allows you to send/receive multiple file handles in a > >single sendmsg/recvmsg call. So why don't we just allow sending of the > >file handles with the monitor command that actually needs them, instead of > >ahead of time using send_fd. This simplifies life for the client because > >they also don't have to worry about cleanup using close_fd if the command > >using the FD fails. > > How do we identify file descriptors and then map them to a command?
IIUC, the FDs sent/received via struct cmsghdr are in a strictly ordered array, so why not just define a placeholder syntax for the commands that maps to the array indexes. eg netdev_add tap,fd=$0,vhost_fd=$1,id=hostnet0 The '$' sign is not valid for a normal FD number, so use of a $0, $1, $2, etc can reliably be substituted with the real FD number from the cmsghdr array elements 0, 1, 2, etc Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|