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.c 3 Mar 2017 09:12:40 -0000 1.26 > +++ usr.sbin/vmctl/vmctl.c 13 Mar 2017 17:14:54 -0000 > @@ -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 -0000 1.53 > +++ usr.sbin/vmd/vmd.c 15 Mar 2017 11:26:16 -0000 > @@ -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 -0000 1.47 > +++ usr.sbin/vmd/vmd.h 13 Mar 2017 16:15:09 -0000 > @@ -87,6 +87,7 @@ struct vmop_result { > struct vmop_info_result { > struct vm_info_result vir_info; > char vir_ttyname[VM_TTYNAME_MAX]; > + char vir_ifname[IF_NAMESIZE]; > uid_t vir_uid; > int64_t vir_gid; > }; > --