All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Cc: kwolf@redhat.com, phrdina@redhat.com,
	Stefan Hajnoczi <stefanha@gmail.com>,
	qemu-devel@nongnu.org, armbru@redhat.com, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 7/7] block: dump to monitor for bdrv_snapshot_dump() and bdrv_image_info_dump()
Date: Wed, 22 May 2013 08:23:26 -0400	[thread overview]
Message-ID: <20130522082326.07f17b27@redhat.com> (raw)
In-Reply-To: <519C28CF.80101@linux.vnet.ibm.com>

On Wed, 22 May 2013 10:09:19 +0800
Wenchao Xia <xiawenc@linux.vnet.ibm.com> wrote:

> 于 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 <xiawenc@linux.vnet.ibm.com> wrote:
> >>
> >>> 于 2013-5-16 20:17, Luiz Capitulino 写道:
> >>>> On Thu, 16 May 2013 10:22:09 +0800
> >>>> Wenchao Xia <xiawenc@linux.vnet.ibm.com> wrote:
> >>>>
> >>>>> 于 2013-5-15 20:28, Luiz Capitulino 写道:
> >>>>>> On Wed, 15 May 2013 10:10:37 +0800
> >>>>>> Wenchao Xia <xiawenc@linux.vnet.ibm.com> wrote:
> >>>>>>
> >>>>>>> 于 2013-5-6 21:22, Luiz Capitulino 写道:
> >>>>>>>> On Mon, 06 May 2013 10:09:43 +0800
> >>>>>>>> Wenchao Xia <xiawenc@linux.vnet.ibm.com> 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 <xiawenc@linux.vnet.ibm.com> wrote:
> >>>>>>>>>>>
> >>>>>>>>>>>> 于 2013-4-30 3:05, Luiz Capitulino 写道:
> >>>>>>>>>>>>> On Fri, 26 Apr 2013 16:46:57 +0200
> >>>>>>>>>>>>> Stefan Hajnoczi <stefanha@gmail.com> 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?

I'm honestly a bit confused with what you're suggesting. I'd just respin the
patches and restart the discussion.

      reply	other threads:[~2013-05-22 12:23 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-26  9:31 [Qemu-devel] [PATCH 0/7] qapi and snapshot code clean up in block layer Wenchao Xia
2013-04-26  9:31 ` [Qemu-devel] [PATCH 1/7] block: drop bs_snapshots global variable Wenchao Xia
2013-04-26  9:31 ` [Qemu-devel] [PATCH 2/7] block: move bdrv_snapshot_find() to block/snapshot.c Wenchao Xia
2013-04-26  9:31 ` [Qemu-devel] [PATCH 3/7] block: move snapshot code in block.c " Wenchao Xia
2013-04-26 19:05   ` Eric Blake
2013-04-26  9:31 ` [Qemu-devel] [PATCH 4/7] block: distinguish id and name in bdrv_find_snapshot() Wenchao Xia
2013-04-26 14:34   ` Stefan Hajnoczi
2013-04-26 14:47     ` Eric Blake
2013-04-27  3:34     ` Wenchao Xia
2013-04-30 17:52       ` Eric Blake
2013-04-30 18:16   ` Eric Blake
2013-05-02  2:02     ` Wenchao Xia
2013-05-02 21:12       ` Pavel Hrdina
2013-04-26  9:31 ` [Qemu-devel] [PATCH 5/7] block: move collect_snapshots() and collect_image_info() to block/qapi.c Wenchao Xia
2013-04-26  9:31 ` [Qemu-devel] [PATCH 6/7] block: move qmp and info dump related code " Wenchao Xia
2013-04-30 17:50   ` Eric Blake
2013-04-26  9:31 ` [Qemu-devel] [PATCH 7/7] block: dump to monitor for bdrv_snapshot_dump() and bdrv_image_info_dump() Wenchao Xia
2013-04-26 14:46   ` Stefan Hajnoczi
2013-04-27  3:37     ` Wenchao Xia
2013-04-29 19:05     ` Luiz Capitulino
2013-05-02  2:05       ` Wenchao Xia
2013-05-02 12:02         ` Luiz Capitulino
2013-05-03  2:51           ` Wenchao Xia
2013-05-06  2:09             ` Wenchao Xia
2013-05-06 13:22               ` Luiz Capitulino
2013-05-15  2:10                 ` Wenchao Xia
2013-05-15 12:28                   ` Luiz Capitulino
2013-05-16  2:22                     ` Wenchao Xia
2013-05-16 12:17                       ` Luiz Capitulino
2013-05-17  3:30                         ` Wenchao Xia
2013-05-17 12:30                           ` Luiz Capitulino
2013-05-20  2:39                             ` Wenchao Xia
2013-05-22  2:09                               ` Wenchao Xia
2013-05-22 12:23                                 ` Luiz Capitulino [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130522082326.07f17b27@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=phrdina@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=xiawenc@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.