lib: apply profile overrides only on successful status

This commit is contained in:
Matt Bilker 2021-11-07 11:28:38 +00:00
parent 8bb4f47c9b
commit 3ca0999210
No known key found for this signature in database
GPG Key ID: 69ADF8AEB6C8B5D1

View File

@ -44,7 +44,7 @@ static CONFIG: Config = {
process::abort();
}
}
},
Err(e) => {
if e.kind() != ErrorKind::NotFound {
eprintln!("Failed to read config: {}", e);
@ -337,24 +337,30 @@ pub unsafe extern "C" fn ioctl(fd: RawFd, request: c_ulong, argp: *mut c_void) -
// Set device type to vGPU capable.
*dev_type_ptr = DEV_TYPE_VGPU_CAPABLE;
}
OP_READ_VGPU_CFG => {
let config = &mut *(io_data.result as *mut VgpuConfig);
info!("{:#?}", config);
if !handle_profile_override(config) {
error!("Failed to apply profile override");
return -1;
}
}
OP_READ_START_CALL => {
let config = &*(io_data.result as *const VgpuStart);
info!("{:#?}", config);
*LAST_MDEV_UUID.lock() = Some(config.uuid);
}
_ => {}
}
if io_data.status == STATUS_OK {
match io_data.op_type {
OP_READ_VGPU_CFG => {
let config = &mut *(io_data.result as *mut VgpuConfig);
info!("{:#?}", config);
if !handle_profile_override(config) {
error!("Failed to apply profile override");
return -1;
}
}
OP_READ_START_CALL => {
let config = &*(io_data.result as *const VgpuStart);
info!("{:#?}", config);
*LAST_MDEV_UUID.lock() = Some(config.uuid);
}
_ => {}
}
}
if io_data.status != STATUS_OK {
// Things seems to work fine even if some operations that fail result in failed assertions.
// So here we change the status value for these cases to cleanup the logs for