From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UeyVB-0003M4-DB for qemu-devel@nongnu.org; Tue, 21 May 2013 22:10:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UeyV5-0003Ca-HX for qemu-devel@nongnu.org; Tue, 21 May 2013 22:10:05 -0400 Received: from e28smtp01.in.ibm.com ([122.248.162.1]:36282) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UeyV4-0003CC-TD for qemu-devel@nongnu.org; Tue, 21 May 2013 22:09:59 -0400 Received: from /spool/local by e28smtp01.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 22 May 2013 07:34:05 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id 6DDF41258052 for ; Wed, 22 May 2013 07:41:50 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r4M29kmX49414280 for ; Wed, 22 May 2013 07:39:47 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r4M29puY002384 for ; Wed, 22 May 2013 12:09:52 +1000 Message-ID: <519C28CF.80101@linux.vnet.ibm.com> Date: Wed, 22 May 2013 10:09:19 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1366968675-1451-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1366968675-1451-8-git-send-email-xiawenc@linux.vnet.ibm.com> <20130426144657.GB7648@stefanha-thinkpad.redhat.com> <20130429150541.298db151@redhat.com> <5181C9D4.4000905@linux.vnet.ibm.com> <20130502080206.21df203f@redhat.com> <51832636.1020900@linux.vnet.ibm.com> <518710E7.5060103@linux.vnet.ibm.com> <20130506092224.18dbac32@redhat.com> <5192EE9D.5030604@linux.vnet.ibm.com> <20130515082848.0ec7ca4c@redhat.com> <519442D1.8070402@linux.vnet.ibm.com> <20130516081740.6c7ee91c@redhat.com> <5195A457.9050402@linux.vnet.ibm.com> <20130517083038.3a0c1472@redhat.com> <51998CEA.6070709@linux.vnet.ibm.com> In-Reply-To: <51998CEA.6070709@linux.vnet.ibm.com> Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 7/7] block: dump to monitor for bdrv_snapshot_dump() and bdrv_image_info_dump() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: kwolf@redhat.com, phrdina@redhat.com, Stefan Hajnoczi , qemu-devel@nongnu.org, armbru@redhat.com, pbonzini@redhat.com 于 2013-5-20 10:39, Wenchao Xia 写道: > 于 2013-5-17 20:30, Luiz Capitulino 写道: >> On Fri, 17 May 2013 11:30:31 +0800 >> Wenchao Xia wrote: >> >>> 于 2013-5-16 20:17, Luiz Capitulino 写道: >>>> On Thu, 16 May 2013 10:22:09 +0800 >>>> Wenchao Xia wrote: >>>> >>>>> 于 2013-5-15 20:28, Luiz Capitulino 写道: >>>>>> On Wed, 15 May 2013 10:10:37 +0800 >>>>>> Wenchao Xia wrote: >>>>>> >>>>>>> 于 2013-5-6 21:22, Luiz Capitulino 写道: >>>>>>>> On Mon, 06 May 2013 10:09:43 +0800 >>>>>>>> Wenchao Xia wrote: >>>>>>>> >>>>>>>>> 于 2013-5-3 10:51, Wenchao Xia 写道: >>>>>>>>>> 于 2013-5-2 20:02, Luiz Capitulino 写道: >>>>>>>>>>> On Thu, 02 May 2013 10:05:08 +0800 >>>>>>>>>>> Wenchao Xia wrote: >>>>>>>>>>> >>>>>>>>>>>> 于 2013-4-30 3:05, Luiz Capitulino 写道: >>>>>>>>>>>>> On Fri, 26 Apr 2013 16:46:57 +0200 >>>>>>>>>>>>> Stefan Hajnoczi wrote: >>>>>>>>>>>>> >>>>>>>>>>>>>> On Fri, Apr 26, 2013 at 05:31:15PM +0800, Wenchao Xia wrote: >>>>>>>>>>>>>>> @@ -2586,10 +2585,12 @@ void do_info_snapshots(Monitor >>>>>>>>>>>>>>> *mon, const >>>>>>>>>>>>>>> QDict *qdict) >>>>>>>>>>>>>>> } >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> if (total > 0) { >>>>>>>>>>>>>>> - monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, >>>>>>>>>>>>>>> sizeof(buf), NULL)); >>>>>>>>>>>>>>> + bdrv_snapshot_dump(NULL); >>>>>>>>>>>>>>> + monitor_printf(mon, "\n"); >>>>>>>>>>>>>> >>>>>>>>>>>>>> Luiz: any issue with mixing monitor_printf(mon) and >>>>>>>>>>>>>> monitor_vprintf(cur_mon) calls? I guess there was a >>>>>>>>>>>>>> reason for >>>>>>>>>>>>>> explicitly passing mon instead of relying on cur_mon. >>>>>>>>>>>>> >>>>>>>>>>>>> where are they being mixed? >>>>>>>>>>>>> >>>>>>>>>>>> bdrv_snapshot_dump() used a global variable >>>>>>>>>>>> "cur_mon" inside, >>>>>>>>>>>> instead >>>>>>>>>>>> of let caller pass in a explicit montior* "mon", I guess >>>>>>>>>>>> that is the >>>>>>>>>>>> question. >>>>>>>>>>> >>>>>>>>>>> I'd have to see the code to tell, but yes, what Stefan >>>>>>>>>>> described is the >>>>>>>>>>> best practice for the Monitor. >>>>>>>>>>> >>>>>>>>>> I think this would not be a problem until qemu wants >>>>>>>>>> more than one >>>>>>>>>> human monitor console, and then we may require a data >>>>>>>>>> structure to tell >>>>>>>>>> where to output the string: stdout, *mon, or even stderr, and >>>>>>>>>> error_printf() also need to be changed. >>>>>>>>>> >>>>>>>>> Luiz, what is your idea? I'd like to respin v2 if no >>>>>>>>> issues for it. >>>>>>>> >>>>>>>> As I said before, I'd have to see the code to tell. But >>>>>>>> answering your comment, >>>>>>>> the code does support multiple monitors. >>>>>>>> >>>>>>> Hi Luiz, >>>>>>> Sorry to ask again, do you think method above is OK now, >>>>>>> waiting for >>>>>>> your confirm. >>>>>> >>>>>> Can you point me to the code in question? >>>>>> >>>>> Sure, it is >>>>> >>>>> + >>>>> +/* >>>>> + * Print to current monitor if we have one, else to stdout. It is >>>>> similar with >>>>> + * error_printf(). >>>>> + * TODO just like error_vprintf() >>>>> + */ >>>>> +void message_printf(const char *fmt, ...) >>>>> +{ >>>>> + va_list ap; >>>>> + >>>>> + va_start(ap, fmt); >>>>> + if (cur_mon) { >>>>> + monitor_vprintf(cur_mon, fmt, ap); >>>>> + } else { >>>>> + vfprintf(stdout, fmt, ap); >>>>> + } >>>>> + va_end(ap); >>>>> +} >>>>> >>>>> This function used global variable cur_mon instead of input >>>>> parameter, >>>>> similar to error_printf(). >>>> >>>> Why do you need it? Why can't you you use error_printf() for example? >>>> >>> error_printf() will print out to stderr in qemu-img, but stdout is >>> wanted for those dump info function. >> >> You can refactor the code so that you can pass a FILE *stream argument to >> error_vprintf() and maybe add error_printf_stream()? >> > The name is a bit confusing, maybe qemu_printf()? Another problem is, > monitor have a buf[] instead of a FILE*, I think it need a structure > include those: > > typdef enum QemuOutputType { > QEMU_OUTPUT_TYPE_STREAM, > QEMU_OUTPUT_TYPE_MONITOR, > } QemuOutputType; > > typedef struct QemuOutput { > QemuOutputType type; > union { > FILE *file; > Monitor *mon; > }; > } > > It may brings some inconvienience to caller, but this is what I can > think out now. > Luiz, I am going to respin V2 as above, can I have you confirm on it? -- Best Regards Wenchao Xia