xen/arm: vpl011: Add a new vuart console type to xenconsole client
authorBhupinder Thakur <bhupinder.thakur@linaro.org>
Wed, 27 Sep 2017 06:13:32 +0000 (11:43 +0530)
committerStefano Stabellini <sstabellini@kernel.org>
Tue, 3 Oct 2017 22:23:37 +0000 (15:23 -0700)
Add a new console type VUART to connect to guest's emualated vuart
console.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/console/client/main.c

index c340cb7de3c6718ddf3282224e263f4c49f0ef69..f92ad3d8cfdd824c6e57b37f0a94d29d0835ae04 100644 (file)
@@ -76,7 +76,7 @@ static void usage(const char *program) {
               "\n"
               "  -h, --help       display this help and exit\n"
               "  -n, --num N      use console number N\n"
-              "  --type TYPE      console type. must be 'pv' or 'serial'\n"
+              "  --type TYPE      console type. must be 'pv', 'serial' or 'vuart'\n"
               "  --start-notify-fd N file descriptor used to notify parent\n"
               , program);
 }
@@ -264,6 +264,7 @@ typedef enum {
        CONSOLE_INVAL,
        CONSOLE_PV,
        CONSOLE_SERIAL,
+       CONSOLE_VUART,
 } console_type;
 
 static struct termios stdin_old_attr;
@@ -344,6 +345,7 @@ int main(int argc, char **argv)
        char *end;
        console_type type = CONSOLE_INVAL;
        bool interactive = 0;
+       char *console_names = "serial, pv, vuart";
 
        while((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) {
                switch(ch) {
@@ -359,9 +361,12 @@ int main(int argc, char **argv)
                                type = CONSOLE_SERIAL;
                        else if (!strcmp(optarg, "pv"))
                                type = CONSOLE_PV;
+                       else if (!strcmp(optarg, "vuart"))
+                               type = CONSOLE_VUART;
                        else {
                                fprintf(stderr, "Invalid type argument\n");
-                               fprintf(stderr, "Console types supported are: serial, pv\n");
+                               fprintf(stderr, "Console types supported are: %s\n",
+                                       console_names);
                                exit(EINVAL);
                        }
                        break;
@@ -437,6 +442,10 @@ int main(int argc, char **argv)
                else
                        snprintf(path, strlen(dom_path) + strlen("/device/console/%d/tty") + 5, "%s/device/console/%d/tty", dom_path, num);
        }
+       if (type == CONSOLE_VUART) {
+               snprintf(path, strlen(dom_path) + strlen("/vuart/0/tty") + 1,
+                        "%s/vuart/0/tty", dom_path);
+       }
 
        /* FIXME consoled currently does not assume domain-0 doesn't have a
           console which is good when we break domain-0 up.  To keep us