]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: fix build on mingw, which lacks termios stuff
authorEric Blake <eblake@redhat.com>
Wed, 4 Sep 2013 21:57:30 +0000 (15:57 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 4 Sep 2013 22:00:36 +0000 (16:00 -0600)
Recent patches to fix handling of Ctrl-C when interacting with
ssh are not portable to mingw, which lacks termios handling.
The simplest solution is to just compile that code out, and
if someone ever appears that has a serious interest in getting
virsh fully functional even with ssh connections, they can
provide patches at that time.

* tools/virsh.h (_vshControl): Make termattr conditional.
* tools/virsh.c (vshTTYIsInterruptCharacter)
(vshTTYDisableInterrupt, vshTTYRestore, cfmakeraw, vshTTYMakeRaw)
(main): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
tools/virsh.c
tools/virsh.h

index 37e971659fab2c5195b4994dd0899d1b9651e81c..bf2fbf81c7c094e10dae423497f71ef74832e690 100644 (file)
@@ -2213,20 +2213,23 @@ vshPrintExtra(vshControl *ctl, const char *format, ...)
 
 
 bool
-vshTTYIsInterruptCharacter(vshControl *ctl,
-                           const char chr)
+vshTTYIsInterruptCharacter(vshControl *ctl ATTRIBUTE_UNUSED,
+                           const char chr ATTRIBUTE_UNUSED)
 {
+#ifndef WIN32
     if (ctl->istty &&
         ctl->termattr.c_cc[VINTR] == chr)
         return true;
+#endif
 
     return false;
 }
 
 
 int
-vshTTYDisableInterrupt(vshControl *ctl)
+vshTTYDisableInterrupt(vshControl *ctl ATTRIBUTE_UNUSED)
 {
+#ifndef WIN32
     struct termios termset = ctl->termattr;
 
     if (!ctl->istty)
@@ -2241,25 +2244,28 @@ vshTTYDisableInterrupt(vshControl *ctl)
 
     if (tcsetattr(STDIN_FILENO, TCSANOW, &termset) < 0)
         return -1;
+#endif
 
     return 0;
 }
 
 
 int
-vshTTYRestore(vshControl *ctl)
+vshTTYRestore(vshControl *ctl ATTRIBUTE_UNUSED)
 {
+#ifndef WIN32
     if (!ctl->istty)
         return 0;
 
     if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &ctl->termattr) < 0)
         return -1;
+#endif
 
     return 0;
 }
 
 
-#ifndef HAVE_CFMAKERAW
+#if !defined(WIN32) && !defined(HAVE_CFMAKERAW)
 /* provide fallback in case cfmakeraw isn't available */
 static void
 cfmakeraw(struct termios *attr)
@@ -2271,12 +2277,14 @@ cfmakeraw(struct termios *attr)
     attr->c_cflag &= ~(CSIZE | PARENB);
     attr->c_cflag |= CS8;
 }
-#endif /* !HAVE_CFMAKERAW */
+#endif /* !WIN32 && !HAVE_CFMAKERAW */
 
 
 int
-vshTTYMakeRaw(vshControl *ctl, bool report_errors)
+vshTTYMakeRaw(vshControl *ctl ATTRIBUTE_UNUSED,
+              bool report_errors ATTRIBUTE_UNUSED)
 {
+#ifndef WIN32
     struct termios rawattr = ctl->termattr;
     char ebuf[1024];
 
@@ -2297,6 +2305,7 @@ vshTTYMakeRaw(vshControl *ctl, bool report_errors)
                      virStrerror(errno, ebuf, sizeof(ebuf)));
         return -1;
     }
+#endif
 
     return 0;
 }
@@ -3249,8 +3258,10 @@ main(int argc, char **argv)
     if (isatty(STDIN_FILENO)) {
         ctl->istty = true;
 
+#ifndef WIN32
         if (tcgetattr(STDIN_FILENO, &ctl->termattr) < 0)
             ctl->istty = false;
+#endif
     }
 
     if (virMutexInit(&ctl->lock) < 0) {
index 8afe13f60d2e062ca133914edc864b74fd492a5f..b5e2715e6521a05a0b20c45f5df3d5a7c050ad8c 100644 (file)
@@ -242,7 +242,9 @@ struct _vshControl {
     const char *escapeChar;     /* String representation of
                                    console escape character */
 
+# ifndef WIN32
     struct termios termattr;    /* settings of the tty terminal */
+# endif
     bool istty;                 /* is the terminal a tty */
 };