[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 2/5] xl: New -t option ("tty") to force \r-based messages



Provide a new xl global option -t which passes
XTL_STDIOSTREAM_PROGRESS_USE_CR to xentoollog.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CC: Olaf Hering <olaf@xxxxxxxxx>
CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
---
 docs/man/xl.pod.1 |    6 ++++++
 tools/libxl/xl.c  |    9 +++++++--
 tools/libxl/xl.h  |    1 +
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1
index e7b9de2..f7ceaa8 100644
--- a/docs/man/xl.pod.1
+++ b/docs/man/xl.pod.1
@@ -81,6 +81,12 @@ Force execution: xl will refuse to run some commands if it 
detects that xend is
 also running, this option will force the execution of those commands, even
 though it is unsafe.
 
+=item B<-t>
+
+Always use carriage-return-based overwriting for printing progress
+messages without scrolling the screen.  Without -t, this is done only
+if stderr is a tty.
+
 =back
 
 =head1 DOMAIN SUBCOMMANDS
diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c
index 657610b..7fdc155 100644
--- a/tools/libxl/xl.c
+++ b/tools/libxl/xl.c
@@ -48,6 +48,7 @@ char *default_gatewaydev = NULL;
 char *default_vifbackend = NULL;
 enum output_format default_output_format = OUTPUT_FORMAT_JSON;
 int claim_mode = 1;
+bool progress_use_cr = 0;
 
 static xentoollog_level minmsglevel = XTL_PROGRESS;
 
@@ -292,7 +293,7 @@ int main(int argc, char **argv)
     int config_len = 0;
     const char *locks[] = XEND_LOCK;
 
-    while ((opt = getopt(argc, argv, "+vfN")) >= 0) {
+    while ((opt = getopt(argc, argv, "+vftN")) >= 0) {
         switch (opt) {
         case 'v':
             if (minmsglevel > 0) minmsglevel--;
@@ -303,6 +304,9 @@ int main(int argc, char **argv)
         case 'f':
             force_execution = 1;
             break;
+        case 't':
+            progress_use_cr = 1;
+            break;
         default:
             fprintf(stderr, "unknown global option\n");
             exit(2);
@@ -317,7 +321,8 @@ int main(int argc, char **argv)
     }
     opterr = 0;
 
-    logger = xtl_createlogger_stdiostream(stderr, minmsglevel,  0);
+    logger = xtl_createlogger_stdiostream(stderr, minmsglevel,
+        (progress_use_cr ? XTL_STDIOSTREAM_PROGRESS_USE_CR : 0));
     if (!logger) exit(1);
 
     atexit(xl_ctx_free);
diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h
index f188708..1a71234 100644
--- a/tools/libxl/xl.h
+++ b/tools/libxl/xl.h
@@ -152,6 +152,7 @@ extern int autoballoon;
 extern int run_hotplug_scripts;
 extern int dryrun_only;
 extern int claim_mode;
+extern bool progress_use_cr;
 extern char *lockfile;
 extern char *default_vifscript;
 extern char *default_bridge;
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.