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:
parent
af4516470b
commit
72c0bf308e
@ -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
|
||||
*/
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user