From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwnZk-0004oE-98 for qemu-devel@nongnu.org; Wed, 10 Jul 2013 02:08:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UwnZj-000161-AF for qemu-devel@nongnu.org; Wed, 10 Jul 2013 02:08:28 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:37692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwnZi-00014f-Np for qemu-devel@nongnu.org; Wed, 10 Jul 2013 02:08:27 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Jul 2013 15:56:12 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 47FA52BB0051 for ; Wed, 10 Jul 2013 16:08:12 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r6A5qsnn2556332 for ; Wed, 10 Jul 2013 15:52:56 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r6A68AUn001191 for ; Wed, 10 Jul 2013 16:08:10 +1000 Message-ID: <51DCFA02.4030202@linux.vnet.ibm.com> Date: Wed, 10 Jul 2013 14:06:58 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1372477981-7512-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1372477981-7512-2-git-send-email-xiawenc@linux.vnet.ibm.com> <20130708111711.0b2631d6@redhat.com> <51DB7040.8020306@linux.vnet.ibm.com> <51DC183E.4020409@linux.vnet.ibm.com> <20130709101439.4e1d45b3@redhat.com> In-Reply-To: <20130709101439.4e1d45b3@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH V5 1/7] monitor: avoid direct use of global *cur_mon in completion functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com 于 2013-7-9 22:14, Luiz Capitulino 写道: > On Tue, 09 Jul 2013 22:03:42 +0800 > Wenchao Xia wrote: > >> >>>> You could pass cur_mon to readline_completion() in readline_handle_byte() >>>> to avoid all this, but it would be preferable to clarify the matter. >>>> >>>> This is also another benefit of having readline_completion() in a >>>> different patch, you can (and should!) clarify this point in the commit >>>> log along with testing results. >>>> >>> OK, I'll test multiple monitors case. >>> >>> >>> >> Do you have an example about how invoke qemu with multiple monitor? >> Do you have recommendation about the way to connect to qemu's moniotr? >> I tried pty with minicom but it seems not good, so wonder your method. > > You can open telnet sessions: > > -monitor tcp:0:4444,server,nowait,telnet \ > -monitor tcp:0:4445,server,nowait,telnet > > But note that, besides testing, I'd like to see an explanation on > the commitlog as to why dropping cur_mon doesn't brake the current > code. > Thanks for the info, it works now. After re-check the code in readline_completion(), I think current code with cur_mon, is redundant: mon = cur_mon; ... } else { monitor_printf(mon, "\n"); ... ... for(i = 0; i < rs->nb_completions; i++) { monitor_printf(rs->mon, "%-*s", max_width, rs->completions[i]); if (++j == nb_cols || i == (rs->nb_completions - 1)) { monitor_printf(rs->mon, "\n"); j = 0; } } readline_show_prompt(rs); } You can see later, it uses rs->mon to printf the auto completion result, so the first 'monitor_printf(mon, "\n");', is used to start a new line for the completion result, so mon should always be equal to rs->mon, I can't think out a case that one monitor instance does not print tips in new line while another monitor instance does. I'll add a few line for it in commit message. About pass cur_mon to readline_completion(), I think parameter *rs already have member rs->mon, allowing specify *mon would specify the encapsulation a bit. -- Best Regards Wenchao Xia