Add the VM name to the process name with setproctitle().

Remove the VM name from some of the thread-naming calls
since it is now in the proc title.
Slightly modify the thread-naming for the net and block
threads.

This improves readability when using top/ps with the -a
and -H options on a system with a large number of bhyve VMs.

Requested by:	Michael Dexter
Reviewed by:	neel
MFC after:	4 weeks
This commit is contained in:
Peter Grehan 2013-11-06 00:25:17 +00:00
parent 8c2a40e9ef
commit 7f5487aca1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=257729
5 changed files with 13 additions and 11 deletions

View File

@ -190,7 +190,7 @@ fbsdrun_start_thread(void *param)
mtp = param;
vcpu = mtp->mt_vcpu;
snprintf(tname, sizeof(tname), "%s vcpu %d", vmname, vcpu);
snprintf(tname, sizeof(tname), "vcpu %d", vcpu);
pthread_set_name_np(mtp->mt_thr, tname);
vm_loop(mtp->mt_ctx, vcpu, vmexit[vcpu].rip);
@ -684,6 +684,11 @@ main(int argc, char *argv[])
assert(error == 0);
}
/*
* Change the proc title to include the VM name.
*/
setproctitle("%s", vmname);
/*
* Add CPU 0
*/

View File

@ -293,7 +293,7 @@ blockif_open(const char *optstr, const char *ident)
pthread_create(&bc->bc_btid, NULL, blockif_thr, bc);
snprintf(tname, sizeof(tname), "%s blk-%s", vmname, ident);
snprintf(tname, sizeof(tname), "blk-%s", ident);
pthread_set_name_np(bc->bc_btid, tname);
return (bc);

View File

@ -381,10 +381,8 @@ mevent_delete_close(struct mevent *evp)
static void
mevent_set_name(void)
{
char tname[MAXCOMLEN + 1];
snprintf(tname, sizeof(tname), "%s mevent", vmname);
pthread_set_name_np(mevent_tid, tname);
pthread_set_name_np(mevent_tid, "mevent");
}
void

View File

@ -1714,11 +1714,9 @@ pci_ahci_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts, int atapi)
/*
* Attempt to open the backing image. Use the PCI
* slot/func/ahci_port for the identifier string
* since that uniquely identifies a storage device.
* slot/func for the identifier string.
*/
snprintf(bident, sizeof(bident), "%d:%d:%d", pi->pi_slot, pi->pi_func,
0);
snprintf(bident, sizeof(bident), "%d:%d", pi->pi_slot, pi->pi_func);
bctxt = blockif_open(opts, bident);
if (bctxt == NULL) {
ret = 1;

View File

@ -588,7 +588,7 @@ pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
*/
if (!mac_provided) {
snprintf(nstr, sizeof(nstr), "%d-%d-%s", pi->pi_slot,
pi->pi_func, vmname);
pi->pi_func, vmname);
MD5Init(&mdctx);
MD5Update(&mdctx, nstr, strlen(nstr));
@ -632,7 +632,8 @@ pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
pthread_mutex_init(&sc->tx_mtx, NULL);
pthread_cond_init(&sc->tx_cond, NULL);
pthread_create(&sc->tx_tid, NULL, pci_vtnet_tx_thread, (void *)sc);
snprintf(tname, sizeof(tname), "%s vtnet%d tx", vmname, pi->pi_slot);
snprintf(tname, sizeof(tname), "vtnet-%d:%d tx", pi->pi_slot,
pi->pi_func);
pthread_set_name_np(sc->tx_tid, tname);
return (0);