Multiple QMP socket clients
Hi,
On a qemu instance started with a qmp unix socket:
-qmp unix:/tmp/ctrl.sock,server,nowait
I am trying to have multiple clients working on that socket but although the qmp server seems to accept the connections, only the first connected client gets his request processed. The next client requests will just hang until the first one exits.
Is that an intended behaviour ?
Thanks in advance for your answers.
Cheers,
Samuel.
Quoted 4 lines · Samuel Ortiz
Hi,
On a qemu instance started with a qmp unix socket:
Quoted 8 lines
-qmp unix:/tmp/ctrl.sock,server,nowait
I am trying to have multiple clients working on that socket but although the qmp server seems to accept the connections, only the first connected client gets his request processed. The next client requests will just hang until the first one exits.
Is that an intended behaviour ?
Yes, the character device code is designed around the idea of a single endpoint.
In the case of the monitor you could work around it by adding multiple -qmp arguemnts, each with different socket. Of course you have to make sure each client doesn't trample on the other client when doing this.
Regards,
Daniel
Signature · 3 lines
|: 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/ :|
Quoted 12 lines · * Daniel P. Berrange ([email protected]) wrote:
Quoted 11 lines · Samuel Ortiz
Hi,
On a qemu instance started with a qmp unix socket:
-qmp unix:/tmp/ctrl.sock,server,nowait
I am trying to have multiple clients working on that socket but although the qmp server seems to accept the connections, only the first connected client gets his request processed. The next client requests will just hang until the first one exits.
Quoted 8 lines
Quoted 1 line
Is that an intended behaviour ?
Yes, the character device code is designed around the idea of a single endpoint.
In the case of the monitor you could work around it by adding multiple -qmp arguemnts, each with different socket. Of course you have to make sure each client doesn't trample on the other client when doing this.
But why does it accept the connection?
I thought you could say only accept a single connection on a socket. (The backlog parameter to listen(2) but I can't find out listen.)
Dave
Quoted 9 lines
Regards,
DanielSignature · 3 lines
|: 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/ :|
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 18 lines · Dr. David Alan Gilbert
Quoted 17 lines · * Daniel P. Berrange ([email protected]) wrote:
Quoted 4 lines · Samuel Ortiz
Hi,
On a qemu instance started with a qmp unix socket:
Quoted 8 lines
-qmp unix:/tmp/ctrl.sock,server,nowait
I am trying to have multiple clients working on that socket but although the qmp server seems to accept the connections, only the first connected client gets his request processed. The next client requests will just hang until the first one exits.
Is that an intended behaviour ?
Yes, the character device code is designed around the idea of a single endpoint.
Quoted 7 lines
Quoted 3 lines
In the case of the monitor you could work around it by adding multiple -qmp arguemnts, each with different socket. Of course you have to make sure each client doesn't trample on the other client when doing this.
But why does it accept the connection?
I thought you could say only accept a single connection on a socket. (The backlog parameter to listen(2) but I can't find out listen.)
QEMU won't accept the connection, as while it is still listen()ing on the socket, it is not poll()ing for incoming clients, so will never trigger accept(). The kernel will queue the incoming connection until QEMU starts polling for clients again. From the client POV this is indistinguishable from QEMU accepting the client, but not processing I/O on it.
Regards,
Daniel
Signature · 3 lines
|: 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/ :|
Quoted 27 lines · Daniel P. Berrange
Quoted 18 lines · Dr. David Alan Gilbert
Quoted 17 lines · * Daniel P. Berrange ([email protected]) wrote:
Quoted 4 lines · Samuel Ortiz
Hi,
On a qemu instance started with a qmp unix socket:
Quoted 8 lines
-qmp unix:/tmp/ctrl.sock,server,nowait
I am trying to have multiple clients working on that socket but although the qmp server seems to accept the connections, only the first connected client gets his request processed. The next client requests will just hang until the first one exits.
Is that an intended behaviour ?
Yes, the character device code is designed around the idea of a single endpoint.
Quoted 7 lines
Quoted 3 lines
In the case of the monitor you could work around it by adding multiple -qmp arguemnts, each with different socket. Of course you have to make sure each client doesn't trample on the other client when doing this.
But why does it accept the connection?
I thought you could say only accept a single connection on a socket. (The backlog parameter to listen(2) but I can't find out listen.)
Quoted 6 lines
QEMU won't accept the connection, as while it is still listen()ing on the socket, it is not poll()ing for incoming clients, so will never trigger
accept(). The kernel will queue the incoming connection until QEMU starts polling for clients again. From the client POV this is indistinguishable from QEMU accepting the client, but not processing I/O on it.
Oh, and the backlog parameter to listen() is fairly useless - it won't stop new clients getting into an established socket state
https://veithen.github.io/2014/01/01/how-tcp-backlog-works-in-linux.html
QEMU could just accept() all incoming connections and explicitly close them if something is already connected, but this just burns CPU really.
Regards,
Daniel
Signature · 3 lines
|: 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/ :|
Quoted 35 lines · * Daniel P. Berrange ([email protected]) wrote:
Quoted 27 lines · Daniel P. Berrange
Quoted 18 lines · Dr. David Alan Gilbert
Quoted 17 lines · * Daniel P. Berrange ([email protected]) wrote:
Quoted 4 lines · Samuel Ortiz
Hi,
On a qemu instance started with a qmp unix socket:
Quoted 8 lines
-qmp unix:/tmp/ctrl.sock,server,nowait
I am trying to have multiple clients working on that socket but although the qmp server seems to accept the connections, only the first connected client gets his request processed. The next client requests will just hang until the first one exits.
Is that an intended behaviour ?
Yes, the character device code is designed around the idea of a single endpoint.
Quoted 7 lines
Quoted 3 lines
In the case of the monitor you could work around it by adding multiple -qmp arguemnts, each with different socket. Of course you have to make sure each client doesn't trample on the other client when doing this.
But why does it accept the connection?
I thought you could say only accept a single connection on a socket. (The backlog parameter to listen(2) but I can't find out listen.)Quoted 6 lines
QEMU won't accept the connection, as while it is still listen()ing on the socket, it is not poll()ing for incoming clients, so will never trigger
accept(). The kernel will queue the incoming connection until QEMU starts polling for clients again. From the client POV this is indistinguishable from QEMU accepting the client, but not processing I/O on it.
Quoted 4 lines
Oh, and the backlog parameter to
listen()is fairly useless - it won't stop new clients getting into an established socket statehttps://veithen.github.io/2014/01/01/how-tcp-backlog-works-in-linux.html
Oh, that's annoying; ok, if that's all we can do that's fine; and I did check with an strace and we do have a :
[pid 22661] listen(9, 1) = 0
and I do only see a single call to accept4() even though the 2nd telnet apparently shows it connected.
Quoted 2 lines
QEMU could just
accept()all incoming connections and explicitly close them if something is already connected, but this just burns CPU really.
It might make failures more obvious than a non-responsive socket.
Dave
Quoted 7 lines
Regards,
DanielSignature · 3 lines
|: 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/ :|
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK