Page MenuHomeFreeBSD

bhyvectl: support querying VM pid
Needs ReviewPublic

Authored by novel on Sat, Aug 22, 10:37 AM.
Tags
None
Referenced Files
F167678018: D59108.id184734.diff
Sun, Aug 23, 5:37 PM
F167677663: D59108.diff
Sun, Aug 23, 5:34 PM
F167628004: D59108.diff
Sun, Aug 23, 7:38 AM
F167625962: D59108.id.diff
Sun, Aug 23, 7:08 AM
Unknown Object (File)
Sat, Aug 22, 2:36 PM
Unknown Object (File)
Sat, Aug 22, 11:06 AM
Unknown Object (File)
Sat, Aug 22, 11:04 AM

Details

Reviewers
andrew
manu
Group Reviewers
bhyve
Summary

Extend bhyvectl(8) to support querying VM pid using the
--get-vm-pid flag.

This is useful in the monitor mode when the VM pid differs
from the main bhyve(8) process run by the user. Knowing the VM pid
is necessary, for example, to query process resource usage or
trigger ACPI shutdown with SIGTERM.

Of course, it could be obtained by matching the monitor process
children by the process title, but it's a little more complex
and fragile than it could be.

Implement that by introducing the VM_GET_PID ioctl to vmm(8),
exposing that through libvmmapi, and using it to implement
bhyvectl --get-vm-pid.

When the VM pid is not known, ESRCH is returned.

This information is now also included in the bhyvectl --get-all
output. The --get-vm-pid fails when vm_get_pid() returns ESRCH,
and --get-all just skips it in this case.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 75963
Build 72846: arc lint + arc unit

Event Timeline

This is a good feature, but I don't think that this is the correct approach design-wise. Adding an ioctl handler to just to fetch a VM's PID is overkill IMO, new ioctl commands should only be added when there's no other way to obtain the needed information (e.g., fetching memsegs and other metadata that is stored in the vmm module).

I strongly suggest that you implement this functionality using bhyve's IPC facilities. These were only reserved for the snapshot subsystem up until very recently, but I had to split these out into a separate subsystem as a part of my hotplugging work.
This should make the implementation way simpler since you just need to register an IPC handler instead of adding a new ioctl.
I just committed the refactor so you can build on top of it.

This is a good feature, but I don't think that this is the correct approach design-wise. Adding an ioctl handler to just to fetch a VM's PID is overkill IMO, new ioctl commands should only be added when there's no other way to obtain the needed information (e.g., fetching memsegs and other metadata that is stored in the vmm module).

I strongly suggest that you implement this functionality using bhyve's IPC facilities. These were only reserved for the snapshot subsystem up until very recently, but I had to split these out into a separate subsystem as a part of my hotplugging work.
This should make the implementation way simpler since you just need to register an IPC handler instead of adding a new ioctl.
I just committed the refactor so you can build on top of it.

Thanks, I'll take a look at the new IPC code.