On Wed, 15 Apr 2020 16:11:14 +0200, Markus Armbruster <arm...@redhat.com> wrote: > Adalbert Lazãr <ala...@bitdefender.com> writes: > > > On Wed, 15 Apr 2020 12:37:34 +0200, Marc-André Lureau > > <marcandre.lur...@gmail.com> wrote: > >> Hi > >> > >> On Wed, Apr 15, 2020 at 3:00 AM Adalbert Lazăr <ala...@bitdefender.com> > >> wrote: > >> > > >> > qmp_chardev_open_socket() ignores the absence of the 'server' argument > >> > and always switches to listen/server mode. > >> > > >> > CC: "Marc-André Lureau" <marcandre.lur...@redhat.com> > >> > CC: Paolo Bonzini <pbonz...@redhat.com> > >> > Signed-off-by: Adalbert Lazăr <ala...@bitdefender.com> > >> > --- > >> > chardev/char-socket.c | 2 +- > >> > 1 file changed, 1 insertion(+), 1 deletion(-) > >> > > >> > diff --git a/chardev/char-socket.c b/chardev/char-socket.c > >> > index 9b2deb0125..fd0106ab85 100644 > >> > --- a/chardev/char-socket.c > >> > +++ b/chardev/char-socket.c > >> > @@ -1310,7 +1310,7 @@ static void qmp_chardev_open_socket(Chardev *chr, > >> > SocketChardev *s = SOCKET_CHARDEV(chr); > >> > ChardevSocket *sock = backend->u.socket.data; > >> > bool do_nodelay = sock->has_nodelay ? sock->nodelay : false; > >> > - bool is_listen = sock->has_server ? sock->server : true; > >> > + bool is_listen = sock->has_server ? sock->server : false; > >> > >> I don't understand what you mean. It defaults to server mode. We can't > >> change that. > > > > First of all, thanks for your comments. > > > > I understand that a chardev socket is either in client mode or in server > > mode. If the 'server' parameter is not used, the socket is put in client > > mode. At least this is the behavior when the socket is created by parsing > > the command line. But, when created through QMP, without the 'server' > > parameter, > > the socket is put in server mode. > > > > Until this moment, I did not think that we can use "server=no" through QMP > > :)) > > Start here: > > $ socat "READLINE,history=$HOME/.qmp_history,prompt=QMP>" > UNIX-CONNECT:$HOME/work/images/test-qmp > {"QMP": {"version": {"qemu": {"micro": 92, "minor": 2, "major": 4}, > "package": "v5.0.0-rc2-30-g25b0509e28"}, "capabilities": ["oob"]}} > QMP>{"execute": "qmp_capabilities"} > {"return": {}} > QMP>{"execute":"chardev-add", "arguments": {"id":"foo", "backend": > {"type": "socket", "data": {"addr": {"type": "inet", "data": {"host": > "0.0.0.0", "port": "2445"}}, "server": false}}}} > {"error": {"class": "GenericError", "desc": "Failed to connect socket: > Connection refused"}} >
Thank you, Markus. I wanted to say that while I was writing the reply, I had an aha! moment and I was amused that I have not thought to use server=no/false and I used the wrong verb tense.