> Date: Fri, 17 Jan 2020 12:23:04 +0100
> From: Klemens Nanni <[email protected]>
> Cc: tech <[email protected]>
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> 
> On Fri, Jan 17, 2020 at 10:01:08AM +0000, Andrew Grillet wrote:
> > Is there any possibility that the same -c option could be added to
> > > ldomctl panic -c <guest>
> > It would be very useful.
> I don't really use panic but if kettenis is fine with adding -c there
> as well, why not.
> 
> The code repitition in ldomctl.c starts to grow, mainly because the
> command functions guest_*() largely to the same with regard to argument
> parsing and HV setup;  if this diff goes in, I can try merging stuff a
> bit.

Might make sense, especially if it is fast enough to catch the ddb output.

ok kettenis@

> Index: ldomctl.8
> ===================================================================
> RCS file: /cvs/src/usr.sbin/ldomctl/ldomctl.8,v
> retrieving revision 1.26
> diff -u -p -r1.26 ldomctl.8
> --- ldomctl.8 16 Jan 2020 16:46:47 -0000      1.26
> +++ ldomctl.8 17 Jan 2020 11:20:53 -0000
> @@ -84,13 +84,17 @@ and the configuration which will be used
>  (after resetting the machine) if it differs from the currently running one.
>  .It Cm list-io
>  List available PCIe devices.
> -.It Cm panic Ar domain
> +.It Cm panic Oo Fl c Oc Ar domain
>  Panic a guest domain.
>  The exact behaviour of this command depends on the OS running in the domain.
>  For
>  .Ox
>  the default behaviour is to enter
>  .Xr ddb 4 .
> +.Bl -tag -width 3n
> +.It Fl c
> +Automatically connect to the guest console.
> +.El
>  .It Cm select Ar configuration
>  Select the next logical domain configuration to use
>  (after resetting the machine).
> Index: ldomctl.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/ldomctl/ldomctl.c,v
> retrieving revision 1.36
> diff -u -p -r1.36 ldomctl.c
> --- ldomctl.c 17 Jan 2020 10:50:20 -0000      1.36
> +++ ldomctl.c 17 Jan 2020 11:20:53 -0000
> @@ -131,8 +131,8 @@ usage(void)
>           "\t%1$s dump|list|list-io\n"
>           "\t%1$s init-system [-n] file\n"
>           "\t%1$s create-vdisk -s size file\n"
> -         "\t%1$s start [-c] domain\n"
> -         "\t%1$s console|panic|status|stop [domain]\n",
> +         "\t%1$s panic|start [-c] domain\n"
> +         "\t%1$s console|status|stop [domain]\n",
>           getprogname());
>  
>       exit(EXIT_FAILURE);
> @@ -503,19 +503,35 @@ guest_panic(int argc, char **argv)
>  {
>       struct hvctl_msg msg;
>       ssize_t nbytes;
> +     uint64_t gid;
> +     int ch, console = 0;
>  
> -     if (argc != 2)
> +     while ((ch = getopt(argc, argv, "c")) != -1) {
> +             switch (ch) {
> +             case 'c':
> +                     console = 1;
> +                     break;
> +             default:
> +                     usage();
> +             }
> +     }
> +     argc -= optind;
> +     argv += optind;
> +
> +     if (argc != 1)
>               usage();
>  
>       hv_config();
>  
> +     gid = find_guest(argv[0]);
> +
>       /*
>        * Stop guest domain.
>        */
>       bzero(&msg, sizeof(msg));
>       msg.hdr.op = HVCTL_OP_GUEST_PANIC;
>       msg.hdr.seq = hvctl_seq++;
> -     msg.msg.guestop.guestid = find_guest(argv[1]);
> +     msg.msg.guestop.guestid = gid;
>       nbytes = write(hvctl_fd, &msg, sizeof(msg));
>       if (nbytes != sizeof(msg))
>               err(1, "write");
> @@ -524,6 +540,9 @@ guest_panic(int argc, char **argv)
>       nbytes = read(hvctl_fd, &msg, sizeof(msg));
>       if (nbytes != sizeof(msg))
>               err(1, "read");
> +
> +     if (console)
> +             console_exec(gid);
>  }
>  
>  void
> 
> 

Reply via email to