All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Question on unixsocket-based chardevs and vhost-user
@ 2016-09-28 16:56 Felipe Franciosi
  2016-09-28 16:59 ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Felipe Franciosi @ 2016-09-28 16:56 UTC (permalink / raw)
  To: Daniel P. Berrange, Paolo Bonzini
  Cc: qemu-devel, Michael S. Tsirkin, Marc-André Lureau

Hi Daniel/Paolo,

I have a question regarding this commit:
-------------8<-------------
Author:     Daniel P. Berrange <berrange@redhat.com>
AuthorDate: Tue Jan 19 11:14:29 2016 +0000
Commit:     Paolo Bonzini <pbonzini@redhat.com>
CommitDate: Tue Jan 26 15:58:11 2016 +0100
-------------8<-------------

One of the hunks replace unix_send_msgfds() with io_channel_send_full():

-------------8<-------------
static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
{
     TCPCharDriver *s = chr->opaque;
     if (s->connected) {
-#ifndef _WIN32
-        if (s->is_unix && s->write_msgfds_num) {
-            return unix_send_msgfds(chr, buf, len);
-        } else
-#endif
-        {
-            return io_channel_send(s->chan, buf, len);
+        int ret =  io_channel_send_full(s->ioc, buf, len,
+                                        s->write_msgfds,
+                                        s->write_msgfds_num);
-------------8<-------------

According to the code (qemu-char.c:968), io_channel_send_full() is just ignoring the s->write_msgfds parameter.

So my question is: when using a chardev implemented by unix sockets, how does one pass file descriptors for vhost-user applications?

I’m actually searching qemu-char.c for “write_msgfds” and scratching my head. There are functions to set it, clear it, etc, but none to send it.

Thanks,
Felipe

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] Question on unixsocket-based chardevs and vhost-user
  2016-09-28 16:56 [Qemu-devel] Question on unixsocket-based chardevs and vhost-user Felipe Franciosi
@ 2016-09-28 16:59 ` Paolo Bonzini
  2016-09-28 17:03   ` Felipe Franciosi
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2016-09-28 16:59 UTC (permalink / raw)
  To: Felipe Franciosi, Daniel P. Berrange
  Cc: qemu-devel, Michael S. Tsirkin, Marc-André Lureau



On 28/09/2016 18:56, Felipe Franciosi wrote:
> Hi Daniel/Paolo,
> 
>  
> 
> I have a question regarding this commit:
> 
> -------------8<-------------
> Author:     Daniel P. Berrange <berrange@redhat.com>
> AuthorDate: Tue Jan 19 11:14:29 2016 +0000
> Commit:     Paolo Bonzini <pbonzini@redhat.com>
> CommitDate: Tue Jan 26 15:58:11 2016 +0100
> -------------8<-------------
> 
> One of the hunks replace unix_send_msgfds() with io_channel_send_full():
> 
> According to the code (qemu-char.c:968), io_channel_send_full() is just
> ignoring the s->write_msgfds parameter.

Hmm, no, it's passing it down:

        ret = qio_channel_writev_full(
            ioc, &iov, 1,
            fds, nfds, NULL);

See the implementation of qio_channel_socket_writev in io/channel-socket.c.

Thanks,

Paolo

> So my question is: when using a chardev implemented by unix sockets, how
> does one pass file descriptors for vhost-user applications?
> 
> I’m actually searching qemu-char.c for “write_msgfds” and scratching my
> head. There are functions to set it, clear it, etc, but none to send it.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] Question on unixsocket-based chardevs and vhost-user
  2016-09-28 16:59 ` Paolo Bonzini
@ 2016-09-28 17:03   ` Felipe Franciosi
  2016-09-28 17:30     ` Felipe Franciosi
  0 siblings, 1 reply; 5+ messages in thread
From: Felipe Franciosi @ 2016-09-28 17:03 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Daniel P. Berrange, qemu-devel, Michael S. Tsirkin,
	Marc-André Lureau

Hi Paolo,

> On 28 Sep 2016, at 17:59, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 
> On 28/09/2016 18:56, Felipe Franciosi wrote:
>> Hi Daniel/Paolo,
>> 
>> 
>> 
>> I have a question regarding this commit:
>> 
>> -------------8<-------------
>> Author:     Daniel P. Berrange <berrange@redhat.com>
>> AuthorDate: Tue Jan 19 11:14:29 2016 +0000
>> Commit:     Paolo Bonzini <pbonzini@redhat.com>
>> CommitDate: Tue Jan 26 15:58:11 2016 +0100
>> -------------8<-------------
>> 
>> One of the hunks replace unix_send_msgfds() with io_channel_send_full():
>> 
>> According to the code (qemu-char.c:968), io_channel_send_full() is just
>> ignoring the s->write_msgfds parameter.
> 
> Hmm, no, it's passing it down:
> 
>        ret = qio_channel_writev_full(
>            ioc, &iov, 1,
>            fds, nfds, NULL);
> 
> See the implementation of qio_channel_socket_writev in io/channel-socket.c.

Ah, so my socket has been plumbed with qio_channel_file_writev() for some reason. That's definitely ignoring the fds. I'll look into why it's not qio_channel_socket_writev().

Thanks!
Felipe

> 
> Thanks,
> 
> Paolo
> 
>> So my question is: when using a chardev implemented by unix sockets, how
>> does one pass file descriptors for vhost-user applications?
>> 
>> I’m actually searching qemu-char.c for “write_msgfds” and scratching my
>> head. There are functions to set it, clear it, etc, but none to send it.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] Question on unixsocket-based chardevs and vhost-user
  2016-09-28 17:03   ` Felipe Franciosi
@ 2016-09-28 17:30     ` Felipe Franciosi
  2016-09-29  8:09       ` Daniel P. Berrange
  0 siblings, 1 reply; 5+ messages in thread
From: Felipe Franciosi @ 2016-09-28 17:30 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Daniel P. Berrange, qemu-devel, Michael S. Tsirkin,
	Marc-André Lureau


> On 28 Sep 2016, at 18:03, Felipe Franciosi <felipe@nutanix.com> wrote:
> 
> Hi Paolo,
> 
>> On 28 Sep 2016, at 17:59, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> 
>> On 28/09/2016 18:56, Felipe Franciosi wrote:
>>> Hi Daniel/Paolo,
>>> 
>>> 
>>> 
>>> I have a question regarding this commit:
>>> 
>>> -------------8<-------------
>>> Author:     Daniel P. Berrange <berrange@redhat.com>
>>> AuthorDate: Tue Jan 19 11:14:29 2016 +0000
>>> Commit:     Paolo Bonzini <pbonzini@redhat.com>
>>> CommitDate: Tue Jan 26 15:58:11 2016 +0100
>>> -------------8<-------------
>>> 
>>> One of the hunks replace unix_send_msgfds() with io_channel_send_full():
>>> 
>>> According to the code (qemu-char.c:968), io_channel_send_full() is just
>>> ignoring the s->write_msgfds parameter.
>> 
>> Hmm, no, it's passing it down:
>> 
>>       ret = qio_channel_writev_full(
>>           ioc, &iov, 1,
>>           fds, nfds, NULL);
>> 
>> See the implementation of qio_channel_socket_writev in io/channel-socket.c.
> 
> Ah, so my socket has been plumbed with qio_channel_file_writev() for some reason. That's definitely ignoring the fds. I'll look into why it's not qio_channel_socket_writev().

Got to the bottom of it. So I was basing myself on this example:
http://git.qemu.org/?p=qemu.git;a=blob;f=qemu-char.c;h=fb456cec345b10b12a051d44067cce29cb1bdf44;hb=HEAD#l1117

It says "open a character device to a unix fd" and then uses the QIO File API. Worth checking if that's correct.

Thanks,
Felipe

> 
> Thanks!
> Felipe
> 
>> 
>> Thanks,
>> 
>> Paolo
>> 
>>> So my question is: when using a chardev implemented by unix sockets, how
>>> does one pass file descriptors for vhost-user applications?
>>> 
>>> I’m actually searching qemu-char.c for “write_msgfds” and scratching my
>>> head. There are functions to set it, clear it, etc, but none to send it.
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] Question on unixsocket-based chardevs and vhost-user
  2016-09-28 17:30     ` Felipe Franciosi
@ 2016-09-29  8:09       ` Daniel P. Berrange
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel P. Berrange @ 2016-09-29  8:09 UTC (permalink / raw)
  To: Felipe Franciosi
  Cc: Paolo Bonzini, qemu-devel, Michael S. Tsirkin,
	Marc-André Lureau

