Merge pull request #8 from kharbranth/master

Add support for unlocking migration support on vGPUs
This commit is contained in:
Matt Bilker 2022-05-05 21:16:08 -04:00 committed by GitHub
commit c6002f455e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

View File

@ -56,4 +56,13 @@ cuda_enabled = 1
frl_enabled = 0 frl_enabled = 0
``` ```
If you want to enable VM migration or snapshotting, you must
recompile the `nvidia-vgpu-vfio` kernel module with `NV_KVM_MIGRATION_UAPI`
equal to 1. Then, create the file `/etc/vgpu_unlock/config.toml` and add the
following:
```toml
unlock_migration = true
```
Happy hacking! Happy hacking!

View File

@ -7,12 +7,18 @@ impl Defaults {
const fn unlock() -> bool { const fn unlock() -> bool {
true true
} }
#[inline]
const fn unlock_migration() -> bool {
false
}
} }
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct Config { pub struct Config {
#[serde(default = "Defaults::unlock")] #[serde(default = "Defaults::unlock")]
pub unlock: bool, pub unlock: bool,
#[serde(default = "Defaults::unlock_migration")]
pub unlock_migration: bool,
} }
impl Default for Config { impl Default for Config {
@ -20,6 +26,7 @@ impl Default for Config {
fn default() -> Self { fn default() -> Self {
Self { Self {
unlock: Defaults::unlock(), unlock: Defaults::unlock(),
unlock_migration: Defaults::unlock_migration(),
} }
} }
} }

View File

@ -75,6 +75,9 @@ const OP_READ_PCI_ID: u32 = 0x20801801;
/// `result` is a pointer to `VgpuConfig`. /// `result` is a pointer to `VgpuConfig`.
const OP_READ_VGPU_CFG: u32 = 0xa0820102; const OP_READ_VGPU_CFG: u32 = 0xa0820102;
/// `result` is a pointer to `bool`.
const OP_READ_VGPU_MIG_CAP: u32 = 0xa0810112;
/// `nvidia-vgpu-mgr` expects this value for a vGPU capable GPU. /// `nvidia-vgpu-mgr` expects this value for a vGPU capable GPU.
const DEV_TYPE_VGPU_CAPABLE: u32 = 3; const DEV_TYPE_VGPU_CAPABLE: u32 = 3;
@ -340,10 +343,16 @@ pub unsafe extern "C" fn ioctl(fd: RawFd, request: c_ulong, argp: *mut c_void) -
// Set device type to vGPU capable. // Set device type to vGPU capable.
*dev_type_ptr = DEV_TYPE_VGPU_CAPABLE; *dev_type_ptr = DEV_TYPE_VGPU_CAPABLE;
} },
OP_READ_VGPU_MIG_CAP if CONFIG.unlock_migration => {
let mig_enabled: *mut bool = io_data.result.cast();
*mig_enabled = true;
},
_ => {} _ => {}
} }
if io_data.status == STATUS_OK { if io_data.status == STATUS_OK {
match io_data.op_type { match io_data.op_type {
OP_READ_VGPU_CFG => { OP_READ_VGPU_CFG => {