Skip to content

Commit

Permalink
move get/set_status from the VhostVdpa implementations
Browse files Browse the repository at this point in the history
I can't figure out where these move to but weirdly things compile when
everything is commented out so what gives?
  • Loading branch information
stsquad committed Jul 18, 2023
1 parent 427d844 commit caf306d
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions crates/vhost/src/vhost_kern/vdpa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,25 @@ impl<AS: GuestAddressSpace> VhostKernVdpa<AS> {
}
}

//impl<T: VhostKernBackend> VhostBackend for T {
// impl<AS: GuestAddressSpace> VhostBackend for VhostKernVdpa<AS> {
// fn get_status(&self) -> Result<u8> {
// let mut status: u8 = 0;

// // SAFETY: This ioctl is called on a valid vhost-vdpa fd and has its
// // return value checked.
// let ret = unsafe { ioctl_with_mut_ref(self, VHOST_VDPA_GET_STATUS(), &mut status) };
// ioctl_result(ret, status)
// }

// fn set_status(&self, status: u8) -> Result<()> {
// // SAFETY: This ioctl is called on a valid vhost-vdpa fd and has its
// // return value checked.
// let ret = unsafe { ioctl_with_ref(self, VHOST_VDPA_SET_STATUS(), &status) };
// ioctl_result(ret, ())
// }
// }

impl<AS: GuestAddressSpace> VhostVdpa for VhostKernVdpa<AS> {
fn get_device_id(&self) -> Result<u32> {
let mut device_id: u32 = 0;
Expand All @@ -101,22 +120,6 @@ impl<AS: GuestAddressSpace> VhostVdpa for VhostKernVdpa<AS> {
ioctl_result(ret, device_id)
}

fn get_status(&self) -> Result<u8> {
let mut status: u8 = 0;

// SAFETY: This ioctl is called on a valid vhost-vdpa fd and has its
// return value checked.
let ret = unsafe { ioctl_with_mut_ref(self, VHOST_VDPA_GET_STATUS(), &mut status) };
ioctl_result(ret, status)
}

fn set_status(&self, status: u8) -> Result<()> {
// SAFETY: This ioctl is called on a valid vhost-vdpa fd and has its
// return value checked.
let ret = unsafe { ioctl_with_ref(self, VHOST_VDPA_SET_STATUS(), &status) };
ioctl_result(ret, ())
}

fn get_config(&self, offset: u32, buffer: &mut [u8]) -> Result<()> {
let mut config = VhostVdpaConfig::new(buffer.len())
.map_err(|_| Error::IoctlError(IOError::from_raw_os_error(libc::ENOMEM)))?;
Expand Down

0 comments on commit caf306d

Please sign in to comment.