> Date: Sat, 17 Sep 2022 10:50:46 +0000
> From: Klemens Nanni <[email protected]>
> 
> In my case, accessing guest domain consoles always happens through SSH,
> ILOM, or conserver, so there's usually one more level to escape.
> 
> Changing cu(1)'s escape character makes things easier to type and harder
> to mess up (~. instead of ~~. kills SSH/whatever instead of the guest
> console).
> 
> Using 'cu -l ttyV* -E@' is not an option as 'ldomctl console -E@ foo'
> takes care of the name-to-tty mapping, which may change with ldom.conf
> changes.
> 
> 'ldomctl start|panic -c foo' also drop into the console but seem like
> briefly used shortcuts (watch boot log, debug a specific thing) whereas
> 'ldomctl console foo' is usually used for long running console access.
> 
> Feedback? OK? (for after release)

Doesn't really make sense to me.  I looked at vmctl(4) and it doesn't
have this option.

> diff --git a/usr.sbin/ldomctl/ldomctl.8 b/usr.sbin/ldomctl/ldomctl.8
> index 6d4b6dee6b5..776a2270809 100644
> --- a/usr.sbin/ldomctl/ldomctl.8
> +++ b/usr.sbin/ldomctl/ldomctl.8
> @@ -44,10 +44,16 @@ in bytes.
>  can be specified with a human-readable scale, using the format described in
>  .Xr scan_scaled 3 ,
>  e.g. 512M.
> -.It Cm console Ar domain
> +.It Cm console Oo Fl E Ar escape_char Oc Ar domain
>  Using
>  .Xr cu 1
>  connect to the console of the guest domain.
> +.Bl -tag -width 3n
> +.It Fl E Ar escape_char
> +Specify an escape character as per
> +.Xr cu 1
> +.Fl E .
> +.El
>  .It Cm delete Ar configuration
>  Delete the specified configuration from non-volatile storage.
>  .It Cm download Ar directory
> diff --git a/usr.sbin/ldomctl/ldomctl.c b/usr.sbin/ldomctl/ldomctl.c
> index e48a560f7db..906ab414488 100644
> --- a/usr.sbin/ldomctl/ldomctl.c
> +++ b/usr.sbin/ldomctl/ldomctl.c
> @@ -131,7 +131,8 @@ usage(void)
>           "\t%1$s init-system [-n] file\n"
>           "\t%1$s create-vdisk -s size file\n"
>           "\t%1$s panic|start [-c] domain\n"
> -         "\t%1$s console|status|stop [domain]\n",
> +         "\t%1$s status|stop [domain]\n"
> +         "\t%1$s console [-E escape_char] domain\n",
>           getprogname());
>  
>       exit(EXIT_FAILURE);
> @@ -403,7 +404,7 @@ download(int argc, char **argv)
>  }
>  
>  void
> -console_exec(uint64_t gid)
> +console_exec(uint64_t gid, const char *escape_char)
>  {
>       struct guest *guest;
>       char console_str[8];
> @@ -419,6 +420,7 @@ console_exec(uint64_t gid)
>  
>               closefrom(STDERR_FILENO + 1);
>               execl(LDOMCTL_CU, LDOMCTL_CU, "-r", "-l", console_str,
> +                 "-E", (escape_char != NULL) ? escape_char : "~",
>                   (char *)NULL);
>               err(1, "failed to open console");
>       }
> @@ -468,7 +470,7 @@ guest_start(int argc, char **argv)
>               err(1, "read");
>  
>       if (console)
> -             console_exec(gid);
> +             console_exec(gid, NULL);
>  }
>  
>  void
> @@ -543,7 +545,7 @@ guest_panic(int argc, char **argv)
>               err(1, "read");
>  
>       if (console)
> -             console_exec(gid);
> +             console_exec(gid, NULL);
>  }
>  
>  void
> @@ -680,15 +682,29 @@ void
>  guest_console(int argc, char **argv)
>  {
>       uint64_t gid;
> +     int ch;
> +     const char *Earg = NULL;
>  
> -     if (argc != 2)
> +     while ((ch = getopt(argc, argv, "E:")) != -1) {
> +             switch (ch) {
> +             case 'E':
> +                     Earg = optarg;
> +                     break;
> +             default:
> +                     usage();
> +             }
> +     }
> +     argc -= optind;
> +     argv += optind;
> +
> +     if (argc != 1)
>               usage();
>  
>       hv_config();
>  
> -     gid = find_guest(argv[1]);
> +     gid = find_guest(argv[0]);
>  
> -     console_exec(gid);
> +     console_exec(gid, Earg);
>  }
>  
>  void
> 
> 

Reply via email to