On Wed, Sep 28, 2016 at 05:30:24PM +0000, Felipe Franciosi wrote:
> 
> > On 28 Sep 2016, at 18:03, Felipe Franciosi <felipe@nutanix.com> wrote:
> > 
> > Hi Paolo,
> > 
> >> On 28 Sep 2016, at 17:59, Paolo Bonzini <pbonzini@redhat.com> wrote:
> >> 
> >> On 28/09/2016 18:56, Felipe Franciosi wrote:
> >>> Hi Daniel/Paolo,
> >>> 
> >>> 
> >>> 
> >>> I have a question regarding this commit:
> >>> 
> >>> -------------8<-------------
> >>> Author:     Daniel P. Berrange <berrange@redhat.com>
> >>> AuthorDate: Tue Jan 19 11:14:29 2016 +0000
> >>> Commit:     Paolo Bonzini <pbonzini@redhat.com>
> >>> CommitDate: Tue Jan 26 15:58:11 2016 +0100
> >>> -------------8<-------------
> >>> 
> >>> One of the hunks replace unix_send_msgfds() with io_channel_send_full():
> >>> 
> >>> According to the code (qemu-char.c:968), io_channel_send_full() is just
> >>> ignoring the s->write_msgfds parameter.
> >> 
> >> Hmm, no, it's passing it down:
> >> 
> >>       ret = qio_channel_writev_full(
> >>           ioc, &iov, 1,
> >>           fds, nfds, NULL);
> >> 
> >> See the implementation of qio_channel_socket_writev in io/channel-socket.c.
> > 
> > Ah, so my socket has been plumbed with qio_channel_file_writev() for some reason. That's definitely ignoring the fds. I'll look into why it's not qio_channel_socket_writev().
> 
> Got to the bottom of it. So I was basing myself on this example:
> http://git.qemu.org/?p=qemu.git;a=blob;f=qemu-char.c;h=fb456cec345b10b12a051d44067cce29cb1bdf44;hb=HEAD#l1117
> 
> It says "open a character device to a unix fd" and then uses the QIO File API. Worth checking if that's correct.

That comment is misleading - when it says "unix fd" is really means a POSIX
file descriptor, as distinct from a Win32 file descriptor. It has nothing
todo with UNIX sockets.


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-09-29  8:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-28 16:56 [Qemu-devel] Question on unixsocket-based chardevs and vhost-user Felipe Franciosi
2016-09-28 16:59 ` Paolo Bonzini
2016-09-28 17:03   ` Felipe Franciosi
2016-09-28 17:30     ` Felipe Franciosi
2016-09-29  8:09       ` Daniel P. Berrange

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.