Page MenuHomeFreeBSD

libvmmapi: Add a struct vcpu and use it in most APIs.
ClosedPublic

Authored by jhb on Jan 19 2023, 6:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 16, 4:04 PM
Unknown Object (File)
Wed, Oct 16, 4:04 PM
Unknown Object (File)
Wed, Oct 16, 4:03 PM
Unknown Object (File)
Wed, Oct 16, 4:03 PM
Unknown Object (File)
Wed, Oct 16, 3:34 PM
Unknown Object (File)
Oct 6 2024, 1:47 PM
Unknown Object (File)
Sep 25 2024, 10:18 AM
Unknown Object (File)
Sep 25 2024, 10:18 AM

Details

Summary

This replaces the 'struct vm, int vcpuid' tuple passed to most API
calls and is similar to the changes recently made in vmm(4) in the
kernel.

struct vcpu is an opaque type managed by libvmmapi. For now it stores
a pointer to the VM context and an integer id.

As an immediate effect this removes the divergence between the kernel
and userland for the instruction emulation code introduced by the
recent vmm(4) changes.

Since this is a major change to the vmmapi API, VMMAPI_VERSION to
0x200 (2.0) and the shared library major version.

While here (and since the major version is bumped), remove unused
vcpu argument from vm_setup_pptdev_msi*().

Add new functions vm_suspend_all_cpus() and vm_resume_all_cpus() for
use by the debug server. The underyling ioctl (which uses a vcpuid of
-1) remains unchanged, but the userlevel API now uses separate
functions for global CPU suspend/resume.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Jan 20 2023, 6:47 AM
markj added a subscriber: markj.

usr/lib/libvmmapi.so.5 should be added to ObsoleteFiles I think.

lib/libvmmapi/vmmapi.c
185

I'd still put this in the vm_* namespace. Hmm, there's also vcpu_reset() though, so I guess it's already a bit inconsistent.

lib/libvmmapi/vmmapi.c
185

Yeah, I was a bit torn. I actually think it would be cleaner if the functions that operate on vCPUs all used the vcpu_ prefix including vm_vcpu_close. However, this trips over the shared vmm_instruction_emul.c code. In the kernel I used vcpu_vm for a function which returns a field from struct vcpu. (I did not need vcpu_id in the kernel though it turns out.)

This revision now requires review to proceed.Mar 1 2023, 10:56 PM
This revision is now accepted and ready to land.Mar 2 2023, 6:56 AM