Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Add v3_cons_sc sanity check for Terminal size
Thomas Naughton [Fri, 24 Aug 2012 15:38:26 +0000 (11:38 -0400)]
linux_usr/v3_cons_sc.c

index a8e7046..6d7e522 100644 (file)
@@ -371,7 +371,32 @@ int send_char_to_palacios_as_scancodes(int fd, unsigned char c)
     }
     return 0;
 }
-    
+
+
+#define MIN_TTY_COLS  80
+#define MIN_TTY_ROWS  25
+int check_terminal_size (void)
+{
+    unsigned short n_cols = 0;
+    unsigned short n_rows = 0;
+    struct winsize winsz; 
+
+    ioctl (fileno(stdin), TIOCGWINSZ, &winsz);
+    n_cols = winsz.ws_col;
+    n_rows = winsz.ws_row;
+
+    if (n_cols < MIN_TTY_COLS || n_rows < MIN_TTY_ROWS) {
+        printf ("Your window is not large enough.\n");
+        printf ("It must be at least %dx%d, but yours is %dx%d\n",
+                MIN_TTY_COLS, MIN_TTY_ROWS, n_cols, n_rows);
+    return (-1);
+    }
+
+    /* SUCCESS */
+    return (0);
+}
+
+
 int main(int argc, char* argv[]) {
     int vm_fd;
     int cons_fd;
@@ -385,6 +410,12 @@ int main(int argc, char* argv[]) {
        return -1;
     }
 
+    /* Check for minimum Terminal size at start */
+    if (0 != check_terminal_size()) {
+        printf ("Error: terminal too small!\n");
+        return -1;
+    }
+
     vm_dev = argv[1];
 
     vm_fd = open(vm_dev, O_RDONLY);
@@ -450,13 +481,6 @@ int main(int argc, char* argv[]) {
 
     //ioctl(STDIN_FILENO, KDSKBMODE, K_RAW);
 
-    if (LINES<25 || COLS<80) { 
-       printf("Your window is not large enough.\nIt must be at least 80x25, but yours is %dx%d\n",COLS,LINES);
-       close(cons_fd);
-       exit(-1);
-    }
-    
-
     while (1) {
        int ret; 
        int bytes_read = 0;