xl: New -t option ("tty") to force \r-based messages
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 7 Jan 2014 18:19:18 +0000 (18:19 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 19 Mar 2014 13:42:13 +0000 (13:42 +0000)
Provide a new xl global option -t which passes
XTL_STDIOSTREAM_PROGRESS_USE_CR to xentoollog.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
docs/man/xl.pod.1
tools/libxl/xl.c
tools/libxl/xl.h

index e7b9de2849f5d757a833b5767cf0e00952341e07..f7ceaa848a1c72d9fc484da443d8a71cbac44c82 100644 (file)
@@ -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
index 657610ba36efdb9148c20507bc067e309a81f99d..7fdc1552dc3578d2df351878b8b7de580eb0195b 100644 (file)
@@ -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);
index f188708bf77c1633f9517c06d3b9c55a024f304d..1a7123457a5db40ae51de8509681bf51a5723a84 100644 (file)
@@ -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;