Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1OA1LI-0008Lu-Pb for qemu-devel@nongnu.org; Thu, 06 May 2010 09:42:20 -0400 Received: from [140.186.70.92] (port=51617 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OA1LD-0008IR-IU for qemu-devel@nongnu.org; Thu, 06 May 2010 09:42:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OA1LC-0002He-18 for qemu-devel@nongnu.org; Thu, 06 May 2010 09:42:15 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:49799) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OA1LB-0002HP-TK for qemu-devel@nongnu.org; Thu, 06 May 2010 09:42:14 -0400 Received: by wyj26 with SMTP id 26so3952998wyj.4 for ; Thu, 06 May 2010 06:42:11 -0700 (PDT) MIME-Version: 1.0 Date: Thu, 6 May 2010 10:42:10 -0300 Message-ID: From: Miguel Di Ciurcio Filho Content-Type: text/plain; charset=ISO-8859-1 Subject: [Qemu-devel] Bug in net/socket.c: info_str is overwritten List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, markmc@redhat.com, lcapitulino@redhat.com Hi there, I'm working on the conversion of the 'info network' command do QMP, and I think I've found some problems. Running qemu like this: qemu -net socket,listen=:3333 In net/socket.c, the function net_socket_listen_init() [1] is called and a listening socket is created. There is nothing registering this, so when using 'info network' as is, no information about this listening socket is shown. When a connection is accepted, the handler net_socket_accept() calls net_socket_fd_init(). If the socket is UDP/multicast net_socket_fd_init() calls net_socket_fd_init_dgram, if the socket is TCP it calls net_socket_fd_init_dgram_stream. [2] In both cases the info_str string is written inside net_socket_fd_init_(stream|dgram) [3], and after that, it is overwritten on a subsequent snprintf() in net_socket_accept() [4]. net_socket_fd_init_(stream|dgram) always puts into the info_str the fd number, and this information is overwritten latter. So, is the fd number relevant to be transmitted over QMP? Right now this information is being lost, IMHO. Same thing happens when qemu is run as a client: net_socket_connect_init() calls net_socket_fd_init_(dgram|stream) and latter overwrites info_str. [1] http://git.qemu.org/qemu.git/tree/net/socket.c#n375 [2] http://git.qemu.org/qemu.git/tree/net/socket.c#n336 [3] http://git.qemu.org/qemu.git/tree/net/socket.c#n310 [4] http://git.qemu.org/qemu.git/tree/net/socket.c#n369