Re: vmctl show

2018-02-10 Thread Mike Larkin
On Sun, Feb 11, 2018 at 12:51:57AM +0100, Peter Hessler wrote:
> My fingers have typed "vmctl show" instead of "vmctl status" for over a
> year now, so add it as an alias.
> 
> OK?
> 
> 
> Index: main.c
> ===
> RCS file: /cvs/openbsd/src/usr.sbin/vmctl/main.c,v
> retrieving revision 1.34
> diff -u -p -u -p -r1.34 main.c
> --- main.c3 Jan 2018 05:39:56 -   1.34
> +++ main.c10 Feb 2018 23:46:44 -
> @@ -68,6 +68,7 @@ struct ctl_command ctl_commands[] = {
>   { "log",CMD_LOG,ctl_log,"(verbose|brief)" },
>   { "reload", CMD_RELOAD, ctl_reload, "" },
>   { "reset",  CMD_RESET,  ctl_reset,  "[all|vms|switches]" },
> + { "show",   CMD_STATUS, ctl_status, "[id]" },
>   { "start",  CMD_START,  ctl_start,  "\"name\""
>   " [-Lc] [-b image] [-r image] [-m size]\n"
>   "\t\t[-n switch] [-i count] [-d disk]*" },
> Index: vmctl.8
> ===
> RCS file: /cvs/openbsd/src/usr.sbin/vmctl/vmctl.8,v
> retrieving revision 1.37
> diff -u -p -u -p -r1.37 vmctl.8
> --- vmctl.8   3 Jan 2018 08:17:18 -   1.37
> +++ vmctl.8   10 Feb 2018 23:48:59 -
> @@ -143,6 +143,10 @@ with '.', '-' or '_'.
>  .It Cm status Op Ar id
>  Lists VMs running on the host, optionally listing just the selected VM
>  .Ar id .
> +.It Cm show Op Ar id
> +An alias for the
> +.Cm status
> +command.
>  .It Cm stop Ar id
>  Stops (terminates) a VM defined by the specified VM
>  .Ar id .
> 
> 
> -- 
> Coito ergo sum
> 

No objections. Since at least 3-4 people have said they want it, go for it.



Re: vmctl show

2018-02-10 Thread Ax0n
Guilty.

On Feb 10, 2018 17:56, "Sebastian Benoit"  wrote:

> Peter Hessler(phess...@openbsd.org) on 2018.02.11 00:51:57 +0100:
> > My fingers have typed "vmctl show" instead of "vmctl status" for over a
> > year now, so add it as an alias.
>
> oh yes please, i thought i was the only stupid one.
>
> > OK?
>
> ok
>
> > Index: main.c
> > ===
> > RCS file: /cvs/openbsd/src/usr.sbin/vmctl/main.c,v
> > retrieving revision 1.34
> > diff -u -p -u -p -r1.34 main.c
> > --- main.c3 Jan 2018 05:39:56 -   1.34
> > +++ main.c10 Feb 2018 23:46:44 -
> > @@ -68,6 +68,7 @@ struct ctl_command ctl_commands[] = {
> >   { "log",CMD_LOG,ctl_log,"(verbose|brief)"
> },
> >   { "reload", CMD_RELOAD, ctl_reload, "" },
> >   { "reset",  CMD_RESET,  ctl_reset,
> "[all|vms|switches]" },
> > + { "show",   CMD_STATUS, ctl_status, "[id]" },
> >   { "start",  CMD_START,  ctl_start,  "\"name\""
> >   " [-Lc] [-b image] [-r image] [-m size]\n"
> >   "\t\t[-n switch] [-i count] [-d disk]*" },
> > Index: vmctl.8
> > ===
> > RCS file: /cvs/openbsd/src/usr.sbin/vmctl/vmctl.8,v
> > retrieving revision 1.37
> > diff -u -p -u -p -r1.37 vmctl.8
> > --- vmctl.8   3 Jan 2018 08:17:18 -   1.37
> > +++ vmctl.8   10 Feb 2018 23:48:59 -
> > @@ -143,6 +143,10 @@ with '.', '-' or '_'.
> >  .It Cm status Op Ar id
> >  Lists VMs running on the host, optionally listing just the selected VM
> >  .Ar id .
> > +.It Cm show Op Ar id
> > +An alias for the
> > +.Cm status
> > +command.
> >  .It Cm stop Ar id
> >  Stops (terminates) a VM defined by the specified VM
> >  .Ar id .
> >
> >
> > --
> > Coito ergo sum
> >
>
>


Re: vmctl show

2018-02-10 Thread Sebastian Benoit
Peter Hessler(phess...@openbsd.org) on 2018.02.11 00:51:57 +0100:
> My fingers have typed "vmctl show" instead of "vmctl status" for over a
> year now, so add it as an alias.

oh yes please, i thought i was the only stupid one.

> OK?

ok

> Index: main.c
> ===
> RCS file: /cvs/openbsd/src/usr.sbin/vmctl/main.c,v
> retrieving revision 1.34
> diff -u -p -u -p -r1.34 main.c
> --- main.c3 Jan 2018 05:39:56 -   1.34
> +++ main.c10 Feb 2018 23:46:44 -
> @@ -68,6 +68,7 @@ struct ctl_command ctl_commands[] = {
>   { "log",CMD_LOG,ctl_log,"(verbose|brief)" },
>   { "reload", CMD_RELOAD, ctl_reload, "" },
>   { "reset",  CMD_RESET,  ctl_reset,  "[all|vms|switches]" },
> + { "show",   CMD_STATUS, ctl_status, "[id]" },
>   { "start",  CMD_START,  ctl_start,  "\"name\""
>   " [-Lc] [-b image] [-r image] [-m size]\n"
>   "\t\t[-n switch] [-i count] [-d disk]*" },
> Index: vmctl.8
> ===
> RCS file: /cvs/openbsd/src/usr.sbin/vmctl/vmctl.8,v
> retrieving revision 1.37
> diff -u -p -u -p -r1.37 vmctl.8
> --- vmctl.8   3 Jan 2018 08:17:18 -   1.37
> +++ vmctl.8   10 Feb 2018 23:48:59 -
> @@ -143,6 +143,10 @@ with '.', '-' or '_'.
>  .It Cm status Op Ar id
>  Lists VMs running on the host, optionally listing just the selected VM
>  .Ar id .
> +.It Cm show Op Ar id
> +An alias for the
> +.Cm status
> +command.
>  .It Cm stop Ar id
>  Stops (terminates) a VM defined by the specified VM
>  .Ar id .
> 
> 
> -- 
> Coito ergo sum
> 



vmctl show

2018-02-10 Thread Peter Hessler
My fingers have typed "vmctl show" instead of "vmctl status" for over a
year now, so add it as an alias.

OK?


Index: main.c
===
RCS file: /cvs/openbsd/src/usr.sbin/vmctl/main.c,v
retrieving revision 1.34
diff -u -p -u -p -r1.34 main.c
--- main.c  3 Jan 2018 05:39:56 -   1.34
+++ main.c  10 Feb 2018 23:46:44 -
@@ -68,6 +68,7 @@ struct ctl_command ctl_commands[] = {
{ "log",CMD_LOG,ctl_log,"(verbose|brief)" },
{ "reload", CMD_RELOAD, ctl_reload, "" },
{ "reset",  CMD_RESET,  ctl_reset,  "[all|vms|switches]" },
+   { "show",   CMD_STATUS, ctl_status, "[id]" },
{ "start",  CMD_START,  ctl_start,  "\"name\""
" [-Lc] [-b image] [-r image] [-m size]\n"
"\t\t[-n switch] [-i count] [-d disk]*" },
Index: vmctl.8
===
RCS file: /cvs/openbsd/src/usr.sbin/vmctl/vmctl.8,v
retrieving revision 1.37
diff -u -p -u -p -r1.37 vmctl.8
--- vmctl.8 3 Jan 2018 08:17:18 -   1.37
+++ vmctl.8 10 Feb 2018 23:48:59 -
@@ -143,6 +143,10 @@ with '.', '-' or '_'.
 .It Cm status Op Ar id
 Lists VMs running on the host, optionally listing just the selected VM
 .Ar id .
+.It Cm show Op Ar id
+An alias for the
+.Cm status
+command.
 .It Cm stop Ar id
 Stops (terminates) a VM defined by the specified VM
 .Ar id .


-- 
Coito ergo sum



Re: vmctl: show tap interface in status output

2017-03-16 Thread Jon Bernard
* Reyk Floeter  wrote:
> On Thu, Mar 16, 2017 at 11:27:24AM -0400, Jon Bernard wrote:
> > Hi,
> > 
> > I made a quick change to show the assigned tap interface in vmctl's
> > status listing.  mlarkin@ pointed out that ifconfig shows this
> > information already, so maybe this isn't useful but I wanted to post it
> > just in case.  I don't have a good answer for the case where multiple
> > interfaces are assigned to a single guest without making a mess of the
> > status output.
> > 
> 
> Well, my problem with this approach:
> 
> - It only shows the first interface, how is this useful?
> - Considering the 80 chars line limit, it shortens the space for VM name.
> 
> And, indeed, ifconfig description shows it already and the "switch"
> concept actually makes it less important to know (you can dynamically
> use switches and assign interface groups to create pf rules and
> everything without even caring about the individual tap names).

That makes a lot more sense, thanks.

> For the information, my suggestion is to put it into a detailed view:
> 
> 1. normal list as it is:
> $ vmctl status
> 
> 2. more detailed information including interfaces etc.:
> $ vmctl status myvm
> (it currently only adds VCPU state)
> 
> For 2., you don't have to put everything into struct vmop_info_result,
> you could just send an additional imsg including the original struct
> vmop_create_params that is part of each struct vmd_vm.

Okay, let me see what I can come up with.  Thanks for the feedback.

-- 
Jon

> 
> Reyk
> 
> > -- 
> > Jon
> > 
> > Index: usr.sbin/vmctl/vmctl.c
> > ===
> > RCS file: /var/cvs/openbsd/src/usr.sbin/vmctl/vmctl.c,v
> > retrieving revision 1.26
> > diff -u -p -r1.26 vmctl.c
> > --- usr.sbin/vmctl/vmctl.c  3 Mar 2017 09:12:40 -   1.26
> > +++ usr.sbin/vmctl/vmctl.c  13 Mar 2017 17:14:54 -
> > @@ -375,8 +375,8 @@ print_vm_info(struct vmop_info_result *l
> > struct passwd *pw;
> > struct group *gr;
> >  
> > -   printf("%5s %5s %5s %7s %7s %7s %12s %s\n", "ID", "PID", "VCPUS",
> > -   "MAXMEM", "CURMEM", "TTY", "OWNER", "NAME");
> > +   printf("%5s %5s %5s %5s %7s %7s %7s %12s %s\n", "ID", "PID",
> > +  "VCPUS", "TAP", "MAXMEM", "CURMEM", "TTY", "OWNER", "NAME");
> >  
> > for (i = 0; i < ct; i++) {
> > vmi = &list[i];
> > @@ -417,15 +417,15 @@ print_vm_info(struct vmop_info_result *l
> > (void)fmt_scaled(vir->vir_used_size, curmem);
> >  
> > /* running vm */
> > -   printf("%5u %5u %5zd %7s %7s %7s %12s %s\n",
> > +   printf("%5u %5u %5zd %5s %7s %7s %7s %12s %s\n",
> > vir->vir_id, vir->vir_creator_pid,
> > -   vir->vir_ncpus, maxmem, curmem,
> > +   vir->vir_ncpus, vmi->vir_ifname, maxmem, 
> > curmem,
> > tty, user, vir->vir_name);
> > } else {
> > /* disabled vm */
> > -   printf("%5s %5s %5zd %7s %7s %7s %12s %s\n",
> > +   printf("%5s %5s %5zd %5s %7s %7s %7s %12s %s\n",
> > "-", "-",
> > -   vir->vir_ncpus, maxmem, curmem,
> > +   vir->vir_ncpus, "-", maxmem, curmem,
> > "-", user, vir->vir_name);
> > }
> > }
> > Index: usr.sbin/vmd/vmd.c
> > ===
> > RCS file: /var/cvs/openbsd/src/usr.sbin/vmd/vmd.c,v
> > retrieving revision 1.53
> > diff -u -p -r1.53 vmd.c
> > --- usr.sbin/vmd/vmd.c  2 Mar 2017 07:33:37 -   1.53
> > +++ usr.sbin/vmd/vmd.c  15 Mar 2017 11:26:16 -
> > @@ -265,6 +265,9 @@ vmd_dispatch_vmm(int fd, struct privsep_
> > if ((vm = vm_getbyid(vir.vir_info.vir_id)) != NULL) {
> > (void)strlcpy(vir.vir_ttyname, vm->vm_ttyname,
> > sizeof(vir.vir_ttyname));
> > +   if (vm->vm_ifs[0].vif_name != NULL)
> > +   (void)strlcpy(vir.vir_ifname, 
> > vm->vm_ifs[0].vif_name,
> > + sizeof(vir.vir_ifname));
> > /* get the user id who started the vm */
> > vir.vir_uid = vm->vm_uid;
> > vir.vir_gid = vm->vm_params.vmc_gid;
> > Index: usr.sbin/vmd/vmd.h
> > ===
> > RCS file: /var/cvs/openbsd/src/usr.sbin/vmd/vmd.h,v
> > retrieving revision 1.47
> > diff -u -p -r1.47 vmd.h
> > --- usr.sbin/vmd/vmd.h  2 Mar 2017 07:33:37 -   1.47
> > +++ usr.sbin/vmd/vmd.h  13 Mar 2017 16:15:09 -
> > @@ -87,6 +87,7 @@ struct vmop_result {
> >  struct vmop_info_result {
> > struct vm_info_resultvir_i

Re: vmctl: show tap interface in status output

2017-03-16 Thread Reyk Floeter
On Thu, Mar 16, 2017 at 11:27:24AM -0400, Jon Bernard wrote:
> Hi,
> 
> I made a quick change to show the assigned tap interface in vmctl's
> status listing.  mlarkin@ pointed out that ifconfig shows this
> information already, so maybe this isn't useful but I wanted to post it
> just in case.  I don't have a good answer for the case where multiple
> interfaces are assigned to a single guest without making a mess of the
> status output.
> 

Well, my problem with this approach:

- It only shows the first interface, how is this useful?
- Considering the 80 chars line limit, it shortens the space for VM name.

And, indeed, ifconfig description shows it already and the "switch"
concept actually makes it less important to know (you can dynamically
use switches and assign interface groups to create pf rules and
everything without even caring about the individual tap names).

For the information, my suggestion is to put it into a detailed view:

1. normal list as it is:
$ vmctl status

2. more detailed information including interfaces etc.:
$ vmctl status myvm
(it currently only adds VCPU state)

For 2., you don't have to put everything into struct vmop_info_result,
you could just send an additional imsg including the original struct
vmop_create_params that is part of each struct vmd_vm.

Reyk

> -- 
> Jon
> 
> Index: usr.sbin/vmctl/vmctl.c
> ===
> RCS file: /var/cvs/openbsd/src/usr.sbin/vmctl/vmctl.c,v
> retrieving revision 1.26
> diff -u -p -r1.26 vmctl.c
> --- usr.sbin/vmctl/vmctl.c3 Mar 2017 09:12:40 -   1.26
> +++ usr.sbin/vmctl/vmctl.c13 Mar 2017 17:14:54 -
> @@ -375,8 +375,8 @@ print_vm_info(struct vmop_info_result *l
>   struct passwd *pw;
>   struct group *gr;
>  
> - printf("%5s %5s %5s %7s %7s %7s %12s %s\n", "ID", "PID", "VCPUS",
> - "MAXMEM", "CURMEM", "TTY", "OWNER", "NAME");
> + printf("%5s %5s %5s %5s %7s %7s %7s %12s %s\n", "ID", "PID",
> +"VCPUS", "TAP", "MAXMEM", "CURMEM", "TTY", "OWNER", "NAME");
>  
>   for (i = 0; i < ct; i++) {
>   vmi = &list[i];
> @@ -417,15 +417,15 @@ print_vm_info(struct vmop_info_result *l
>   (void)fmt_scaled(vir->vir_used_size, curmem);
>  
>   /* running vm */
> - printf("%5u %5u %5zd %7s %7s %7s %12s %s\n",
> + printf("%5u %5u %5zd %5s %7s %7s %7s %12s %s\n",
>   vir->vir_id, vir->vir_creator_pid,
> - vir->vir_ncpus, maxmem, curmem,
> + vir->vir_ncpus, vmi->vir_ifname, maxmem, 
> curmem,
>   tty, user, vir->vir_name);
>   } else {
>   /* disabled vm */
> - printf("%5s %5s %5zd %7s %7s %7s %12s %s\n",
> + printf("%5s %5s %5zd %5s %7s %7s %7s %12s %s\n",
>   "-", "-",
> - vir->vir_ncpus, maxmem, curmem,
> + vir->vir_ncpus, "-", maxmem, curmem,
>   "-", user, vir->vir_name);
>   }
>   }
> Index: usr.sbin/vmd/vmd.c
> ===
> RCS file: /var/cvs/openbsd/src/usr.sbin/vmd/vmd.c,v
> retrieving revision 1.53
> diff -u -p -r1.53 vmd.c
> --- usr.sbin/vmd/vmd.c2 Mar 2017 07:33:37 -   1.53
> +++ usr.sbin/vmd/vmd.c15 Mar 2017 11:26:16 -
> @@ -265,6 +265,9 @@ vmd_dispatch_vmm(int fd, struct privsep_
>   if ((vm = vm_getbyid(vir.vir_info.vir_id)) != NULL) {
>   (void)strlcpy(vir.vir_ttyname, vm->vm_ttyname,
>   sizeof(vir.vir_ttyname));
> + if (vm->vm_ifs[0].vif_name != NULL)
> + (void)strlcpy(vir.vir_ifname, 
> vm->vm_ifs[0].vif_name,
> +   sizeof(vir.vir_ifname));
>   /* get the user id who started the vm */
>   vir.vir_uid = vm->vm_uid;
>   vir.vir_gid = vm->vm_params.vmc_gid;
> Index: usr.sbin/vmd/vmd.h
> ===
> RCS file: /var/cvs/openbsd/src/usr.sbin/vmd/vmd.h,v
> retrieving revision 1.47
> diff -u -p -r1.47 vmd.h
> --- usr.sbin/vmd/vmd.h2 Mar 2017 07:33:37 -   1.47
> +++ usr.sbin/vmd/vmd.h13 Mar 2017 16:15:09 -
> @@ -87,6 +87,7 @@ struct vmop_result {
>  struct vmop_info_result {
>   struct vm_info_resultvir_info;
>   char vir_ttyname[VM_TTYNAME_MAX];
> + char vir_ifname[IF_NAMESIZE];
>   uid_tvir_uid;
>   int64_t  vir_gid;
>  };
> 

-- 



vmctl: show tap interface in status output

2017-03-16 Thread Jon Bernard
Hi,

I made a quick change to show the assigned tap interface in vmctl's
status listing.  mlarkin@ pointed out that ifconfig shows this
information already, so maybe this isn't useful but I wanted to post it
just in case.  I don't have a good answer for the case where multiple
interfaces are assigned to a single guest without making a mess of the
status output.

-- 
Jon

Index: usr.sbin/vmctl/vmctl.c
===
RCS file: /var/cvs/openbsd/src/usr.sbin/vmctl/vmctl.c,v
retrieving revision 1.26
diff -u -p -r1.26 vmctl.c
--- usr.sbin/vmctl/vmctl.c  3 Mar 2017 09:12:40 -   1.26
+++ usr.sbin/vmctl/vmctl.c  13 Mar 2017 17:14:54 -
@@ -375,8 +375,8 @@ print_vm_info(struct vmop_info_result *l
struct passwd *pw;
struct group *gr;
 
-   printf("%5s %5s %5s %7s %7s %7s %12s %s\n", "ID", "PID", "VCPUS",
-   "MAXMEM", "CURMEM", "TTY", "OWNER", "NAME");
+   printf("%5s %5s %5s %5s %7s %7s %7s %12s %s\n", "ID", "PID",
+  "VCPUS", "TAP", "MAXMEM", "CURMEM", "TTY", "OWNER", "NAME");
 
for (i = 0; i < ct; i++) {
vmi = &list[i];
@@ -417,15 +417,15 @@ print_vm_info(struct vmop_info_result *l
(void)fmt_scaled(vir->vir_used_size, curmem);
 
/* running vm */
-   printf("%5u %5u %5zd %7s %7s %7s %12s %s\n",
+   printf("%5u %5u %5zd %5s %7s %7s %7s %12s %s\n",
vir->vir_id, vir->vir_creator_pid,
-   vir->vir_ncpus, maxmem, curmem,
+   vir->vir_ncpus, vmi->vir_ifname, maxmem, 
curmem,
tty, user, vir->vir_name);
} else {
/* disabled vm */
-   printf("%5s %5s %5zd %7s %7s %7s %12s %s\n",
+   printf("%5s %5s %5zd %5s %7s %7s %7s %12s %s\n",
"-", "-",
-   vir->vir_ncpus, maxmem, curmem,
+   vir->vir_ncpus, "-", maxmem, curmem,
"-", user, vir->vir_name);
}
}
Index: usr.sbin/vmd/vmd.c
===
RCS file: /var/cvs/openbsd/src/usr.sbin/vmd/vmd.c,v
retrieving revision 1.53
diff -u -p -r1.53 vmd.c
--- usr.sbin/vmd/vmd.c  2 Mar 2017 07:33:37 -   1.53
+++ usr.sbin/vmd/vmd.c  15 Mar 2017 11:26:16 -
@@ -265,6 +265,9 @@ vmd_dispatch_vmm(int fd, struct privsep_
if ((vm = vm_getbyid(vir.vir_info.vir_id)) != NULL) {
(void)strlcpy(vir.vir_ttyname, vm->vm_ttyname,
sizeof(vir.vir_ttyname));
+   if (vm->vm_ifs[0].vif_name != NULL)
+   (void)strlcpy(vir.vir_ifname, 
vm->vm_ifs[0].vif_name,
+ sizeof(vir.vir_ifname));
/* get the user id who started the vm */
vir.vir_uid = vm->vm_uid;
vir.vir_gid = vm->vm_params.vmc_gid;
Index: usr.sbin/vmd/vmd.h
===
RCS file: /var/cvs/openbsd/src/usr.sbin/vmd/vmd.h,v
retrieving revision 1.47
diff -u -p -r1.47 vmd.h
--- usr.sbin/vmd/vmd.h  2 Mar 2017 07:33:37 -   1.47
+++ usr.sbin/vmd/vmd.h  13 Mar 2017 16:15:09 -
@@ -87,6 +87,7 @@ struct vmop_result {
 struct vmop_info_result {
struct vm_info_resultvir_info;
char vir_ttyname[VM_TTYNAME_MAX];
+   char vir_ifname[IF_NAMESIZE];
uid_tvir_uid;
int64_t  vir_gid;
 };