tools/xc: restore logging in xc_save
PATCH 1/1 tools/xc: restore logging in xc_save
# HG changeset patch
# User Olaf Hering <[email protected]>
# Date 1359745022 -3600
# Node ID d76b38b799293ff17fed8eaaac8fbbebced1b72f # Parent 6d1d516ecaade56f796e3216e9931fdcc12282cd tools/xc: restore logging in xc_save
Prior to xen-4.1 the helper xc_save would print some progress during migration. With the new xc_interface_open API no more messages were printed because no logger was configured.
Restore previous behaviour by providing a logger. The progress in xc_domain_save will be disabled because its output lacks a linefeed which makes xend.log look ugly.
tools/xcutils/xc_save.c +10 -5
@@ -166,17 +166,15 @@ static int switch_qemu_logdirty(int domiint main (int argc,char **argv) { -unsigned int maxit, max_f; +unsigned int maxit, max_f, lflags;int io_fd, ret, port;struct save_callbacks callbacks; +xentoollog_level lvl; +xentoollog_logger *l;if (argc !=6 )errx (1 ,"usage: %s iofd domid maxit maxf flags" , argv[0 ]); - si.xch =xc_interface_open (0 ,0 ,0 ); -if (!si.xch) -errx (1 ,"failed to open control interface" ); - io_fd =atoi (argv[1 ]); si.domid =atoi (argv[2 ]); maxit =atoi (argv[3 ]);
@@ -185,6 +183,13 @@ main(int argc, char **argv) si.suspend_evtchn =-1 ; + lvl = si.flags &XCFLAGS_DEBUG ?XTL_DEBUG :XTL_DETAIL ; + lflags =XTL_STDIOSTREAM_HIDE_PROGRESS ; + l = (xentoollog_logger *)xtl_createlogger_stdiostream (stderr, lvl, lflags); + si.xch =xc_interface_open (l,0 ,0 ); +if (!si.xch) +errx (1 ,"failed to open control interface" ); + si.xce =xc_evtchn_open (NULL ,0 );if (si.xce ==NULL )warnx ("failed to open event channel handle" );
Quoted 42 lines · Olaf Hering
# HG changeset patch
# User Olaf Hering <[email protected]>
# Date 1359745022 -3600
# Node IDd76b38b799293ff17fed8eaaac8fbbebced1b72f# Parent6d1d516ecaade56f796e3216e9931fdcc12282cdtools/xc: restore logging inxc_savePrior to xen-4.1 the helper
xc_savewould print some progress during migration. With the newxc_interface_openAPI no more messages were printed because no logger was configured.Restore previous behaviour by providing a logger. The progress in
xc_domain_savewill be disabled because its output lacks a linefeed which makes xend.log look ugly.Signed-off-by Olaf Hering <[email protected]>diff -r
6d1d516ecaad-rd76b38b79929tools/xcutils/xc_save.ctools/xcutils/xc_save.c +3
-5@@ -166,17 +166,15 @@ static int switch_qemu_logdirty(int domiint main (int argc,char **argv) { -unsigned int maxit, max_f; +unsigned int maxit, max_f, lflags;int io_fd, ret, port;struct save_callbacks callbacks; +xentoollog_level lvl; +xentoollog_logger *l;if (argc !=6 )errx (1 ,"usage: %s iofd domid maxit maxf flags" , argv[0 ]); - si.xch =xc_interface_open (0 ,0 ,0 ); -if (!si.xch) -errx (1 ,"failed to open control interface" ); - io_fd =atoi (argv[1 ]); si.domid =atoi (argv[2 ]); maxit =atoi (argv[3 ]);
tools/xcutils/xc_save.c main(int argc, char **argv) · line 187
Quoted 5 lines
tools/xcutils/xc_save.c +2
-0@@ -185,6 +183,13 @@ main(int argc, char **argv) si.suspend_evtchn =-1 ; + lvl = si.flags &XCFLAGS_DEBUG ?XTL_DEBUG :XTL_DETAIL ; + lflags =XTL_STDIOSTREAM_HIDE_PROGRESS ;
Would it be useful (as an extension) to implement an XTL_STDIOSTREAM flag which makes it output something more suitable for logging, e.g. ...10%...20%...30%...
(or perhaps automatic based on isatty(outputfd)?)
tools/xcutils/xc_save.c main(int argc, char **argv) · line 188
Quoted 1 line
tools/xcutils/xc_save.c +1
-0+ l = (xentoollog_logger *)xtl_createlogger_stdiostream (stderr, lvl, lflags);
Might this fail and therefore require error handling?
The lvl and lflags variables seem a bit useless to me.
Quoted 12 lines
tools/xcutils/xc_save.c +4
-0+ si.xch =xc_interface_open (l,0 ,0 ); +if (!si.xch) +errx (1 ,"failed to open control interface" ); + si.xce =xc_evtchn_open (NULL ,0 );if (si.xce ==NULL )warnx ("failed to open event channel handle" );_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 8 lines · Ian Campbell
tools/xcutils/xc_save.c main(int argc, char **argv) · line 187
Quoted 2 lines · Olaf Hering
tools/xcutils/xc_save.c +2
-0+ lvl = si.flags &XCFLAGS_DEBUG ?XTL_DEBUG :XTL_DETAIL ; + lflags =XTL_STDIOSTREAM_HIDE_PROGRESS ;Would it be useful (as an extension) to implement an
XTL_STDIOSTREAMflag which makes it output something more suitable for logging, e.g. ...10%...20%...30%...
(or perhaps automatic based on isatty(outputfd)?)
I was thinking about that, to extend the called progress functions. In the case of xend.log it would produce many lines of progress. Since the default xend logging is limited to 1MB, the xend.log file would be rotated quickly and maybe useful logging output will be lost?
But for other callers of the progress functions it might be useful to have a parsable output so that they dont have to jump through the hoops. No idea if any caller makes use of the progress, given that it did not work at all without the other patch I sent last Friday.
Quoted 3 lines
Quoted 1 line
+ l = (
xentoollog_logger*)xtl_createlogger_stdiostream(stderr, lvl, lflags);Might this fail and therefore require error handling?
If it fails then no logging will happen.
Quoted 1 line
The lvl and lflags variables seem a bit useless to me.
They are there to keep the lines short.
Olaf
Ian Campbell
Acked-byQuoted 6 lines · Olaf Hering
Quoted 4 lines · Ian Campbell
Quoted 2 lines · Olaf Hering
tools/xcutils/xc_save.c +2
-0+ lvl = si.flags &XCFLAGS_DEBUG ?XTL_DEBUG :XTL_DETAIL ; + lflags =XTL_STDIOSTREAM_HIDE_PROGRESS ;
Quoted 7 lines
Quoted 4 lines
Would it be useful (as an extension) to implement an
XTL_STDIOSTREAMflag which makes it output something more suitable for logging, e.g. ...10%...20%...30%...
(or perhaps automatic based on isatty(outputfd)?)I was thinking about that, to extend the called progress functions. In the case of xend.log it would produce many lines of progress.
How come many lines? I imaged the above as a single line.
Quoted 7 lines
Since the default xend logging is limited to 1MB, the xend.log file would be rotated quickly and maybe useful logging output will be lost?
But for other callers of the progress functions it might be useful to have a parsable output so that they dont have to jump through the hoops. No idea if any caller makes use of the progress, given that it did not work at all without the other patch I sent last Friday.
xl migrate uses AFAIK, which isn't to say it wasn't broken ;-)
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
+ l = (
xentoollog_logger*)xtl_createlogger_stdiostream(stderr, lvl, lflags);Might this fail and therefore require error handling?
If it fails then no logging will happen.
Which I suppose is better than failing the migration altogether.
Quoted 4 lines
Quoted 2 lines
The lvl and lflags variables seem a bit useless to me.
They are there to keep the lines short
I would have done:
l = (xentoollog_logger *)xtl_createlogger_stdiostream(stderr,
si.flags & XCFLAGS_DEBUG ? XTL_DEBUG: XTL_DETAIL, XTL_STDIOSTREAM_HIDE_PROGRESS);
But OK.
I think that addresses both of my questions, so
Although I did mean to ask why the code had to move?
(I've been avoiding committing anything while we sort out the staging backlog, and I seem to have a massive email backlog this morning to boot, but this is in my queue)
Ian.
Quoted 12 lines · Ian Campbell
Quoted 11 lines · Olaf Hering
Quoted 8 lines · Ian Campbell
tools/xcutils/xc_save.c main(int argc, char **argv) · line 187
Quoted 2 lines · Olaf Hering
tools/xcutils/xc_save.c +2
-0+ lvl = si.flags &XCFLAGS_DEBUG ?XTL_DEBUG :XTL_DETAIL ; + lflags =XTL_STDIOSTREAM_HIDE_PROGRESS ;Would it be useful (as an extension) to implement an
XTL_STDIOSTREAMflag which makes it output something more suitable for logging, e.g. ...10%...20%...30%...
(or perhaps automatic based on isatty(outputfd)?)
Quoted 4 lines
Quoted 2 lines
I was thinking about that, to extend the called progress functions. In the case of xend.log it would produce many lines of progress.
How come many lines? I imaged the above as a single line.
Oh, I did not realize that we did not talk about XTL_STDIOSTREAM_HIDE_PROGRESS but about another new flag.
Quoted 4 lines
Quoted 2 lines
No idea if any caller makes use of the progress, given that it did not work at all without the other patch I sent last Friday.
xl migrate uses AFAIK, which isn't to say it wasn't broken ;-)
For me it was not printed without the patch in
<[email protected]>
Quoted 1 line
Although I did mean to ask why the code had to move?
To get to si.flags.
Olaf
Quoted 14 lines · Olaf Hering
Quoted 12 lines · Ian Campbell
Quoted 11 lines · Olaf Hering
Quoted 8 lines · Ian Campbell
tools/xcutils/xc_save.c main(int argc, char **argv) · line 187
Quoted 2 lines · Olaf Hering
tools/xcutils/xc_save.c +2
-0+ lvl = si.flags &XCFLAGS_DEBUG ?XTL_DEBUG :XTL_DETAIL ; + lflags =XTL_STDIOSTREAM_HIDE_PROGRESS ;Would it be useful (as an extension) to implement an
XTL_STDIOSTREAMflag which makes it output something more suitable for logging, e.g. ...10%...20%...30%...
(or perhaps automatic based on isatty(outputfd)?)
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I was thinking about that, to extend the called progress functions. In the case of xend.log it would produce many lines of progress.
How come many lines? I imaged the above as a single line.
Oh, I did not realize that we did not talk about
XTL_STDIOSTREAM_HIDE_PROGRESSbut about another new flag.
Right, or perhaps changing the behaviour of the !HIDE_PROGRESS flag based on isatty, which would also perhaps fix the ugliness here:
http://www.chiark.greenend.org.uk/~xensrcts/logs/15367/test-amd64-amd64-xl/11.ts-guest-localmigrate.log
(not a big deal though)
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
No idea if any caller makes use of the progress, given that it did not work at all without the other patch I sent last Friday.
xl migrate uses AFAIK, which isn't to say it wasn't broken ;-)
For me it was not printed without the patch in
<[email protected]>
I guess this is in my queue somewhere, I'll take a look.
Quoted 3 lines
Quoted 1 line
Although I did mean to ask why the code had to move?
To get to si.flags.
A-ha!
Thanks,
Ian.
Quoted 46 lines · Ian Campbell
Quoted 45 lines · Olaf Hering
# HG changeset patch
# User Olaf Hering <[email protected]>
# Date 1359745022 -3600
# Node IDd76b38b799293ff17fed8eaaac8fbbebced1b72f# Parent6d1d516ecaade56f796e3216e9931fdcc12282cdtools/xc: restore logging inxc_savePrior to xen-4.1 the helper
xc_savewould print some progress during migration. With the newxc_interface_openAPI no more messages were printed because no logger was configured.Restore previous behaviour by providing a logger. The progress in
xc_domain_savewill be disabled because its output lacks a linefeed which makes xend.log look ugly.Signed-off-by Olaf Hering <[email protected]>diff -r
6d1d516ecaad-rd76b38b79929tools/xcutils/xc_save.ctools/xcutils/xc_save.c +3
-5@@ -166,17 +166,15 @@ static int switch_qemu_logdirty(int domiint main (int argc,char **argv) { -unsigned int maxit, max_f; +unsigned int maxit, max_f, lflags;int io_fd, ret, port;struct save_callbacks callbacks; +xentoollog_level lvl; +xentoollog_logger *l;if (argc !=6 )errx (1 ,"usage: %s iofd domid maxit maxf flags" , argv[0 ]); - si.xch =xc_interface_open (0 ,0 ,0 ); -if (!si.xch) -errx (1 ,"failed to open control interface" ); - io_fd =atoi (argv[1 ]); si.domid =atoi (argv[2 ]); maxit =atoi (argv[3 ]);@@ -185,6 +183,13 @@ main(int argc, char **argv) si.suspend_evtchn =-1 ;
Quoted 7 lines
tools/xcutils/xc_save.c main(int argc, char **argv) · line 187
Quoted 2 lines
tools/xcutils/xc_save.c +2
-0+ lvl = si.flags &XCFLAGS_DEBUG ?XTL_DEBUG :XTL_DETAIL ; + lflags =XTL_STDIOSTREAM_HIDE_PROGRESS ;Would it be useful (as an extension) to implement an
XTL_STDIOSTREAMflag which makes it output something more suitable for logging, e.g. ...10%...20%...30%...
(or perhaps automatic based on isatty(outputfd)?)
It could be as simple as this tested patch, if its a logfile always write a new line.
What do you think about this approach?
Olaf
tools/xc: handle tty output differently in stdiostream_progress
tools/libxc/xtl_logger_stdio.c +6 -4
@@ -86,7 +86,7 @@ static void stdiostream_progress(struct const char *doing_what, int percent, unsigned long done, unsigned long total) { xentoollog_logger_stdiostream *lg = (void*)logger_in; -int newpel, extra_erase; +int newpel, extra_erase, istty;xentoollog_level this_level;if (lg->flags &XTL_STDIOSTREAM_HIDE_PROGRESS )
@@ -105,7 +105,9 @@ static void stdiostream_progress(structif (this_level < lg->min_level)return ; -if (lg->progress_erase_len) + istty =isatty (fileno (lg->f)) >0 ; + +if (istty && lg->progress_erase_len)putc ('\r' , lg->f); lg->progress_last_percent = percent;
@@ -113,10 +115,10 @@ static void stdiostream_progress(struct newpel =fprintf (lg->f,"%s%s" "%s: %lu/%lu %3d%%%s" , context?context:"" , context?": " :"" , doing_what, done, total, percent, - done == total ?"\n" :"" ); + (done == total) || !istty ?"\n" :"" ); extra_erase = lg->progress_erase_len - newpel; -if (extra_erase >0 ) +if (istty && extra_erase >0 )fprintf (lg->f,"%*s\r" , extra_erase,"" ); lg->progress_erase_len = newpel;
Quoted 1 line · Olaf Hering
What do you think about this approach?
I think its not perfect. If XTL_STDIOSTREAM_SHOW_PID or XTL_STDIOSTREAM_SHOW_DATE is requested, then both will not be printed. I will let stdiostream_vmessage print the message if the output is not a tty.
Olaf