Need to know the size and count of kvm_run.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 441
- Forks
- 151
- Avg merge
- 14d 20h
- Merged PRs (30d)
- 1
Description
Hello, I am reading the code of the vcpu run function, but I have a problem: When the KVM encounters an I/O request and exits, the processing logic of rust-ioctl is to multiply count by size as the length of the return value data_slice array. What if the back-end code needs to use these two variables?
The related code is as follows:
KVM_EXIT_IO => {
let run_start = run as *mut kvm_run as *mut u8;
// Safe because the exit_reason (which comes from the kernel) told us which
// union field to use.
let io = unsafe { run.__bindgen_anon_1.io };
let port = io.port;
let data_size = io.count as usize * io.size as usize;
// The data_offset is defined by the kernel to be some number of bytes into the
// kvm_run stucture, which we have fully mmap'd.
let data_ptr = unsafe { run_start.offset(io.data_offset as isize) };
// The slice's lifetime is limited to the lifetime of this vCPU, which is equal
// to the mmap of the `kvm_run` struct that this is slicing from.
let data_slice = unsafe {
std::slice::from_raw_parts_mut::<u8>(data_ptr as *mut u8, data_size)
};
match u32::from(io.direction) {
KVM_EXIT_IO_IN => Ok(VcpuExit::IoIn(port, data_slice)),
KVM_EXIT_IO_OUT => Ok(VcpuExit::IoOut(port, data_slice)),
_ => Err(errno::Error::new(EINVAL)),
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the vcpu run function's KVM_EXIT_IO branch shown in the issue and inspect how rust-ioctl derives the data slice length from io.count and io.size. Clarify how the backend needs to access those values; done when the required information is available to the caller and the behavior is verified by the project's tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100